xref: /llvm-project/llvm/test/DebugInfo/X86/containing-type-extension-rust.ll (revision 3a05e01d1a76984fe1532bd237edbbb7ed9db6ea)
1; RUN: llc -O0 -filetype=obj < %s > %t
2; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s
3
4; Check that any type can have a vtable holder.
5; CHECK: [[SP:.*]]: DW_TAG_structure_type
6; CHECK-NOT: TAG
7; CHECK: DW_AT_containing_type [DW_FORM_ref4] ({{.*}} "f64")
8; CHECK: DW_AT_name [DW_FORM_strp] {{.*}}= "vtable")
9
10; This was compiled using
11; rustc -g --emit=llvm-ir t2.rs
12; ... and then edited by hand, because rustc is using a somewhat older llvm.
13;
14; t2.rs is:
15;
16; // trait object test case
17;
18; pub trait T {
19; }
20;
21; impl T for f64 {
22; }
23;
24; pub fn main() {
25;     let tu = &23.0f64 as &T;
26; }
27; t2.rs ends here ^^^
28
29; ModuleID = 't2.cgu-0.rs'
30source_filename = "t2.cgu-0.rs"
31target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
32target triple = "x86_64-unknown-linux-gnu"
33
34@ref.0 = internal unnamed_addr constant double 2.300000e+01, align 8
35@vtable.1 = internal unnamed_addr constant { ptr, i64, i64 } { ptr @_ZN4core3ptr13drop_in_place17h2818a933abde117eE, i64 8, i64 8 }, align 8, !dbg !0
36@__rustc_debug_gdb_scripts_section__ = linkonce_odr unnamed_addr constant [34 x i8] c"\01gdb_load_rust_pretty_printers.py\00", section ".debug_gdb_scripts", align 1
37
38; core::ptr::drop_in_place
39; Function Attrs: uwtable
40define internal void @_ZN4core3ptr13drop_in_place17h2818a933abde117eE(ptr) unnamed_addr #0 !dbg !11 {
41start:
42  %arg0 = alloca ptr
43  store ptr %0, ptr %arg0
44  call void @llvm.dbg.declare(metadata ptr %arg0, metadata !20, metadata !22), !dbg !23
45  ret void, !dbg !24
46}
47
48; t2::main
49; Function Attrs: uwtable
50define internal void @_ZN2t24main17h6319e6ac7de3a097E() unnamed_addr #0 !dbg !25 {
51start:
52  %tu = alloca { ptr, ptr }
53  call void @llvm.dbg.declare(metadata ptr %tu, metadata !29, metadata !22), !dbg !37
54  %0 = getelementptr inbounds { ptr, ptr }, ptr %tu, i32 0, i32 0, !dbg !37
55  store ptr @ref.0, ptr %0, !dbg !37
56  %1 = getelementptr inbounds { ptr, ptr }, ptr %tu, i32 0, i32 1, !dbg !37
57  store ptr @vtable.1, ptr %1, !dbg !37
58  ret void, !dbg !38
59}
60
61; Function Attrs: nounwind readnone
62declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
63
64define i32 @main(i32, ptr) unnamed_addr #2 {
65top:
66  %2 = load volatile i8, ptr @__rustc_debug_gdb_scripts_section__, align 1
67  %3 = sext i32 %0 to i64
68; call std::rt::lang_start
69  %4 = call i64 @_ZN3std2rt10lang_start17h2626caf1112a00beE(ptr @_ZN2t24main17h6319e6ac7de3a097E, i64 %3, ptr %1)
70  %5 = trunc i64 %4 to i32
71  ret i32 %5
72}
73
74; std::rt::lang_start
75declare i64 @_ZN3std2rt10lang_start17h2626caf1112a00beE(ptr, i64, ptr) unnamed_addr #3
76
77attributes #0 = { uwtable "frame-pointer"="all" "probe-stack"="__rust_probestack" }
78attributes #1 = { nounwind readnone }
79attributes #2 = { "frame-pointer"="all" }
80attributes #3 = { "frame-pointer"="all" "probe-stack"="__rust_probestack" }
81
82!llvm.module.flags = !{!6, !7}
83!llvm.dbg.cu = !{!8}
84
85!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
86!1 = distinct !DIGlobalVariable(name: "vtable", scope: null, file: !2, type: !3, isLocal: true, isDefinition: true)
87!2 = !DIFile(filename: "<unknown>", directory: "")
88!3 = !DICompositeType(tag: DW_TAG_structure_type, name: "vtable", file: !2, size: 64, align: 64, flags: DIFlagArtificial, elements: !4, vtableHolder: !5, identifier: "vtable")
89!4 = !{}
90!5 = !DIBasicType(name: "f64", size: 64, encoding: DW_ATE_float)
91!6 = !{i32 1, !"PIE Level", i32 2}
92!7 = !{i32 2, !"Debug Info Version", i32 3}
93!8 = distinct !DICompileUnit(language: DW_LANG_Rust, file: !9, producer: "clang LLVM (rustc version 1.22.0-dev)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !10)
94!9 = !DIFile(filename: "t2.rs", directory: "/home/tromey/Rust")
95!10 = !{!0}
96!11 = distinct !DISubprogram(name: "drop_in_place<f64>", linkageName: "_ZN4core3ptr18drop_in_place<f64>E", scope: !13, file: !12, line: 59, type: !15, isLocal: false, isDefinition: true, scopeLine: 59, flags: DIFlagPrototyped, isOptimized: false, unit: !8, templateParams: !18, retainedNodes: !4)
97!12 = !DIFile(filename: "/home/tromey/Rust/rust/src/libcore/ptr.rs", directory: "")
98!13 = !DINamespace(name: "ptr", scope: !14)
99!14 = !DINamespace(name: "core", scope: null)
100!15 = !DISubroutineType(types: !16)
101!16 = !{null, !17}
102!17 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "*mut f64", baseType: !5, size: 64, align: 64)
103!18 = !{!19}
104!19 = !DITemplateTypeParameter(name: "T", type: !5)
105!20 = !DILocalVariable(arg: 1, scope: !11, file: !21, line: 1, type: !17)
106!21 = !DIFile(filename: "t2.rs", directory: "")
107!22 = !DIExpression()
108!23 = !DILocation(line: 1, scope: !11)
109!24 = !DILocation(line: 59, scope: !11)
110!25 = distinct !DISubprogram(name: "main", linkageName: "_ZN2t24mainE", scope: !26, file: !9, line: 9, type: !27, scopeLine: 9, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagMainSubprogram, isOptimized: false, unit: !8, templateParams: !4, retainedNodes: !4)
111!26 = !DINamespace(name: "t2", scope: null)
112!27 = !DISubroutineType(types: !28)
113!28 = !{null}
114!29 = !DILocalVariable(name: "tu", scope: !30, file: !9, line: 10, type: !31, align: 8)
115!30 = distinct !DILexicalBlock(scope: !25, file: !9, line: 10, column: 4)
116!31 = !DICompositeType(tag: DW_TAG_structure_type, name: "&T", scope: !26, file: !2, size: 128, align: 64, elements: !32, identifier: "b9f642b757d8ad3984c1e721e3ce6016d14d9322")
117!32 = !{!33, !36}
118!33 = !DIDerivedType(tag: DW_TAG_member, name: "pointer", scope: !31, file: !2, baseType: !34, size: 64, align: 64, flags: DIFlagArtificial)
119!34 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "*const u8", baseType: !35, size: 64, align: 64)
120!35 = !DIBasicType(name: "u8", size: 8, encoding: DW_ATE_unsigned)
121!36 = !DIDerivedType(tag: DW_TAG_member, name: "vtable", scope: !31, file: !2, baseType: !34, size: 64, align: 64, offset: 64, flags: DIFlagArtificial)
122!37 = !DILocation(line: 10, scope: !30)
123!38 = !DILocation(line: 11, scope: !25)
124