71 lines · cpp
1// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i686-pc-win32 -mconstructor-aliases -fno-rtti | FileCheck %s2 3struct A {4 A() : a(42) {}5 A(const A &o) : a(o.a) {}6 ~A() {}7 int a;8};9 10struct B {11 A foo(A o);12 A __cdecl bar(A o);13 A __stdcall baz(A o);14 A __fastcall qux(A o);15};16 17A B::foo(A x) {18 return x;19}20 21// CHECK-LABEL: define dso_local x86_thiscallcc ptr @"?foo@B@@QAE?AUA@@U2@@Z"22// CHECK: (ptr noundef %this, ptr inalloca(<{ ptr, %struct.A }>) %0)23// CHECK: getelementptr inbounds nuw <{ ptr, %struct.A }>, ptr %{{.*}}, i32 0, i32 024// CHECK: load ptr, ptr25// CHECK: ret ptr26 27A B::bar(A x) {28 return x;29}30 31// CHECK-LABEL: define dso_local ptr @"?bar@B@@QAA?AUA@@U2@@Z"32// CHECK: (ptr inalloca(<{ ptr, ptr, %struct.A }>) %0)33// CHECK: getelementptr inbounds nuw <{ ptr, ptr, %struct.A }>, ptr %{{.*}}, i32 0, i32 134// CHECK: load ptr, ptr35// CHECK: ret ptr36 37A B::baz(A x) {38 return x;39}40 41// CHECK-LABEL: define dso_local x86_stdcallcc ptr @"?baz@B@@QAG?AUA@@U2@@Z"42// CHECK: (ptr inalloca(<{ ptr, ptr, %struct.A }>) %0)43// CHECK: getelementptr inbounds nuw <{ ptr, ptr, %struct.A }>, ptr %{{.*}}, i32 0, i32 144// CHECK: load ptr, ptr45// CHECK: ret ptr46 47A B::qux(A x) {48 return x;49}50 51// CHECK-LABEL: define dso_local x86_fastcallcc void @"?qux@B@@QAI?AUA@@U2@@Z"52// CHECK: (ptr inreg noundef %this, ptr dead_on_unwind inreg noalias writable sret(%struct.A) align 4 %agg.result, ptr inalloca(<{ %struct.A }>) %0)53// CHECK: ret void54 55int main() {56 B b;57 A a = b.foo(A());58 a = b.bar(a);59 a = b.baz(a);60 a = b.qux(a);61}62 63// CHECK: call x86_thiscallcc ptr @"?foo@B@@QAE?AUA@@U2@@Z"64// CHECK: (ptr noundef %{{[^,]*}}, ptr inalloca(<{ ptr, %struct.A }>) %{{[^,]*}})65// CHECK: call ptr @"?bar@B@@QAA?AUA@@U2@@Z"66// CHECK: (ptr inalloca(<{ ptr, ptr, %struct.A }>) %{{[^,]*}})67// CHECK: call x86_stdcallcc ptr @"?baz@B@@QAG?AUA@@U2@@Z"68// CHECK: (ptr inalloca(<{ ptr, ptr, %struct.A }>) %{{[^,]*}})69// CHECK: call x86_fastcallcc void @"?qux@B@@QAI?AUA@@U2@@Z"70// CHECK: (ptr inreg noundef %{{[^,]*}}, ptr dead_on_unwind inreg writable sret(%struct.A) align 4 %{{.*}}, ptr inalloca(<{ %struct.A }>) %{{[^,]*}})71