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;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
[CodeGenModule] Assume dso_local for -fpic -fno-semantic-interposition
Summary:
Clang -fpic defaults to -fno-semantic-interposition (GCC -fpic defaults
to -fsemantic-interposition).
Users need to specify -fsemantic-interposition to get semantic
interposition behavior.
Semantic interposition is currently a best-effort feature. There may
still be some cases where it is not handled well.
Reviewers: peter.smith, rnk, serge-sans-paille, sfertile, jfb, jdoerfert
Subscribers: dschuff, jyknight, dylanmckay, nemanjai, jvesely, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, arphaman, PkmX, jocewei, jsji, Jim, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D73865
2020-02-03 04:23:47 +08:00
|
|
|
// CHECK-LABEL: define dso_local void @_Z4testv()
|
2012-02-22 11:04:13 +08:00
|
|
|
void test( void ) {
|
2018-10-15 23:43:00 +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();
|
|
|
|
}
|