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;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @_Z4testv()
|
2012-02-22 11:04:13 +08:00
|
|
|
void test( void ) {
|
2020-11-17 07:04:55 +08:00
|
|
|
// CHECK: call void @_ZN1CC1Ev(%class.C* {{[^,]*}} [[C:%.+]])
|
2012-02-22 11:04:13 +08:00
|
|
|
C c;
|
|
|
|
|
2020-11-17 07:04:55 +08:00
|
|
|
// CHECK: call x86_thiscallcc void @_ZNK1C5SmallEv(%struct.S* sret(%struct.S) align 4 %{{.+}}, %class.C* {{[^,]*}} [[C]])
|
2012-02-22 11:04:13 +08:00
|
|
|
(void)c.Small();
|
2020-11-17 07:04:55 +08:00
|
|
|
// CHECK: call x86_thiscallcc void @_ZNK1C6MediumEv(%struct.M* sret(%struct.M) align 4 %{{.+}}, %class.C* {{[^,]*}} [[C]])
|
2012-02-22 11:04:13 +08:00
|
|
|
(void)c.Medium();
|
|
|
|
}
|