Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 5a081f0

Browse files
authored
Merge pull request #126 from cuviper/rust-global-isel-dbg.declare
[GlobalISel] Lower dbg.declare into indirect DBG_VALUE
2 parents 284b1ce + 1c34cd5 commit 5a081f0

File tree

3 files changed

+74
-6
lines changed

3 files changed

+74
-6
lines changed

lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -758,9 +758,12 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID,
758758
// instructions (in fact, they get ignored if they *do* exist).
759759
MF->setVariableDbgInfo(DI.getVariable(), DI.getExpression(),
760760
getOrCreateFrameIndex(*AI), DI.getDebugLoc());
761-
} else
762-
MIRBuilder.buildDirectDbgValue(getOrCreateVReg(*Address),
763-
DI.getVariable(), DI.getExpression());
761+
} else {
762+
// A dbg.declare describes the address of a source variable, so lower it
763+
// into an indirect DBG_VALUE.
764+
MIRBuilder.buildIndirectDbgValue(getOrCreateVReg(*Address),
765+
DI.getVariable(), DI.getExpression());
766+
}
764767
return true;
765768
}
766769
case Intrinsic::dbg_label: {
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
; RUN: llc -global-isel -mtriple=aarch64 %s -stop-after=irtranslator -o - | FileCheck %s
2+
; RUN: llc -mtriple=aarch64 -global-isel --global-isel-abort=0 -o /dev/null
3+
4+
; struct NTCopy {
5+
; NTCopy();
6+
; NTCopy(const NTCopy &);
7+
; int x;
8+
; };
9+
; int foo(NTCopy o) {
10+
; return o.x;
11+
; }
12+
13+
; ModuleID = 'ntcopy.cpp'
14+
source_filename = "ntcopy.cpp"
15+
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
16+
target triple = "aarch64-unknown-linux-gnu"
17+
18+
%struct.NTCopy = type { i32 }
19+
20+
; CHECK-LABEL: name: _Z3foo6NTCopy
21+
; CHECK: DBG_VALUE debug-use %{{[0-9]+}}(p0), 0, !23, !DIExpression(), debug-location !24
22+
; Function Attrs: noinline nounwind optnone
23+
define dso_local i32 @_Z3foo6NTCopy(%struct.NTCopy* %o) #0 !dbg !7 {
24+
entry:
25+
call void @llvm.dbg.declare(metadata %struct.NTCopy* %o, metadata !23, metadata !DIExpression()), !dbg !24
26+
%x = getelementptr inbounds %struct.NTCopy, %struct.NTCopy* %o, i32 0, i32 0, !dbg !25
27+
%0 = load i32, i32* %x, align 4, !dbg !25
28+
ret i32 %0, !dbg !26
29+
}
30+
31+
; Function Attrs: nounwind readnone speculatable
32+
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
33+
34+
attributes #0 = { noinline nounwind optnone }
35+
attributes #1 = { nounwind readnone speculatable }
36+
37+
!llvm.dbg.cu = !{!0}
38+
!llvm.module.flags = !{!3, !4, !5}
39+
!llvm.ident = !{!6}
40+
41+
!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, nameTableKind: None)
42+
!1 = !DIFile(filename: "ntcopy.cpp", directory: "/tmp")
43+
!2 = !{}
44+
!3 = !{i32 2, !"Dwarf Version", i32 4}
45+
!4 = !{i32 2, !"Debug Info Version", i32 3}
46+
!5 = !{i32 1, !"wchar_size", i32 4}
47+
!6 = !{!"clang version 8.0.0 "}
48+
!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)
49+
!8 = !DISubroutineType(types: !9)
50+
!9 = !{!10, !11}
51+
!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
52+
!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "NTCopy", file: !1, line: 1, size: 32, flags: DIFlagTypePassByReference, elements: !12, identifier: "_ZTS6NTCopy")
53+
!12 = !{!13, !14, !18}
54+
!13 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !11, file: !1, line: 4, baseType: !10, size: 32)
55+
!14 = !DISubprogram(name: "NTCopy", scope: !11, file: !1, line: 2, type: !15, isLocal: false, isDefinition: false, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false)
56+
!15 = !DISubroutineType(types: !16)
57+
!16 = !{null, !17}
58+
!17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
59+
!18 = !DISubprogram(name: "NTCopy", scope: !11, file: !1, line: 3, type: !19, isLocal: false, isDefinition: false, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false)
60+
!19 = !DISubroutineType(types: !20)
61+
!20 = !{null, !17, !21}
62+
!21 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !22, size: 64)
63+
!22 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !11)
64+
!23 = !DILocalVariable(name: "o", arg: 1, scope: !7, file: !1, line: 6, type: !11)
65+
!24 = !DILocation(line: 6, column: 16, scope: !7)
66+
!25 = !DILocation(line: 7, column: 12, scope: !7)
67+
!26 = !DILocation(line: 7, column: 3, scope: !7)

test/CodeGen/AArch64/GlobalISel/debug-insts.ll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@
66
; CHECK: - { id: {{.*}}, name: in.addr, type: default, offset: 0, size: {{.*}}, alignment: {{.*}},
77
; CHECK-NEXT: callee-saved-register: '', callee-saved-restored: true,
88
; CHECK-NEXT: debug-info-variable: '!11', debug-info-expression: '!DIExpression()',
9-
; CHECK: DBG_VALUE debug-use %0(s32), debug-use $noreg, !11, !DIExpression(), debug-location !12
109
define void @debug_declare(i32 %in) #0 !dbg !7 {
1110
entry:
1211
%in.addr = alloca i32, align 4
1312
store i32 %in, i32* %in.addr, align 4
1413
call void @llvm.dbg.declare(metadata i32* %in.addr, metadata !11, metadata !DIExpression()), !dbg !12
15-
call void @llvm.dbg.declare(metadata i32 %in, metadata !11, metadata !DIExpression()), !dbg !12
1614
ret void, !dbg !12
1715
}
1816

1917
; CHECK-LABEL: name: debug_declare_vla
20-
; CHECK: DBG_VALUE debug-use %{{[0-9]+}}(p0), debug-use $noreg, !14, !DIExpression(), debug-location !15
18+
; CHECK: DBG_VALUE debug-use %{{[0-9]+}}(p0), 0, !14, !DIExpression(), debug-location !15
2119
define void @debug_declare_vla(i32 %in) #0 !dbg !13 {
2220
entry:
2321
%vla.addr = alloca i32, i32 %in

0 commit comments

Comments
 (0)