[llvm] [DWARFLinker] Allow emission of repeated identical discriminators (PR #98255)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 9 17:31:54 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-debuginfo
Author: David Tellenbach (dtellenbach)
<details>
<summary>Changes</summary>
Zero discriminator for each row in the line-table to correctly emit repeated but identical discriminators.
Without this patch line-tables like
0x0000000100003bac 12 20 0 0 65 0
0x0000000100003bb4 12 30 0 0 65 0
0x0000000100003bbc 12 28 0 0 65 0
0x0000000100003bcc 12 17 0 0 65 0
get falsely linked as
0x0000000100003bac 12 20 0 0 65 0
0x0000000100003bb4 12 30 0 0 0 0
0x0000000100003bbc 12 28 0 0 0 0
0x0000000100003bcc 12 17 0 0 0 0
---
Full diff: https://github.com/llvm/llvm-project/pull/98255.diff
6 Files Affected:
- (modified) llvm/lib/DWARFLinker/Classic/DWARFStreamer.cpp (+1)
- (modified) llvm/lib/DWARFLinker/Parallel/DebugLineSectionEmitter.h (+1)
- (modified) llvm/test/tools/dsymutil/ARM/discriminator.test (+7-9)
- (added) llvm/test/tools/dsymutil/ARM/discriminator_repeated.test (+51)
- (added) llvm/test/tools/dsymutil/Inputs/discriminator_repeated.arm64.dylib ()
- (added) llvm/test/tools/dsymutil/Inputs/discriminator_repeated.arm64.o ()
``````````diff
diff --git a/llvm/lib/DWARFLinker/Classic/DWARFStreamer.cpp b/llvm/lib/DWARFLinker/Classic/DWARFStreamer.cpp
index cc4ee2a1b4aec..74df2eb9d68ae 100644
--- a/llvm/lib/DWARFLinker/Classic/DWARFStreamer.cpp
+++ b/llvm/lib/DWARFLinker/Classic/DWARFStreamer.cpp
@@ -1110,6 +1110,7 @@ void DwarfStreamer::emitLineTableRows(
LineSectionSize += /* extended op */ 1 + getULEB128Size(Size + 1) +
/* discriminator */ 1 + Size;
}
+ Discriminator = 0;
if (Isa != Row.Isa) {
Isa = Row.Isa;
diff --git a/llvm/lib/DWARFLinker/Parallel/DebugLineSectionEmitter.h b/llvm/lib/DWARFLinker/Parallel/DebugLineSectionEmitter.h
index 0c4395589248a..38357c7f97314 100644
--- a/llvm/lib/DWARFLinker/Parallel/DebugLineSectionEmitter.h
+++ b/llvm/lib/DWARFLinker/Parallel/DebugLineSectionEmitter.h
@@ -359,6 +359,7 @@ class DebugLineSectionEmitter {
Section.emitIntVal(dwarf::DW_LNE_set_discriminator, 1);
encodeULEB128(Discriminator, Section.OS);
}
+ Discriminator = 0;
if (Isa != Row.Isa) {
Isa = Row.Isa;
diff --git a/llvm/test/tools/dsymutil/ARM/discriminator.test b/llvm/test/tools/dsymutil/ARM/discriminator.test
index d89d9af95d281..5d258786889cc 100644
--- a/llvm/test/tools/dsymutil/ARM/discriminator.test
+++ b/llvm/test/tools/dsymutil/ARM/discriminator.test
@@ -6,18 +6,16 @@
;
; with -g -fdebug-info-for-profiling -O2.
-RUN: dsymutil --flat --linker=classic -oso-prepend-path %p -o - \
-RUN: --oso-prepend-path %p/../Inputs --verify-dwarf=none \
-RUN: %p/../Inputs/discriminator.arm64.dylib | llvm-dwarfdump -debug-line - \
-RUN: | FileCheck %s
+RUN: dsymutil --flat --linker=classic -o - --oso-prepend-path %p/../Inputs \
+RUN: --verify-dwarf=none %p/../Inputs/discriminator.arm64.dylib \
+RUN: | llvm-dwarfdump -debug-line - | FileCheck %s
-RUN: dsymutil --flat --linker=parallel -oso-prepend-path %p -o - \
-RUN: --oso-prepend-path %p/../Inputs --verify-dwarf=none \
-RUN: %p/../Inputs/discriminator.arm64.dylib | llvm-dwarfdump -debug-line - \
-RUN: | FileCheck %s
+RUN: dsymutil --flat --linker=parallel -o - --oso-prepend-path %p/../Inputs \
+RUN: --verify-dwarf=none %p/../Inputs/discriminator.arm64.dylib \
+RUN: | llvm-dwarfdump -debug-line - | FileCheck %s
CHECK: Address Line Column File ISA Discriminator OpIndex Flags
CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------- -------------
CHECK-NEXT: 0x0000000000003f98 2 10 0 0 0 0 is_stmt prologue_end
CHECK-NEXT: 0x0000000000003fa4 2 3 0 0 6 0
-CHECK-NEXT: 0x0000000000003fa8 2 3 0 0 0 0 end_sequence
\ No newline at end of file
+CHECK-NEXT: 0x0000000000003fa8 2 3 0 0 6 0 end_sequence
\ No newline at end of file
diff --git a/llvm/test/tools/dsymutil/ARM/discriminator_repeated.test b/llvm/test/tools/dsymutil/ARM/discriminator_repeated.test
new file mode 100644
index 0000000000000..1c4dfc133abde
--- /dev/null
+++ b/llvm/test/tools/dsymutil/ARM/discriminator_repeated.test
@@ -0,0 +1,51 @@
+; The input at Inputs/discriminator_repeated.arm64.* were
+; produced by compiling
+;
+; void loop(int X, int Y, unsigned int **A, unsigned int **B, unsigned int **C) {
+; for (int i = 0; i < X; i++)
+; for (int j = 0; j < Y; j++)
+; C[i][j] += A[i][j] + B[i][j];
+; }
+;
+; with -g -fdebug-info-for-profiling -O2.
+
+RUN: dsymutil --flat --linker=classic -o - --oso-prepend-path %p/../Inputs \
+RUN: --verify-dwarf=none %p/../Inputs/discriminator_repeated.arm64.dylib \
+RUN: | llvm-dwarfdump -debug-line - | FileCheck %s
+
+RUN: dsymutil --flat --linker=parallel -o - --oso-prepend-path %p/../Inputs \
+RUN: --verify-dwarf=none %p/../Inputs/discriminator_repeated.arm64.dylib \
+RUN: | llvm-dwarfdump -debug-line - | FileCheck %s
+
+CHECK: Address Line Column File ISA Discriminator OpIndex Flags
+CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------- -------------
+CHECK-NEXT: 0x0000000000003e8c 2 3 0 0 2 0 is_stmt prologue_end
+CHECK-NEXT: 0x0000000000003e94 0 3 0 0 0 0
+CHECK-NEXT: 0x0000000000003e98 2 21 0 0 2 0
+CHECK-NEXT: 0x0000000000003ea0 2 3 0 0 2 0
+CHECK-NEXT: 0x0000000000003eac 2 27 0 0 4 0
+CHECK-NEXT: 0x0000000000003eb0 2 3 0 0 2 0
+CHECK-NEXT: 0x0000000000003eb8 3 5 0 0 2 0 is_stmt
+CHECK-NEXT: 0x0000000000003ec0 0 5 0 0 0 0
+CHECK-NEXT: 0x0000000000003ecc 3 5 0 0 2 0
+CHECK-NEXT: 0x0000000000003ed4 0 5 0 0 0 0
+CHECK-NEXT: 0x0000000000003ed8 3 5 0 0 0 0
+CHECK-NEXT: 0x0000000000003eec 4 18 0 0 0 0 is_stmt
+CHECK-NEXT: 0x0000000000003ef0 4 28 0 0 0 0
+CHECK-NEXT: 0x0000000000003ef4 4 15 0 0 0 0
+CHECK-NEXT: 0x0000000000003ef8 4 26 0 0 0 0
+CHECK-NEXT: 0x0000000000003efc 4 15 0 0 0 0
+CHECK-NEXT: 0x0000000000003f04 3 23 0 0 2 0 is_stmt
+CHECK-NEXT: 0x0000000000003f08 3 5 0 0 2 0
+CHECK-NEXT: 0x0000000000003f10 0 5 0 0 0 0
+CHECK-NEXT: 0x0000000000003f14 3 5 0 0 2 0
+CHECK-NEXT: 0x0000000000003f3c 3 5 0 0 0 0
+CHECK-NEXT: 0x0000000000003f4c 4 18 0 0 65 0 is_stmt
+CHECK-NEXT: 0x0000000000003f54 4 28 0 0 65 0
+CHECK-NEXT: 0x0000000000003f5c 4 26 0 0 65 0
+CHECK-NEXT: 0x0000000000003f6c 4 15 0 0 65 0
+CHECK-NEXT: 0x0000000000003f8c 3 29 0 0 4100 0 is_stmt
+CHECK-NEXT: 0x0000000000003f94 0 29 0 0 0 0
+CHECK-NEXT: 0x0000000000003f98 3 5 0 0 4098 0
+CHECK-NEXT: 0x0000000000003fa4 5 1 0 0 0 0 is_stmt
+CHECK-NEXT: 0x0000000000003fa8 5 1 0 0 0 0 is_stmt end_sequence
\ No newline at end of file
diff --git a/llvm/test/tools/dsymutil/Inputs/discriminator_repeated.arm64.dylib b/llvm/test/tools/dsymutil/Inputs/discriminator_repeated.arm64.dylib
new file mode 100755
index 0000000000000..62b7a42499a65
Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/discriminator_repeated.arm64.dylib differ
diff --git a/llvm/test/tools/dsymutil/Inputs/discriminator_repeated.arm64.o b/llvm/test/tools/dsymutil/Inputs/discriminator_repeated.arm64.o
new file mode 100644
index 0000000000000..ebfac06d592d8
Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/discriminator_repeated.arm64.o differ
``````````
</details>
https://github.com/llvm/llvm-project/pull/98255
More information about the llvm-commits
mailing list