summaryrefslogtreecommitdiff
path: root/lib/Linker
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2010-10-06 20:18:44 +0000
committerBill Wendling <isanbard@gmail.com>2010-10-06 20:18:44 +0000
commit933f9bdb00a8fe48833c4ea3ded20a6a90c405b0 (patch)
tree262a32e64ba36d283b5a8a28b242af5a27e10a1a /lib/Linker
parent5f0d700278b98f00a7f1cd792e10acbb76447be1 (diff)
downloadllvm-933f9bdb00a8fe48833c4ea3ded20a6a90c405b0.tar.gz
llvm-933f9bdb00a8fe48833c4ea3ded20a6a90c405b0.tar.bz2
llvm-933f9bdb00a8fe48833c4ea3ded20a6a90c405b0.tar.xz
Revert "RequiresUnique" patch. This should be handled at a lower level.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115827 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Linker')
-rw-r--r--lib/Linker/LinkModules.cpp44
1 files changed, 7 insertions, 37 deletions
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index de443910a9..7e8245a9e3 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -19,16 +19,18 @@
#include "llvm/Linker.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
-#include "llvm/Instructions.h"
#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/TypeSymbolTable.h"
#include "llvm/ValueSymbolTable.h"
+#include "llvm/Instructions.h"
+#include "llvm/Assembly/Writer.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Path.h"
#include "llvm/Transforms/Utils/ValueMapper.h"
+#include "llvm/ADT/DenseMap.h"
using namespace llvm;
// Error - Simple wrapper function to conditionally assign to E and return true.
@@ -454,24 +456,6 @@ static void LinkNamedMDNodes(Module *Dest, Module *Src,
}
}
-// RequiresUnique - Returns true if the global variable needs to be
-// unique. I.e., there shouldn't be a new global variable created in the
-// destination Module, rather the source variable's initializer needs to be
-// identical to the destination variable's initializer.
-static bool RequiresUnique(const GlobalVariable *SGV,
- const GlobalVariable *DGV) {
- const StringRef SrcSec(SGV->getSection());
- const StringRef DstSec(DGV->getSection());
-
- // The Objective-C __image_info section should be unique.
- if (SrcSec == DstSec &&
- (SrcSec.find("__objc_imageinfo") != StringRef::npos ||
- SrcSec.find("__image_info") != StringRef::npos))
- return true;
-
- return false;
-}
-
// LinkGlobals - Loop through the global variables in the src module and merge
// them into the dest module.
static bool LinkGlobals(Module *Dest, const Module *Src,
@@ -486,24 +470,10 @@ static bool LinkGlobals(Module *Dest, const Module *Src,
const GlobalVariable *SGV = I;
GlobalValue *DGV = 0;
- GlobalValue *SymTabGV =
- cast_or_null<GlobalValue>(DestSymTab.lookup(SGV->getName()));
-
- // Check to see if the symbol exists in the destination module and needs to
- // be merged instead of replaced.
- if (SymTabGV) {
- const GlobalVariable *GV = dyn_cast<GlobalVariable>(SymTabGV);
- if (GV && RequiresUnique(SGV, GV)) {
- // Make sure to remember this mapping.
- ValueMap[SGV] = SymTabGV;
- continue;
- }
- }
-
- // Check to see if we may have to link the global with a global, alias, or
+ // Check to see if may have to link the global with the global, alias or
// function.
if (SGV->hasName() && !SGV->hasLocalLinkage())
- DGV = SymTabGV;
+ DGV = cast_or_null<GlobalValue>(DestSymTab.lookup(SGV->getName()));
// If we found a global with the same name in the dest module, but it has
// internal linkage, we are really not doing any linkage here.
@@ -849,10 +819,10 @@ static bool LinkGlobalInits(Module *Dest, const Module *Src,
// Grab destination global variable or alias.
GlobalValue *DGV = cast<GlobalValue>(ValueMap[SGV]->stripPointerCasts());
- // If dest is a global variable, check that initializers match.
+ // If dest if global variable, check that initializers match.
if (GlobalVariable *DGVar = dyn_cast<GlobalVariable>(DGV)) {
if (DGVar->hasInitializer()) {
- if (SGV->hasExternalLinkage() || RequiresUnique(SGV, DGVar)) {
+ if (SGV->hasExternalLinkage()) {
if (DGVar->getInitializer() != SInit)
return Error(Err, "Global Variable Collision on '" +
SGV->getName() +