Fix PR245: Linking weak and strong global variables is dependent on link order
authorChris Lattner <sabre@nondot.org>
Tue, 17 Feb 2004 21:56:04 +0000 (21:56 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 17 Feb 2004 21:56:04 +0000 (21:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11565 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Linker/LinkModules.cpp
lib/Transforms/Utils/Linker.cpp
lib/VMCore/Linker.cpp

index aa7720ece35c60748d5aad76885afa11c8f75178..529fb7714893841f231833524c1d6a8e51972b22 100644 (file)
@@ -566,7 +566,6 @@ static bool LinkGlobalInits(Module *Dest, const Module *Src,
 
       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 '" + 
@@ -575,6 +574,9 @@ static bool LinkGlobalInits(Module *Dest, const Module *Src,
         } 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()) {
           assert(0 && "Appending linkage unimplemented!");
         } else {
index aa7720ece35c60748d5aad76885afa11c8f75178..529fb7714893841f231833524c1d6a8e51972b22 100644 (file)
@@ -566,7 +566,6 @@ static bool LinkGlobalInits(Module *Dest, const Module *Src,
 
       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 '" + 
@@ -575,6 +574,9 @@ static bool LinkGlobalInits(Module *Dest, const Module *Src,
         } 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()) {
           assert(0 && "Appending linkage unimplemented!");
         } else {
index aa7720ece35c60748d5aad76885afa11c8f75178..529fb7714893841f231833524c1d6a8e51972b22 100644 (file)
@@ -566,7 +566,6 @@ static bool LinkGlobalInits(Module *Dest, const Module *Src,
 
       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 '" + 
@@ -575,6 +574,9 @@ static bool LinkGlobalInits(Module *Dest, const Module *Src,
         } 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()) {
           assert(0 && "Appending linkage unimplemented!");
         } else {