summaryrefslogtreecommitdiff
path: root/lib/Linker/LinkModules.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-11-01 02:46:39 +0000
committerChris Lattner <sabre@nondot.org>2009-11-01 02:46:39 +0000
commit2a749d36475bda8964e996725ea101aec3ee15cf (patch)
tree7e3a7c3f6b3dc4fe8deb652af6f7884862c849b8 /lib/Linker/LinkModules.cpp
parentcdfc940912d56a63b6f12eaa7f3faf79cf74c693 (diff)
downloadllvm-2a749d36475bda8964e996725ea101aec3ee15cf.tar.gz
llvm-2a749d36475bda8964e996725ea101aec3ee15cf.tar.bz2
llvm-2a749d36475bda8964e996725ea101aec3ee15cf.tar.xz
implement linker support for BlockAddress.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85700 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Linker/LinkModules.cpp')
-rw-r--r--lib/Linker/LinkModules.cpp30
1 files changed, 13 insertions, 17 deletions
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index e64c200cf6..8ece835bfe 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -349,8 +349,7 @@ static void PrintMap(const std::map<const Value*, Value*> &M) {
// RemapOperand - Use ValueMap to convert constants from one module to another.
static Value *RemapOperand(const Value *In,
- std::map<const Value*, Value*> &ValueMap,
- LLVMContext &Context) {
+ std::map<const Value*, Value*> &ValueMap) {
std::map<const Value*,Value*>::const_iterator I = ValueMap.find(In);
if (I != ValueMap.end())
return I->second;
@@ -365,31 +364,29 @@ static Value *RemapOperand(const Value *In,
if (const ConstantArray *CPA = dyn_cast<ConstantArray>(CPV)) {
std::vector<Constant*> Operands(CPA->getNumOperands());
for (unsigned i = 0, e = CPA->getNumOperands(); i != e; ++i)
- Operands[i] =cast<Constant>(RemapOperand(CPA->getOperand(i), ValueMap,
- Context));
- Result =
- ConstantArray::get(cast<ArrayType>(CPA->getType()), Operands);
+ Operands[i] =cast<Constant>(RemapOperand(CPA->getOperand(i), ValueMap));
+ Result = ConstantArray::get(cast<ArrayType>(CPA->getType()), Operands);
} else if (const ConstantStruct *CPS = dyn_cast<ConstantStruct>(CPV)) {
std::vector<Constant*> Operands(CPS->getNumOperands());
for (unsigned i = 0, e = CPS->getNumOperands(); i != e; ++i)
- Operands[i] =cast<Constant>(RemapOperand(CPS->getOperand(i), ValueMap,
- Context));
- Result =
- ConstantStruct::get(cast<StructType>(CPS->getType()), Operands);
+ Operands[i] =cast<Constant>(RemapOperand(CPS->getOperand(i), ValueMap));
+ Result = ConstantStruct::get(cast<StructType>(CPS->getType()), Operands);
} else if (isa<ConstantPointerNull>(CPV) || isa<UndefValue>(CPV)) {
Result = const_cast<Constant*>(CPV);
} else if (const ConstantVector *CP = dyn_cast<ConstantVector>(CPV)) {
std::vector<Constant*> Operands(CP->getNumOperands());
for (unsigned i = 0, e = CP->getNumOperands(); i != e; ++i)
- Operands[i] = cast<Constant>(RemapOperand(CP->getOperand(i), ValueMap,
- Context));
+ Operands[i] = cast<Constant>(RemapOperand(CP->getOperand(i), ValueMap));
Result = ConstantVector::get(Operands);
} else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CPV)) {
std::vector<Constant*> Ops;
for (unsigned i = 0, e = CE->getNumOperands(); i != e; ++i)
- Ops.push_back(cast<Constant>(RemapOperand(CE->getOperand(i),ValueMap,
- Context)));
+ Ops.push_back(cast<Constant>(RemapOperand(CE->getOperand(i),ValueMap)));
Result = CE->getWithOperands(Ops);
+ } else if (const BlockAddress *CE = dyn_cast<BlockAddress>(CPV)) {
+ Result = BlockAddress::get(
+ cast<Function>(RemapOperand(CE->getFunction(), ValueMap)),
+ CE->getBasicBlock());
} else {
assert(!isa<GlobalValue>(CPV) && "Unmapped global?");
llvm_unreachable("Unknown type of derived type constant value!");
@@ -896,8 +893,7 @@ static bool LinkGlobalInits(Module *Dest, const Module *Src,
if (SGV->hasInitializer()) { // Only process initialized GV's
// Figure out what the initializer looks like in the dest module...
Constant *SInit =
- cast<Constant>(RemapOperand(SGV->getInitializer(), ValueMap,
- Dest->getContext()));
+ cast<Constant>(RemapOperand(SGV->getInitializer(), ValueMap));
// Grab destination global variable or alias.
GlobalValue *DGV = cast<GlobalValue>(ValueMap[SGV]->stripPointerCasts());
@@ -1084,7 +1080,7 @@ static bool LinkFunctionBody(Function *Dest, Function *Src,
for (Instruction::op_iterator OI = I->op_begin(), OE = I->op_end();
OI != OE; ++OI)
if (!isa<Instruction>(*OI) && !isa<BasicBlock>(*OI))
- *OI = RemapOperand(*OI, ValueMap, Dest->getContext());
+ *OI = RemapOperand(*OI, ValueMap);
// There is no need to map the arguments anymore.
for (Function::arg_iterator I = Src->arg_begin(), E = Src->arg_end();