summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-12-02 05:56:05 +0000
committerChris Lattner <sabre@nondot.org>2007-12-02 05:56:05 +0000
commitc5b3aab66bc3a08acc4c00aeeebc5799ad9e8e4f (patch)
treeed7dc94bbcefb7eb6ca6d2bc9552d94e4918ce6b /clang
parente15d0dd63fabea7047dbbc16fcbc0b7d7c72dc56 (diff)
downloadbcm5719-llvm-c5b3aab66bc3a08acc4c00aeeebc5799ad9e8e4f.tar.gz
bcm5719-llvm-c5b3aab66bc3a08acc4c00aeeebc5799ad9e8e4f.zip
merge functions with multiple function decls if they have the same name.
llvm-svn: 44505
Diffstat (limited to 'clang')
-rw-r--r--clang/CodeGen/CodeGenModule.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/CodeGen/CodeGenModule.cpp b/clang/CodeGen/CodeGenModule.cpp
index 54009b0e423..b76d5e35eef 100644
--- a/clang/CodeGen/CodeGenModule.cpp
+++ b/clang/CodeGen/CodeGenModule.cpp
@@ -40,6 +40,13 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalDecl(const ValueDecl *D) {
const llvm::Type *Ty = getTypes().ConvertType(ASTTy);
if (isa<FunctionDecl>(D)) {
const llvm::FunctionType *FTy = cast<llvm::FunctionType>(Ty);
+
+ // Check to see if the function already exists.
+ if (llvm::Function *F = getModule().getFunction(D->getName())) {
+ // If so, make sure it is the correct type.
+ return llvm::ConstantExpr::getBitCast(F, llvm::PointerType::get(FTy));
+ }
+
// FIXME: param attributes for sext/zext etc.
return Entry = new llvm::Function(FTy, llvm::Function::ExternalLinkage,
D->getName(), &getModule());
OpenPOWER on IntegriCloud