mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 10:56:06 +00:00

All data structures and values associated with handling virtual functions / inheritance, as well as RTTI, are globals and thus can only reside in the global address space. This was not taken fully taken into account because for most targets, global & generic appear to coincide. However, on targets where global & generic ASes differ (e.g. AMDGPU), this was problematic, since it led to the generation of invalid bitcasts (which would trigger asserts in Debug) and less than optimal code. This patch does two things: ensures that vtables, vptrs, vtts, typeinfo are generated in the right AS, and populated accordingly; removes a bunch of bitcasts which look like left-overs from the typed ptr era. Reviewed By: yxsamliu Differential Revision: https://reviews.llvm.org/D153092
28 lines
857 B
C++
28 lines
857 B
C++
// RUN: %clang_cc1 -std=c++20 -triple=amdgcn-amd-amdhsa %s -emit-llvm -o - | FileCheck %s --implicit-check-not=DoNotEmit
|
|
|
|
// constexpr virtual functions can be called at runtime and go in the vtable as
|
|
// normal. But they are implicitly inline so are never the key function.
|
|
|
|
struct DoNotEmit {
|
|
virtual constexpr void f();
|
|
};
|
|
constexpr void DoNotEmit::f() {}
|
|
|
|
// CHECK-DAG: @_ZTV1B = {{.*}} addrspace(1) constant { [3 x ptr addrspace(1)] } { {{.*}} null, {{.*}} @_ZTI1B, {{.*}} @_ZN1B1fEv
|
|
struct B {
|
|
// CHECK-DAG: define {{.*}} @_ZN1B1fEv
|
|
virtual constexpr void f() {}
|
|
};
|
|
B b;
|
|
|
|
struct CBase {
|
|
virtual constexpr void f(); // not key function
|
|
};
|
|
|
|
// CHECK-DAG: @_ZTV1C = {{.*}} addrspace(1) constant {{.*}} null, {{.*}} @_ZTI1C, {{.*}} @_ZN1C1fEv
|
|
struct C : CBase {
|
|
void f(); // key function
|
|
};
|
|
// CHECK-DAG: define {{.*}} @_ZN1C1fEv
|
|
void C::f() {}
|