diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2012-06-28 14:28:57 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2012-06-28 14:28:57 +0000 |
commit | ea01d7661751e062bb670cc1a0bdfee5789cb96f (patch) | |
tree | 46cf0d6f634b99dba0278c232d90f9e1638b86ae /test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp | |
parent | de981f3ff163bc9ec69e4c5e7316e94276412993 (diff) |
Don't devirtualize calls when we don't have the correct type of the this pointer
handy. It can be done, but we would have to build a derived-to-base cast
during codegen to compute the correct this pointer.
I will handle covariant returns next.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159350 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp')
-rw-r--r-- | test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp b/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp index ba92012bce..d1deb77fa8 100644 --- a/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp +++ b/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp @@ -80,7 +80,11 @@ namespace Test5 { // CHECK: define void @_ZN5Test51fEPNS_1CE void f(C* d) { - // CHECK: call void @_ZN5Test51B1fEv + // FIXME: It should be possible to devirtualize this case, but that is + // not implemented yet. + // CHECK: getelementptr + // CHECK-NEXT: %[[FUNC:.*]] = load + // CHECK-NEXT: call void %[[FUNC]] static_cast<A*>(d)->f(); } } @@ -133,3 +137,18 @@ namespace Test7 { return static_cast<bar*>(z)->f(); } } + +namespace Test8 { + struct A { virtual ~A() {} }; + struct B { + int b; + virtual int foo() { return b; } + }; + struct C final : A, B { }; + // CHECK: define i32 @_ZN5Test84testEPNS_1CE + int test(C *c) { + // CHECK: %[[THIS:.*]] = phi + // CHECK-NEXT: call i32 @_ZN5Test81B3fooEv(%"struct.Test8::B"* %[[THIS]]) + return static_cast<B*>(c)->foo(); + } +} |