forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reland (again): [DWARF] Allow cross-CU references of subprogram defin…
…itions This is a revert-of-revert (i.e. this reverts commit 802bec8, which itself reverted fa4701e and 79daafc) with a fix folded in. The problem was that call site tags weren't emitted properly when LTO was enabled along with split-dwarf. This required a minor fix. I've added a reduced test case in test/DebugInfo/X86/fission-call-site.ll. Original commit message: This allows a call site tag in CU A to reference a callee DIE in CU B without resorting to creating an incomplete duplicate DIE for the callee inside of CU A. We already allow cross-CU references of subprogram declarations, so it doesn't seem like definitions ought to be special. This improves entry value evaluation and tail call frame synthesis in the LTO setting. During LTO, it's common for cross-module inlining to produce a call in some CU A where the callee resides in a different CU, and there is no declaration subprogram for the callee anywhere. In this case llvm would (unnecessarily, I think) emit an empty DW_TAG_subprogram in order to fill in the call site tag. That empty 'definition' defeats entry value evaluation etc., because the debugger can't figure out what it means. As a follow-up, maybe we could add a DWARF verifier check that a DW_TAG_subprogram at least has a DW_AT_name attribute. Update #1: Reland with a fix to create a declaration DIE when the declaration is missing from the CU's retainedTypes list. The declaration is left out of the retainedTypes list in two cases: 1) Re-compiling pre-r266445 bitcode (in which declarations weren't added to the retainedTypes list), and 2) Doing LTO function importing (which doesn't update the retainedTypes list). It's possible to handle (1) and (2) by modifying the retainedTypes list (in AutoUpgrade, or in the LTO importing logic resp.), but I don't see an advantage to doing it this way, as it would cause more DWARF to be emitted compared to creating the declaration DIEs lazily. Update #2: Fold in a fix for call site tag emission in the split-dwarf + LTO case. Tested with a stage2 ThinLTO+RelWithDebInfo build of clang, and with a ReleaseLTO-g build of the test suite. rdar://46577651, rdar://57855316, rdar://57840415, rdar://58888440 Differential Revision: https://reviews.llvm.org/D70350
- Loading branch information
Showing
10 changed files
with
372 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
llvm/test/DebugInfo/AArch64/unretained-declaration-subprogram.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
; RUN: llc -mtriple=arm64-apple-ios -filetype=obj < %s -o %t.o | ||
; RUN: llvm-dwarfdump %t.o | FileCheck %s -implicit-check-not=DW_TAG_subprogram | ||
|
||
; The declaration subprogram for "function" is not in the CU's list of | ||
; retained types. Test that a DWARF call site entry can still be constructed. | ||
|
||
; CHECK: DW_TAG_subprogram | ||
; CHECK: DW_AT_name {{.*}}__hidden#3_ | ||
; CHECK: DW_TAG_call_site | ||
; CHECK: DW_AT_call_origin (0x{{0+}}[[FUNCTION_DIE:.*]]) | ||
|
||
; CHECK: 0x{{0+}}[[FUNCTION_DIE]]: DW_TAG_subprogram | ||
; CHECK: DW_AT_name {{.*}}function | ||
|
||
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128" | ||
target triple = "arm64-apple-ios9.0.0" | ||
|
||
define i32 @main() local_unnamed_addr !dbg !8 { | ||
%1 = tail call [2 x i64] @function([2 x i64] zeroinitializer), !dbg !11 | ||
%2 = extractvalue [2 x i64] %1, 0, !dbg !11 | ||
%3 = trunc i64 %2 to i32, !dbg !11 | ||
ret i32 %3, !dbg !12 | ||
} | ||
|
||
declare !dbg !13 [2 x i64] @function([2 x i64]) local_unnamed_addr | ||
|
||
!llvm.module.flags = !{!0, !1, !2, !3, !4} | ||
!llvm.dbg.cu = !{!5} | ||
!llvm.ident = !{!7} | ||
|
||
!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 13, i32 4]} | ||
!1 = !{i32 7, !"Dwarf Version", i32 4} | ||
!2 = !{i32 2, !"Debug Info Version", i32 3} | ||
!3 = !{i32 1, !"wchar_size", i32 4} | ||
!4 = !{i32 7, !"PIC Level", i32 2} | ||
!5 = distinct !DICompileUnit(language: DW_LANG_C99, file: !6, producer: "__hidden#0_", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, nameTableKind: None) | ||
!6 = !DIFile(filename: "__hidden#1_", directory: "__hidden#2_") | ||
!7 = !{!"Apple clang version 11.0.0 (llvm-project fa407d93fd5e618d76378c1ce4e4f517e0563278) (+internal-os)"} | ||
!8 = distinct !DISubprogram(name: "__hidden#3_", scope: !6, file: !6, line: 9, type: !9, scopeLine: 9, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !5) | ||
!9 = !DISubroutineType(types: !10) | ||
!10 = !{} | ||
!11 = !DILocation(line: 12, column: 10, scope: !8) | ||
!12 = !DILocation(line: 13, column: 3, scope: !8) | ||
!13 = !DISubprogram(name: "function", scope: !6, file: !6, line: 7, type: !9, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
; Check that call site entries are emitted correctly when using split-dwarf | ||
; together with some form of LTO. | ||
|
||
; Original C source: | ||
; | ||
; // cu1.c | ||
; extern void callee(void); | ||
; void caller(void) { | ||
; callee(); | ||
; } | ||
; | ||
; // cu2.c | ||
; __attribute__((optnone)) void callee(void) {} | ||
; | ||
; Steps to reproduce: | ||
; | ||
; (The -O1 here is needed to trigger call site entry emission, as these tags are | ||
; generally not emitted at -O0.) | ||
; | ||
; clang -target x86_64-unknown-linux-gnu -gsplit-dwarf=split -O1 ~/tmp/cu1.c -S -emit-llvm -o ~/tmp/cu1.ll | ||
; clang -target x86_64-unknown-linux-gnu -gsplit-dwarf=split -O1 ~/tmp/cu2.c -S -emit-llvm -o ~/tmp/cu2.ll | ||
; llvm-link -o ~/tmp/cu-merged.bc ~/tmp/cu1.ll ~/tmp/cu2.ll | ||
; llc -split-dwarf-file=foo.dwo -O0 -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o - ~/tmp/cu-merged.bc | ||
|
||
; RUN: llc -split-dwarf-file=foo.dwo -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t | ||
; RUN: llvm-dwarfdump %t | FileCheck %s | ||
|
||
; CHECK: DW_TAG_GNU_call_site | ||
; CHECK-NEXT: DW_AT_abstract_origin {{.*}} "callee" | ||
|
||
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
define dso_local void @caller() local_unnamed_addr !dbg !14 { | ||
entry: | ||
call void @callee(), !dbg !15 | ||
ret void, !dbg !16 | ||
} | ||
|
||
define dso_local void @callee() local_unnamed_addr noinline optnone !dbg !17 { | ||
entry: | ||
ret void, !dbg !19 | ||
} | ||
|
||
!llvm.dbg.cu = !{!0, !8} | ||
!llvm.ident = !{!10, !10} | ||
!llvm.module.flags = !{!11, !12, !13} | ||
|
||
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0 (git@github.com:llvm/llvm-project.git 170f4b972e7bcf1f2af98bdd7145954efd16e038)", isOptimized: true, runtimeVersion: 0, splitDebugFilename: "cu1.dwo", emissionKind: FullDebug, enums: !2, retainedTypes: !3, splitDebugInlining: false, nameTableKind: GNU) | ||
!1 = !DIFile(filename: "/Users/vsk/tmp/cu1.c", directory: "/Users/vsk/src/builds/llvm-project-master-RA") | ||
!2 = !{} | ||
!3 = !{!4} | ||
!4 = !DISubprogram(name: "callee", scope: !5, file: !5, line: 1, type: !6, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) | ||
!5 = !DIFile(filename: "tmp/cu1.c", directory: "/Users/vsk") | ||
!6 = !DISubroutineType(types: !7) | ||
!7 = !{null} | ||
!8 = distinct !DICompileUnit(language: DW_LANG_C99, file: !9, producer: "clang version 11.0.0 (git@github.com:llvm/llvm-project.git 170f4b972e7bcf1f2af98bdd7145954efd16e038)", isOptimized: true, runtimeVersion: 0, splitDebugFilename: "cu2.dwo", emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: GNU) | ||
!9 = !DIFile(filename: "/Users/vsk/tmp/cu2.c", directory: "/Users/vsk/src/builds/llvm-project-master-RA") | ||
!10 = !{!"clang version 11.0.0 (git@github.com:llvm/llvm-project.git 170f4b972e7bcf1f2af98bdd7145954efd16e038)"} | ||
!11 = !{i32 7, !"Dwarf Version", i32 4} | ||
!12 = !{i32 2, !"Debug Info Version", i32 3} | ||
!13 = !{i32 1, !"wchar_size", i32 4} | ||
!14 = distinct !DISubprogram(name: "caller", scope: !5, file: !5, line: 2, type: !6, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) | ||
!15 = !DILocation(line: 3, column: 3, scope: !14) | ||
!16 = !DILocation(line: 4, column: 1, scope: !14) | ||
!17 = distinct !DISubprogram(name: "callee", scope: !18, file: !18, line: 1, type: !6, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !8, retainedNodes: !2) | ||
!18 = !DIFile(filename: "tmp/cu2.c", directory: "/Users/vsk") | ||
!19 = !DILocation(line: 1, column: 45, scope: !17) |
Oops, something went wrong.