summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-21 06:53:34 +0000
committerChris Lattner <sabre@nondot.org>2009-03-21 06:53:34 +0000
commit9e8120e0674798dd74ac66229b981443f8c5f4fc (patch)
treea94ab05fe4ffc80dea9d6eee8f03325530b21b23 /clang/lib/CodeGen/CodeGenModule.cpp
parent316e1c19dfeeff0f55609471f5b64d32ea3b3ef6 (diff)
downloadbcm5719-llvm-9e8120e0674798dd74ac66229b981443f8c5f4fc.tar.gz
bcm5719-llvm-9e8120e0674798dd74ac66229b981443f8c5f4fc.zip
avoid making constant folding logic eliminate obviously dead bitcasts, speeding up PR3810
by ~2%. llvm-svn: 67434
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index b03513a0147..a0024aa9bb5 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/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 =
OpenPOWER on IntegriCloud