diff options
author | Chris Lattner <sabre@nondot.org> | 2009-03-21 06:53:34 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-03-21 06:53:34 +0000 |
commit | 8f431a554367d2828b82612b456c3a2ce737e799 (patch) | |
tree | 031da8f7e5f63d310c4cf3a1571d54a163a8efd3 /lib/CodeGen/CodeGenModule.cpp | |
parent | 91058ff73fd3b00275348dd4d49f83501dfc0542 (diff) |
avoid making constant folding logic eliminate obviously dead bitcasts, speeding up PR3810
by ~2%.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67434 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index b03513a014..a0024aa9bb 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -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 = |