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 dso_local void @"?variadic_sret@C@@QAA?AUS@@PBDZZ"(%struct.C* {{[^,]*}} %this, %struct.S* noalias sret(%struct.S) align 4 %agg.result, i8* noundef %f, ...) 23 // CHECK: define dso_local void @"?cdecl_sret@C@@QAA?AUS@@XZ"(%struct.C* {{[^,]*}} %this, %struct.S* noalias sret(%struct.S) align 4 %agg.result) 24 // CHECK: define dso_local void @"?byval_and_sret@C@@QAA?AUS@@U2@@Z"(%struct.C* {{[^,]*}} %this, %struct.S* noalias sret(%struct.S) align 4 %agg.result, %struct.S* noundef byval(%struct.S) 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 dso_local noundef i32 @main() 33 // CHECK: call void {{.*}} @"?variadic_sret@C@@QAA?AUS@@PBDZZ" 34 // CHECK: call void @"?cdecl_sret@C@@QAA?AUS@@XZ" 35 // CHECK: call void @"?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 dso_local x86_fastcallcc void @"?f@A@@QAI?AUS@@H@Z"(%struct.A* inreg noundef %this, %struct.S* inreg noalias sret(%struct.S) align 4 %agg.result, i32 noundef %x) 45