Revert "[MC] output inlined-at debug info (#106230)"

This reverts commit f3dc358953a13caf7521fc615a08f6317930351c.

This causes a large compile-time regression:
https://llvm-compile-time-tracker.com/compare.php?from=267403442264959f6b06e227ff450c385f4b3ef2&to=f3dc358953a13caf7521fc615a08f6317930351c&stat=instructions:u
This commit is contained in:
Nikita Popov 2025-03-07 09:45:15 +01:00
parent d7f409d39a
commit aa1d2cc5d7
10 changed files with 25 additions and 104 deletions

View File

@ -141,8 +141,8 @@ public:
SMLoc Loc) override;
void emitDwarfLocDirective(unsigned FileNo, unsigned Line, unsigned Column,
unsigned Flags, unsigned Isa,
unsigned Discriminator, StringRef FileName,
StringRef Comment = {}) override;
unsigned Discriminator,
StringRef FileName) override;
void emitDwarfAdvanceLineAddr(int64_t LineDelta, const MCSymbol *LastLabel,
const MCSymbol *Label,
unsigned PointerSize) override;

View File

@ -887,8 +887,7 @@ public:
virtual void emitDwarfLocDirective(unsigned FileNo, unsigned Line,
unsigned Column, unsigned Flags,
unsigned Isa, unsigned Discriminator,
StringRef FileName,
StringRef Comment = {});
StringRef FileName);
/// This implements the '.loc_label Name' directive.
virtual void emitDwarfLocLabelDirective(SMLoc Loc, StringRef Name);

View File

@ -2057,14 +2057,6 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
}
}
auto RecordSourceLine = [&](auto &DL, auto Flags) {
SmallString<128> LocationString;
raw_svector_ostream OS(LocationString);
DL.print(OS);
const MDNode *Scope = DL.getScope();
recordSourceLine(DL.getLine(), DL.getCol(), Scope, Flags, LocationString);
};
// When we emit a line-0 record, we don't update PrevInstLoc; so look at
// the last line number actually emitted, to see if it was line 0.
unsigned LastAsmLine =
@ -2092,7 +2084,8 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
// But we might be coming back to it after a line 0 record.
if ((LastAsmLine == 0 && DL.getLine() != 0) || Flags) {
// Reinstate the source location but not marked as a statement.
RecordSourceLine(DL, Flags);
const MDNode *Scope = DL.getScope();
recordSourceLine(DL.getLine(), DL.getCol(), Scope, Flags);
}
return;
}
@ -2143,7 +2136,8 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
if (DL.getLine() && (DL.getLine() != OldLine || ForceIsStmt))
Flags |= DWARF2_FLAG_IS_STMT;
RecordSourceLine(DL, Flags);
const MDNode *Scope = DL.getScope();
recordSourceLine(DL.getLine(), DL.getCol(), Scope, Flags);
// If we're not at line 0, remember this location.
if (DL.getLine())
@ -2278,8 +2272,7 @@ findPrologueEndLoc(const MachineFunction *MF) {
static void recordSourceLine(AsmPrinter &Asm, unsigned Line, unsigned Col,
const MDNode *S, unsigned Flags, unsigned CUID,
uint16_t DwarfVersion,
ArrayRef<std::unique_ptr<DwarfCompileUnit>> DCUs,
StringRef Comment = {}) {
ArrayRef<std::unique_ptr<DwarfCompileUnit>> DCUs) {
StringRef Fn;
unsigned FileNo = 1;
unsigned Discriminator = 0;
@ -2293,7 +2286,7 @@ static void recordSourceLine(AsmPrinter &Asm, unsigned Line, unsigned Col,
.getOrCreateSourceID(Scope->getFile());
}
Asm.OutStreamer->emitDwarfLocDirective(FileNo, Line, Col, Flags, 0,
Discriminator, Fn, Comment);
Discriminator, Fn);
}
const MachineInstr *
@ -2624,10 +2617,10 @@ void DwarfDebug::endFunctionImpl(const MachineFunction *MF) {
// Register a source line with debug info. Returns the unique label that was
// emitted and which provides correspondence to the source line list.
void DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, const MDNode *S,
unsigned Flags, StringRef Location) {
unsigned Flags) {
::recordSourceLine(*Asm, Line, Col, S, Flags,
Asm->OutStreamer->getContext().getDwarfCompileUnitID(),
getDwarfVersion(), getUnits(), Location);
getDwarfVersion(), getUnits());
}
//===----------------------------------------------------------------------===//

View File

