llvm/clang/test/CodeGenCXX/thunk-returning-memptr.cpp
Roman Lebedev a624cec56d
[Clang][Codegen] Do not annotate thunk's this/return types with align/deref/nonnull attrs
As it was discovered in post-commit feedback
for 0aa0458f14,
we handle thunks incorrectly, and end up annotating
their this/return with attributes that are valid
for their callees, not for thunks themselves.

While it would be good to fix this properly,
and keep annotating them on thunks,
i've tried doing that in https://reviews.llvm.org/D100388
with little success, and the patch is stuck for a month now.

So for now, as a stopgap measure, subj.
2021-05-13 20:33:08 +03:00

28 lines
695 B
C++

// RUN: %clang_cc1 -triple=i686 -emit-llvm -o - %s | FileCheck %s
struct X;
typedef void (X::*memptr)();
struct A {
virtual memptr f();
};
struct B {
virtual memptr f();
};
struct C : A, B {
C();
memptr f() override __attribute__((noinline)) { return nullptr; };
};
C::C() {}
// Make sure the member pointer is returned from the thunk via the return slot.
// Because of the tail call, the return value cannot be copied into a local
// alloca. (PR39901)
// CHECK-LABEL: define linkonce_odr void @_ZThn4_N1C1fEv({ i32, i32 }* noalias sret({ i32, i32 }) align 4 %agg.result, %struct.C* %this)
// CHECK: tail call void @_ZN1C1fEv({ i32, i32 }* sret({ i32, i32 }) align 4 %agg.result