Changes in directory llvm/lib/Linker:
LinkArchives.cpp updated: 1.50 -> 1.51 LinkModules.cpp updated: 1.116 -> 1.117 --- Log message: Adding dllimport, dllexport and external weak linkage types. DLL* linkages got full (I hope) codegeneration support in C & both x86 assembler backends. External weak linkage added for future use, we don't provide any codegeneration, etc. support for it. --- Diffs of the changes: (+39 -13) LinkArchives.cpp | 10 ++++++++-- LinkModules.cpp | 42 +++++++++++++++++++++++++++++++----------- 2 files changed, 39 insertions(+), 13 deletions(-) Index: llvm/lib/Linker/LinkArchives.cpp diff -u llvm/lib/Linker/LinkArchives.cpp:1.50 llvm/lib/Linker/LinkArchives.cpp:1.51 --- llvm/lib/Linker/LinkArchives.cpp:1.50 Fri Jul 7 15:56:50 2006 +++ llvm/lib/Linker/LinkArchives.cpp Thu Sep 14 13:23:26 2006 @@ -65,16 +65,22 @@ if (I->hasName()) { if (I->isExternal()) UndefinedSymbols.insert(I->getName()); - else if (!I->hasInternalLinkage()) + else if (!I->hasInternalLinkage()) { + assert(!I->hasDLLImportLinkage() + && "Found dllimported non-external symbol!"); DefinedSymbols.insert(I->getName()); + } } for (Module::global_iterator I = M->global_begin(), E = M->global_end(); I != E; ++I) if (I->hasName()) { if (I->isExternal()) UndefinedSymbols.insert(I->getName()); - else if (!I->hasInternalLinkage()) + else if (!I->hasInternalLinkage()) { + assert(!I->hasDLLImportLinkage() + && "Found dllimported non-external symbol!"); DefinedSymbols.insert(I->getName()); + } } // Prune out any defined symbols from the undefined symbols set... Index: llvm/lib/Linker/LinkModules.cpp diff -u llvm/lib/Linker/LinkModules.cpp:1.116 llvm/lib/Linker/LinkModules.cpp:1.117 --- llvm/lib/Linker/LinkModules.cpp:1.116 Fri Jul 14 17:21:31 2006 +++ llvm/lib/Linker/LinkModules.cpp Thu Sep 14 13:23:26 2006 @@ -359,9 +359,16 @@ } else if (Src->isExternal()) { // If Src is external or if both Src & Drc are external.. Just link the // external globals, we aren't adding anything. - LinkFromSrc = false; - LT = Dest->getLinkage(); - } else if (Dest->isExternal()) { + if (Src->hasDLLImportLinkage()) { + if (Dest->isExternal()) { + LinkFromSrc = true; + LT = Src->getLinkage(); + } + } else { + LinkFromSrc = false; + LT = Dest->getLinkage(); + } + } else if (Dest->isExternal() && !Dest->hasDLLImportLinkage()) { // If Dest is external but Src is not: LinkFromSrc = true; LT = Src->getLinkage(); @@ -372,7 +379,7 @@ LinkFromSrc = true; // Special cased. LT = Src->getLinkage(); } else if (Src->hasWeakLinkage() || Src->hasLinkOnceLinkage()) { - // At this point we know that Dest has LinkOnce, External or Weak linkage. + // At this point we know that Dest has LinkOnce, External, Weak, DLL* linkage. if (Dest->hasLinkOnceLinkage() && Src->hasWeakLinkage()) { LinkFromSrc = true; LT = Src->getLinkage(); @@ -381,11 +388,16 @@ LT = Dest->getLinkage(); } } else if (Dest->hasWeakLinkage() || Dest->hasLinkOnceLinkage()) { - // At this point we know that Src has External linkage. + // At this point we know that Src has External or DLL* linkage. LinkFromSrc = true; LT = GlobalValue::ExternalLinkage; } else { - assert(Dest->hasExternalLinkage() && Src->hasExternalLinkage() && + assert((Dest->hasExternalLinkage() || + Dest->hasDLLImportLinkage() || + Dest->hasDLLExportLinkage()) && + (Src->hasExternalLinkage() || + Src->hasDLLImportLinkage() || + Src->hasDLLExportLinkage()) && "Unexpected linkage type!"); return Error(Err, "Linking globals named '" + Src->getName() + "': symbol multiply defined!"); @@ -425,7 +437,8 @@ if (DGV && DGV->hasInternalLinkage()) DGV = 0; - assert(SGV->hasInitializer() || SGV->hasExternalLinkage() && + assert(SGV->hasInitializer() || + SGV->hasExternalLinkage() || SGV->hasDLLImportLinkage() && "Global must either be external or have an initializer!"); GlobalValue::LinkageTypes NewLinkage; @@ -565,7 +578,7 @@ // static bool LinkFunctionProtos(Module *Dest, const Module *Src, std::map<const Value*, Value*> &ValueMap, - std::map<std::string, GlobalValue*> &GlobalsByName, + std::map<std::string, GlobalValue*> &GlobalsByName, std::string *Err) { SymbolTable *ST = (SymbolTable*)&Dest->getSymbolTable(); @@ -604,12 +617,19 @@ } else if (SF->isExternal()) { // If SF is external or if both SF & DF are external.. Just link the // external functions, we aren't adding anything. - ValueMap.insert(std::make_pair(SF, DF)); - } else if (DF->isExternal()) { // If DF is external but SF is not... + if (SF->hasDLLImportLinkage()) { + if (DF->isExternal()) { + ValueMap.insert(std::make_pair(SF, DF)); + DF->setLinkage(SF->getLinkage()); + } + } else { + ValueMap.insert(std::make_pair(SF, DF)); + } + } else if (DF->isExternal() && !DF->hasDLLImportLinkage()) { + // If DF is external but SF is not... // Link the external functions, update linkage qualifiers 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)); _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits