2012-02-22 11:04:13 +08:00
|
|
|
// For MSVC ABI compatibility, all structures returned by value using the
|
|
|
|
// thiscall calling convention must use the hidden parameter.
|
|
|
|
//
|
2013-09-04 12:12:25 +08:00
|
|
|
// RUN: %clang_cc1 -triple i386-PC-Win32 %s -fms-compatibility -emit-llvm -o - | FileCheck %s
|
2012-02-22 11:04:13 +08:00
|
|
|
|
|
|
|
// This structure would normally be returned via EAX
|
|
|
|
struct S {
|
|
|
|
int i;
|
|
|
|
};
|
|
|
|
|
|
|
|
// This structure would normally be returned via EAX/EDX
|
|
|
|
struct M {
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
};
|
|
|
|
|
|
|
|
class C {
|
|
|
|
public:
|
|
|
|
C() {}
|
|
|
|
|
|
|
|
struct S __attribute__((thiscall)) Small() const {
|
|
|
|
struct S s = { 0 };
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct M __attribute__((thiscall)) Medium() const {
|
|
|
|
struct M m = { 0 };
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @_Z4testv()
|
2012-02-22 11:04:13 +08:00
|
|
|
void test( void ) {
|
2012-02-22 11:36:54 +08:00
|
|
|
// CHECK: call void @_ZN1CC1Ev(%class.C* [[C:%.+]])
|
2012-02-22 11:04:13 +08:00
|
|
|
C c;
|
|
|
|
|
2012-02-22 11:36:54 +08:00
|
|
|
// CHECK: call x86_thiscallcc void @_ZNK1C5SmallEv(%struct.S* sret %{{.+}}, %class.C* [[C]])
|
2012-02-22 11:04:13 +08:00
|
|
|
(void)c.Small();
|
2012-02-22 11:36:54 +08:00
|
|
|
// CHECK: call x86_thiscallcc void @_ZNK1C6MediumEv(%struct.M* sret %{{.+}}, %class.C* [[C]])
|
2012-02-22 11:04:13 +08:00
|
|
|
(void)c.Medium();
|
|
|
|
}
|