[cfe-commits] r67434 - /cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Chris Lattner sabre at nondot.org
Fri Mar 20 23:53:34 PDT 2009


Author: lattner
Date: Sat Mar 21 01:53:34 2009
New Revision: 67434

URL: http://llvm.org/viewvc/llvm-project?rev=67434&view=rev
Log:
avoid making constant folding logic eliminate obviously dead bitcasts, speeding up PR3810
by ~2%.

Modified:
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=67434&r1=67433&r2=67434&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sat Mar 21 01:53:34 2009
@@ -824,7 +824,9 @@
   if (!Entry)
     Entry = EmitForwardFunctionDefinition(D, 0);
 
-  return llvm::ConstantExpr::getBitCast(Entry, PTy);
+  if (Entry->getType() != PTy)
+    return llvm::ConstantExpr::getBitCast(Entry, PTy);
+  return Entry;
 }
 
 void CodeGenModule::EmitGlobalFunctionDefinition(const FunctionDecl *D) {
@@ -954,8 +956,11 @@
 
   llvm::GlobalValue *&ExistingFn =
     GlobalDeclMap[getContext().Idents.get(Name).getName()];
-  if (ExistingFn)
+  if (ExistingFn) {
+    if (ExistingFn->getType() == Ty)
+      return FunctionSlot = ExistingFn;
     return FunctionSlot = llvm::ConstantExpr::getBitCast(ExistingFn, Ty);
+  }
 
   // FIXME: param attributes for sext/zext etc.
   return FunctionSlot = ExistingFn =





More information about the cfe-commits mailing list