[cfe-commits] r65141 - /cfe/trunk/lib/CodeGen/CGCall.cpp
Daniel Dunbar
daniel at zuster.org
Fri Feb 20 10:54:31 PST 2009
Author: ddunbar
Date: Fri Feb 20 12:54:31 2009
New Revision: 65141
URL: http://llvm.org/viewvc/llvm-project?rev=65141&view=rev
Log:
Take advantage of noreturn attribute to add unreachable instruction &
clear insertion point. The rest of IRgen should theoretically take
advantage of this to avoid emitting dead code. Theory != Practice.
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=65141&r1=65140&r2=65141&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Fri Feb 20 12:54:31 2009
@@ -1760,6 +1760,18 @@
if (const llvm::Function *F = dyn_cast<llvm::Function>(Callee))
CI->setCallingConv(F->getCallingConv());
+
+ // If the call doesn't return, finish the basic block and clear the
+ // insertion point; this allows the rest of IRgen to discard
+ // unreachable code.
+ if (CI->doesNotReturn()) {
+ Builder.CreateUnreachable();
+ Builder.ClearInsertionPoint();
+
+ // Return a reasonable RValue.
+ return GetUndefRValue(RetTy);
+ }
+
if (CI->getType() != llvm::Type::VoidTy)
CI->setName("call");
More information about the cfe-commits
mailing list