160 lines · c
1// RUN: %clang_cc1 -triple i386-unknown-unknown -Wno-strict-prototypes -emit-llvm < %s | FileCheck %s2 3void __attribute__((fastcall)) f1(void);4void __attribute__((stdcall)) f2(void);5void __attribute__((thiscall)) f3(void);6void __attribute__((fastcall)) f4(void) {7// CHECK-LABEL: define{{.*}} x86_fastcallcc void @f4()8 f1();9// CHECK: call x86_fastcallcc void @f1()10}11void __attribute__((stdcall)) f5(void) {12// CHECK-LABEL: define{{.*}} x86_stdcallcc void @f5()13 f2();14// CHECK: call x86_stdcallcc void @f2()15}16void __attribute__((thiscall)) f6(void) {17// CHECK-LABEL: define{{.*}} x86_thiscallcc void @f6()18 f3();19// CHECK: call x86_thiscallcc void @f3()20}21 22// PR528023void (__attribute__((fastcall)) *pf1)(void) = f1;24void (__attribute__((stdcall)) *pf2)(void) = f2;25void (__attribute__((thiscall)) *pf3)(void) = f3;26void (__attribute__((fastcall)) *pf4)(void) = f4;27void (__attribute__((stdcall)) *pf5)(void) = f5;28void (__attribute__((thiscall)) *pf6)(void) = f6;29 30int main(void) {31 f4(); f5(); f6();32 // CHECK: call x86_fastcallcc void @f4()33 // CHECK: call x86_stdcallcc void @f5()34 // CHECK: call x86_thiscallcc void @f6()35 pf1(); pf2(); pf3(); pf4(); pf5(); pf6();36 // CHECK: call x86_fastcallcc void %{{.*}}()37 // CHECK: call x86_stdcallcc void %{{.*}}()38 // CHECK: call x86_thiscallcc void %{{.*}}()39 // CHECK: call x86_fastcallcc void %{{.*}}()40 // CHECK: call x86_stdcallcc void %{{.*}}()41 // CHECK: call x86_thiscallcc void %{{.*}}()42 return 0;43}44 45// PR711746void __attribute((stdcall)) f7(foo) int foo; {}47void f8(void) {48 f7(0);49 // CHECK: call x86_stdcallcc void @f7(i32 noundef 0)50}51 52void __attribute__((fastcall)) foo1(int y);53void bar1(int y) {54 // CHECK-LABEL: define{{.*}} void @bar155 // CHECK: call x86_fastcallcc void @foo1(i32 inreg noundef %56 foo1(y);57}58 59struct S1 {60 int x;61};62void __attribute__((fastcall)) foo2(struct S1 y);63void bar2(struct S1 y) {64 // CHECK-LABEL: define{{.*}} void @bar265 // CHECK: call x86_fastcallcc void @foo2(i32 inreg undef, i32 %66 foo2(y);67}68 69void __attribute__((fastcall)) foo3(int *y);70void bar3(int *y) {71 // CHECK-LABEL: define{{.*}} void @bar372 // CHECK: call x86_fastcallcc void @foo3(ptr inreg noundef %73 foo3(y);74}75 76enum Enum {Eval};77void __attribute__((fastcall)) foo4(enum Enum y);78void bar4(enum Enum y) {79 // CHECK-LABEL: define{{.*}} void @bar480 // CHECK: call x86_fastcallcc void @foo4(i32 inreg noundef %81 foo4(y);82}83 84struct S2 {85 int x1;86 double x2;87 double x3;88};89void __attribute__((fastcall)) foo5(struct S2 y);90void bar5(struct S2 y) {91 // CHECK-LABEL: define{{.*}} void @bar592 // CHECK: call x86_fastcallcc void @foo5(ptr noundef byval(%struct.S2) align 4 %93 foo5(y);94}95 96void __attribute__((fastcall)) foo6(long long y);97void bar6(long long y) {98 // CHECK-LABEL: define{{.*}} void @bar699 // CHECK: call x86_fastcallcc void @foo6(i64 noundef %100 foo6(y);101}102 103void __attribute__((fastcall)) foo7(int a, struct S1 b, int c);104void bar7(int a, struct S1 b, int c) {105 // CHECK-LABEL: define{{.*}} void @bar7106 // CHECK: call x86_fastcallcc void @foo7(i32 inreg noundef %{{.*}}, i32 %{{.*}}, i32 noundef %{{.*}}107 foo7(a, b, c);108}109 110void __attribute__((fastcall)) foo8(struct S1 a, int b);111void bar8(struct S1 a, int b) {112 // CHECK-LABEL: define{{.*}} void @bar8113 // CHECK: call x86_fastcallcc void @foo8(i32 inreg undef, i32 %{{.*}}, i32 inreg noundef %114 foo8(a, b);115}116 117void __attribute__((fastcall)) foo9(struct S2 a, int b);118void bar9(struct S2 a, int b) {119 // CHECK-LABEL: define{{.*}} void @bar9120 // CHECK: call x86_fastcallcc void @foo9(ptr noundef byval(%struct.S2) align 4 %{{.*}}, i32 noundef %121 foo9(a, b);122}123 124void __attribute__((fastcall)) foo10(float y, int x);125void bar10(float y, int x) {126 // CHECK-LABEL: define{{.*}} void @bar10127 // CHECK: call x86_fastcallcc void @foo10(float noundef %{{.*}}, i32 inreg noundef %128 foo10(y, x);129}130 131void __attribute__((fastcall)) foo11(double y, int x);132void bar11(double y, int x) {133 // CHECK-LABEL: define{{.*}} void @bar11134 // CHECK: call x86_fastcallcc void @foo11(double noundef %{{.*}}, i32 inreg noundef %135 foo11(y, x);136}137 138struct S3 {139 float x;140};141void __attribute__((fastcall)) foo12(struct S3 y, int x);142void bar12(struct S3 y, int x) {143 // CHECK-LABEL: define{{.*}} void @bar12144 // CHECK: call x86_fastcallcc void @foo12(float %{{.*}}, i32 inreg noundef %145 foo12(y, x);146}147 148void __attribute__((fastcall)) foo13(long long a, int b, int c);149void bar13(long long a, int b, int c) {150 // CHECK-LABEL: define{{.*}} void @bar13151 // CHECK: call x86_fastcallcc void @foo13(i64 noundef %{{.*}}, i32 inreg noundef %{{.*}}, i32 inreg noundef %152 foo13(a, b, c);153}154 155struct S2 __attribute__((fastcall)) foo14(int a) {156 // CHECK-LABEL: define dso_local x86_fastcallcc void @foo14(ptr dead_on_unwind noalias writable sret(%struct.S2) align 4 %agg.result, i32 inreg noundef %a)157 struct S2 r = {a};158 return r;159}160