[cfe-commits] r83886 - in /cfe/trunk: lib/CodeGen/CGCXX.cpp test/CodeGenCXX/devirtualize-virtual-function-calls.cpp
Anders Carlsson
andersca at mac.com
Mon Oct 12 12:59:15 PDT 2009
Author: andersca
Date: Mon Oct 12 14:59:15 2009
New Revision: 83886
URL: http://llvm.org/viewvc/llvm-project?rev=83886&view=rev
Log:
Even more devirtualization cleverness.
Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=83886&r1=83885&r2=83886&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Mon Oct 12 14:59:15 2009
@@ -210,10 +210,14 @@
return false;
}
- // We can always devirtualize calls on temporaries.
+ // We can always devirtualize calls on temporary object expressions.
if (isa<CXXTemporaryObjectExpr>(Base))
return true;
+ // And calls on bound temporaries.
+ if (isa<CXXBindTemporaryExpr>(Base))
+ return true;
+
// Check if this is a call expr that returns a record type.
if (const CallExpr *CE = dyn_cast<CallExpr>(Base))
return CE->getCallReturnType()->isRecordType();
Modified: cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp?rev=83886&r1=83885&r2=83886&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp Mon Oct 12 14:59:15 2009
@@ -29,3 +29,19 @@
// CHECK: call void @_ZN1A1fEv
a.h().f();
}
+
+struct B {
+ virtual void f();
+ ~B();
+
+ B h();
+};
+
+
+void f() {
+ // CHECK: call void @_ZN1B1fEv
+ B().f();
+
+ // CHECK: call void @_ZN1B1fEv
+ B().h().f();
+}
More information about the cfe-commits
mailing list