|
|
6e53ac |
From 9959e0572c47e3cdedb51d05bf76bb56965ede98 Mon Sep 17 00:00:00 2001
|
|
|
6e53ac |
From: Tom Stellard <tstellar@redhat.com>
|
|
|
6e53ac |
Date: Fri, 7 Sep 2018 22:19:20 -0700
|
|
|
6e53ac |
Subject: [PATCH] [GlobalISel] Lower dbg.declare into indirect DBG_VALUE
|
|
|
6e53ac |
|
|
|
6e53ac |
Summary:
|
|
|
6e53ac |
D31439 changed the semantics of dbg.declare to take the address of a
|
|
|
6e53ac |
variable as the first argument, making it indirect. It specifically
|
|
|
6e53ac |
updated FastISel for this change here:
|
|
|
6e53ac |
|
|
|
6e53ac |
https://reviews.llvm.org/D31439#change-WVArzi177jPl
|
|
|
6e53ac |
|
|
|
6e53ac |
GlobalISel needs to follow suit, or else it will be missing a level of
|
|
|
6e53ac |
indirection in the generated debuginfo. This problem was seen in a Rust
|
|
|
6e53ac |
debuginfo test on aarch64, since GlobalISel is used at -O0 for aarch64.
|
|
|
6e53ac |
|
|
|
6e53ac |
https://github.com/rust-lang/rust/issues/49807
|
|
|
6e53ac |
https://bugzilla.redhat.com/show_bug.cgi?id=1611597
|
|
|
6e53ac |
https://bugzilla.redhat.com/show_bug.cgi?id=1625768
|
|
|
6e53ac |
|
|
|
6e53ac |
Reviewers: dblaikie, aprantl, t.p.northover, javed.absar, rnk
|
|
|
6e53ac |
|
|
|
6e53ac |
Reviewed By: rnk
|
|
|
6e53ac |
|
|
|
6e53ac |
Subscribers: #debug-info, rovka, kristof.beyls, JDevlieghere, llvm-commits, tstellar
|
|
|
6e53ac |
|
|
|
6e53ac |
Differential Revision: https://reviews.llvm.org/D51749
|
|
|
6e53ac |
---
|
|
|
6e53ac |
lib/CodeGen/GlobalISel/IRTranslator.cpp | 9 ++--
|
|
|
6e53ac |
test/CodeGen/AArch64/GlobalISel/debug-cpp.ll | 67 ++++++++++++++++++++++++++
|
|
|
6e53ac |
test/CodeGen/AArch64/GlobalISel/debug-insts.ll | 4 +-
|
|
|
6e53ac |
3 files changed, 74 insertions(+), 6 deletions(-)
|
|
|
6e53ac |
create mode 100644 test/CodeGen/AArch64/GlobalISel/debug-cpp.ll
|
|
|
6e53ac |
|
|
|
6e53ac |
diff --git a/lib/CodeGen/GlobalISel/IRTranslator.cpp b/lib/CodeGen/GlobalISel/IRTranslator.cpp
|
|
|
6e53ac |
index 75496fb..9926be3 100644
|
|
|
6e53ac |
--- a/lib/CodeGen/GlobalISel/IRTranslator.cpp
|
|
|
6e53ac |
+++ b/lib/CodeGen/GlobalISel/IRTranslator.cpp
|
|
|
6e53ac |
@@ -763,9 +763,12 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID,
|
|
|
6e53ac |
// instructions (in fact, they get ignored if they *do* exist).
|
|
|
6e53ac |
MF->setVariableDbgInfo(DI.getVariable(), DI.getExpression(),
|
|
|
6e53ac |
getOrCreateFrameIndex(*AI), DI.getDebugLoc());
|
|
|
6e53ac |
- } else
|
|
|
6e53ac |
- MIRBuilder.buildDirectDbgValue(getOrCreateVReg(*Address),
|
|
|
6e53ac |
- DI.getVariable(), DI.getExpression());
|
|
|
6e53ac |
+ } else {
|
|
|
6e53ac |
+ // A dbg.declare describes the address of a source variable, so lower it
|
|
|
6e53ac |
+ // into an indirect DBG_VALUE.
|
|
|
6e53ac |
+ MIRBuilder.buildIndirectDbgValue(getOrCreateVReg(*Address),
|
|
|
6e53ac |
+ DI.getVariable(), DI.getExpression());
|
|
|
6e53ac |
+ }
|
|
|
6e53ac |
return true;
|
|
|
6e53ac |
}
|
|
|
6e53ac |
case Intrinsic::vaend:
|
|
|
6e53ac |
diff --git a/test/CodeGen/AArch64/GlobalISel/debug-cpp.ll b/test/CodeGen/AArch64/GlobalISel/debug-cpp.ll
|
|
|
6e53ac |
new file mode 100644
|
|
|
6e53ac |
index 0000000..e5a4e55
|
|
|
6e53ac |
--- /dev/null
|
|
|
6e53ac |
+++ b/test/CodeGen/AArch64/GlobalISel/debug-cpp.ll
|
|
|
6e53ac |
@@ -0,0 +1,67 @@
|
|
|
6e53ac |
+; RUN: llc -global-isel -mtriple=aarch64 %s -stop-after=irtranslator -o - | FileCheck %s
|
|
|
6e53ac |
+; RUN: llc -mtriple=aarch64 -global-isel --global-isel-abort=0 -o /dev/null
|
|
|
6e53ac |
+
|
|
|
6e53ac |
+; struct NTCopy {
|
|
|
6e53ac |
+; NTCopy();
|
|
|
6e53ac |
+; NTCopy(const NTCopy &);
|
|
|
6e53ac |
+; int x;
|
|
|
6e53ac |
+; };
|
|
|
6e53ac |
+; int foo(NTCopy o) {
|
|
|
6e53ac |
+; return o.x;
|
|
|
6e53ac |
+; }
|
|
|
6e53ac |
+
|
|
|
6e53ac |
+; ModuleID = 'ntcopy.cpp'
|
|
|
6e53ac |
+source_filename = "ntcopy.cpp"
|
|
|
6e53ac |
+target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
|
|
|
6e53ac |
+target triple = "aarch64-unknown-linux-gnu"
|
|
|
6e53ac |
+
|
|
|
6e53ac |
+%struct.NTCopy = type { i32 }
|
|
|
6e53ac |
+
|
|
|
6e53ac |
+; CHECK-LABEL: name: _Z3foo6NTCopy
|
|
|
6e53ac |
+; CHECK: DBG_VALUE debug-use %{{[0-9]+}}(p0), 0, !23, !DIExpression(), debug-location !24
|
|
|
6e53ac |
+; Function Attrs: noinline nounwind optnone
|
|
|
6e53ac |
+define dso_local i32 @_Z3foo6NTCopy(%struct.NTCopy* %o) #0 !dbg !7 {
|
|
|
6e53ac |
+entry:
|
|
|
6e53ac |
+ call void @llvm.dbg.declare(metadata %struct.NTCopy* %o, metadata !23, metadata !DIExpression()), !dbg !24
|
|
|
6e53ac |
+ %x = getelementptr inbounds %struct.NTCopy, %struct.NTCopy* %o, i32 0, i32 0, !dbg !25
|
|
|
6e53ac |
+ %0 = load i32, i32* %x, align 4, !dbg !25
|
|
|
6e53ac |
+ ret i32 %0, !dbg !26
|
|
|
6e53ac |
+}
|
|
|
6e53ac |
+
|
|
|
6e53ac |
+; Function Attrs: nounwind readnone speculatable
|
|
|
6e53ac |
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
|
|
|
6e53ac |
+
|
|
|
6e53ac |
+attributes #0 = { noinline nounwind optnone }
|
|
|
6e53ac |
+attributes #1 = { nounwind readnone speculatable }
|
|
|
6e53ac |
+
|
|
|
6e53ac |
+!llvm.dbg.cu = !{!0}
|
|
|
6e53ac |
+!llvm.module.flags = !{!3, !4, !5}
|
|
|
6e53ac |
+!llvm.ident = !{!6}
|
|
|
6e53ac |
+
|
|
|
6e53ac |
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 8.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
|
|
|
6e53ac |
+!1 = !DIFile(filename: "ntcopy.cpp", directory: "/tmp")
|
|
|
6e53ac |
+!2 = !{}
|
|
|
6e53ac |
+!3 = !{i32 2, !"Dwarf Version", i32 4}
|
|
|
6e53ac |
+!4 = !{i32 2, !"Debug Info Version", i32 3}
|
|
|
6e53ac |
+!5 = !{i32 1, !"wchar_size", i32 4}
|
|
|
6e53ac |
+!6 = !{!"clang version 8.0.0 "}
|
|
|
6e53ac |
+!7 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foo6NTCopy", scope: !1, file: !1, line: 6, type: !8, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
|
|
|
6e53ac |
+!8 = !DISubroutineType(types: !9)
|
|
|
6e53ac |
+!9 = !{!10, !11}
|
|
|
6e53ac |
+!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
|
|
6e53ac |
+!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "NTCopy", file: !1, line: 1, size: 32, elements: !12, identifier: "_ZTS6NTCopy")
|
|
|
6e53ac |
+!12 = !{!13, !14, !18}
|
|
|
6e53ac |
+!13 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !11, file: !1, line: 4, baseType: !10, size: 32)
|
|
|
6e53ac |
+!14 = !DISubprogram(name: "NTCopy", scope: !11, file: !1, line: 2, type: !15, isLocal: false, isDefinition: false, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false)
|
|
|
6e53ac |
+!15 = !DISubroutineType(types: !16)
|
|
|
6e53ac |
+!16 = !{null, !17}
|
|
|
6e53ac |
+!17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
|
|
|
6e53ac |
+!18 = !DISubprogram(name: "NTCopy", scope: !11, file: !1, line: 3, type: !19, isLocal: false, isDefinition: false, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false)
|
|
|
6e53ac |
+!19 = !DISubroutineType(types: !20)
|
|
|
6e53ac |
+!20 = !{null, !17, !21}
|
|
|
6e53ac |
+!21 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !22, size: 64)
|
|
|
6e53ac |
+!22 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !11)
|
|
|
6e53ac |
+!23 = !DILocalVariable(name: "o", arg: 1, scope: !7, file: !1, line: 6, type: !11)
|
|
|
6e53ac |
+!24 = !DILocation(line: 6, column: 16, scope: !7)
|
|
|
6e53ac |
+!25 = !DILocation(line: 7, column: 12, scope: !7)
|
|
|
6e53ac |
+!26 = !DILocation(line: 7, column: 3, scope: !7)
|
|
|
6e53ac |
diff --git a/test/CodeGen/AArch64/GlobalISel/debug-insts.ll b/test/CodeGen/AArch64/GlobalISel/debug-insts.ll
|
|
|
6e53ac |
index 8309e00..256eb37 100644
|
|
|
6e53ac |
--- a/test/CodeGen/AArch64/GlobalISel/debug-insts.ll
|
|
|
6e53ac |
+++ b/test/CodeGen/AArch64/GlobalISel/debug-insts.ll
|
|
|
6e53ac |
@@ -6,18 +6,16 @@
|
|
|
6e53ac |
; CHECK: - { id: {{.*}}, name: in.addr, type: default, offset: 0, size: {{.*}}, alignment: {{.*}},
|
|
|
6e53ac |
; CHECK-NEXT: callee-saved-register: '', callee-saved-restored: true,
|
|
|
6e53ac |
; CHECK-NEXT: debug-info-variable: '!11', debug-info-expression: '!DIExpression()',
|
|
|
6e53ac |
-; CHECK: DBG_VALUE debug-use %0(s32), debug-use $noreg, !11, !DIExpression(), debug-location !12
|
|
|
6e53ac |
define void @debug_declare(i32 %in) #0 !dbg !7 {
|
|
|
6e53ac |
entry:
|
|
|
6e53ac |
%in.addr = alloca i32, align 4
|
|
|
6e53ac |
store i32 %in, i32* %in.addr, align 4
|
|
|
6e53ac |
call void @llvm.dbg.declare(metadata i32* %in.addr, metadata !11, metadata !DIExpression()), !dbg !12
|
|
|
6e53ac |
- call void @llvm.dbg.declare(metadata i32 %in, metadata !11, metadata !DIExpression()), !dbg !12
|
|
|
6e53ac |
ret void, !dbg !12
|
|
|
6e53ac |
}
|
|
|
6e53ac |
|
|
|
6e53ac |
; CHECK-LABEL: name: debug_declare_vla
|
|
|
6e53ac |
-; CHECK: DBG_VALUE debug-use %{{[0-9]+}}(p0), debug-use $noreg, !14, !DIExpression(), debug-location !15
|
|
|
6e53ac |
+; CHECK: DBG_VALUE debug-use %{{[0-9]+}}(p0), 0, !14, !DIExpression(), debug-location !15
|
|
|
6e53ac |
define void @debug_declare_vla(i32 %in) #0 !dbg !13 {
|
|
|
6e53ac |
entry:
|
|
|
6e53ac |
%vla.addr = alloca i32, i32 %in
|
|
|
6e53ac |
--
|
|
|
6e53ac |
1.8.3.1
|
|
|
6e53ac |
|