]> granicus.if.org Git - clang/commitdiff
avoid making constant folding logic eliminate obviously dead bitcasts, speeding up...
authorChris Lattner <sabre@nondot.org>
Sat, 21 Mar 2009 06:53:34 +0000 (06:53 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 21 Mar 2009 06:53:34 +0000 (06:53 +0000)
by ~2%.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67434 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenModule.cpp

index b03513a0147ec929e8da243cdfff2c31272115fe..a0024aa9bb5f4cdbb14672418d4d9dc0486203a3 100644 (file)
@@ -824,7 +824,9 @@ llvm::Constant *CodeGenModule::GetAddrOfFunction(const FunctionDecl *D) {
   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::Value *CodeGenModule::getBuiltinLibFunction(unsigned BuiltinID) {
 
   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 =