forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-apply 3fab2d1, now with a triple added
Was reverted in 1c1b670 as it broke all non-x86 bots. Original commit message: [DebugInfo][InstrRef] Add a max-stack-slots-to-track cut-out In certain circumstances with things like autogenerated code and asan, you can end up with thousands of Values live at the same time, causing a large working set and a lot of information spilled to the stack. Unfortunately InstrRefBasedLDV doesn't cope well with this and consumes a lot of memory when there are many many stack slots. See the reproducer in D116821. It seems very unlikely that a developer would be able to reason about hundreds of live named local variables at the same time, so a huge working set and many stack slots is an indicator that we're likely analysing autogenerated or instrumented code. In those cases: gracefully degrade by setting an upper bound on the amount of stack slots to track. This limits peak memory consumption, at the cost of dropping some variable locations, but in a rare scenario where it's unlikely someone is actually going to use them. In terms of the patch, this adds a cl::opt for max number of stack slots to track, and has the stack-slot-numbering code optionally return None. That then filters through a number of code paths, which can then chose to not track a spill / restore if it touches an untracked spill slot. The added test checks that we drop variable locations that are on the stack, if we set the limit to zero. Differential Revision: https://reviews.llvm.org/D118601
- Loading branch information
Showing
4 changed files
with
169 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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 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 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,90 @@ | ||
# RUN: llc %s -o - -experimental-debug-variable-locations \ | ||
# RUN: -mtriple=x86_64-unknown-unknown \ | ||
# RUN: -run-pass=livedebugvalues -livedebugvalues-max-stack-slots=0 | \ | ||
# RUN: FileCheck %s --implicit-check-not=DBG_VALUE | ||
# RUN: llc %s -o - -experimental-debug-variable-locations \ | ||
# RUN: -mtriple=x86_64-unknown-unknown \ | ||
# RUN: -run-pass=livedebugvalues -livedebugvalues-max-stack-slots=100 | \ | ||
# RUN: FileCheck %s --check-prefixes=NOLIMIT --implicit-check-not=DBG_VALUE | ||
# | ||
# Test that spills of live values to the stack are NOT tracked by | ||
# LiveDebugValues if an internal accounting limit is exceeded -- in this test, | ||
# set to zero. This is to avoid scenarios where we track thousands of stack | ||
# slots, which can show up with autogenerated code and/or asan. | ||
# | ||
# This is a copy of livedebugvalues_stackslot_subregs.mir, here the stack slot | ||
# limit is set to zero, meaning the spill shouldn't be tracked. | ||
# | ||
## Capture variable num, | ||
# CHECK: ![[VARNUM:[0-9]+]] = !DILocalVariable | ||
# | ||
## There should be no variable location, just a single DBG_VALUE $noreg. | ||
# CHECK: DBG_VALUE $noreg | ||
# | ||
## And then another. | ||
# CHECK: DBG_VALUE $noreg | ||
# | ||
## Test that if there's no limit, we _do_ get some locations. | ||
# NOLIMIT: DBG_INSTR_REF 1, 0 | ||
# NOLIMIT-NEXT: DBG_VALUE $esi | ||
# | ||
# NOLIMIT: DBG_INSTR_REF 5, | ||
# NOLIMIT-NEXT: DBG_VALUE $rsp | ||
--- | | ||
define i8 @test(i32 %bar) local_unnamed_addr !dbg !7 { | ||
entry: | ||
ret i8 0, !dbg !12 | ||
} | ||
|
||
declare dso_local void @ext(i64) | ||
|
||
!llvm.dbg.cu = !{!0} | ||
!llvm.module.flags = !{!3, !4, !5, !6} | ||
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) | ||
!1 = !DIFile(filename: "foo.cpp", directory: ".") | ||
!2 = !DIBasicType(name: "int", size: 8, encoding: DW_ATE_signed) | ||
!3 = !{i32 2, !"Dwarf Version", i32 4} | ||
!4 = !{i32 2, !"Debug Info Version", i32 3} | ||
!5 = !{i32 1, !"wchar_size", i32 2} | ||
!6 = !{i32 7, !"PIC Level", i32 2} | ||
!7 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !1, file: !1, line: 6, type: !8, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !10) | ||
!8 = !DISubroutineType(types: !9) | ||
!9 = !{!2, !2} | ||
!10 = !{!11} | ||
!11 = !DILocalVariable(name: "baz", scope: !7, file: !1, line: 7, type: !2) | ||
!12 = !DILocation(line: 10, scope: !7) | ||
... | ||
--- | ||
name: test | ||
tracksRegLiveness: true | ||
liveins: | ||
- { reg: '$rdi', virtual-reg: '' } | ||
stack: | ||
- { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8, | ||
stack-id: default, callee-saved-register: '', callee-saved-restored: true, | ||
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } | ||
body: | | ||
bb.0: | ||
liveins: $rdi, $rax, $rbx | ||
$eax = MOV32ri 0, debug-instr-number 1 | ||
$edi = COPY $eax | ||
MOV64mr $rsp, 1, $noreg, 16, $noreg, $rdi :: (store 8 into %stack.0) | ||
$rsi = MOV64rm $rsp, 1, $noreg, 8, $noreg :: (load 8 from %stack.0) | ||
MOV64mr $rsp, 1, $noreg, 16, $noreg, $rbx :: (store 8 into %stack.0) | ||
$rax = MOV64ri 0 | ||
$rdi = MOV64ri 0 | ||
DBG_INSTR_REF 1, 0, !11, !DIExpression(), debug-location !12 | ||
; This shouldn't find anything -- we have disabled tracking of spills. | ||
; In addition to plain spills, spills that are folded into instructions | ||
; shouldn't be tracked either. | ||
INC32m $rsp, 1, $noreg, 4, $noreg, implicit-def dead $eflags, debug-instr-number 5, debug-location !12 :: (store (s32) into %stack.0) | ||
DBG_INSTR_REF 5, 1000000, !11, !DIExpression(), debug-location !12 | ||
; Shouldn't be able to find the reference to instr 5's memory operand. | ||
RET64 $rsi, debug-location !12 | ||
... |
Oops, something went wrong.