[cfe-commits] r83882 - in /cfe/trunk: lib/CodeGen/CGCXX.cpp test/CodeGenCXX/devirtualize-virtual-function-calls.cpp
Anders Carlsson
andersca at mac.com
Mon Oct 12 12:45:47 PDT 2009
Author: andersca
Date: Mon Oct 12 14:45:47 2009
New Revision: 83882
URL: http://llvm.org/viewvc/llvm-project?rev=83882&view=rev
Log:
Devirtualize calls on temporaries. A().f() for example.
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=83882&r1=83881&r2=83882&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Mon Oct 12 14:45:47 2009
@@ -206,8 +206,14 @@
// This is a record decl. We know the type and can devirtualize it.
return VD->getType()->isRecordType();
}
+
+ return false;
}
+ // We can always devirtualize calls on temporaries.
+ if (isa<CXXTemporaryObjectExpr>(Base))
+ return true;
+
// 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=83882&r1=83881&r2=83882&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:45:47 2009
@@ -15,4 +15,7 @@
// CHECK: call void %
ar.f();
+
+ // CHECK: call void @_ZN1A1fEv
+ A().f();
}
More information about the cfe-commits
mailing list