This patch contains all of the clang changes from D72959. - Generalize the relative vtables ABI such that it can be used by other targets. - Add an enum VTableComponentLayout which controls whether components in the vtable should be pointers to other structs or relative offsets to those structs. Other ABIs can change this enum to restructure how components in the vtable are laid out/accessed. - Add methods to ConstantInitBuilder for inserting relative offsets to a specified position in the aggregate being constructed. - Fix failing tests under new PM and ASan and MSan issues. See D72959 for background info. Differential Revision: https://reviews.llvm.org/D77592
38 lines
1.6 KiB
C++
38 lines
1.6 KiB
C++
// ByVal attributes should propogate through to produce proper assembly and
|
|
// avoid "unpacking" structs within the stubs on x86_64.
|
|
|
|
// RUN: %clang_cc1 %s -triple=x86_64-unknown-fuchsia -S -o - -emit-llvm -fexperimental-relative-c++-abi-vtables | FileCheck %s
|
|
|
|
struct LargeStruct {
|
|
char x[24];
|
|
virtual ~LargeStruct() {}
|
|
};
|
|
|
|
struct fidl_string {
|
|
unsigned long long size;
|
|
char *data;
|
|
};
|
|
static_assert(sizeof(fidl_string) == 16, "");
|
|
|
|
class Base {
|
|
public:
|
|
virtual void func(LargeStruct, fidl_string, LargeStruct, fidl_string) = 0;
|
|
};
|
|
|
|
class Derived : public Base {
|
|
public:
|
|
void func(LargeStruct, fidl_string, LargeStruct, fidl_string) override;
|
|
};
|
|
|
|
// The original function takes a byval pointer.
|
|
// CHECK: define void @_ZN7Derived4funcE11LargeStruct11fidl_stringS0_S1_(%class.Derived* %this, %struct.LargeStruct* %ls, i64 %sv1.coerce0, i8* %sv1.coerce1, %struct.LargeStruct* %ls2, %struct.fidl_string* byval(%struct.fidl_string) align 8 %sv2) unnamed_addr
|
|
|
|
// So the stub should take and pass one also.
|
|
// CHECK: define hidden void @_ZN7Derived4funcE11LargeStruct11fidl_stringS0_S1_.stub(%class.Derived* %0, %struct.LargeStruct* %1, i64 %2, i8* %3, %struct.LargeStruct* %4, %struct.fidl_string* byval(%struct.fidl_string) align 8 %5) unnamed_addr {{#[0-9]+}} comdat
|
|
// CHECK-NEXT: entry:
|
|
// CHECK-NEXT: tail call void @_ZN7Derived4funcE11LargeStruct11fidl_stringS0_S1_(%class.Derived* %0, %struct.LargeStruct* %1, i64 %2, i8* %3, %struct.LargeStruct* %4, %struct.fidl_string* byval(%struct.fidl_string) align 8 %5)
|
|
// CHECK-NEXT: ret void
|
|
// CHECK-NEXT: }
|
|
|
|
void Derived::func(LargeStruct ls, fidl_string sv1, LargeStruct ls2, fidl_string sv2) {}
|