[llvm] [InstCombine][DebugInfo] Update debug value uses in `freelyInvertAllUsersOf` (PR #137013)
Orlando Cazalet-Hyams via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 25 02:39:57 PDT 2025
https://github.com/OCHyams commented:
Interesting - so this is a case where we generate incorrect locations (without your patch). Out of curiosity, are you able to share how you found the bug?
I agree the case you fixed looks like it was wrong before, but I'm worried the fix is too broad - e.g. does this case work with your patch?
https://godbolt.org/z/713j8Yqad
```
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define i32 @test(i32 noundef %x, i32 noundef %y) !dbg !10 {
entry:
%cmp = icmp ne i32 %x, 0, !dbg !19
%not = xor i1 %cmp, 1
#dbg_value(i1 %not, !17, !DIExpression(), !18)
%conv = zext i1 %not to i32, !dbg !19
ret i32 %conv, !dbg !21
}
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8}
!llvm.ident = !{!9}
!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 21.0.0git", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "test.c", directory: "/", checksumkind: CSK_MD5, checksum: "b2d9ffc7905684d8b7c3b52a3136e57c")
!2 = !{i32 7, !"Dwarf Version", i32 5}
!3 = !{i32 2, !"Debug Info Version", i32 3}
!4 = !{i32 1, !"wchar_size", i32 4}
!5 = !{i32 8, !"PIC Level", i32 2}
!6 = !{i32 7, !"PIE Level", i32 2}
!7 = !{i32 7, !"uwtable", i32 2}
!8 = !{i32 7, !"debug-info-assignment-tracking", i1 true}
!9 = !{!"clang version 21.0.0git"}
!10 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 1, type: !11, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !14)
!11 = !DISubroutineType(types: !12)
!12 = !{!13, !13, !13}
!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!14 = !{!15, !16, !17}
!15 = !DILocalVariable(name: "x", arg: 1, scope: !10, file: !1, line: 1, type: !13)
!16 = !DILocalVariable(name: "y", arg: 2, scope: !10, file: !1, line: 1, type: !13)
!17 = !DILocalVariable(name: "z", scope: !10, file: !1, line: 2, type: !13)
!18 = !DILocation(line: 0, scope: !10)
!19 = !DILocation(line: 2, column: 13, scope: !10)
!20 = !DILocation(line: 3, column: 12, scope: !10)
!21 = !DILocation(line: 3, column: 3, scope: !10)
```
AFAICT that's a `freelyInvertAllUsersOf` call that gets the debug info correct (without your patch).
https://github.com/llvm/llvm-project/pull/137013
More information about the llvm-commits
mailing list