1 ; RUN: llc < %s | FileCheck --check-prefixes=CHECK %s
2 ; RUN: llc -O0 < %s | FileCheck --check-prefixes=CHECK %s
4 ; RUN: llc --try-experimental-debuginfo-iterators < %s | FileCheck --check-prefixes=CHECK %s
5 ; RUN: llc --try-experimental-debuginfo-iterators -O0 < %s | FileCheck --check-prefixes=CHECK %s
7 ; Source to regenerate:
8 ; $ clang -cc1 -triple x86_64-windows-msvc t.cpp -debug-info-kind=limited \
9 ; -gcodeview -O2 -fms-extensions -emit-llvm -o t.ll
11 ; extern "C" struct Foo {
12 ; __declspec(allocator) virtual ptr alloc();
14 ; extern "C" __declspec(allocator) Foo *alloc_foo();
15 ; extern "C" void use_result(ptr);
16 ; extern "C" Foo *call_tail() {
19 ; extern "C" int call_virtual(Foo *p) {
20 ; use_result(p->alloc());
23 ; extern "C" int call_multiple() {
24 ; use_result(alloc_foo());
25 ; use_result(alloc_foo());
30 source_filename = "t.cpp"
31 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
32 target triple = "x86_64-unknown-windows-msvc"
34 %struct.Foo = type { ptr }
36 ; Function Attrs: nounwind
37 define dso_local ptr @call_tail() local_unnamed_addr #0 !dbg !7 {
39 %call = tail call ptr @alloc_foo() #3, !dbg !13, !heapallocsite !12
40 ret ptr %call, !dbg !13
43 declare dso_local ptr @alloc_foo() local_unnamed_addr #1
45 ; Function Attrs: nounwind
46 define dso_local i32 @call_virtual(ptr %p) local_unnamed_addr #0 !dbg !14 {
48 call void @llvm.dbg.value(metadata ptr %p, metadata !19, metadata !DIExpression()), !dbg !20
49 %vtable = load ptr, ptr %p, align 8, !dbg !21, !tbaa !22
50 %0 = load ptr, ptr %vtable, align 8, !dbg !21
51 %call = tail call ptr %0(ptr %p) #3, !dbg !21, !heapallocsite !2
52 tail call void @use_result(ptr %call) #3, !dbg !21
56 declare dso_local void @use_result(ptr) local_unnamed_addr #1
58 ; Function Attrs: nounwind
59 define dso_local i32 @call_multiple() local_unnamed_addr #0 !dbg !26 {
61 %call = tail call ptr @alloc_foo() #3, !dbg !29, !heapallocsite !12
62 tail call void @use_result(ptr %call) #3, !dbg !29
63 %call1 = tail call ptr @alloc_foo() #3, !dbg !30, !heapallocsite !12
64 tail call void @use_result(ptr %call1) #3, !dbg !30
68 ; Function Attrs: nounwind readnone speculatable willreturn
69 declare void @llvm.dbg.value(metadata, metadata, metadata) #2
72 ; Don't emit metadata for tail calls.
73 ; CHECK-LABEL: call_tail: # @call_tail
74 ; CHECK: jmp alloc_foo
76 ; CHECK-LABEL: call_virtual: # @call_virtual
77 ; CHECK: callq *{{.*}}%rax{{.*}}
78 ; CHECK-NEXT: [[LABEL1:.Ltmp[0-9]+]]:
80 ; CHECK-LABEL: call_multiple: # @call_multiple
81 ; CHECK: callq alloc_foo
82 ; CHECK-NEXT: [[LABEL3:.Ltmp[0-9]+]]:
83 ; CHECK: callq alloc_foo
84 ; CHECK-NEXT: [[LABEL5:.Ltmp[0-9]+]]:
86 ; CHECK-LABEL: .short 4423 # Record kind: S_GPROC32_ID
87 ; CHECK: .short 4446 # Record kind: S_HEAPALLOCSITE
88 ; CHECK-NEXT: .secrel32 [[LABEL0:.Ltmp[0-9]+]]
89 ; CHECK-NEXT: .secidx [[LABEL0]]
90 ; CHECK-NEXT: .short [[LABEL1]]-[[LABEL0]]
92 ; CHECK: .short 4446 # Record kind: S_HEAPALLOCSITE
93 ; CHECK-NEXT: .secrel32 [[LABEL2:.Ltmp[0-9]+]]
94 ; CHECK-NEXT: .secidx [[LABEL2]]
95 ; CHECK-NEXT: .short [[LABEL3]]-[[LABEL2]]
96 ; CHECK-NEXT: .long 4096
97 ; CHECK: .short 4446 # Record kind: S_HEAPALLOCSITE
98 ; CHECK-NEXT: .secrel32 [[LABEL4:.Ltmp[0-9]+]]
99 ; CHECK-NEXT: .secidx [[LABEL4]]
100 ; CHECK-NEXT: .short [[LABEL5]]-[[LABEL4]]
101 ; CHECK-NEXT: .long 4096
103 attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
104 attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
105 attributes #2 = { nounwind readnone speculatable willreturn }
106 attributes #3 = { nounwind }
109 !llvm.module.flags = !{!3, !4, !5}
112 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0 (https://github.com/llvm/llvm-project.git fa686ea7650235c6dff988cc8cba49e130b3d5f8)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
113 !1 = !DIFile(filename: "<stdin>", directory: "/usr/local/google/home/akhuang/testing/heapallocsite", checksumkind: CSK_MD5, checksum: "e0a04508b4229fc4aee0baa364e25987")
115 !3 = !{i32 2, !"CodeView", i32 1}
116 !4 = !{i32 2, !"Debug Info Version", i32 3}
117 !5 = !{i32 1, !"wchar_size", i32 2}
118 !6 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git fa686ea7650235c6dff988cc8cba49e130b3d5f8)"}
119 !7 = distinct !DISubprogram(name: "call_tail", scope: !8, file: !8, line: 6, type: !9, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
120 !8 = !DIFile(filename: "t.cpp", directory: "/usr/local/google/home/akhuang/testing/heapallocsite", checksumkind: CSK_MD5, checksum: "e0a04508b4229fc4aee0baa364e25987")
121 !9 = !DISubroutineType(types: !10)
123 !11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)
124 !12 = !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !8, line: 1, flags: DIFlagFwdDecl, identifier: ".?AUFoo@@")
125 !13 = !DILocation(line: 7, scope: !7)
126 !14 = distinct !DISubprogram(name: "call_virtual", scope: !8, file: !8, line: 9, type: !15, scopeLine: 9, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !18)
127 !15 = !DISubroutineType(types: !16)
129 !17 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
131 !19 = !DILocalVariable(name: "p", arg: 1, scope: !14, file: !8, line: 9, type: !11)
132 !20 = !DILocation(line: 0, scope: !14)
133 !21 = !DILocation(line: 10, scope: !14)
134 !22 = !{!23, !23, i64 0}
135 !23 = !{!"vtable pointer", !24, i64 0}
136 !24 = !{!"Simple C++ TBAA"}
137 !25 = !DILocation(line: 11, scope: !14)
138 !26 = distinct !DISubprogram(name: "call_multiple", scope: !8, file: !8, line: 13, type: !27, scopeLine: 13, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
139 !27 = !DISubroutineType(types: !28)
141 !29 = !DILocation(line: 14, scope: !26)
142 !30 = !DILocation(line: 15, scope: !26)
143 !31 = !DILocation(line: 16, scope: !26)