//===- Linker.cpp - Module Linker Implementation --------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
//
// This file implements the LLVM module linker.
//
//===----------------------------------------------------------------------===//
#include "llvm/Transforms/Utils/Linker.h"
+#include "llvm/Constants.h"
+#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
#include "llvm/SymbolTable.h"
-#include "llvm/DerivedTypes.h"
#include "llvm/iOther.h"
-#include "llvm/Constants.h"
+#include "llvm/Assembly/Writer.h"
+using namespace llvm;
// Error - Simple wrapper function to conditionally assign to E and return true.
// This just makes error return conditions a little bit simpler...
return true;
}
+//
+// Function: ResolveTypes()
+//
+// Description:
+// Attempt to link the two specified types together.
+//
+// Inputs:
+// DestTy - The type to which we wish to resolve.
+// SrcTy - The original type which we want to resolve.
+// Name - The name of the type.
+//
+// Outputs:
+// DestST - The symbol table in which the new type should be placed.
+//
+// Return value:
+// true - There is an error and the types cannot yet be linked.
+// false - No errors.
+//
+static bool ResolveTypes(const Type *DestTy, const Type *SrcTy,
+ SymbolTable *DestST, const std::string &Name) {
+ if (DestTy == SrcTy) return false; // If already equal, noop
+
+ // Does the type already exist in the module?
+ if (DestTy && !isa<OpaqueType>(DestTy)) { // Yup, the type already exists...
+ if (const OpaqueType *OT = dyn_cast<OpaqueType>(SrcTy)) {
+ const_cast<OpaqueType*>(OT)->refineAbstractTypeTo(DestTy);
+ } else {
+ return true; // Cannot link types... neither is opaque and not-equal
+ }
+ } else { // Type not in dest module. Add it now.
+ if (DestTy) // Type _is_ in module, just opaque...
+ const_cast<OpaqueType*>(cast<OpaqueType>(DestTy))
+ ->refineAbstractTypeTo(SrcTy);
+ else if (!Name.empty())
+ DestST->insert(Name, const_cast<Type*>(SrcTy));
+ }
+ return false;
+}
+
+static const FunctionType *getFT(const PATypeHolder &TH) {
+ return cast<FunctionType>(TH.get());
+}
+static const StructType *getST(const PATypeHolder &TH) {
+ return cast<StructType>(TH.get());
+}
+
+// RecursiveResolveTypes - This is just like ResolveTypes, except that it
+// recurses down into derived types, merging the used types if the parent types
+// are compatible.
+//
+static bool RecursiveResolveTypesI(const PATypeHolder &DestTy,
+ const PATypeHolder &SrcTy,
+ SymbolTable *DestST, const std::string &Name,
+ std::vector<std::pair<PATypeHolder, PATypeHolder> > &Pointers) {
+ const Type *SrcTyT = SrcTy.get();
+ const Type *DestTyT = DestTy.get();
+ if (DestTyT == SrcTyT) return false; // If already equal, noop
+
+ // If we found our opaque type, resolve it now!
+ if (isa<OpaqueType>(DestTyT) || isa<OpaqueType>(SrcTyT))
+ return ResolveTypes(DestTyT, SrcTyT, DestST, Name);
+
+ // Two types cannot be resolved together if they are of different primitive
+ // type. For example, we cannot resolve an int to a float.
+ if (DestTyT->getPrimitiveID() != SrcTyT->getPrimitiveID()) return true;
+
+ // Otherwise, resolve the used type used by this derived type...
+ switch (DestTyT->getPrimitiveID()) {
+ case Type::FunctionTyID: {
+ if (cast<FunctionType>(DestTyT)->isVarArg() !=
+ cast<FunctionType>(SrcTyT)->isVarArg() ||
+ cast<FunctionType>(DestTyT)->getNumContainedTypes() !=
+ cast<FunctionType>(SrcTyT)->getNumContainedTypes())
+ return true;
+ for (unsigned i = 0, e = getFT(DestTy)->getNumContainedTypes(); i != e; ++i)
+ if (RecursiveResolveTypesI(getFT(DestTy)->getContainedType(i),
+ getFT(SrcTy)->getContainedType(i), DestST, "",
+ Pointers))
+ return true;
+ return false;
+ }
+ case Type::StructTyID: {
+ if (getST(DestTy)->getNumContainedTypes() !=
+ getST(SrcTy)->getNumContainedTypes()) return 1;
+ for (unsigned i = 0, e = getST(DestTy)->getNumContainedTypes(); i != e; ++i)
+ if (RecursiveResolveTypesI(getST(DestTy)->getContainedType(i),
+ getST(SrcTy)->getContainedType(i), DestST, "",
+ Pointers))
+ return true;
+ return false;
+ }
+ case Type::ArrayTyID: {
+ const ArrayType *DAT = cast<ArrayType>(DestTy.get());
+ const ArrayType *SAT = cast<ArrayType>(SrcTy.get());
+ if (DAT->getNumElements() != SAT->getNumElements()) return true;
+ return RecursiveResolveTypesI(DAT->getElementType(), SAT->getElementType(),
+ DestST, "", Pointers);
+ }
+ case Type::PointerTyID: {
+ // If this is a pointer type, check to see if we have already seen it. If
+ // so, we are in a recursive branch. Cut off the search now. We cannot use
+ // an associative container for this search, because the type pointers (keys
+ // in the container) change whenever types get resolved...
+ //
+ for (unsigned i = 0, e = Pointers.size(); i != e; ++i)
+ if (Pointers[i].first == DestTy)
+ return Pointers[i].second != SrcTy;
+
+ // Otherwise, add the current pointers to the vector to stop recursion on
+ // this pair.
+ Pointers.push_back(std::make_pair(DestTyT, SrcTyT));
+ bool Result =
+ RecursiveResolveTypesI(cast<PointerType>(DestTy.get())->getElementType(),
+ cast<PointerType>(SrcTy.get())->getElementType(),
+ DestST, "", Pointers);
+ Pointers.pop_back();
+ return Result;
+ }
+ default: assert(0 && "Unexpected type!"); return true;
+ }
+}
+
+static bool RecursiveResolveTypes(const PATypeHolder &DestTy,
+ const PATypeHolder &SrcTy,
+ SymbolTable *DestST, const std::string &Name){
+ std::vector<std::pair<PATypeHolder, PATypeHolder> > PointerTypes;
+ return RecursiveResolveTypesI(DestTy, SrcTy, DestST, Name, PointerTypes);
+}
+
+
// LinkTypes - Go through the symbol table of the Src module and see if any
// types are named in the src module that are not named in the Dst module.
// Make sure there are no type name conflicts.
const SymbolTable *SrcST = &Src->getSymbolTable();
// Look for a type plane for Type's...
- SymbolTable::const_iterator PI = SrcST->find(Type::TypeTy);
- if (PI == SrcST->end()) return false; // No named types, do nothing.
+ SymbolTable::type_const_iterator TI = SrcST->type_begin();
+ SymbolTable::type_const_iterator TE = SrcST->type_end();
+ if (TI == TE) return false; // No named types, do nothing.
- const SymbolTable::VarMap &VM = PI->second;
- for (SymbolTable::type_const_iterator I = VM.begin(), E = VM.end();
- I != E; ++I) {
- const std::string &Name = I->first;
- const Type *RHS = cast<Type>(I->second);
+ // Some types cannot be resolved immediately because they depend on other
+ // types being resolved to each other first. This contains a list of types we
+ // are waiting to recheck.
+ std::vector<std::string> DelayedTypesToResolve;
+
+ for ( ; TI != TE; ++TI ) {
+ const std::string &Name = TI->first;
+ Type *RHS = TI->second;
// Check to see if this type name is already in the dest module...
- const Type *Entry = cast_or_null<Type>(DestST->lookup(Type::TypeTy, Name));
- if (Entry && !isa<OpaqueType>(Entry)) { // Yup, the value already exists...
- if (Entry != RHS) {
- if (OpaqueType *OT = dyn_cast<OpaqueType>(const_cast<Type*>(RHS))) {
- OT->refineAbstractTypeTo(Entry);
- } else {
- // If it's the same, noop. Otherwise, error.
- return Error(Err, "Type named '" + Name +
- "' of different shape in modules.\n Src='" +
- Entry->getDescription() + "'.\n Dst='" +
- RHS->getDescription() + "'");
- }
+ Type *Entry = DestST->lookupType(Name);
+
+ if (ResolveTypes(Entry, RHS, DestST, Name)) {
+ // They look different, save the types 'till later to resolve.
+ DelayedTypesToResolve.push_back(Name);
+ }
+ }
+
+ // Iteratively resolve types while we can...
+ while (!DelayedTypesToResolve.empty()) {
+ // Loop over all of the types, attempting to resolve them if possible...
+ unsigned OldSize = DelayedTypesToResolve.size();
+
+ // Try direct resolution by name...
+ for (unsigned i = 0; i != DelayedTypesToResolve.size(); ++i) {
+ const std::string &Name = DelayedTypesToResolve[i];
+ Type *T1 = SrcST->lookupType(Name);
+ Type *T2 = DestST->lookupType(Name);
+ if (!ResolveTypes(T2, T1, DestST, Name)) {
+ // We are making progress!
+ DelayedTypesToResolve.erase(DelayedTypesToResolve.begin()+i);
+ --i;
}
- } else { // Type not in dest module. Add it now.
- if (Entry) {
- OpaqueType *OT = cast<OpaqueType>(const_cast<Type*>(Entry));
- OT->refineAbstractTypeTo(RHS);
+ }
+
+ // Did we not eliminate any types?
+ if (DelayedTypesToResolve.size() == OldSize) {
+ // Attempt to resolve subelements of types. This allows us to merge these
+ // two types: { int* } and { opaque* }
+ for (unsigned i = 0, e = DelayedTypesToResolve.size(); i != e; ++i) {
+ const std::string &Name = DelayedTypesToResolve[i];
+ PATypeHolder T1(SrcST->lookupType(Name));
+ PATypeHolder T2(DestST->lookupType(Name));
+
+ if (!RecursiveResolveTypes(T2, T1, DestST, Name)) {
+ // We are making progress!
+ DelayedTypesToResolve.erase(DelayedTypesToResolve.begin()+i);
+
+ // Go back to the main loop, perhaps we can resolve directly by name
+ // now...
+ break;
+ }
}
- // TODO: FIXME WHEN TYPES AREN'T CONST
- DestST->insert(Name, const_cast<Type*>(RHS));
+ // If we STILL cannot resolve the types, then there is something wrong.
+ // Report the warning and delete one of the names.
+ if (DelayedTypesToResolve.size() == OldSize) {
+ const std::string &Name = DelayedTypesToResolve.back();
+
+ const Type *T1 = SrcST->lookupType(Name);
+ const Type *T2 = DestST->lookupType(Name);
+ std::cerr << "WARNING: Type conflict between types named '" << Name
+ << "'.\n Src='";
+ WriteTypeSymbolic(std::cerr, T1, Src);
+ std::cerr << "'.\n Dest='";
+ WriteTypeSymbolic(std::cerr, T2, Dest);
+ std::cerr << "'\n";
+
+ // Remove the symbol name from the destination.
+ DelayedTypesToResolve.pop_back();
+ }
}
}
+
+
return false;
}
// Check to see if it's a constant that we are interesting in transforming...
if (const Constant *CPV = dyn_cast<Constant>(In)) {
- if (!isa<DerivedType>(CPV->getType()) && !isa<ConstantExpr>(CPV))
+ if ((!isa<DerivedType>(CPV->getType()) && !isa<ConstantExpr>(CPV)) ||
+ isa<ConstantAggregateZero>(CPV))
return const_cast<Constant*>(CPV); // Simple constants stay identical...
Constant *Result = 0;
assert(CE->getOpcode() == Instruction::Cast);
Value *V = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap);
Result = ConstantExpr::getCast(cast<Constant>(V), CE->getType());
+ } else if (CE->getNumOperands() == 3) {
+ // Select instruction
+ assert(CE->getOpcode() == Instruction::Select);
+ Value *V1 = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap);
+ Value *V2 = RemapOperand(CE->getOperand(1), LocalMap, GlobalMap);
+ Value *V3 = RemapOperand(CE->getOperand(2), LocalMap, GlobalMap);
+ Result = ConstantExpr::getSelect(cast<Constant>(V1), cast<Constant>(V2),
+ cast<Constant>(V3));
} else if (CE->getNumOperands() == 2) {
// Binary operator...
Value *V1 = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap);
Value *V2 = RemapOperand(CE->getOperand(1), LocalMap, GlobalMap);
Result = ConstantExpr::get(CE->getOpcode(), cast<Constant>(V1),
- cast<Constant>(V2));
+ cast<Constant>(V2));
} else {
assert(0 && "Unknown constant expr type!");
}
return 0;
}
+/// FindGlobalNamed - Look in the specified symbol table for a global with the
+/// specified name and type. If an exactly matching global does not exist, see
+/// if there is a global which is "type compatible" with the specified
+/// name/type. This allows us to resolve things like '%x = global int*' with
+/// '%x = global opaque*'.
+///
+static GlobalValue *FindGlobalNamed(const std::string &Name, const Type *Ty,
+ SymbolTable *ST) {
+ // See if an exact match exists in the symbol table...
+ if (Value *V = ST->lookup(Ty, Name)) return cast<GlobalValue>(V);
+
+ // It doesn't exist exactly, scan through all of the type planes in the symbol
+ // table, checking each of them for a type-compatible version.
+ //
+ for (SymbolTable::plane_iterator PI = ST->plane_begin(), PE = ST->plane_end();
+ PI != PE; ++PI) {
+ SymbolTable::ValueMap &VM = PI->second;
+
+ // Does this type plane contain an entry with the specified name?
+ SymbolTable::value_iterator VI = VM.find(Name);
+ if (VI != VM.end()) {
+ //
+ // Ensure that this type if placed correctly into the symbol table.
+ //
+ assert(VI->second->getType() == PI->first && "Type conflict!");
+
+ //
+ // Save a reference to the new type. Resolving the type can modify the
+ // symbol table, invalidating the TI variable.
+ //
+ Value *ValPtr = VI->second;
+
+ //
+ // Determine whether we can fold the two types together, resolving them.
+ // If so, we can use this value.
+ //
+ if (!RecursiveResolveTypes(Ty, PI->first, ST, ""))
+ return cast<GlobalValue>(ValPtr);
+ }
+ }
+ return 0; // Otherwise, nothing could be found.
+}
+
// LinkGlobals - Loop through the global variables in the src module and merge
// them into the dest module.
// that may be in a module level symbol table are Global Vars and
// Functions, and they both have distinct, nonoverlapping, possible types.
//
- DGV = cast_or_null<GlobalVariable>(ST->lookup(SGV->getType(),
- SGV->getName()));
+ DGV = cast_or_null<GlobalVariable>(FindGlobalNamed(SGV->getName(),
+ SGV->getType(), ST));
}
assert(SGV->hasInitializer() || SGV->hasExternalLinkage() &&
} else if (DGV->isExternal()) { // If DGV is external but SGV is not...
ValueMap.insert(std::make_pair(SGV, DGV));
DGV->setLinkage(SGV->getLinkage()); // Inherit linkage!
+ } else if (SGV->hasWeakLinkage() || SGV->hasLinkOnceLinkage()) {
+ // At this point we know that DGV has LinkOnce, Appending, Weak, or
+ // External linkage. If DGV is Appending, this is an error.
+ if (DGV->hasAppendingLinkage())
+ return Error(Err, "Linking globals named '" + SGV->getName() +
+ " ' with 'weak' and 'appending' linkage is not allowed!");
+
+ if (SGV->isConstant() != DGV->isConstant())
+ return Error(Err, "Global Variable Collision on '" +
+ SGV->getType()->getDescription() + " %" + SGV->getName() +
+ "' - Global variables differ in const'ness");
+
+ // Otherwise, just perform the link.
+ ValueMap.insert(std::make_pair(SGV, DGV));
+
+ // Linkonce+Weak = Weak
+ if (DGV->hasLinkOnceLinkage() && SGV->hasWeakLinkage())
+ DGV->setLinkage(SGV->getLinkage());
+
+ } else if (DGV->hasWeakLinkage() || DGV->hasLinkOnceLinkage()) {
+ // At this point we know that SGV has LinkOnce, Appending, or External
+ // linkage. If SGV is Appending, this is an error.
+ if (SGV->hasAppendingLinkage())
+ return Error(Err, "Linking globals named '" + SGV->getName() +
+ " ' with 'weak' and 'appending' linkage is not allowed!");
+
+ if (SGV->isConstant() != DGV->isConstant())
+ return Error(Err, "Global Variable Collision on '" +
+ SGV->getType()->getDescription() + " %" + SGV->getName() +
+ "' - Global variables differ in const'ness");
+
+ if (!SGV->hasLinkOnceLinkage())
+ DGV->setLinkage(SGV->getLinkage()); // Inherit linkage!
+ ValueMap.insert(std::make_pair(SGV, DGV));
+
} else if (SGV->getLinkage() != DGV->getLinkage()) {
return Error(Err, "Global variables named '" + SGV->getName() +
"' have different linkage specifiers!");
} else if (SGV->hasExternalLinkage()) {
// Allow linking two exactly identical external global variables...
- if (SGV->isConstant() != DGV->isConstant() ||
- SGV->getInitializer() != DGV->getInitializer())
+ if (SGV->isConstant() != DGV->isConstant())
return Error(Err, "Global Variable Collision on '" +
SGV->getType()->getDescription() + " %" + SGV->getName() +
"' - Global variables differ in const'ness");
- ValueMap.insert(std::make_pair(SGV, DGV));
- } else if (SGV->hasLinkOnceLinkage()) {
- // If the global variable has a name, and that name is already in use in
- // the Dest module, make sure that the name is a compatible global
- // variable...
- //
- // Check to see if the two GV's have the same Const'ness...
- if (SGV->isConstant() != DGV->isConstant())
+
+ if (SGV->getInitializer() != DGV->getInitializer())
return Error(Err, "Global Variable Collision on '" +
SGV->getType()->getDescription() + " %" + SGV->getName() +
- "' - Global variables differ in const'ness");
+ "' - External linkage globals have different initializers");
- // Okay, everything is cool, remember the mapping...
ValueMap.insert(std::make_pair(SGV, DGV));
} else if (SGV->hasAppendingLinkage()) {
// No linking is performed yet. Just insert a new copy of the global, and
GlobalVariable *DGV = cast<GlobalVariable>(ValueMap[SGV]);
if (DGV->hasInitializer()) {
- assert(SGV->getLinkage() == DGV->getLinkage());
if (SGV->hasExternalLinkage()) {
if (DGV->getInitializer() != SInit)
return Error(Err, "Global Variable Collision on '" +
SGV->getType()->getDescription() +"':%"+SGV->getName()+
" - Global variables have different initializers");
- } else if (DGV->hasLinkOnceLinkage()) {
+ } else if (DGV->hasLinkOnceLinkage() || DGV->hasWeakLinkage()) {
+ // Nothing is required, mapped values will take the new global
+ // automatically.
+ } else if (SGV->hasLinkOnceLinkage() || SGV->hasWeakLinkage()) {
// Nothing is required, mapped values will take the new global
// automatically.
} else if (DGV->hasAppendingLinkage()) {
// that may be in a module level symbol table are Global Vars and
// Functions, and they both have distinct, nonoverlapping, possible types.
//
- DF = cast_or_null<Function>(ST->lookup(SF->getType(), SF->getName()));
+ DF = cast_or_null<Function>(FindGlobalNamed(SF->getName(), SF->getType(),
+ ST));
if (!DF || SF->hasInternalLinkage() || DF->hasInternalLinkage()) {
// Function does not already exist, simply insert an function signature
ValueMap.insert(std::make_pair(SF, DF));
DF->setLinkage(SF->getLinkage());
+ } else if (SF->hasWeakLinkage() || SF->hasLinkOnceLinkage()) {
+ // At this point we know that DF has LinkOnce, Weak, or External linkage.
+ ValueMap.insert(std::make_pair(SF, DF));
+
+ // Linkonce+Weak = Weak
+ if (DF->hasLinkOnceLinkage() && SF->hasWeakLinkage())
+ DF->setLinkage(SF->getLinkage());
+
+ } else if (DF->hasWeakLinkage() || DF->hasLinkOnceLinkage()) {
+ // At this point we know that SF has LinkOnce or External linkage.
+ ValueMap.insert(std::make_pair(SF, DF));
+ if (!SF->hasLinkOnceLinkage()) // Don't inherit linkonce linkage
+ DF->setLinkage(SF->getLinkage());
+
} else if (SF->getLinkage() != DF->getLinkage()) {
return Error(Err, "Functions named '" + SF->getName() +
"' have different linkage specifiers!");
return Error(Err, "Function '" +
SF->getFunctionType()->getDescription() + "':\"" +
SF->getName() + "\" - Function is already defined!");
- } else if (SF->hasLinkOnceLinkage()) {
- // Completely ignore the source function.
- ValueMap.insert(std::make_pair(SF, DF));
} else {
assert(0 && "Unknown linkage configuration found!");
}
Function *DF = cast<Function>(ValueMap[SF]); // Destination function
// DF not external SF external?
- if (!DF->isExternal()) {
- if (DF->hasLinkOnceLinkage()) continue; // No relinkage for link-once!
- if (Err)
- *Err = "Function '" + (SF->hasName() ? SF->getName() :std::string(""))
- + "' body multiply defined!";
- return true;
+ if (DF->isExternal()) {
+ // Only provide the function body if there isn't one already.
+ if (LinkFunctionBody(DF, SF, ValueMap, Err))
+ return true;
}
-
- if (LinkFunctionBody(DF, SF, ValueMap, Err)) return true;
}
}
return false;
// Merge the initializer...
Inits.reserve(NewSize);
- ConstantArray *I = cast<ConstantArray>(G1->getInitializer());
- for (unsigned i = 0, e = T1->getNumElements(); i != e; ++i)
- Inits.push_back(cast<Constant>(I->getValues()[i]));
- I = cast<ConstantArray>(G2->getInitializer());
- for (unsigned i = 0, e = T2->getNumElements(); i != e; ++i)
- Inits.push_back(cast<Constant>(I->getValues()[i]));
+ if (ConstantArray *I = dyn_cast<ConstantArray>(G1->getInitializer())) {
+ for (unsigned i = 0, e = T1->getNumElements(); i != e; ++i)
+ Inits.push_back(cast<Constant>(I->getValues()[i]));
+ } else {
+ assert(isa<ConstantAggregateZero>(G1->getInitializer()));
+ Constant *CV = Constant::getNullValue(T1->getElementType());
+ for (unsigned i = 0, e = T1->getNumElements(); i != e; ++i)
+ Inits.push_back(CV);
+ }
+ if (ConstantArray *I = dyn_cast<ConstantArray>(G2->getInitializer())) {
+ for (unsigned i = 0, e = T2->getNumElements(); i != e; ++i)
+ Inits.push_back(cast<Constant>(I->getValues()[i]));
+ } else {
+ assert(isa<ConstantAggregateZero>(G2->getInitializer()));
+ Constant *CV = Constant::getNullValue(T2->getElementType());
+ for (unsigned i = 0, e = T2->getNumElements(); i != e; ++i)
+ Inits.push_back(CV);
+ }
NG->setInitializer(ConstantArray::get(NewType, Inits));
Inits.clear();
// the problem. Upon failure, the Dest module could be in a modified state, and
// shouldn't be relied on to be consistent.
//
-bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) {
- if (Dest->getEndianness() != Src->getEndianness())
+bool llvm::LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) {
+ if (Dest->getEndianness() == Module::AnyEndianness)
+ Dest->setEndianness(Src->getEndianness());
+ if (Dest->getPointerSize() == Module::AnyPointerSize)
+ Dest->setPointerSize(Src->getPointerSize());
+
+ if (Src->getEndianness() != Module::AnyEndianness &&
+ Dest->getEndianness() != Src->getEndianness())
std::cerr << "WARNING: Linking two modules of different endianness!\n";
- if (Dest->getPointerSize() != Src->getPointerSize())
+ if (Src->getPointerSize() != Module::AnyPointerSize &&
+ Dest->getPointerSize() != Src->getPointerSize())
std::cerr << "WARNING: Linking two modules of different pointer size!\n";
// LinkTypes - Go through the symbol table of the Src module and see if any
// Add all of the appending globals already in the Dest module to
// AppendingVars.
for (Module::giterator I = Dest->gbegin(), E = Dest->gend(); I != E; ++I)
- AppendingVars.insert(std::make_pair(I->getName(), I));
+ if (I->hasAppendingLinkage())
+ AppendingVars.insert(std::make_pair(I->getName(), I));
// Insert all of the globals in src into the Dest module... without linking
// initializers (which could refer to functions not yet mapped over).
return false;
}
+// vim: sw=2