Skip to content

Commit 8ab1dd3

Browse files
authored
[DWARFLinker] Allow emission of repeated identical discriminators (#98255)
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
1 parent d38a8e9 commit 8ab1dd3

File tree

6 files changed

+60
-9
lines changed

6 files changed

+60
-9
lines changed

llvm/lib/DWARFLinker/Classic/DWARFStreamer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,7 @@ void DwarfStreamer::emitLineTableRows(
11101110
LineSectionSize += /* extended op */ 1 + getULEB128Size(Size + 1) +
11111111
/* discriminator */ 1 + Size;
11121112
}
1113+
Discriminator = 0;
11131114

11141115
if (Isa != Row.Isa) {
11151116
Isa = Row.Isa;

llvm/lib/DWARFLinker/Parallel/DebugLineSectionEmitter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ class DebugLineSectionEmitter {
359359
Section.emitIntVal(dwarf::DW_LNE_set_discriminator, 1);
360360
encodeULEB128(Discriminator, Section.OS);
361361
}
362+
Discriminator = 0;
362363

363364
if (Isa != Row.Isa) {
364365
Isa = Row.Isa;

llvm/test/tools/dsymutil/ARM/discriminator.test

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@
66
;
77
; with -g -fdebug-info-for-profiling -O2.
88

9-
RUN: dsymutil --flat --linker=classic -oso-prepend-path %p -o - \
10-
RUN: --oso-prepend-path %p/../Inputs --verify-dwarf=none \
11-
RUN: %p/../Inputs/discriminator.arm64.dylib | llvm-dwarfdump -debug-line - \
12-
RUN: | FileCheck %s
9+
RUN: dsymutil --flat --linker=classic -o - --oso-prepend-path %p/../Inputs \
10+
RUN: --verify-dwarf=none %p/../Inputs/discriminator.arm64.dylib \
11+
RUN: | llvm-dwarfdump -debug-line - | FileCheck %s
1312

14-
RUN: dsymutil --flat --linker=parallel -oso-prepend-path %p -o - \
15-
RUN: --oso-prepend-path %p/../Inputs --verify-dwarf=none \
16-
RUN: %p/../Inputs/discriminator.arm64.dylib | llvm-dwarfdump -debug-line - \
17-
RUN: | FileCheck %s
13+
RUN: dsymutil --flat --linker=parallel -o - --oso-prepend-path %p/../Inputs \
14+
RUN: --verify-dwarf=none %p/../Inputs/discriminator.arm64.dylib \
15+
RUN: | llvm-dwarfdump -debug-line - | FileCheck %s
1816

1917
CHECK: Address Line Column File ISA Discriminator OpIndex Flags
2018
CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------- -------------
2119
CHECK-NEXT: 0x0000000000003f98 2 10 0 0 0 0 is_stmt prologue_end
2220
CHECK-NEXT: 0x0000000000003fa4 2 3 0 0 6 0
23-
CHECK-NEXT: 0x0000000000003fa8 2 3 0 0 0 0 end_sequence
21+
CHECK-NEXT: 0x0000000000003fa8 2 3 0 0 6 0 end_sequence
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
; The input at Inputs/discriminator_repeated.arm64.* were
2+
; produced by compiling
3+
;
4+
; void loop(int X, int Y, unsigned int **A, unsigned int **B, unsigned int **C) {
5+
; for (int i = 0; i < X; i++)
6+
; for (int j = 0; j < Y; j++)
7+
; C[i][j] += A[i][j] + B[i][j];
8+
; }
9+
;
10+
; with -g -fdebug-info-for-profiling -O2.
11+
12+
RUN: dsymutil --flat --linker=classic -o - --oso-prepend-path %p/../Inputs \
13+
RUN: --verify-dwarf=none %p/../Inputs/discriminator_repeated.arm64.dylib \
14+
RUN: | llvm-dwarfdump -debug-line - | FileCheck %s
15+
16+
RUN: dsymutil --flat --linker=parallel -o - --oso-prepend-path %p/../Inputs \
17+
RUN: --verify-dwarf=none %p/../Inputs/discriminator_repeated.arm64.dylib \
18+
RUN: | llvm-dwarfdump -debug-line - | FileCheck %s
19+
20+
CHECK: Address Line Column File ISA Discriminator OpIndex Flags
21+
CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------- -------------
22+
CHECK-NEXT: 0x0000000000003e8c 2 3 0 0 2 0 is_stmt prologue_end
23+
CHECK-NEXT: 0x0000000000003e94 0 3 0 0 0 0
24+
CHECK-NEXT: 0x0000000000003e98 2 21 0 0 2 0
25+
CHECK-NEXT: 0x0000000000003ea0 2 3 0 0 2 0
26+
CHECK-NEXT: 0x0000000000003eac 2 27 0 0 4 0
27+
CHECK-NEXT: 0x0000000000003eb0 2 3 0 0 2 0
28+
CHECK-NEXT: 0x0000000000003eb8 3 5 0 0 2 0 is_stmt
29+
CHECK-NEXT: 0x0000000000003ec0 0 5 0 0 0 0
30+
CHECK-NEXT: 0x0000000000003ecc 3 5 0 0 2 0
31+
CHECK-NEXT: 0x0000000000003ed4 0 5 0 0 0 0
32+
CHECK-NEXT: 0x0000000000003ed8 3 5 0 0 0 0
33+
CHECK-NEXT: 0x0000000000003eec 4 18 0 0 0 0 is_stmt
34+
CHECK-NEXT: 0x0000000000003ef0 4 28 0 0 0 0
35+
CHECK-NEXT: 0x0000000000003ef4 4 15 0 0 0 0
36+
CHECK-NEXT: 0x0000000000003ef8 4 26 0 0 0 0
37+
CHECK-NEXT: 0x0000000000003efc 4 15 0 0 0 0
38+
CHECK-NEXT: 0x0000000000003f04 3 23 0 0 2 0 is_stmt
39+
CHECK-NEXT: 0x0000000000003f08 3 5 0 0 2 0
40+
CHECK-NEXT: 0x0000000000003f10 0 5 0 0 0 0
41+
CHECK-NEXT: 0x0000000000003f14 3 5 0 0 2 0
42+
CHECK-NEXT: 0x0000000000003f3c 3 5 0 0 0 0
43+
CHECK-NEXT: 0x0000000000003f4c 4 18 0 0 65 0 is_stmt
44+
CHECK-NEXT: 0x0000000000003f54 4 28 0 0 65 0
45+
CHECK-NEXT: 0x0000000000003f5c 4 26 0 0 65 0
46+
CHECK-NEXT: 0x0000000000003f6c 4 15 0 0 65 0
47+
CHECK-NEXT: 0x0000000000003f8c 3 29 0 0 4100 0 is_stmt
48+
CHECK-NEXT: 0x0000000000003f94 0 29 0 0 0 0
49+
CHECK-NEXT: 0x0000000000003f98 3 5 0 0 4098 0
50+
CHECK-NEXT: 0x0000000000003fa4 5 1 0 0 0 0 is_stmt
51+
CHECK-NEXT: 0x0000000000003fa8 5 1 0 0 0 0 is_stmt end_sequence
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)