-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[KeyInstr] Use DISubprogram's is-key-instructions-on flag at DWARF emission #144104
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
Open
OCHyams
wants to merge
2
commits into
llvm:main
Choose a base branch
from
OCHyams:ki-sp-flag-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+123
−5
Open
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
99 changes: 99 additions & 0 deletions
99
llvm/test/DebugInfo/KeyInstructions/X86/dwarf-inline-modes.mir
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,99 @@ | ||
# RUN: llc %s --start-after=livedebugvalues --dwarf-use-key-instructions --filetype=obj -o - \ | ||
# RUN: | llvm-objdump -d - --no-show-raw-insn \ | ||
# RUN: | FileCheck %s --check-prefix=OBJ | ||
|
||
# RUN: llc %s --start-after=livedebugvalues --dwarf-use-key-instructions --filetype=obj -o - \ | ||
# RUN: | llvm-dwarfdump - --debug-line \ | ||
# RUN: | FileCheck %s --check-prefix=DBG | ||
|
||
# Test is_stmt emission for a key-instructions function inlined into a | ||
# not-key-instructions function, and vice versa. | ||
|
||
--- | | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
define hidden noundef i32 @key() local_unnamed_addr !dbg !5 { | ||
entry: | ||
ret i32 0 | ||
} | ||
|
||
define hidden noundef i32 @not_key() local_unnamed_addr !dbg !9 { | ||
entry: | ||
ret i32 0 | ||
} | ||
|
||
!llvm.dbg.cu = !{!0} | ||
!llvm.module.flags = !{!2, !3} | ||
!llvm.ident = !{!4} | ||
|
||
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_17, file: !1, producer: "clang version 21.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, splitDebugInlining: false, nameTableKind: None) | ||
!1 = !DIFile(filename: "test.cpp", directory: "/") | ||
!2 = !{i32 7, !"Dwarf Version", i32 5} | ||
!3 = !{i32 2, !"Debug Info Version", i32 3} | ||
!4 = !{!"clang version 21.0.0"} | ||
!5 = distinct !DISubprogram(name: "key", scope: !1, file: !1, line: 1, type: !6, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, keyInstructions: true) | ||
!6 = !DISubroutineType(types: !7) | ||
!7 = !{} | ||
!9 = distinct !DISubprogram(name: "not_key", scope: !1, file: !1, line: 1, type: !6, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, keyInstructions: false) | ||
!10 = distinct !DILocation(line: 5, scope: !5) | ||
!11 = distinct !DILocation(line: 9, scope: !9) | ||
... | ||
--- | ||
name: key | ||
alignment: 16 | ||
body: | | ||
bb.0.entry: | ||
|
||
; OBJ: 0000000000000000 <key>: | ||
; OBJ-NEXT: 0: movl $0x1, %eax | ||
; OBJ-NEXT: 5: movl $0x2, %eax | ||
; OBJ-NEXT: a: movl $0x3, %eax | ||
; OBJ-NEXT: f: movl $0x4, %eax | ||
; OBJ-NEXT: 14: movl $0x5, %eax | ||
; OBJ-NEXT: 19: retq | ||
; | ||
; DBG: Address Line Column File ISA Discriminator OpIndex Flags | ||
; DBG-NEXT: ------------------ ------ ------ ------ --- ------------- ------- ------------- | ||
; DBG-NEXT: 0x0000000000000000 1 0 0 0 0 0 is_stmt prologue_end | ||
; DBG-NEXT: 0x0000000000000005 2 0 0 0 0 0 is_stmt | ||
; DBG-NEXT: 0x000000000000000a 2 0 0 0 0 0 | ||
; DBG-NEXT: 0x000000000000000f 3 0 0 0 0 0 is_stmt | ||
; DBG-NEXT: 0x0000000000000014 3 0 0 0 0 0 | ||
; | ||
$eax = MOV32ri 1, debug-location !DILocation(line: 1, scope: !5) ; is_stmt (prologue_end) | ||
$eax = MOV32ri 2, debug-location !DILocation(line: 2, scope: !5, atomGroup: 1, atomRank: 1) ; is_stmt (key) | ||
$eax = MOV32ri 3, debug-location !DILocation(line: 2, scope: !9, inlinedAt: !10) | ||
$eax = MOV32ri 4, debug-location !DILocation(line: 3, scope: !9, inlinedAt: !10) ; is_stmt (not_key) | ||
$eax = MOV32ri 5, debug-location !DILocation(line: 3, scope: !5, atomGroup: 1, atomRank: 2) ; is_stmt (key) | ||
RET64 $eax, debug-location !DILocation(line: 3, scope: !5, atomGroup: 1, atomRank: 1) | ||
... | ||
--- | ||
name: not_key | ||
alignment: 16 | ||
body: | | ||
bb.0.entry: | ||
|
||
; OBJ: 0000000000000020 <not_key>: | ||
; OBJ-NEXT: 20: movl $0x1, %eax | ||
; OBJ-NEXT: 25: movl $0x2, %eax | ||
; OBJ-NEXT: 2a: movl $0x3, %eax | ||
; OBJ-NEXT: 2f: retq | ||
; | ||
; TODO: Currently key inlined into not-key is treated as not-key. Investigate | ||
; performance implications of honouring the flag in this scenario. | ||
; | ||
; Address Line Column File ISA Discriminator OpIndex Flags | ||
; ------------------ ------ ------ ------ --- ------------- ------- ------------- | ||
; DBG-NEXT: 0x0000000000000020 1 0 0 0 0 0 is_stmt prologue_end | ||
; DBG-NEXT: 0x0000000000000025 2 0 0 0 0 0 is_stmt | ||
; DBG-NEXT: 0x000000000000002a 3 0 0 0 0 0 is_stmt | ||
; DBG-NEXT: 0x000000000000002f 3 0 0 0 0 0 | ||
; | ||
; NOTE: The `is_stmt` comments at the end of the lines reflects what we want | ||
; to see if the TODO above is resolved. | ||
; | ||
$eax = MOV32ri 1, debug-location !DILocation(line: 1, scope: !9) ; is_stmt (prologue_end) | ||
$eax = MOV32ri 2, debug-location !DILocation(line: 2, scope: !5, inlinedAt: !11, atomGroup: 1, atomRank: 2) | ||
$eax = MOV32ri 3, debug-location !DILocation(line: 3, scope: !5, inlinedAt: !11, atomGroup: 1, atomRank: 1) ; is_stmt (key) | ||
RET64 $eax, debug-location !DILocation(line: 3, scope: !9) | ||
... |
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.
This is an immense nitpick, but IMO the comment should open by stating the premise "There may be a mixture of scopes using KIs, and not using KIs" or something similar. It's sufficiently non-obvious that it should be made explicit to the future reader.