1 ; RUN: llc -O0 < %s | FileCheck %s
2 ; FIXME: Add test for llc with optimizations once it is implemented.
4 ; Source to regenerate:
5 ; $ clang --target=x86_64-windows-msvc -S heapallocsite.cpp -g -gcodeview -o t.ll \
6 ; -emit-llvm -O0 -Xclang -disable-llvm-passes -fms-extensions
9 ; __declspec(allocator) virtual void *alloc();
12 ; extern "C" __declspec(allocator) Foo *alloc_foo();
14 ; extern "C" void use_alloc(void*);
15 ; extern "C" void call_virtual(Foo *p) {
16 ; use_alloc(p->alloc());
19 ; extern "C" void call_multiple() {
20 ; use_alloc(alloc_foo());
21 ; use_alloc(alloc_foo());
24 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
25 target triple = "x86_64-unknown-windows-msvc"
27 %struct.Foo = type { i32 (...)** }
29 ; Function Attrs: noinline optnone uwtable
30 define dso_local void @call_virtual(%struct.Foo* %p) #0 !dbg !8 {
32 %p.addr = alloca %struct.Foo*, align 8
33 store %struct.Foo* %p, %struct.Foo** %p.addr, align 8
34 call void @llvm.dbg.declare(metadata %struct.Foo** %p.addr, metadata !13, metadata !DIExpression()), !dbg !14
35 %0 = load %struct.Foo*, %struct.Foo** %p.addr, align 8, !dbg !15
36 %1 = bitcast %struct.Foo* %0 to i8* (%struct.Foo*)***, !dbg !15
37 %vtable = load i8* (%struct.Foo*)**, i8* (%struct.Foo*)*** %1, align 8, !dbg !15
38 %vfn = getelementptr inbounds i8* (%struct.Foo*)*, i8* (%struct.Foo*)** %vtable, i64 0, !dbg !15
39 %2 = load i8* (%struct.Foo*)*, i8* (%struct.Foo*)** %vfn, align 8, !dbg !15
40 %call = call i8* %2(%struct.Foo* %0), !dbg !15, !heapallocsite !2
41 call void @use_alloc(i8* %call), !dbg !15
45 ; Function Attrs: nounwind readnone speculatable
46 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
48 declare dso_local void @use_alloc(i8*) #2
50 ; Function Attrs: noinline optnone uwtable
51 define dso_local void @call_multiple() #0 !dbg !17 {
53 %call = call %struct.Foo* @alloc_foo(), !dbg !20, !heapallocsite !12
54 %0 = bitcast %struct.Foo* %call to i8*, !dbg !20
55 call void @use_alloc(i8* %0), !dbg !20
56 %call1 = call %struct.Foo* @alloc_foo(), !dbg !21, !heapallocsite !12
57 %1 = bitcast %struct.Foo* %call1 to i8*, !dbg !21
58 call void @use_alloc(i8* %1), !dbg !21
62 declare dso_local %struct.Foo* @alloc_foo() #2
64 ; CHECK-LABEL: call_virtual: # @call_virtual
65 ; CHECK: .Lheapallocsite0:
66 ; CHECK: callq *(%rax)
67 ; CHECK: .Lheapallocsite1:
70 ; CHECK-LABEL: call_multiple: # @call_multiple
71 ; CHECK: .Lheapallocsite4:
72 ; CHECK: callq alloc_foo
73 ; CHECK: .Lheapallocsite5:
74 ; CHECK: .Lheapallocsite2:
75 ; CHECK: callq alloc_foo
76 ; CHECK: .Lheapallocsite3:
79 ; CHECK-LABEL: .short 4423 # Record kind: S_GPROC32_ID
80 ; CHECK: .short 4446 # Record kind: S_HEAPALLOCSITE
81 ; CHECK-NEXT: .secrel32 .Lheapallocsite0
82 ; CHECK-NEXT: .secidx .Lheapallocsite0
83 ; CHECK-NEXT: .short .Lheapallocsite1-.Lheapallocsite0
85 ; CHECK-NEXT: .p2align 2
86 ; CHECK-LABEL: .short 4431 # Record kind: S_PROC_ID_END
88 ; CHECK-LABEL: .short 4423 # Record kind: S_GPROC32_ID
89 ; CHECK: .short 4446 # Record kind: S_HEAPALLOCSITE
90 ; CHECK-NEXT: .secrel32 .Lheapallocsite2
91 ; CHECK-NEXT: .secidx .Lheapallocsite2
92 ; CHECK-NEXT: .short .Lheapallocsite3-.Lheapallocsite2
93 ; CHECK-NEXT: .long 4096
94 ; CHECK-NEXT: .p2align 2
96 ; CHECK: .short 4446 # Record kind: S_HEAPALLOCSITE
97 ; CHECK-NEXT: .secrel32 .Lheapallocsite4
98 ; CHECK-NEXT: .secidx .Lheapallocsite4
99 ; CHECK-NEXT: .short .Lheapallocsite5-.Lheapallocsite4
100 ; CHECK-NEXT: .long 4096
101 ; CHECK-NEXT: .p2align 2
102 ; CHECK-LABEL: .short 4431 # Record kind: S_PROC_ID_END
105 !llvm.module.flags = !{!3, !4, !5, !6}
108 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 9.0.0 (https://github.com/llvm/llvm-project.git 9c8073f44f786fbf47335e53f20abe64429e8e47)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)!1 = !DIFile(filename: "filename", directory: "directory", checksumkind: CSK_MD5, checksum: "096443b661a0af36da9006330c08f97e")
110 !3 = !{i32 2, !"CodeView", i32 1}
111 !4 = !{i32 2, !"Debug Info Version", i32 3}
112 !5 = !{i32 1, !"wchar_size", i32 2}
113 !6 = !{i32 7, !"PIC Level", i32 2}
114 !7 = !{!"clang version 9.0.0 (https://github.com/llvm/llvm-project.git 9c8073f44f786fbf47335e53f20abe64429e8e47)"}
115 !8 = distinct !DISubprogram(name: "call_virtual", scope: !1, file: !1, line: 8, type: !9, scopeLine: 8, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
116 !9 = !DISubroutineType(types: !10)
118 !11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)
119 !12 = !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !1, line: 1, flags: DIFlagFwdDecl, identifier: ".?AUFoo@@")
120 !13 = !DILocalVariable(name: "p", arg: 1, scope: !8, file: !1, line: 8, type: !11)
121 !14 = !DILocation(line: 8, scope: !8)
122 !15 = !DILocation(line: 9, scope: !8)
123 !16 = !DILocation(line: 10, scope: !8)
124 !17 = distinct !DISubprogram(name: "call_multiple", scope: !1, file: !1, line: 12, type: !18, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
125 !18 = !DISubroutineType(types: !19)
127 !20 = !DILocation(line: 13, scope: !17)
128 !21 = !DILocation(line: 14, scope: !17)
129 !22 = !DILocation(line: 15, scope: !17)