Skip to content

Commit 5b9a072

Browse files
committed
Revert a5c8ec4 "[CGDebugInfo] Emit subprograms for decls when AT_tail_call is understood"
This caused Chromium builds to fail with "inlinable function call in a function with debug info must have a !dbg location" errors. See https://bugs.chromium.org/p/chromium/issues/detail?id=1022296#c1 for a reproducer. > Currently, clang emits subprograms for declared functions when the > target debugger or DWARF standard is known to support entry values > (DW_OP_entry_value & the GNU equivalent). > > Treat DW_AT_tail_call the same way to allow debuggers to follow cross-TU > tail calls. > > Pre-patch debug session with a cross-TU tail call: > > ``` > * frame #0: 0x0000000100000fa4 main`target at b.c:4:3 [opt] > frame #1: 0x0000000100000f99 main`main at a.c:8:10 [opt] > ``` > > Post-patch (note that the tail-calling frame, "helper", is visible): > > ``` > * frame #0: 0x0000000100000fa4 main`target at b.c:4:3 [opt] > frame #1: 0x0000000100000f80 main`helper [opt] [artificial] > frame #2: 0x0000000100000f99 main`main at a.c:8:10 [opt] > ``` > > rdar://46577651 > > Differential Revision: https://reviews.llvm.org/D69743
1 parent dec8d8d commit 5b9a072

File tree

4 files changed

+10
-31
lines changed

4 files changed

+10
-31
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -3748,7 +3748,9 @@ void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
37483748
void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
37493749
QualType CalleeType,
37503750
const FunctionDecl *CalleeDecl) {
3751-
if (!CallOrInvoke || getCallSiteRelatedAttrs() == llvm::DINode::FlagZero)
3751+
auto &CGOpts = CGM.getCodeGenOpts();
3752+
if (!CGOpts.EnableDebugEntryValues || !CGM.getLangOpts().Optimize ||
3753+
!CallOrInvoke)
37523754
return;
37533755

37543756
auto *Func = CallOrInvoke->getCalledFunction();
@@ -4822,10 +4824,10 @@ llvm::DINode::DIFlags CGDebugInfo::getCallSiteRelatedAttrs() const {
48224824
bool SupportsDWARFv4Ext =
48234825
CGM.getCodeGenOpts().DwarfVersion == 4 &&
48244826
(CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB ||
4825-
CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::GDB);
4827+
(CGM.getCodeGenOpts().EnableDebugEntryValues &&
4828+
CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::GDB));
48264829

4827-
if (!SupportsDWARFv4Ext && CGM.getCodeGenOpts().DwarfVersion < 5 &&
4828-
!CGM.getCodeGenOpts().EnableDebugEntryValues)
4830+
if (!SupportsDWARFv4Ext && CGM.getCodeGenOpts().DwarfVersion < 5)
48294831
return llvm::DINode::FlagZero;
48304832

48314833
return llvm::DINode::FlagAllCallsDescribed;

clang/test/CodeGen/debug-info-extern-call.c

+4-17
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
1-
// When entry values are emitted, expect a subprogram for extern decls so that
2-
// the dwarf generator can describe call site parameters at extern call sites.
3-
//
4-
// RUN: %clang -Xclang -femit-debug-entry-values -g -O2 -target x86_64-none-linux-gnu -S -emit-llvm %s -o - | FileCheck %s -check-prefix=ENTRY-VAL
5-
// ENTRY-VAL: !DISubprogram(name: "fn1"
1+
// RUN: %clang -Xclang -femit-debug-entry-values -g -O2 -target x86_64-none-linux-gnu -S -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-EXT
2+
// CHECK-EXT: !DISubprogram(name: "fn1"
63

7-
// Similarly, when the debugger tuning is gdb, expect a subprogram for extern
8-
// decls so that the dwarf generator can describe information needed for tail
9-
// call frame reconstrution.
10-
//
11-
// RUN: %clang -g -O2 -target x86_64-none-linux-gnu -ggdb -S -emit-llvm %s -o - | FileCheck %s -check-prefix=GDB
12-
// GDB: !DISubprogram(name: "fn1"
13-
//
14-
// Do not emit a subprogram for extern decls when entry values are disabled and
15-
// the tuning is not set to gdb.
16-
//
17-
// RUN: %clang -g -O2 -target x86_64-none-linux-gnu -gsce -S -emit-llvm %s -o - | FileCheck %s -check-prefix=SCE
18-
// SCE-NOT: !DISubprogram(name: "fn1"
4+
// RUN: %clang -g -O2 -target x86_64-none-linux-gnu -S -emit-llvm %s -o - | FileCheck %s
5+
// CHECK-NOT: !DISubprogram(name: "fn1"
196

207
extern int fn1(int a, int b);
218

clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656

5757
// NO-ATTR-NOT: FlagAllCallsDescribed
5858

59-
// HAS-ATTR-DAG: DISubprogram(name: "declaration1", {{.*}}, flags: DIFlagPrototyped
6059
// HAS-ATTR-DAG: DISubprogram(name: "declaration2", {{.*}}, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition
6160
// HAS-ATTR-DAG: DISubprogram(name: "struct1", {{.*}}, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
6261
// HAS-ATTR-DAG: DISubprogram(name: "struct1", {{.*}}, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition

llvm/test/DebugInfo/X86/dwarf-callsite-related-attrs.ll

-9
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@
2525

2626
@sink = global i32 0, align 4, !dbg !0
2727

28-
define void @__has_no_subprogram() {
29-
entry:
30-
%0 = load volatile i32, i32* @sink, align 4
31-
%inc = add nsw i32 %0, 1
32-
store volatile i32 %inc, i32* @sink, align 4
33-
ret void
34-
}
35-
3628
; ASM: DW_TAG_subprogram
3729
; ASM: DW_AT_call_all_calls
3830
; OBJ: [[bat_sp:.*]]: DW_TAG_subprogram
@@ -78,7 +70,6 @@ entry:
7870
; OBJ: DW_AT_call_tail_call
7971
define void @_Z3foov() !dbg !25 {
8072
entry:
81-
tail call void @__has_no_subprogram()
8273
tail call void @_Z3barv(), !dbg !26
8374
tail call void @_Z3batv(), !dbg !27
8475
tail call void @_Z3barv(), !dbg !26

0 commit comments

Comments
 (0)