brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · 7802ed4 Raw
42 lines · cpp
1// For MSVC ABI compatibility, all structures returned by value using the2// thiscall calling convention must use the hidden parameter.3//4// RUN: %clang_cc1 -triple i386-PC-Win32 %s -fms-compatibility -emit-llvm -o - | FileCheck %s5 6// This structure would normally be returned via EAX7struct S {8  int i;9};10 11// This structure would normally be returned via EAX/EDX12struct M {13  int i;14  int j;15};16 17class C {18public:19  C() {}20 21  struct S __attribute__((thiscall)) Small() const {22    struct S s = { 0 };23    return s;24  }25 26  struct M __attribute__((thiscall)) Medium() const {27    struct M m = { 0 };28    return m;29  }30};31 32// CHECK-LABEL: define{{.*}} void @_Z4testv()33void test( void ) {34// CHECK: call void @_ZN1CC1Ev(ptr {{[^,]*}} [[C:%.+]])35  C c;36 37// CHECK: call x86_thiscallcc void @_ZNK1C5SmallEv(ptr dead_on_unwind writable sret(%struct.S) align 4 %{{.+}}, ptr {{[^,]*}} [[C]])38  (void)c.Small();39// CHECK: call x86_thiscallcc void @_ZNK1C6MediumEv(ptr dead_on_unwind writable sret(%struct.M) align 4 %{{.+}}, ptr {{[^,]*}} [[C]])40  (void)c.Medium();41}42