1 // RUN: %clang_cc1 -triple i386-pc-win32 -emit-llvm %s -o - | FileCheck %s 2 3 // PR15768 4 5 // A trivial 20 byte struct is returned indirectly and taken as byval. 6 struct S { 7 S(); 8 int a, b, c, d, e; 9 }; 10 11 struct C { 12 S variadic_sret(const char *f, ...); 13 S __cdecl cdecl_sret(); 14 S __cdecl byval_and_sret(S a); 15 int c; 16 }; 17 18 S C::variadic_sret(const char *f, ...) { return S(); } 19 S C::cdecl_sret() { return S(); } 20 S C::byval_and_sret(S a) { return S(); } 21 22 // CHECK: define void @"\01?variadic_sret@C@@QAA?AUS@@PBDZZ"(%struct.C* %this, %struct.S* noalias sret %agg.result, i8* %f, ...) 23 // CHECK: define void @"\01?cdecl_sret@C@@QAA?AUS@@XZ"(%struct.C* %this, %struct.S* noalias sret %agg.result) 24 // CHECK: define void @"\01?byval_and_sret@C@@QAA?AUS@@U2@@Z"(%struct.C* %this, %struct.S* noalias sret %agg.result, %struct.S* byval align 4 %a) 25 26 int main() { 27 C c; 28 c.variadic_sret("asdf"); 29 c.cdecl_sret(); 30 c.byval_and_sret(S()); 31 } 32 // CHECK-LABEL: define i32 @main() 33 // CHECK: call void {{.*}} @"\01?variadic_sret@C@@QAA?AUS@@PBDZZ" 34 // CHECK: call void @"\01?cdecl_sret@C@@QAA?AUS@@XZ" 35 // CHECK: call void @"\01?byval_and_sret@C@@QAA?AUS@@U2@@Z" 36 37 // __fastcall has similar issues. 38 struct A { 39 S __fastcall f(int x); 40 }; 41 S A::f(int x) { 42 return S(); 43 } 44 // CHECK-LABEL: define x86_fastcallcc void @"\01?f@A@@QAI?AUS@@H@Z"(%struct.A* inreg %this, %struct.S* inreg noalias sret %agg.result, i32 %x) 45