Skip to content

Commit 51a29b5

Browse files
committed
Revert2 "[DebugInfo][DWARF] Set is_stmt on first non-line-0 instruction in BB (#105524)"
Reverted due to large .debug_line size regressions for some configurations; work currently in place to improve the output of this behaviour in PR #108251. This patch also modifies two tests that were created or modified after the original commit landed and are affected by the revert: llvm/test/CodeGen/X86/pseudo_cmov_lower2.ll llvm/test/DebugInfo/X86/empty-line-info.ll This reverts commit 5fef40c.
1 parent 090850f commit 51a29b5

File tree

9 files changed

+16
-61
lines changed

9 files changed

+16
-61
lines changed

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,8 +2061,10 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
20612061
unsigned LastAsmLine =
20622062
Asm->OutStreamer->getContext().getCurrentDwarfLoc().getLine();
20632063

2064-
bool PrevInstInDiffBB = PrevInstBB && PrevInstBB != MI->getParent();
2065-
if (DL == PrevInstLoc && !PrevInstInDiffBB) {
2064+
bool PrevInstInSameSection =
2065+
(!PrevInstBB ||
2066+
PrevInstBB->getSectionID() == MI->getParent()->getSectionID());
2067+
if (DL == PrevInstLoc && PrevInstInSameSection) {
20662068
// If we have an ongoing unspecified location, nothing to do here.
20672069
if (!DL)
20682070
return;
@@ -2091,7 +2093,8 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
20912093
// possibly debug information; we want it to have a source location.
20922094
// - Instruction is at the top of a block; we don't want to inherit the
20932095
// location from the physically previous (maybe unrelated) block.
2094-
if (UnknownLocations == Enable || PrevLabel || PrevInstInDiffBB) {
2096+
if (UnknownLocations == Enable || PrevLabel ||
2097+
(PrevInstBB && PrevInstBB != MI->getParent())) {
20952098
// Preserve the file and column numbers, if we can, to save space in
20962099
// the encoded line table.
20972100
// Do not update PrevInstLoc, it remembers the last non-0 line.
@@ -2116,11 +2119,9 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
21162119
PrologEndLoc = nullptr;
21172120
}
21182121
// If the line changed, we call that a new statement; unless we went to
2119-
// line 0 and came back, in which case it is not a new statement. We also
2120-
// mark is_stmt for the first non-0 line in each BB, in case a predecessor BB
2121-
// ends with a different line.
2122+
// line 0 and came back, in which case it is not a new statement.
21222123
unsigned OldLine = PrevInstLoc ? PrevInstLoc.getLine() : LastAsmLine;
2123-
if (DL.getLine() && (DL.getLine() != OldLine || PrevInstInDiffBB))
2124+
if (DL.getLine() && DL.getLine() != OldLine)
21242125
Flags |= DWARF2_FLAG_IS_STMT;
21252126

21262127
const MDNode *Scope = DL.getScope();

llvm/test/CodeGen/Thumb2/pr52817.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ define i32 @test(ptr %arg, ptr %arg1, ptr %arg2) #0 !dbg !6 {
2424
; CHECK-NEXT: movs r3, #0
2525
; CHECK-NEXT: LBB0_1: @ %bb3
2626
; CHECK-NEXT: @ =>This Inner Loop Header: Depth=1
27-
; CHECK-NEXT: .loc 1 0 0 is_stmt 0 @ :0:0
2827
; CHECK-NEXT: adds r5, r3, #1
2928
; CHECK-NEXT: str.w lr, [r2]
3029
; CHECK-NEXT: cmp.w lr, #0
@@ -37,7 +36,7 @@ define i32 @test(ptr %arg, ptr %arg1, ptr %arg2) #0 !dbg !6 {
3736
; CHECK-NEXT: movne r6, #0
3837
; CHECK-NEXT: Ltmp0:
3938
; CHECK-NEXT: @DEBUG_VALUE: test:this <- [DW_OP_LLVM_arg 0, DW_OP_plus_uconst 135168, DW_OP_LLVM_arg 1, DW_OP_constu 4, DW_OP_mul, DW_OP_plus, DW_OP_plus_uconst 4, DW_OP_stack_value] $r0, $r5
40-
; CHECK-NEXT: .loc 1 28 24 prologue_end is_stmt 1 @ test.cpp:28:24
39+
; CHECK-NEXT: .loc 1 28 24 prologue_end @ test.cpp:28:24
4140
; CHECK-NEXT: strne.w r6, [r8]
4241
; CHECK-NEXT: moveq r6, #1
4342
; CHECK-NEXT: ldr r4, [r4, #4]

llvm/test/CodeGen/X86/fsafdo_test1.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
; Check that fs-afdo discriminators are generated.
55
; V01: .loc 1 7 3 is_stmt 0 discriminator 2 # foo.c:7:3
66
; V01: .loc 1 9 5 is_stmt 1 discriminator 2 # foo.c:9:5
7-
; V0: .loc 1 9 5 is_stmt 1 discriminator 11266 # foo.c:9:5
7+
; V0: .loc 1 9 5 discriminator 11266 # foo.c:9:5
88
; V0: .loc 1 7 3 is_stmt 1 discriminator 11266 # foo.c:7:3
9-
; V1: .loc 1 9 5 is_stmt 1 discriminator 514 # foo.c:9:5
9+
; V1: .loc 1 9 5 discriminator 514 # foo.c:9:5
1010
; V1: .loc 1 7 3 is_stmt 1 discriminator 258 # foo.c:7:3
1111
; Check that variable __llvm_fs_discriminator__ is generated.
1212
; V01: .type __llvm_fs_discriminator__,@object # @__llvm_fs_discriminator__

llvm/test/CodeGen/X86/fsafdo_test4.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
; CHECK: .loc 1 0 3 # foo.c:0:3
88
; CHECK: .loc 1 9 5 is_stmt 1 discriminator 2 # foo.c:9:5
99
; CHECK: .loc 1 0 5 is_stmt 0 # :0:5
10-
; CHECK: .loc 1 9 5 is_stmt 1 discriminator 2 # foo.c:9:5
11-
; CHECK: .loc 1 0 5 is_stmt 0 # :0:5
10+
; CHECK: .loc 1 9 5 discriminator 2 # foo.c:9:5
11+
; CHECK: .loc 1 0 5 # :0:5
1212
; CHECK: .loc 1 7 3 is_stmt 1 discriminator 2 # foo.c:7:3
1313
; CHECK: .loc 1 14 3 # foo.c:14:3
1414
; Check that variable __llvm_fs_discriminator__ is NOT generated.

llvm/test/CodeGen/X86/pseudo_cmov_lower2.ll

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,6 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
198198
; Like the test for @foo1, but check that the inserted dbg.value does not
199199
; affect codegen. The CHECK items below should always be identical to @foo1,
200200
; minus the DEBUG_VALUE line and changes in labels..
201-
; We produce a scope-line source location for the entry block, and then
202-
; explicitly terminate it in the second block, as there are no other source
203-
; locations in the function.
204201
define double @foo1_g(float %p1, double %p2, double %p3) nounwind !dbg !4 {
205202
; CHECK-LABEL: foo1_g:
206203
; CHECK: .file 1 "." "test.c"
@@ -211,7 +208,6 @@ define double @foo1_g(float %p1, double %p2, double %p3) nounwind !dbg !4 {
211208
; CHECK-NEXT: movsd {{.*#+}} xmm0 = [1.25E+0,0.0E+0]
212209
; CHECK-NEXT: jae .LBB6_1
213210
; CHECK-NEXT: # %bb.2: # %entry
214-
; CHECK-NEXT: .loc 1 0 0 is_stmt 0
215211
; CHECK-NEXT: addsd %xmm2, %xmm0
216212
; CHECK-NEXT: jmp .LBB6_3
217213
; CHECK-NEXT: .LBB6_1:

llvm/test/DebugInfo/MIR/X86/empty-inline.mir

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
# CHECK: Address Line Column File ISA Discriminator OpIndex Flags
1515
# CHECK-NEXT: ---
1616
# CHECK-NEXT: 25 0 1 0 0 0 is_stmt
17-
# CHECK-NEXT: 0 0 1 0 0 0
1817
# CHECK-NEXT: 29 28 1 0 0 0 is_stmt prologue_end
19-
# CHECK-NEXT: 29 28 1 0 0 0 is_stmt
2018
# CHECK-NEXT: 29 28 1 0 0 0 is_stmt end_sequence
2119
--- |
2220
source_filename = "t.ll"

llvm/test/DebugInfo/X86/discriminator.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "frame-pointer"=
5959

6060
; CHECK: Address Line Column File ISA Discriminator OpIndex Flags
6161
; CHECK: ------------------ ------ ------ ------ --- ------------- ------- -------------
62-
; CHECK: 0x000000000000000a 2 0 1 0 42 0 is_stmt{{$}}
62+
; CHECK: 0x000000000000000a 2 0 1 0 42 0 {{$}}

llvm/test/DebugInfo/X86/empty-line-info.ll

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ entry:
1919
}
2020

2121
;; In a function with no source location, but multiple blocks, there will be
22-
;; an opening scope-line, but it'll be automagically terminated when we switch
23-
;; to a new block. Test for this behaviour, and preserve the unconditional
24-
;; branch by compiling -O0.
22+
;; an opening scope-line. Test for this behaviour, and preserve the
23+
;; unconditional branch by compiling -O0.
2524

2625
; UNOPT-LABEL: bar:
2726
; UNOPT-NEXT: .Lfunc_begin1:
@@ -30,7 +29,6 @@ entry:
3029
; UNOPT-NEXT: movq %rdi, -8(%rsp)
3130
; UNOPT-NEXT: jmp .LBB1_1
3231
; UNOPT-LABEL: .LBB1_1:
33-
; UNOPT-NEXT: .loc 1 0 0 is_stmt 0
3432
; UNOPT-NEXT: movq -8(%rsp), %rax
3533

3634
define dso_local noundef i32 @bar(ptr nocapture noundef writeonly %baz) local_unnamed_addr !dbg !20 {

llvm/test/DebugInfo/X86/is_stmt-at-block-start.ll

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)