[cfe-commits] r83883 - in /cfe/trunk: lib/CodeGen/CGCXX.cpp test/CodeGenCXX/devirtualize-virtual-function-calls.cpp
Anders Carlsson
andersca at mac.com
Mon Oct 12 12:51:33 PDT 2009
Author: andersca
Date: Mon Oct 12 14:51:33 2009
New Revision: 83883
URL: http://llvm.org/viewvc/llvm-project?rev=83883&view=rev
Log:
More devirtualization improvements.
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=83883&r1=83882&r2=83883&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Mon Oct 12 14:51:33 2009
@@ -214,6 +214,10 @@
if (isa<CXXTemporaryObjectExpr>(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();
+
// We can't devirtualize the call.
return false;
}
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=83883&r1=83882&r2=83883&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:51:33 2009
@@ -2,8 +2,12 @@
struct A {
virtual void f();
+
+ A h();
};
+A g();
+
void f(A a, A *ap, A& ar) {
// This should not be a virtual function call.
@@ -18,4 +22,10 @@
// CHECK: call void @_ZN1A1fEv
A().f();
+
+ // CHECK: call void @_ZN1A1fEv
+ g().f();
+
+ // CHECK: call void @_ZN1A1fEv
+ a.h().f();
}
More information about the cfe-commits
mailing list