[cfe-commits] r44505 - /cfe/trunk/CodeGen/CodeGenModule.cpp
Chris Lattner
sabre at nondot.org
Sat Dec 1 21:56:06 PST 2007
Author: lattner
Date: Sat Dec 1 23:56:05 2007
New Revision: 44505
URL: http://llvm.org/viewvc/llvm-project?rev=44505&view=rev
Log:
merge functions with multiple function decls if they have the same name.
Modified:
cfe/trunk/CodeGen/CodeGenModule.cpp
Modified: cfe/trunk/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenModule.cpp?rev=44505&r1=44504&r2=44505&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/CodeGen/CodeGenModule.cpp Sat Dec 1 23:56:05 2007
@@ -40,6 +40,13 @@
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());
More information about the cfe-commits
mailing list