-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[LiveDebugVariables] Fix a DBG_VALUE reordering issue #111124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# RUN: llc -emit-call-site-info %s -mtriple=mips -start-before=register-coalescer -stop-after=virtregrewriter -o - | FileCheck %s | ||
|
||
# Verify that LiveDebugVariables does not reorder the stack location DBG_VALUE | ||
# and the fragmented DBG_VALUEs for aaa, as the latter may represent a stale | ||
# value. It should also not reorder the DBG_VALUEs for the different variables, | ||
# as that results in noise in pass before/after diffs. | ||
|
||
# CHECK-DAG: ![[aaa:[0-9]+]] = !DILocalVariable(name: "aaa" | ||
# CHECK-DAG: ![[bbb:[0-9]+]] = !DILocalVariable(name: "bbb" | ||
# CHECK-DAG: ![[ccc:[0-9]+]] = !DILocalVariable(name: "ccc" | ||
# CHECK-DAG: ![[ddd:[0-9]+]] = !DILocalVariable(name: "ddd" | ||
|
||
# CHECK: DBG_VALUE 1001, $noreg, ![[aaa]], !DIExpression(DW_OP_LLVM_fragment, 0, 16) | ||
# CHECK-NEXT: DBG_VALUE 1002, $noreg, ![[aaa]], !DIExpression(DW_OP_LLVM_fragment, 16, 16) | ||
# CHECK-NEXT: DBG_VALUE 222, $noreg, ![[bbb]], !DIExpression() | ||
# CHECK-NEXT: DBG_VALUE 333, $noreg, ![[ccc]], !DIExpression() | ||
# CHECK-NEXT: DBG_VALUE 444, $noreg, ![[ddd]], !DIExpression() | ||
# CHECK-NEXT: DBG_VALUE %stack.0, 0, ![[aaa]], !DIExpression() | ||
|
||
--- | | ||
target datalayout = "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64" | ||
target triple = "mips" | ||
|
||
define dso_local i32 @main() local_unnamed_addr #0 !dbg !3 { | ||
entry: | ||
ret i32 0, !dbg !12 | ||
} | ||
|
||
declare !dbg !14 dso_local i32 @foo() local_unnamed_addr | ||
|
||
declare void @llvm.dbg.value(metadata, metadata, metadata) | ||
|
||
attributes #0 = { "frame-pointer"="all" } | ||
|
||
!llvm.dbg.cu = !{!0} | ||
!llvm.module.flags = !{!2} | ||
|
||
!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 19.0.0git", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) | ||
!1 = !DIFile(filename: "main.c", directory: "/", checksumkind: CSK_MD5, checksum: "9edfcd32ce51b21ab508a4a0755aa78b") | ||
!2 = !{i32 2, !"Debug Info Version", i32 3} | ||
!3 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 12, type: !4, scopeLine: 12, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !7) | ||
!4 = !DISubroutineType(types: !5) | ||
!5 = !{!6} | ||
!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) | ||
!7 = !{!8, !9, !10, !11} | ||
!8 = !DILocalVariable(name: "aaa", scope: !3, file: !1, line: 13, type: !6) | ||
!9 = !DILocalVariable(name: "bbb", scope: !3, file: !1, line: 13, type: !6) | ||
!10 = !DILocalVariable(name: "ccc", scope: !3, file: !1, line: 13, type: !6) | ||
!11 = !DILocalVariable(name: "ddd", scope: !3, file: !1, line: 13, type: !6) | ||
!12 = !DILocation(line: 13, scope: !3) | ||
!13 = !{i64 2147496201} | ||
!14 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !4, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized) | ||
|
||
... | ||
--- | ||
name: main | ||
alignment: 4 | ||
tracksRegLiveness: true | ||
registers: | ||
- { id: 0, class: gpr32 } | ||
frameInfo: | ||
maxAlignment: 1 | ||
adjustsStack: true | ||
hasCalls: true | ||
callSites: | ||
- { bb: 0, offset: 1 } | ||
machineFunctionInfo: {} | ||
body: | | ||
bb.0.entry: | ||
ADJCALLSTACKDOWN 16, 0, implicit-def dead $sp, implicit $sp, debug-location !12 | ||
JAL @foo, csr_o32_fpxx, implicit-def dead $ra, implicit-def $sp, implicit-def $v0, debug-location !12 | ||
ADJCALLSTACKUP 16, 0, implicit-def dead $sp, implicit $sp, debug-location !12 | ||
%0:gpr32 = COPY killed $v0, debug-location !12 | ||
DBG_VALUE 1001, $noreg, !8, !DIExpression(DW_OP_LLVM_fragment, 0, 16), debug-location !12 | ||
DBG_VALUE 1002, $noreg, !8, !DIExpression(DW_OP_LLVM_fragment, 16, 16), debug-location !12 | ||
DBG_VALUE 222, $noreg, !9, !DIExpression(), debug-location !12 | ||
DBG_VALUE 333, $noreg, !10, !DIExpression(), debug-location !12 | ||
DBG_VALUE 444, $noreg, !11, !DIExpression(), debug-location !12 | ||
DBG_VALUE %0, $noreg, !8, !DIExpression(), debug-location !12 | ||
INLINEASM &"", 1 /* sideeffect attdialect */, 12 /* clobber */, implicit-def dead early-clobber $v0, 12 /* clobber */, implicit-def dead early-clobber $v1, 12 /* clobber */, implicit-def dead early-clobber $a0, 12 /* clobber */, implicit-def dead early-clobber $a1, 12 /* clobber */, implicit-def dead early-clobber $a2, 12 /* clobber */, implicit-def dead early-clobber $a3, 12 /* clobber */, implicit-def dead early-clobber $t0, 12 /* clobber */, implicit-def dead early-clobber $t1, 12 /* clobber */, implicit-def dead early-clobber $t2, 12 /* clobber */, implicit-def dead early-clobber $t3, 12 /* clobber */, implicit-def dead early-clobber $t4, 12 /* clobber */, implicit-def dead early-clobber $t5, 12 /* clobber */, implicit-def dead early-clobber $t6, 12 /* clobber */, implicit-def dead early-clobber $t7, 12 /* clobber */, implicit-def dead early-clobber $t8, 12 /* clobber */, implicit-def dead early-clobber $t9, 12 /* clobber */, implicit-def dead early-clobber $gp, 12 /* clobber */, implicit-def dead early-clobber $ra, 12 /* clobber */, implicit-def dead early-clobber $s0, 12 /* clobber */, implicit-def dead early-clobber $s1, 12 /* clobber */, implicit-def dead early-clobber $s2, 12 /* clobber */, implicit-def dead early-clobber $s3, 12 /* clobber */, implicit-def dead early-clobber $s4, 12 /* clobber */, implicit-def dead early-clobber $s5, 12 /* clobber */, implicit-def dead early-clobber $s6, 12 /* clobber */, implicit-def dead early-clobber $s7, 12 /* clobber */, implicit-def dead early-clobber $at, !13, debug-location !12 | ||
$v0 = COPY killed %0, debug-location !12 | ||
RetRA implicit killed $v0, debug-location !12 | ||
|
||
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard for me to analyse just from the github UI as this isn't a MIR test, but !120 = gScene, !121 = gSceneOffsets, which are ordered !120, !121 in the two pre-isel dbg.values. In the old check lines the DEBUG_VALUE lines come out in the right order, but now they're flipped?
Chances are I'm reading it wrong, or there's some other re-ordering happening somewhere in LLVM that LDVars was just accidentally undoing, seeing how the order in other test files changes is fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case the debug values get reordered at isel due to the order of the lowered parameters. I should perhaps have added an XXX note about that in the test. I can do that.