Skip to content

Commit 61f2bcc

Browse files
committed
Add test for LLVM debug infos codegen.
1 parent 6ac4451 commit 61f2bcc

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

src/d/llvm/debuginfo.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ struct DebugInfoScopeGen {
376376
dalign,
377377
0, // ulong OffsetInBits
378378
LLVMDIFlags.Zero,
379-
null, // LLVMMetadataRef DerivedFrom
379+
base, // LLVMMetadataRef DerivedFrom
380380
elements.ptr,
381381
cast(uint) elements.length,
382382
base, // LLVMMetadataRef VTableHolder

test/llvm/dbg.d

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// RUN: %sdc %s -g -O2 -S --emit-llvm -o - | FileCheck %s
2+
module dbg;
3+
4+
enum E {
5+
A,
6+
B,
7+
S,
8+
}
9+
10+
class A {
11+
uint foo() {
12+
return E.A;
13+
// CHECK: _D3dbg1A3fooFC3dbg1AZk({{.*}} !dbg [[A_FOO:![a-z0-9\.]+]] {
14+
}
15+
}
16+
17+
class B : A {
18+
override uint foo() {
19+
return E.B;
20+
// CHECK: _D3dbg1B3fooFC3dbg1BZk({{.*}} !dbg [[B_FOO:![a-z0-9\.]+]] {
21+
}
22+
}
23+
24+
struct S {
25+
uint foo() {
26+
return E.S;
27+
// CHECK: _D3dbg1S3fooFKS3dbg1SZk({{.*}} !dbg [[S_FOO:![a-z0-9\.]+]] {
28+
}
29+
}
30+
31+
// CHECK: !llvm.dbg.cu = !{[[CU:![a-z0-9\.]+]]}
32+
33+
// CHECK-DAG: [[VOID:![a-z0-9\.]+]] = !DIBasicType(name: "void")
34+
// CHECK-DAG: [[VOID_STAR:![a-z0-9\.]+]] = !DIDerivedType(tag: DW_TAG_pointer_type, name: "void*", baseType: [[VOID]], size: 64, align: 64, dwarfAddressSpace: 0)
35+
// CHECK-DAG: [[UINT:![a-z0-9\.]+]] = !DIBasicType(name: "uint", size: 32, encoding: DW_ATE_unsigned)
36+
37+
// CHECK-DAG: [[FILE:![a-z0-9\.]+]] = !DIFile(filename: "dbg.d", directory: "[[SDC_PATH:.*]]/test/llvm")
38+
// CHECK-DAG: [[CU]] = distinct !DICompileUnit(language: DW_LANG_D, file: [[FILE]], producer: "The Snazzy D compiler.", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false)
39+
// CHECK-DAG: [[MODULE:![a-z0-9\.]+]] = !DIModule(scope: [[FILE]], name: "dbg")
40+
// CHECK-DAG: [[OBJECT_FILE:![a-z0-9\.]+]] = !DIFile(filename: "object.d", directory: "[[SDLIB_PATH:.*]]")
41+
// CHECK-DAG: [[OBJECT_MODULE:![a-z0-9\.]+]] = !DIModule(scope: [[OBJECT_FILE]], name: "object")
42+
43+
// CHECK-DAG: [[VTBL:![a-z0-9\.]+]] = !DIDerivedType(tag: DW_TAG_member, name: "__vtbl", scope: [[OBJECT:![a-z0-9\.]+]], file: [[OBJECT_FILE]], line: 19, baseType: [[VOID_STAR]], size: 64, align: 64)
44+
// CHECK-DAG: [[OBJECT_FIELDS:![a-z0-9\.]+]] = !{[[VTBL]]}
45+
// CHECK-DAG: [[OBJECT]] = distinct !DICompositeType(tag: DW_TAG_class_type, name: "Object", scope: [[OBJECT_MODULE]], file: [[OBJECT_FILE]], line: 19, baseType: [[OBJECT]], size: 64, align: 64, elements: [[OBJECT_FIELDS]], vtableHolder: [[OBJECT]], identifier: "C6object6Object")
46+
47+
// CHECK-DAG: [[A_BASE:![a-z0-9\.]+]] = !DIDerivedType(tag: DW_TAG_inheritance, scope: [[A:![a-z0-9\.]+]], baseType: [[OBJECT]], extraData: i32 0)
48+
// CHECK-DAG: [[A_FIELDS:![a-z0-9\.]+]] = !{[[A_BASE]]}
49+
// CHECK-DAG: [[A]] = !DICompositeType(tag: DW_TAG_class_type, name: "A", scope: [[MODULE]], file: [[FILE]], line: 10, baseType: [[OBJECT]], size: 64, align: 64, elements: [[A_FIELDS]], vtableHolder: [[OBJECT]], identifier: "C3dbg1A")
50+
// CHECK-DAG: [[A_REF:![a-z0-9\.]+]] = !DIDerivedType(tag: DW_TAG_reference_type, baseType: [[A]])
51+
// CHECK-DAG: [[A_FOO_TYPE_ELEMENTS:![a-z0-9\.]+]] = !{[[UINT]], [[A_REF]]}
52+
// CHECK-DAG: [[A_FOO_TYPE:![a-z0-9\.]+]] = !DISubroutineType(types: [[A_FOO_TYPE_ELEMENTS]])
53+
// CHECK-DAG: [[A_FOO]] = distinct !DISubprogram(name: "foo", linkageName: "_D3dbg1A3fooFC3dbg1AZk", scope: [[A]], file: [[FILE]], line: 11, type: [[A_FOO_TYPE]], spFlags: DISPFlagDefinition, unit: [[CU]])
54+
55+
// CHECK-DAG: [[B_BASE:![a-z0-9\.]+]] = !DIDerivedType(tag: DW_TAG_inheritance, scope: [[B:![a-z0-9\.]+]], baseType: [[A]], extraData: i32 0)
56+
// CHECK-DAG: [[B_FIELDS:![a-z0-9\.]+]] = !{[[B_BASE]]}
57+
// CHECK-DAG: [[B]] = !DICompositeType(tag: DW_TAG_class_type, name: "B", scope: [[MODULE]], file: [[FILE]], line: 17, baseType: [[A]], size: 64, align: 64, elements: [[B_FIELDS]], vtableHolder: [[A]], identifier: "C3dbg1B")
58+
// CHECK-DAG: [[B_REF:![a-z0-9\.]+]] = !DIDerivedType(tag: DW_TAG_reference_type, baseType: [[B]])
59+
// CHECK-DAG: [[B_FOO_TYPE_ELEMENTS:![a-z0-9\.]+]] = !{[[UINT]], [[B_REF]]}
60+
// CHECK-DAG: [[B_FOO_TYPE:![a-z0-9\.]+]] = !DISubroutineType(types: [[B_FOO_TYPE_ELEMENTS]])
61+
// CHECK-DAG: [[B_FOO:![a-z0-9\.]+]] = distinct !DISubprogram(name: "foo", linkageName: "_D3dbg1B3fooFC3dbg1BZk", scope: [[B]], file: [[FILE]], line: 18, type: [[B_FOO_TYPE]], spFlags: DISPFlagDefinition, unit: [[CU]])
62+
63+
// CHECK-DAG: [[S_FIELDS:![a-z0-9\.]+]] = !{}
64+
// CHECK-DAG: [[S:![a-z0-9\.]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "S", scope: [[MODULE]], file: [[FILE]], line: 24, align: 8, elements: [[S_FIELDS]], identifier: "S3dbg1S")
65+
// CHECK-DAG: [[S_REF:![a-z0-9\.]+]] = !DIDerivedType(tag: DW_TAG_reference_type, baseType: [[S]])
66+
// CHECK-DAG: [[S_FOO_TYPE_ELEMENTS:![a-z0-9\.]+]] = !{[[UINT]], [[S_REF]]}
67+
// CHECK-DAG: [[S_FOO_TYPE:![a-z0-9\.]+]] = !DISubroutineType(types: [[S_FOO_TYPE_ELEMENTS]])
68+
// CHECK-DAG: [[S_FOO:![a-z0-9\.]+]] = distinct !DISubprogram(name: "foo", linkageName: "_D3dbg1S3fooFKS3dbg1SZk", scope: [[S]], file: [[FILE]], line: 25, type: !28, spFlags: DISPFlagDefinition, unit: [[CU]])

0 commit comments

Comments
 (0)