aboutsummaryrefslogtreecommitdiff
path: root/CodeGen/CodeGenModule.cpp
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
commit028380e5a61725c996a62554495d5c91d6eba415 (patch)
treecb7924451ebfd133250e369d1dfc94d63abb244e /CodeGen/CodeGenModule.cpp
parent434415af9de3cd9d72d43a78ffe714250fab83dc (diff)
merge functions with multiple function decls if they have the same name.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44505 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CodeGen/CodeGenModule.cpp')
-rw-r--r--CodeGen/CodeGenModule.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/CodeGen/CodeGenModule.cpp b/CodeGen/CodeGenModule.cpp
index 54009b0e42..b76d5e35ee 100644
--- a/CodeGen/CodeGenModule.cpp
+++ b/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());