Skip to content

Commit f899c3e

Browse files
committed
[KeyInstr] Fully support mixed key/non-key inlining modes
<link to cost>
1 parent 7354123 commit f899c3e

File tree

2 files changed

+11
-23
lines changed

2 files changed

+11
-23
lines changed

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,13 +2081,12 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
20812081

20822082
// There may be a mixture of scopes using and not using Key Instructions.
20832083
// Not-Key-Instructions functions inlined into Key Instructions functions
2084-
// should use not-key is_stmt handling. Key Instructions functions inlined
2085-
// into not-key-instructions functions currently fall back to not-key
2086-
// handling to avoid having to run computeKeyInstructions for all functions
2087-
// (which will impact non-key-instructions builds).
2088-
// TODO: Investigate the performance impact of doing that.
2084+
// should use not-key is_stmt handling. Key instructions functions inlined
2085+
// into not-key-instructions functions should use Key Instructions is_stmt
2086+
// handling.
20892087
bool ScopeUsesKeyInstructions =
2090-
KeyInstructionsAreStmts && DL && SP->getKeyInstructionsEnabled();
2088+
KeyInstructionsAreStmts && DL &&
2089+
DL->getScope()->getSubprogram()->getKeyInstructionsEnabled();
20912090

20922091
bool IsKey = false;
20932092
if (ScopeUsesKeyInstructions && DL && DL.getLine())
@@ -2663,17 +2662,12 @@ void DwarfDebug::beginFunctionImpl(const MachineFunction *MF) {
26632662
PrologEndLoc = emitInitialLocDirective(
26642663
*MF, Asm->OutStreamer->getContext().getDwarfCompileUnitID());
26652664

2666-
// If this function wasn't built with Key Instructions but has a function
2667-
// inlined into it that was, we treat the inlined instance as if it wasn't
2668-
// built with Key Instructions. If this function was built with Key
2669-
// Instructions but a function inlined into it wasn't then we continue to use
2670-
// Key Instructions for this function and fall back to non-key behaviour for
2671-
// the inlined function (except it doesn't benefit from
2672-
// findForceIsStmtInstrs).
2673-
if (KeyInstructionsAreStmts && SP->getKeyInstructionsEnabled())
2665+
// Run both `findForceIsStmtInstrs` and `computeKeyInstructions` because
2666+
// not-key-instructions functions may be inlined into key-instructions
2667+
// functions and vice versa.
2668+
if (KeyInstructionsAreStmts)
26742669
computeKeyInstructions(MF);
2675-
else
2676-
findForceIsStmtInstrs(MF);
2670+
findForceIsStmtInstrs(MF);
26772671
}
26782672

26792673
unsigned

llvm/test/DebugInfo/KeyInstructions/X86/dwarf-inline-modes.mir

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,13 @@ body: |
7979
; OBJ-NEXT: 2a: movl $0x3, %eax
8080
; OBJ-NEXT: 2f: retq
8181
;
82-
; TODO: Currently key inlined into not-key is treated as not-key. Investigate
83-
; performance implications of honouring the flag in this scenario.
84-
;
8582
; Address Line Column File ISA Discriminator OpIndex Flags
8683
; ------------------ ------ ------ ------ --- ------------- ------- -------------
8784
; DBG-NEXT: 0x0000000000000020 1 0 0 0 0 0 is_stmt prologue_end
88-
; DBG-NEXT: 0x0000000000000025 2 0 0 0 0 0 is_stmt
85+
; DBG-NEXT: 0x0000000000000025 2 0 0 0 0 0
8986
; DBG-NEXT: 0x000000000000002a 3 0 0 0 0 0 is_stmt
9087
; DBG-NEXT: 0x000000000000002f 3 0 0 0 0 0
9188
;
92-
; NOTE: The `is_stmt` comments at the end of the lines reflects what we want
93-
; to see if the TODO above is resolved.
94-
;
9589
$eax = MOV32ri 1, debug-location !DILocation(line: 1, scope: !9) ; is_stmt (prologue_end)
9690
$eax = MOV32ri 2, debug-location !DILocation(line: 2, scope: !5, inlinedAt: !11, atomGroup: 1, atomRank: 2)
9791
$eax = MOV32ri 3, debug-location !DILocation(line: 3, scope: !5, inlinedAt: !11, atomGroup: 1, atomRank: 1) ; is_stmt (key)

0 commit comments

Comments
 (0)