You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when no uses of %6 depended on the most significant bits.
However, since the metadata references in the dbg.value intrinsics aren't dealt with in any special way, a debugger would print the wrong value for variable !18 (showing a zero extended value instead of a sign extended value).
I figure that it would be more correct to invalidate the debug-uses (presenting an undef value), or somehow magically "salvage" the correct value by some fancy DIExpression based on %5.
Here is an example with full IR (compile with "opt -bdce"):
Extended Description
The patch from https://reviews.llvm.org/D60413 (commit 7bf1683)
teached bit-tracking dead code elimination to rewrite:
%6 = sext i32 %5 to i64, !dbg !26
call void @llvm.dbg.value(metadata i64 %6, metadata !18, metadata !DIExpression()), !dbg !27
as
%6 = zext i32 %5 to i64, !dbg !26
call void @llvm.dbg.value(metadata i64 %6, metadata !18, metadata !DIExpression()), !dbg !27
when no uses of %6 depended on the most significant bits.
However, since the metadata references in the dbg.value intrinsics aren't dealt with in any special way, a debugger would print the wrong value for variable !18 (showing a zero extended value instead of a sign extended value).
I figure that it would be more correct to invalidate the debug-uses (presenting an undef value), or somehow magically "salvage" the correct value by some fancy DIExpression based on %5.
Here is an example with full IR (compile with "opt -bdce"):
;-----------------------------------------------------------------------------
; ModuleID = './example.ll'
source_filename = "./example.ll"
; Function Attrs: nounwind uwtable
define i32 @foo(i32 %0, i32 %1, i32* %2, i32* %3) #0 !dbg !7 {
%5 = add nsw i32 %0, 2, !dbg !25
%6 = sext i32 %5 to i64, !dbg !26
call void @llvm.dbg.value(metadata i64 %6, metadata !18, metadata !DIExpression()), !dbg !27
%7 = icmp sgt i32 %1, 0, !dbg !28
br i1 %7, label %8, label %11, !dbg !29
8: ; preds = %4
%9 = or i64 %6, 5, !dbg !30
call void @llvm.dbg.value(metadata i64 %9, metadata !20, metadata !DIExpression()), !dbg !31
%10 = trunc i64 %9 to i32, !dbg !32
store i32 %10, i32* %2, align 4, !dbg !33, !tbaa !34
br label %14, !dbg !38
11: ; preds = %4
%12 = add nsw i64 %6, 3, !dbg !39
call void @llvm.dbg.value(metadata i64 %12, metadata !23, metadata !DIExpression()), !dbg !40
%13 = trunc i64 %12 to i32, !dbg !41
store i32 %13, i32* %3, align 4, !dbg !42, !tbaa !34
br label %14
14: ; preds = %11, %8
ret i32 undef, !dbg !43
}
; Function Attrs: nounwind readnone speculatable willreturn
declare void @llvm.dbg.value(metadata, metadata, metadata) #1
attributes #0 = { nounwind uwtable }
attributes #1 = { nounwind readnone speculatable willreturn }
!llvm.dbg.cu = !{#0}
!llvm.module.flags = !{#3, !4, !5}
!llvm.ident = !{#6}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0 (https://github.com/llvm/llvm-project.git 2b37174)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "example.c", directory: "/home/ce")
!2 = !{}
!3 = !{i32 7, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{i32 1, !"wchar_size", i32 4}
!6 = !{!"clang version 12.0.0 (https://github.com/llvm/llvm-project.git 2b37174)"}
!7 = distinct !DISubprogram(name: "foo", scope: !8, file: !8, line: 2, type: !9, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13)
!8 = !DIFile(filename: "
The text was updated successfully, but these errors were encountered: