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 | 3b33c4ecf00a13f855032d4aa0d466b3fa75dac6 (patch) | |
tree | d5a80a1a4af4d6b477b7bf842e5b05e99b72770c /clang/test | |
parent | 92658b8149f88b2d2b2dac4893e4ace97b2aa9f8 (diff) | |
download | bcm5719-llvm-3b33c4ecf00a13f855032d4aa0d466b3fa75dac6.tar.gz bcm5719-llvm-3b33c4ecf00a13f855032d4aa0d466b3fa75dac6.zip |
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.
llvm-svn: 159350
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp b/clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp index ba92012bce3..d1deb77fa80 100644 --- a/clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp +++ b/clang/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(); + } +} |