diff options
author | Hans Wennborg <hans@hanshq.net> | 2018-12-07 08:17:26 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2018-12-07 08:17:26 +0000 |
commit | 86aba5eeeee1048ccc5be60c76e35a1ed42d2fe6 (patch) | |
tree | 53d8df5de8579ab85cad34de2eb34c3cf76044e4 /clang/test/CodeGenCXX/thunk-returning-memptr.cpp | |
parent | 25d505953a34b526d9985f2e631128069a9c22d7 (diff) | |
download | bcm5719-llvm-86aba5eeeee1048ccc5be60c76e35a1ed42d2fe6.tar.gz bcm5719-llvm-86aba5eeeee1048ccc5be60c76e35a1ed42d2fe6.zip |
Fix thunks returning memptrs via sret by emitting also scalar return values directly in sret slot (PR39901)
Thunks that return member pointers via sret are broken due to using temporary
storage for the return value on the stack and then passing that pointer to a
tail call, violating the rule that a tail call can't access allocas in the
caller (see bug).
Since r90526, we put aggregate return values directly in the sret slot, but
this doesn't apply to member pointers which are considered scalar.
Unless I'm missing something subtle, we should be able to always use the sret
slot directly for indirect return values.
Differential revision: https://reviews.llvm.org/D55371
llvm-svn: 348569
Diffstat (limited to 'clang/test/CodeGenCXX/thunk-returning-memptr.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/thunk-returning-memptr.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/thunk-returning-memptr.cpp b/clang/test/CodeGenCXX/thunk-returning-memptr.cpp new file mode 100644 index 00000000000..0b7870c6d65 --- /dev/null +++ b/clang/test/CodeGenCXX/thunk-returning-memptr.cpp @@ -0,0 +1,27 @@ +// 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 %agg.result, %struct.C* %this) +// CHECK: tail call void @_ZN1C1fEv({ i32, i32 }* sret %agg.result |