@ -679,7 +679,7 @@ private:
/// label that was emitted and which provides correspondence to the
/// source line list.
void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
unsigned Flags, StringRef Location = {});
unsigned Flags);
/// Populate LexicalScope entries with variables' info.
void collectEntityInfo(DwarfCompileUnit &TheCU, const DISubprogram *SP,

View File

@ -294,8 +294,8 @@ public:
unsigned CUID = 0) override;
void emitDwarfLocDirective(unsigned FileNo, unsigned Line, unsigned Column,
unsigned Flags, unsigned Isa,
unsigned Discriminator, StringRef FileName,
StringRef Location = {}) override;
unsigned Discriminator,
StringRef FileName) override;
virtual void emitDwarfLocLabelDirective(SMLoc Loc, StringRef Name) override;
MCSymbol *getDwarfLineTableSymbol(unsigned CUID) override;
@ -1688,8 +1688,7 @@ void MCAsmStreamer::emitDwarfFile0Directive(
void MCAsmStreamer::emitDwarfLocDirective(unsigned FileNo, unsigned Line,
unsigned Column, unsigned Flags,
unsigned Isa, unsigned Discriminator,
StringRef FileName,
StringRef Comment) {
StringRef FileName) {
// If target doesn't support .loc/.file directive, we need to record the lines
// same way like we do in object mode.
if (MAI->isAIX()) {
@ -1697,7 +1696,7 @@ void MCAsmStreamer::emitDwarfLocDirective(unsigned FileNo, unsigned Line,
// first one gets a line entry.
MCDwarfLineEntry::make(this, getCurrentSectionOnly());
this->MCStreamer::emitDwarfLocDirective(FileNo, Line, Column, Flags, Isa,
Discriminator, FileName, Comment);
Discriminator, FileName);
return;
}
@ -1728,15 +1727,12 @@ void MCAsmStreamer::emitDwarfLocDirective(unsigned FileNo, unsigned Line,
if (IsVerboseAsm) {
OS.PadToColumn(MAI->getCommentColumn());
OS << MAI->getCommentString() << ' ';
if (Comment.empty())
OS << FileName << ':' << Line << ':' << Column;
else
OS << Comment;
OS << MAI->getCommentString() << ' ' << FileName << ':'
<< Line << ':' << Column;
}
EmitEOL();
this->MCStreamer::emitDwarfLocDirective(FileNo, Line, Column, Flags, Isa,
Discriminator, FileName, Comment);
Discriminator, FileName);
}
void MCAsmStreamer::emitDwarfLocLabelDirective(SMLoc Loc, StringRef Name) {

View File

@ -418,14 +418,13 @@ void MCObjectStreamer::emitDwarfLocDirective(unsigned FileNo, unsigned Line,
unsigned Column, unsigned Flags,
unsigned Isa,
unsigned Discriminator,
StringRef FileName,
StringRef Comment) {
StringRef FileName) {
// In case we see two .loc directives in a row, make sure the
// first one gets a line entry.
MCDwarfLineEntry::make(this, getCurrentSectionOnly());
this->MCStreamer::emitDwarfLocDirective(FileNo, Line, Column, Flags, Isa,
Discriminator, FileName, Comment);
Discriminator, FileName);
}
static const MCExpr *buildSymbolDiff(MCObjectStreamer &OS, const MCSymbol *A,

View File

@ -238,7 +238,7 @@ void MCStreamer::emitCFIMTETaggedFrame() {
void MCStreamer::emitDwarfLocDirective(unsigned FileNo, unsigned Line,
unsigned Column, unsigned Flags,
unsigned Isa, unsigned Discriminator,
StringRef FileName, StringRef Comment) {
StringRef FileName) {
getContext().setCurrentDwarfLoc(FileNo, Line, Column, Flags, Isa,
Discriminator);
}

View File

@ -1,66 +0,0 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx908 < %s | FileCheck %s
define amdgpu_kernel void @_Z3fooPiiii(ptr addrspace(1) nocapture noundef writeonly %c.coerce, i32 noundef %a, i32 noundef %b, i32 noundef %d) !dbg !9 {
; CHECK-LABEL: _Z3fooPiiii:
; CHECK: .Lfunc_begin0:
; CHECK-NEXT: .file 0 "test" "a.hip" md5 0x004a28df8cfd98cdd2c71d5d814d9c6b
; CHECK-NEXT: .cfi_sections .debug_frame
; CHECK-NEXT: .cfi_startproc
; CHECK-NEXT: ; %bb.0: ; %entry
; CHECK-NEXT: .file 1 "." "a.h"
; CHECK-NEXT: .loc 1 5 12 prologue_end ; ./a.h:5:12 @[ a.hip:12:8 ]
; CHECK-NEXT: s_load_dwordx4 s[0:3], s[8:9], 0x8
; CHECK-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
; CHECK-NEXT: v_mov_b32_e32 v0, 0
; CHECK-NEXT: s_waitcnt lgkmcnt(0)
; CHECK-NEXT: s_add_i32 s1, s1, s0
; CHECK-NEXT: .Ltmp0:
; CHECK-NEXT: .loc 1 5 12 is_stmt 0 ; ./a.h:5:12 @[ a.hip:13:9 ]
; CHECK-NEXT: s_add_i32 s0, s2, s0
; CHECK-NEXT: .Ltmp1:
; CHECK-NEXT: .file 2 "a.hip"
; CHECK-NEXT: .loc 2 13 6 is_stmt 1 ; a.hip:13:6
; CHECK-NEXT: s_mul_i32 s0, s0, s1
; CHECK-NEXT: v_mov_b32_e32 v1, s0
; CHECK-NEXT: global_store_dword v0, v1, s[4:5]
; CHECK-NEXT: .loc 2 14 1 ; a.hip:14:1
; CHECK-NEXT: s_endpgm
; CHECK-NEXT: .Ltmp2:
entry:
%add.i = add nsw i32 %b, %a, !dbg !13
%add.i3 = add nsw i32 %d, %a, !dbg !17
%mul = mul nsw i32 %add.i3, %add.i, !dbg !19
store i32 %mul, ptr addrspace(1) %c.coerce, align 4, !dbg !19, !tbaa !20
ret void, !dbg !24
}
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!2, !3, !4, !5, !6, !7}
!llvm.ident = !{!8}
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 20.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "a.hip", directory: "test", checksumkind: CSK_MD5, checksum: "004a28df8cfd98cdd2c71d5d814d9c6b")
!2 = !{i32 1, !"amdhsa_code_object_version", i32 500}
!3 = !{i32 1, !"amdgpu_printf_kind", !"hostcall"}
!4 = !{i32 7, !"Dwarf Version", i32 5}
!5 = !{i32 2, !"Debug Info Version", i32 3}
!6 = !{i32 1, !"wchar_size", i32 4}
!7 = !{i32 8, !"PIC Level", i32 2}
!8 = !{!"clang version 20.0.0"}
!9 = distinct !DISubprogram(name: "foo", scope: !10, file: !10, line: 11, type: !11, scopeLine: 11, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
!10 = !DIFile(filename: "a.hip", directory: "test")
!11 = !DISubroutineType(types: !12)
!12 = !{}
!13 = !DILocation(line: 5, column: 12, scope: !14, inlinedAt: !16)
!14 = distinct !DISubprogram(name: "bar", scope: !15, file: !15, line: 4, type: !11, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
!15 = !DIFile(filename: "./a.h", directory: "test")
!16 = distinct !DILocation(line: 12, column: 8, scope: !9)
!17 = !DILocation(line: 5, column: 12, scope: !14, inlinedAt: !18)
!18 = distinct !DILocation(line: 13, column: 9, scope: !9)
!19 = !DILocation(line: 13, column: 6, scope: !9)
!20 = !{!21, !21, i64 0}
!21 = !{!"int", !22, i64 0}
!22 = !{!"omnipotent char", !23, i64 0}
!23 = !{!"Simple C++ TBAA"}
!24 = !DILocation(line: 14, column: 1, scope: !9)

View File

@ -6,7 +6,7 @@
; CHECK-LABEL: f
; CHECK: entsp [[S:[0-9]+]]
; ...the prologue...
; CHECK: .loc 1 2 0 prologue_end # test.c:2
; CHECK: .loc 1 2 0 prologue_end # test.c:2:0
; CHECK: add r0, r0, 1
; CHECK: retsp [[S]]
define i32 @f(i32 %a) !dbg !4 {

View File

@ -18,8 +18,8 @@
; Make sure the condition test is attributed to the inline function, not the
; location of the test's operands within the caller.
; ASM: # inline-seldag-test.c:4:0
; ASM: .loc 1 2 0 # inline-seldag-test.c:2 @[ inline-seldag-test.c:6:7 ]
; ASM: # inline-seldag-test.c:2:0
; ASM-NOT: .loc
; ASM: testl
; Function Attrs: nounwind uwtable