Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aabf18d

Browse files
authored
Revert "[DebugLine] Correct debug line emittion" (llvm#158343)
Reverts llvm#157529 Sorry, I missed that the missed that the LLVM test was using clang - layering dictates thats not OK. Please readjust the test case to work like the existing test coverage (or perhaps the existing test coverage is sufficient?) and post a new PR.
1 parent 1756b6e commit aabf18d

File tree

4 files changed

+49
-162
lines changed

4 files changed

+49
-162
lines changed

llvm/lib/MC/MCDwarf.cpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -181,47 +181,37 @@ void MCDwarfLineTable::emitOne(
181181

182182
unsigned FileNum, LastLine, Column, Flags, Isa, Discriminator;
183183
bool IsAtStartSeq;
184-
MCSymbol *PrevLabel;
184+
MCSymbol *LastLabel;
185185
auto init = [&]() {
186186
FileNum = 1;
187187
LastLine = 1;
188188
Column = 0;
189189
Flags = DWARF2_LINE_DEFAULT_IS_STMT ? DWARF2_FLAG_IS_STMT : 0;
190190
Isa = 0;
191191
Discriminator = 0;
192-
PrevLabel = nullptr;
192+
LastLabel = nullptr;
193193
IsAtStartSeq = true;
194194
};
195195
init();
196196

197197
// Loop through each MCDwarfLineEntry and encode the dwarf line number table.
198198
bool EndEntryEmitted = false;
199-
for (auto It = LineEntries.begin(); It != LineEntries.end(); ++It) {
200-
auto LineEntry = *It;
201-
MCSymbol *CurrLabel = LineEntry.getLabel();
199+
for (const MCDwarfLineEntry &LineEntry : LineEntries) {
200+
MCSymbol *Label = LineEntry.getLabel();
202201
const MCAsmInfo *asmInfo = MCOS->getContext().getAsmInfo();
203202

204203
if (LineEntry.LineStreamLabel) {
205204
if (!IsAtStartSeq) {
206-
auto *Label = CurrLabel;
207-
auto NextIt = It + 1;
208-
// LineEntry with a null Label is probably a fake LineEntry we added
209-
// when `-emit-func-debug-line-table-offsets` in order to terminate the
210-
// sequence. Look for the next Label if possible, otherwise we will set
211-
// the PC to the end of the section.
212-
if (!Label && NextIt != LineEntries.end()) {
213-
Label = NextIt->getLabel();
214-
}
215-
MCOS->emitDwarfLineEndEntry(Section, PrevLabel,
216-
/*EndLabel =*/Label);
205+
MCOS->emitDwarfLineEndEntry(Section, LastLabel,
206+
/*EndLabel =*/LastLabel);
217207
init();
218208
}
219209
MCOS->emitLabel(LineEntry.LineStreamLabel, LineEntry.StreamLabelDefLoc);
220210
continue;
221211
}
222212

223213
if (LineEntry.IsEndEntry) {
224-
MCOS->emitDwarfAdvanceLineAddr(INT64_MAX, PrevLabel, CurrLabel,
214+
MCOS->emitDwarfAdvanceLineAddr(INT64_MAX, LastLabel, Label,
225215
asmInfo->getCodePointerSize());
226216
init();
227217
EndEntryEmitted = true;
@@ -268,12 +258,12 @@ void MCDwarfLineTable::emitOne(
268258
// At this point we want to emit/create the sequence to encode the delta in
269259
// line numbers and the increment of the address from the previous Label
270260
// and the current Label.
271-
MCOS->emitDwarfAdvanceLineAddr(LineDelta, PrevLabel, CurrLabel,
261+
MCOS->emitDwarfAdvanceLineAddr(LineDelta, LastLabel, Label,
272262
asmInfo->getCodePointerSize());
273263

274264
Discriminator = 0;
275265
LastLine = LineEntry.getLine();
276-
PrevLabel = CurrLabel;
266+
LastLabel = Label;
277267
IsAtStartSeq = false;
278268
}
279269

@@ -283,7 +273,7 @@ void MCDwarfLineTable::emitOne(
283273
// does not track ranges nor terminate the line table. In that case,
284274
// conservatively use the section end symbol to end the line table.
285275
if (!EndEntryEmitted && !IsAtStartSeq)
286-
MCOS->emitDwarfLineEndEntry(Section, PrevLabel);
276+
MCOS->emitDwarfLineEndEntry(Section, LastLabel);
287277
}
288278

289279
void MCDwarfLineTable::endCurrentSeqAndEmitLineStreamLabel(MCStreamer *MCOS,

llvm/test/DebugInfo/ARM/stmt_seq_macho.test

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

llvm/test/DebugInfo/X86/DW_AT_LLVM_stmt_seq_sec_offset.ll

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
; STMT_SEQ: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset] (0x00000043)
1515
; STMT_SEQ: DW_AT_name {{.*}}func01
1616
; STMT_SEQ: DW_TAG_subprogram [[[ABBREV_CODE2]]]
17-
; STMT_SEQ: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset] (0x00000058)
17+
; STMT_SEQ: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset] (0x00000056)
1818
; STMT_SEQ: DW_AT_name {{.*}}main
1919

2020
;; Check the entire line sequence to see that it's correct
@@ -29,23 +29,22 @@
2929
; STMT_SEQ-NEXT: 0x00000050: 05 DW_LNS_set_column (3)
3030
; STMT_SEQ-NEXT: 0x00000052: 67 address += 6, line += 1, op-index += 0
3131
; STMT_SEQ-NEXT: 0x0000000000000006 6 3 0 0 0 0 is_stmt
32-
; STMT_SEQ-NEXT: 0x00000053: 02 DW_LNS_advance_pc (addr += 2, op-index += 0)
33-
; STMT_SEQ-NEXT: 0x00000055: 00 DW_LNE_end_sequence
34-
; STMT_SEQ-NEXT: 0x0000000000000008 6 3 0 0 0 0 is_stmt end_sequence
35-
; STMT_SEQ-NEXT: 0x00000058: 04 DW_LNS_set_file (0)
36-
; STMT_SEQ-NEXT: 0x0000005a: 00 DW_LNE_set_address (0x00000008)
37-
; STMT_SEQ-NEXT: 0x00000061: 03 DW_LNS_advance_line (10)
38-
; STMT_SEQ-NEXT: 0x00000063: 01 DW_LNS_copy
32+
; STMT_SEQ-NEXT: 0x00000053: 00 DW_LNE_end_sequence
33+
; STMT_SEQ-NEXT: 0x0000000000000006 6 3 0 0 0 0 is_stmt end_sequence
34+
; STMT_SEQ-NEXT: 0x00000056: 04 DW_LNS_set_file (0)
35+
; STMT_SEQ-NEXT: 0x00000058: 00 DW_LNE_set_address (0x00000008)
36+
; STMT_SEQ-NEXT: 0x0000005f: 03 DW_LNS_advance_line (10)
37+
; STMT_SEQ-NEXT: 0x00000061: 01 DW_LNS_copy
3938
; STMT_SEQ-NEXT: 0x0000000000000008 10 0 0 0 0 0 is_stmt
40-
; STMT_SEQ-NEXT: 0x00000064: 05 DW_LNS_set_column (10)
41-
; STMT_SEQ-NEXT: 0x00000066: 0a DW_LNS_set_prologue_end
42-
; STMT_SEQ-NEXT: 0x00000067: 83 address += 8, line += 1, op-index += 0
39+
; STMT_SEQ-NEXT: 0x00000062: 05 DW_LNS_set_column (10)
40+
; STMT_SEQ-NEXT: 0x00000064: 0a DW_LNS_set_prologue_end
41+
; STMT_SEQ-NEXT: 0x00000065: 83 address += 8, line += 1, op-index += 0
4342
; STMT_SEQ-NEXT: 0x0000000000000010 11 10 0 0 0 0 is_stmt prologue_end
44-
; STMT_SEQ-NEXT: 0x00000068: 05 DW_LNS_set_column (3)
45-
; STMT_SEQ-NEXT: 0x0000006a: 9f address += 10, line += 1, op-index += 0
43+
; STMT_SEQ-NEXT: 0x00000066: 05 DW_LNS_set_column (3)
44+
; STMT_SEQ-NEXT: 0x00000068: 9f address += 10, line += 1, op-index += 0
4645
; STMT_SEQ-NEXT: 0x000000000000001a 12 3 0 0 0 0 is_stmt
47-
; STMT_SEQ-NEXT: 0x0000006b: 02 DW_LNS_advance_pc (addr += 5, op-index += 0)
48-
; STMT_SEQ-NEXT: 0x0000006d: 00 DW_LNE_end_sequence
46+
; STMT_SEQ-NEXT: 0x00000069: 02 DW_LNS_advance_pc (addr += 5, op-index += 0)
47+
; STMT_SEQ-NEXT: 0x0000006b: 00 DW_LNE_end_sequence
4948
; STMT_SEQ-NEXT: 0x000000000000001f 12 3 0 0 0 0 is_stmt end_sequence
5049

5150
; generated from:

llvm/test/MC/ELF/debug-loc-label.s

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,43 @@
1717
# CHECK-LINE-TABLE-NEXT: 0x0000002a: 00 DW_LNE_set_address (0x0000000000000000)
1818
# CHECK-LINE-TABLE-NEXT: 0x00000035: 01 DW_LNS_copy
1919
# CHECK-LINE-TABLE-NEXT: 0x0000000000000000 1 1 1 0 0 0 is_stmt
20-
# CHECK-LINE-TABLE-NEXT: 0x00000036: 02 DW_LNS_advance_pc (addr += 8, op-index += 0)
21-
# CHECK-LINE-TABLE-NEXT: 0x00000038: 00 DW_LNE_end_sequence
22-
# CHECK-LINE-TABLE-NEXT: 0x0000000000000008 1 1 1 0 0 0 is_stmt end_sequence
23-
# CHECK-LINE-TABLE-NEXT: 0x0000003b: 05 DW_LNS_set_column (2)
24-
# CHECK-LINE-TABLE-NEXT: 0x0000003d: 00 DW_LNE_set_address (0x0000000000000008)
25-
# CHECK-LINE-TABLE-NEXT: 0x00000048: 01 DW_LNS_copy
20+
# CHECK-LINE-TABLE-NEXT: 0x00000036: 00 DW_LNE_end_sequence
21+
# CHECK-LINE-TABLE-NEXT: 0x0000000000000000 1 1 1 0 0 0 is_stmt end_sequence
22+
# CHECK-LINE-TABLE-NEXT: 0x00000039: 05 DW_LNS_set_column (2)
23+
# CHECK-LINE-TABLE-NEXT: 0x0000003b: 00 DW_LNE_set_address (0x0000000000000008)
24+
# CHECK-LINE-TABLE-NEXT: 0x00000046: 01 DW_LNS_copy
2625
# CHECK-LINE-TABLE-NEXT: 0x0000000000000008 1 2 1 0 0 0 is_stmt
27-
# CHECK-LINE-TABLE-NEXT: 0x00000049: 02 DW_LNS_advance_pc (addr += 8, op-index += 0)
28-
# CHECK-LINE-TABLE-NEXT: 0x0000004b: 00 DW_LNE_end_sequence
29-
# CHECK-LINE-TABLE-NEXT: 0x0000000000000010 1 2 1 0 0 0 is_stmt end_sequence
30-
# CHECK-LINE-TABLE-NEXT: 0x0000004e: 05 DW_LNS_set_column (3)
31-
# CHECK-LINE-TABLE-NEXT: 0x00000050: 00 DW_LNE_set_address (0x0000000000000010)
32-
# CHECK-LINE-TABLE-NEXT: 0x0000005b: 01 DW_LNS_copy
26+
# CHECK-LINE-TABLE-NEXT: 0x00000047: 00 DW_LNE_end_sequence
27+
# CHECK-LINE-TABLE-NEXT: 0x0000000000000008 1 2 1 0 0 0 is_stmt end_sequence
28+
# CHECK-LINE-TABLE-NEXT: 0x0000004a: 05 DW_LNS_set_column (3)
29+
# CHECK-LINE-TABLE-NEXT: 0x0000004c: 00 DW_LNE_set_address (0x0000000000000010)
30+
# CHECK-LINE-TABLE-NEXT: 0x00000057: 01 DW_LNS_copy
3331
# CHECK-LINE-TABLE-NEXT: 0x0000000000000010 1 3 1 0 0 0 is_stmt
34-
# CHECK-LINE-TABLE-NEXT: 0x0000005c: 02 DW_LNS_advance_pc (addr += 8, op-index += 0)
35-
# CHECK-LINE-TABLE-NEXT: 0x0000005e: 00 DW_LNE_end_sequence
36-
# CHECK-LINE-TABLE-NEXT: 0x0000000000000018 1 3 1 0 0 0 is_stmt end_sequence
37-
# CHECK-LINE-TABLE-NEXT: 0x00000061: 05 DW_LNS_set_column (4)
38-
# CHECK-LINE-TABLE-NEXT: 0x00000063: 00 DW_LNE_set_address (0x0000000000000018)
39-
# CHECK-LINE-TABLE-NEXT: 0x0000006e: 01 DW_LNS_copy
32+
# CHECK-LINE-TABLE-NEXT: 0x00000058: 00 DW_LNE_end_sequence
33+
# CHECK-LINE-TABLE-NEXT: 0x0000000000000010 1 3 1 0 0 0 is_stmt end_sequence
34+
# CHECK-LINE-TABLE-NEXT: 0x0000005b: 05 DW_LNS_set_column (4)
35+
# CHECK-LINE-TABLE-NEXT: 0x0000005d: 00 DW_LNE_set_address (0x0000000000000018)
36+
# CHECK-LINE-TABLE-NEXT: 0x00000068: 01 DW_LNS_copy
4037
# CHECK-LINE-TABLE-NEXT: 0x0000000000000018 1 4 1 0 0 0 is_stmt
41-
# CHECK-LINE-TABLE-NEXT: 0x0000006f: 05 DW_LNS_set_column (5)
42-
# CHECK-LINE-TABLE-NEXT: 0x00000071: 01 DW_LNS_copy
38+
# CHECK-LINE-TABLE-NEXT: 0x00000069: 05 DW_LNS_set_column (5)
39+
# CHECK-LINE-TABLE-NEXT: 0x0000006b: 01 DW_LNS_copy
4340
# CHECK-LINE-TABLE-NEXT: 0x0000000000000018 1 5 1 0 0 0 is_stmt
44-
# CHECK-LINE-TABLE-NEXT: 0x00000072: 02 DW_LNS_advance_pc (addr += 8, op-index += 0)
45-
# CHECK-LINE-TABLE-NEXT: 0x00000074: 00 DW_LNE_end_sequence
46-
# CHECK-LINE-TABLE-NEXT: 0x0000000000000020 1 5 1 0 0 0 is_stmt end_sequence
41+
# CHECK-LINE-TABLE-NEXT: 0x0000006c: 00 DW_LNE_end_sequence
42+
# CHECK-LINE-TABLE-NEXT: 0x0000000000000018 1 5 1 0 0 0 is_stmt end_sequence
4743

4844
# CHECK-SYM: Symbol table '.symtab' contains 9 entries:
4945
# CHECK-SYM-NEXT: Num: Value Size Type Bind Vis Ndx Name
5046
# CHECK-SYM-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
5147
# CHECK-SYM-NEXT: 1: 0000000000000000 0 FILE LOCAL DEFAULT ABS test.c
5248
# CHECK-SYM-NEXT: 2: 0000000000000000 0 SECTION LOCAL DEFAULT 2 .text
53-
# CHECK-SYM-NEXT: 3: 000000000000003b 0 NOTYPE LOCAL DEFAULT 3 my_label_02
54-
# CHECK-SYM-NEXT: 4: 000000000000004e 0 NOTYPE LOCAL DEFAULT 3 my_label_03
55-
# CHECK-SYM-NEXT: 5: 0000000000000061 0 NOTYPE LOCAL DEFAULT 3 my_label_04
56-
# CHECK-SYM-NEXT: 6: 000000000000004e 0 NOTYPE LOCAL DEFAULT 3 my_label_03.1
57-
# CHECK-SYM-NEXT: 7: 0000000000000077 0 NOTYPE LOCAL DEFAULT 3 my_label_05
49+
# CHECK-SYM-NEXT: 3: 0000000000000039 0 NOTYPE LOCAL DEFAULT 3 my_label_02
50+
# CHECK-SYM-NEXT: 4: 000000000000004a 0 NOTYPE LOCAL DEFAULT 3 my_label_03
51+
# CHECK-SYM-NEXT: 5: 000000000000005b 0 NOTYPE LOCAL DEFAULT 3 my_label_04
52+
# CHECK-SYM-NEXT: 6: 000000000000004a 0 NOTYPE LOCAL DEFAULT 3 my_label_03.1
53+
# CHECK-SYM-NEXT: 7: 000000000000006f 0 NOTYPE LOCAL DEFAULT 3 my_label_05
5854
# CHECK-SYM-NEXT: 8: 0000000000000000 0 FUNC GLOBAL DEFAULT 2 foo
5955

60-
# CHECK-OFFSETS: 0000 3b000000 4e000000 61000000
56+
# CHECK-OFFSETS: 0000 39000000 4a000000 5b000000
6157

6258
.text
6359
.file "test.c"

0 commit comments

Comments
 (0)