2
2
; FIXME: Add test for llc with optimizations once it is implemented.
3
3
4
4
; Source to regenerate:
5
- ; $ clang --target=x86_64-windows-msvc -S heapallocsite.c -g -gcodeview -o t.ll \
5
+ ; $ clang --target=x86_64-windows-msvc -S heapallocsite.cpp -g -gcodeview -o t.ll \
6
6
; -emit-llvm -O0 -Xclang -disable-llvm-passes -fms-extensions
7
- ; __declspec(allocator) char *myalloc(void);
8
- ; void f() {
9
- ; myalloc()
10
- ; }
11
7
;
12
8
; struct Foo {
13
9
; __declspec(allocator) virtual void *alloc();
14
10
; };
15
- ; void use_alloc(void*);
16
- ; void do_alloc(Foo *p) {
11
+ ;
12
+ ; extern "C" __declspec(allocator) Foo *alloc_foo();
13
+ ;
14
+ ; extern "C" void use_alloc(void*);
15
+ ; extern "C" void call_virtual(Foo *p) {
17
16
; use_alloc(p->alloc());
18
17
; }
18
+ ;
19
+ ; extern "C" void call_multiple() {
20
+ ; use_alloc(alloc_foo());
21
+ ; use_alloc(alloc_foo());
22
+ ; }
19
23
20
24
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
21
25
target triple = "x86_64-unknown-windows-msvc"
22
26
23
27
%struct.Foo = type { i32 (...)** }
24
28
25
29
; Function Attrs: noinline optnone uwtable
26
- define dso_local void @f ( ) #0 !dbg !8 {
30
+ define dso_local void @call_virtual ( %struct.Foo* %p ) #0 !dbg !8 {
27
31
entry:
28
- %call = call i8* @myalloc (), !dbg !11 , !heapallocsite !2
29
- ret void , !dbg !12
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
42
+ ret void , !dbg !16
30
43
}
31
44
32
- ; CHECK-LABEL: f: # @f
33
- ; CHECK: .Lheapallocsite0:
34
- ; CHECK: callq myalloc
35
- ; CHECK: .Lheapallocsite1:
36
- ; CHECK: retq
45
+ ; Function Attrs: nounwind readnone speculatable
46
+ declare void @llvm.dbg.declare (metadata , metadata , metadata ) #1
37
47
38
- declare dso_local i8* @myalloc ( ) #1
48
+ declare dso_local void @use_alloc ( i8* ) #2
39
49
40
50
; Function Attrs: noinline optnone uwtable
41
- define dso_local void @do_alloc ( %struct.Foo* %p ) #0 !dbg !13 {
51
+ define dso_local void @call_multiple ( ) #0 !dbg !17 {
42
52
entry:
43
- %p.addr = alloca %struct.Foo* , align 8
44
- store %struct.Foo* %p , %struct.Foo** %p.addr , align 8
45
- call void @llvm.dbg.declare (metadata %struct.Foo** %p.addr , metadata !18 , metadata !DIExpression ()), !dbg !19
46
- %0 = load %struct.Foo* , %struct.Foo** %p.addr , align 8 , !dbg !20
47
- %1 = bitcast %struct.Foo* %0 to i8* (%struct.Foo* )***, !dbg !20
48
- %vtable = load i8* (%struct.Foo* )**, i8* (%struct.Foo* )*** %1 , align 8 , !dbg !20
49
- %vfn = getelementptr inbounds i8* (%struct.Foo* )*, i8* (%struct.Foo* )** %vtable , i64 0 , !dbg !20
50
- %2 = load i8* (%struct.Foo* )*, i8* (%struct.Foo* )** %vfn , align 8 , !dbg !20
51
- %call = call i8* %2 (%struct.Foo* %0 ), !dbg !20 , !heapallocsite !2
52
- call void @use_alloc (i8* %call ), !dbg !20
53
- ret void , !dbg !21
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
59
+ ret void , !dbg !22
54
60
}
55
61
56
- ; CHECK-LABEL: do_alloc: # @do_alloc
57
- ; CHECK: .Lheapallocsite2:
62
+ declare dso_local %struct.Foo* @alloc_foo () #2
63
+
64
+ ; CHECK-LABEL: call_virtual: # @call_virtual
65
+ ; CHECK: .Lheapallocsite0:
58
66
; CHECK: callq *(%rax)
67
+ ; CHECK: .Lheapallocsite1:
68
+ ; CHECK: retq
69
+
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
59
76
; CHECK: .Lheapallocsite3:
60
77
; CHECK: retq
61
78
@@ -73,39 +90,40 @@ entry:
73
90
; CHECK-NEXT: .secrel32 .Lheapallocsite2
74
91
; CHECK-NEXT: .secidx .Lheapallocsite2
75
92
; CHECK-NEXT: .short .Lheapallocsite3-.Lheapallocsite2
76
- ; CHECK-NEXT: .long 3
93
+ ; CHECK-NEXT: .long 4096
77
94
; CHECK-NEXT: .p2align 2
78
- ; CHECK-LABEL: .short 4431 # Record kind: S_PROC_ID_END
79
-
80
- ; Function Attrs: nounwind readnone speculatable
81
- declare void @llvm.dbg.declare (metadata , metadata , metadata ) #2
82
95
83
- declare dso_local void @use_alloc (i8* ) #1
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
84
103
85
104
!llvm.dbg.cu = !{!0 }
86
105
!llvm.module.flags = !{!3 , !4 , !5 , !6 }
87
106
!llvm.ident = !{!7 }
88
107
89
- !0 = distinct !DICompileUnit (language: DW_LANG_C99, file: !1 , producer: "clang version 9.0.0 (https://github.com/llvm/llvm-project.git 4eff3de99423a62fd6e833e29c71c1e62ba6140b)" , isOptimized: false , runtimeVersion: 0 , emissionKind: FullDebug, enums: !2 , nameTableKind: None)
90
- !1 = !DIFile (filename: "heapallocsite.cpp" , directory: "C:\5C src\5C test" , checksumkind: CSK_MD5, checksum: "6d758cfa3834154a04ce8a55102772a9" )
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" )
91
109
!2 = !{}
92
110
!3 = !{i32 2 , !"CodeView" , i32 1 }
93
111
!4 = !{i32 2 , !"Debug Info Version" , i32 3 }
94
112
!5 = !{i32 1 , !"wchar_size" , i32 2 }
95
113
!6 = !{i32 7 , !"PIC Level" , i32 2 }
96
- !7 = !{!"clang version 9.0.0 (https://github.com/llvm/llvm-project.git 4eff3de99423a62fd6e833e29c71c1e62ba6140b )" }
97
- !8 = distinct !DISubprogram (name: "f " , scope: !1 , file: !1 , line: 3 , type: !9 , scopeLine: 3 , spFlags: DISPFlagDefinition, unit: !0 , retainedNodes: !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 )
98
116
!9 = !DISubroutineType (types: !10 )
99
- !10 = !{null }
100
- !11 = !DILocation (line: 4 , scope : !8 )
101
- !12 = !DILocation (line: 5 , scope: !8 )
102
- !13 = distinct !DISubprogram (name: "do_alloc " , scope: !1 , file: !1 , line: 11 , type: !14 , scopeLine: 11 , flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0 , retainedNodes: !2 )
103
- !14 = !DISubroutineType (types: !15 )
104
- !15 = !{ null , !16 }
105
- !16 = !DIDerivedType (tag: DW_TAG_pointer_type, baseType : !17 , size: 64 )
106
- !17 = !DICompositeType (tag: DW_TAG_structure_type, name: "Foo" , file: !1 , line: 7 , flags: DIFlagFwdDecl )
107
- !18 = !DILocalVariable (name: "p" , arg: 1 , scope: !13 , file: !1 , line: 11 , type: !16 )
108
- !19 = !DILocation (line: 11 , scope: !13 )
109
- !20 = !DILocation (line: 12 , scope: !13 )
110
- !21 = !DILocation (line: 13 , scope: !13 )
111
-
117
+ !10 = !{null , !11 }
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 )
126
+ !19 = !{ null }
127
+ !20 = !DILocation (line: 13 , scope: !17 )
128
+ !21 = !DILocation (line: 14 , scope: !17 )
129
+ !22 = !DILocation (line: 15 , scope: !17 )
0 commit comments