[llvm] 51a29b5 - Revert2 "[DebugInfo][DWARF] Set is_stmt on first non-line-0 instruction in BB (#105524)"
Stephen Tozer via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 17 10:30:55 PDT 2024
Author: Stephen Tozer
Date: 2024-09-17T18:29:20+01:00
New Revision: 51a29b5f16efab7f46106b6ce14cbfa50d991040
URL: https://github.com/llvm/llvm-project/commit/51a29b5f16efab7f46106b6ce14cbfa50d991040
DIFF: https://github.com/llvm/llvm-project/commit/51a29b5f16efab7f46106b6ce14cbfa50d991040.diff
LOG: 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 5fef40c2c477e92187bd4e5c18091eca6b8465cc.
Added:
Modified:
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/test/CodeGen/Thumb2/pr52817.ll
llvm/test/CodeGen/X86/fsafdo_test1.ll
llvm/test/CodeGen/X86/fsafdo_test4.ll
llvm/test/CodeGen/X86/pseudo_cmov_lower2.ll
llvm/test/DebugInfo/MIR/X86/empty-inline.mir
llvm/test/DebugInfo/X86/discriminator.ll
llvm/test/DebugInfo/X86/empty-line-info.ll
Removed:
llvm/test/DebugInfo/X86/is_stmt-at-block-start.ll
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 148b620c2b62b7..e9649f9ff81658 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2061,8 +2061,10 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
unsigned LastAsmLine =
Asm->OutStreamer->getContext().getCurrentDwarfLoc().getLine();
- bool PrevInstInDiffBB = PrevInstBB && PrevInstBB != MI->getParent();
- if (DL == PrevInstLoc && !PrevInstInDiffBB) {
+ bool PrevInstInSameSection =
+ (!PrevInstBB ||
+ PrevInstBB->getSectionID() == MI->getParent()->getSectionID());
+ if (DL == PrevInstLoc && PrevInstInSameSection) {
// If we have an ongoing unspecified location, nothing to do here.
if (!DL)
return;
@@ -2091,7 +2093,8 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
// possibly debug information; we want it to have a source location.
// - Instruction is at the top of a block; we don't want to inherit the
// location from the physically previous (maybe unrelated) block.
- if (UnknownLocations == Enable || PrevLabel || PrevInstInDiffBB) {
+ if (UnknownLocations == Enable || PrevLabel ||
+ (PrevInstBB && PrevInstBB != MI->getParent())) {
// Preserve the file and column numbers, if we can, to save space in
// the encoded line table.
// Do not update PrevInstLoc, it remembers the last non-0 line.
@@ -2116,11 +2119,9 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
PrologEndLoc = nullptr;
}
// If the line changed, we call that a new statement; unless we went to
- // line 0 and came back, in which case it is not a new statement. We also
- // mark is_stmt for the first non-0 line in each BB, in case a predecessor BB
- // ends with a
diff erent line.
+ // line 0 and came back, in which case it is not a new statement.
unsigned OldLine = PrevInstLoc ? PrevInstLoc.getLine() : LastAsmLine;
- if (DL.getLine() && (DL.getLine() != OldLine || PrevInstInDiffBB))
+ if (DL.getLine() && DL.getLine() != OldLine)
Flags |= DWARF2_FLAG_IS_STMT;
const MDNode *Scope = DL.getScope();
diff --git a/llvm/test/CodeGen/Thumb2/pr52817.ll b/llvm/test/CodeGen/Thumb2/pr52817.ll
index 12daeedf43d818..87615f0a1f7ef4 100644
--- a/llvm/test/CodeGen/Thumb2/pr52817.ll
+++ b/llvm/test/CodeGen/Thumb2/pr52817.ll
@@ -24,7 +24,6 @@ define i32 @test(ptr %arg, ptr %arg1, ptr %arg2) #0 !dbg !6 {
; CHECK-NEXT: movs r3, #0
; CHECK-NEXT: LBB0_1: @ %bb3
; CHECK-NEXT: @ =>This Inner Loop Header: Depth=1
-; CHECK-NEXT: .loc 1 0 0 is_stmt 0 @ :0:0
; CHECK-NEXT: adds r5, r3, #1
; CHECK-NEXT: str.w lr, [r2]
; CHECK-NEXT: cmp.w lr, #0
@@ -37,7 +36,7 @@ define i32 @test(ptr %arg, ptr %arg1, ptr %arg2) #0 !dbg !6 {
; CHECK-NEXT: movne r6, #0
; CHECK-NEXT: Ltmp0:
; 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
-; CHECK-NEXT: .loc 1 28 24 prologue_end is_stmt 1 @ test.cpp:28:24
+; CHECK-NEXT: .loc 1 28 24 prologue_end @ test.cpp:28:24
; CHECK-NEXT: strne.w r6, [r8]
; CHECK-NEXT: moveq r6, #1
; CHECK-NEXT: ldr r4, [r4, #4]
diff --git a/llvm/test/CodeGen/X86/fsafdo_test1.ll b/llvm/test/CodeGen/X86/fsafdo_test1.ll
index 043d47e18e96df..e80a7f2f354f2d 100644
--- a/llvm/test/CodeGen/X86/fsafdo_test1.ll
+++ b/llvm/test/CodeGen/X86/fsafdo_test1.ll
@@ -4,9 +4,9 @@
; Check that fs-afdo discriminators are generated.
; V01: .loc 1 7 3 is_stmt 0 discriminator 2 # foo.c:7:3
; V01: .loc 1 9 5 is_stmt 1 discriminator 2 # foo.c:9:5
-; V0: .loc 1 9 5 is_stmt 1 discriminator 11266 # foo.c:9:5
+; V0: .loc 1 9 5 discriminator 11266 # foo.c:9:5
; V0: .loc 1 7 3 is_stmt 1 discriminator 11266 # foo.c:7:3
-; V1: .loc 1 9 5 is_stmt 1 discriminator 514 # foo.c:9:5
+; V1: .loc 1 9 5 discriminator 514 # foo.c:9:5
; V1: .loc 1 7 3 is_stmt 1 discriminator 258 # foo.c:7:3
; Check that variable __llvm_fs_discriminator__ is generated.
; V01: .type __llvm_fs_discriminator__, at object # @__llvm_fs_discriminator__
diff --git a/llvm/test/CodeGen/X86/fsafdo_test4.ll b/llvm/test/CodeGen/X86/fsafdo_test4.ll
index c9b9ed5b9c919e..effc72b44ade80 100644
--- a/llvm/test/CodeGen/X86/fsafdo_test4.ll
+++ b/llvm/test/CodeGen/X86/fsafdo_test4.ll
@@ -7,8 +7,8 @@
; CHECK: .loc 1 0 3 # foo.c:0:3
; CHECK: .loc 1 9 5 is_stmt 1 discriminator 2 # foo.c:9:5
; CHECK: .loc 1 0 5 is_stmt 0 # :0:5
-; CHECK: .loc 1 9 5 is_stmt 1 discriminator 2 # foo.c:9:5
-; CHECK: .loc 1 0 5 is_stmt 0 # :0:5
+; CHECK: .loc 1 9 5 discriminator 2 # foo.c:9:5
+; CHECK: .loc 1 0 5 # :0:5
; CHECK: .loc 1 7 3 is_stmt 1 discriminator 2 # foo.c:7:3
; CHECK: .loc 1 14 3 # foo.c:14:3
; Check that variable __llvm_fs_discriminator__ is NOT generated.
diff --git a/llvm/test/CodeGen/X86/pseudo_cmov_lower2.ll b/llvm/test/CodeGen/X86/pseudo_cmov_lower2.ll
index 19253d67c14945..ee3d31bb73dca4 100644
--- a/llvm/test/CodeGen/X86/pseudo_cmov_lower2.ll
+++ b/llvm/test/CodeGen/X86/pseudo_cmov_lower2.ll
@@ -198,9 +198,6 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
; Like the test for @foo1, but check that the inserted dbg.value does not
; affect codegen. The CHECK items below should always be identical to @foo1,
; minus the DEBUG_VALUE line and changes in labels..
-; We produce a scope-line source location for the entry block, and then
-; explicitly terminate it in the second block, as there are no other source
-; locations in the function.
define double @foo1_g(float %p1, double %p2, double %p3) nounwind !dbg !4 {
; CHECK-LABEL: foo1_g:
; CHECK: .file 1 "." "test.c"
@@ -211,7 +208,6 @@ define double @foo1_g(float %p1, double %p2, double %p3) nounwind !dbg !4 {
; CHECK-NEXT: movsd {{.*#+}} xmm0 = [1.25E+0,0.0E+0]
; CHECK-NEXT: jae .LBB6_1
; CHECK-NEXT: # %bb.2: # %entry
-; CHECK-NEXT: .loc 1 0 0 is_stmt 0
; CHECK-NEXT: addsd %xmm2, %xmm0
; CHECK-NEXT: jmp .LBB6_3
; CHECK-NEXT: .LBB6_1:
diff --git a/llvm/test/DebugInfo/MIR/X86/empty-inline.mir b/llvm/test/DebugInfo/MIR/X86/empty-inline.mir
index 58775e8cd852fb..695b7c60365b1d 100644
--- a/llvm/test/DebugInfo/MIR/X86/empty-inline.mir
+++ b/llvm/test/DebugInfo/MIR/X86/empty-inline.mir
@@ -14,9 +14,7 @@
# CHECK: Address Line Column File ISA Discriminator OpIndex Flags
# CHECK-NEXT: ---
# CHECK-NEXT: 25 0 1 0 0 0 is_stmt
-# CHECK-NEXT: 0 0 1 0 0 0
# CHECK-NEXT: 29 28 1 0 0 0 is_stmt prologue_end
-# CHECK-NEXT: 29 28 1 0 0 0 is_stmt
# CHECK-NEXT: 29 28 1 0 0 0 is_stmt end_sequence
--- |
source_filename = "t.ll"
diff --git a/llvm/test/DebugInfo/X86/discriminator.ll b/llvm/test/DebugInfo/X86/discriminator.ll
index 120d928b5676b0..ef89838acf0324 100644
--- a/llvm/test/DebugInfo/X86/discriminator.ll
+++ b/llvm/test/DebugInfo/X86/discriminator.ll
@@ -59,4 +59,4 @@ attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "frame-pointer"=
; CHECK: Address Line Column File ISA Discriminator OpIndex Flags
; CHECK: ------------------ ------ ------ ------ --- ------------- ------- -------------
-; CHECK: 0x000000000000000a 2 0 1 0 42 0 is_stmt{{$}}
+; CHECK: 0x000000000000000a 2 0 1 0 42 0 {{$}}
diff --git a/llvm/test/DebugInfo/X86/empty-line-info.ll b/llvm/test/DebugInfo/X86/empty-line-info.ll
index e726e5c882460c..232e1da1c901c0 100644
--- a/llvm/test/DebugInfo/X86/empty-line-info.ll
+++ b/llvm/test/DebugInfo/X86/empty-line-info.ll
@@ -19,9 +19,8 @@ entry:
}
;; In a function with no source location, but multiple blocks, there will be
-;; an opening scope-line, but it'll be automagically terminated when we switch
-;; to a new block. Test for this behaviour, and preserve the unconditional
-;; branch by compiling -O0.
+;; an opening scope-line. Test for this behaviour, and preserve the
+;; unconditional branch by compiling -O0.
; UNOPT-LABEL: bar:
; UNOPT-NEXT: .Lfunc_begin1:
@@ -30,7 +29,6 @@ entry:
; UNOPT-NEXT: movq %rdi, -8(%rsp)
; UNOPT-NEXT: jmp .LBB1_1
; UNOPT-LABEL: .LBB1_1:
-; UNOPT-NEXT: .loc 1 0 0 is_stmt 0
; UNOPT-NEXT: movq -8(%rsp), %rax
define dso_local noundef i32 @bar(ptr nocapture noundef writeonly %baz) local_unnamed_addr !dbg !20 {
diff --git a/llvm/test/DebugInfo/X86/is_stmt-at-block-start.ll b/llvm/test/DebugInfo/X86/is_stmt-at-block-start.ll
deleted file mode 100644
index f4e98512675d9d..00000000000000
--- a/llvm/test/DebugInfo/X86/is_stmt-at-block-start.ll
+++ /dev/null
@@ -1,37 +0,0 @@
-;; Checks that when an instruction at the start of a BasicBlock has the same
-;; DebugLoc as the instruction at the end of the previous BasicBlock, we add
-;; is_stmt to the new line, to ensure that we still step on it if we arrive from
-;; a BasicBlock other than the immediately preceding one.
-
-; RUN: %llc_dwarf -mtriple=x86_64-unknown-linux -O0 -filetype=obj < %s | llvm-dwarfdump --debug-line - | FileCheck %s
-
-; CHECK: {{0x[0-9a-f]+}} 13 5 {{.+}} is_stmt
-; CHECK-NEXT: {{0x[0-9a-f]+}} 13 5 {{.+}} is_stmt
-
-define void @_Z1fi(i1 %cond) !dbg !21 {
-entry:
- br i1 %cond, label %if.then2, label %if.else4
-
-if.then2: ; preds = %entry
- br label %if.end8, !dbg !24
-
-if.else4: ; preds = %entry
- %0 = load i32, ptr null, align 4, !dbg !24
- %call5 = call i1 null(i32 %0)
- ret void
-
-if.end8: ; preds = %if.then2
- ret void
-}
-
-!llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!20}
-
-!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 20.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
-!1 = !DIFile(filename: "test.cpp", directory: "/home/gbtozers/dev/upstream-llvm")
-!20 = !{i32 2, !"Debug Info Version", i32 3}
-!21 = distinct !DISubprogram(name: "f", linkageName: "_Z1fi", scope: !1, file: !1, line: 7, type: !22, scopeLine: 7, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0)
-!22 = distinct !DISubroutineType(types: !23)
-!23 = !{null}
-!24 = !DILocation(line: 13, column: 5, scope: !25)
-!25 = distinct !DILexicalBlock(scope: !21, file: !1, line: 11, column: 27)
More information about the llvm-commits
mailing list