1 ; RUN: opt < %s -passes=globalopt -S | FileCheck %s
3 declare token @llvm.call.preallocated.setup(i32)
4 declare ptr @llvm.call.preallocated.arg(token, i32)
6 define internal i32 @f(ptr %m) {
7 ; CHECK-LABEL: define internal fastcc i32 @f
12 define internal x86_thiscallcc i32 @g(ptr %m) {
13 ; CHECK-LABEL: define internal fastcc i32 @g
18 ; Leave this one alone, because the user went out of their way to request this
20 define internal coldcc i32 @h(ptr %m) {
21 ; CHECK-LABEL: define internal coldcc i32 @h
26 define internal i32 @j(ptr %m) {
27 ; CHECK-LABEL: define internal i32 @j
32 define internal i32 @inalloca(ptr inalloca(i32) %p) {
33 ; CHECK-LABEL: define internal fastcc i32 @inalloca(ptr %p)
34 %rv = load i32, ptr %p
38 define i32 @inalloca2_caller(ptr inalloca(i32) %p) {
39 %rv = musttail call i32 @inalloca2(ptr inalloca(i32) %p)
42 define internal i32 @inalloca2(ptr inalloca(i32) %p) {
43 ; Because of the musttail caller, this inalloca cannot be dropped.
44 ; CHECK-LABEL: define internal i32 @inalloca2(ptr inalloca(i32) %p)
45 %rv = load i32, ptr %p
49 define internal i32 @preallocated(ptr preallocated(i32) %p) {
50 ; CHECK-LABEL: define internal fastcc i32 @preallocated(ptr %p)
51 %rv = load i32, ptr %p
55 define void @call_things() {
58 call x86_thiscallcc i32 @g(ptr %m)
59 call coldcc i32 @h(ptr %m)
61 %args = alloca inalloca i32
62 call i32 @inalloca(ptr inalloca(i32) %args)
63 %c = call token @llvm.call.preallocated.setup(i32 1)
64 %N = call ptr @llvm.call.preallocated.arg(token %c, i32 0) preallocated(i32)
65 call i32 @preallocated(ptr preallocated(i32) %N) ["preallocated"(token %c)]
68 ; CHECK-LABEL: define void @call_things()
69 ; CHECK: call fastcc i32 @f
70 ; CHECK: call fastcc i32 @g
71 ; CHECK: call coldcc i32 @h
73 ; CHECK: call fastcc i32 @inalloca(ptr %args)
74 ; CHECK-NOT: llvm.call.preallocated
75 ; CHECK: call fastcc i32 @preallocated(ptr %paarg)
77 @llvm.used = appending global [1 x ptr] [
79 ], section "llvm.metadata"