[llvm-commits] [llvm] r85020 - in /llvm/trunk: include/llvm/Transforms/Utils/ValueMapper.h lib/Transforms/Utils/CloneFunction.cpp lib/Transforms/Utils/CloneModule.cpp lib/Transforms/Utils/ValueMapper.cpp
Dan Gohman
gohman at apple.com
Sat Oct 24 16:37:17 PDT 2009
Author: djg
Date: Sat Oct 24 18:37:16 2009
New Revision: 85020
URL: http://llvm.org/viewvc/llvm-project?rev=85020&view=rev
Log:
MapValue doesn't needs its LLVMContext argument.
Modified:
llvm/trunk/include/llvm/Transforms/Utils/ValueMapper.h
llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp
llvm/trunk/lib/Transforms/Utils/CloneModule.cpp
llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp
Modified: llvm/trunk/include/llvm/Transforms/Utils/ValueMapper.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/ValueMapper.h?rev=85020&r1=85019&r2=85020&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/ValueMapper.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/ValueMapper.h Sat Oct 24 18:37:16 2009
@@ -20,10 +20,9 @@
namespace llvm {
class Value;
class Instruction;
- class LLVMContext;
typedef DenseMap<const Value *, Value *> ValueMapTy;
- Value *MapValue(const Value *V, ValueMapTy &VM, LLVMContext &Context);
+ Value *MapValue(const Value *V, ValueMapTy &VM);
void RemapInstruction(Instruction *I, ValueMapTy &VM);
} // End llvm namespace
Modified: llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp?rev=85020&r1=85019&r2=85020&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp Sat Oct 24 18:37:16 2009
@@ -20,7 +20,6 @@
#include "llvm/IntrinsicInst.h"
#include "llvm/GlobalVariable.h"
#include "llvm/Function.h"
-#include "llvm/LLVMContext.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Transforms/Utils/ValueMapper.h"
@@ -329,8 +328,7 @@
SmallVector<Constant*, 8> Ops;
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
if (Constant *Op = dyn_cast_or_null<Constant>(MapValue(I->getOperand(i),
- ValueMap,
- Context)))
+ ValueMap)))
Ops.push_back(Op);
else
return 0; // All operands not constant!
@@ -366,7 +364,6 @@
ClonedCodeInfo *CodeInfo,
const TargetData *TD) {
assert(NameSuffix && "NameSuffix cannot be null!");
- LLVMContext &Context = OldFunc->getContext();
#ifndef NDEBUG
for (Function::const_arg_iterator II = OldFunc->arg_begin(),
@@ -437,7 +434,7 @@
if (BasicBlock *MappedBlock =
cast_or_null<BasicBlock>(ValueMap[PN->getIncomingBlock(pred)])) {
Value *InVal = MapValue(PN->getIncomingValue(pred),
- ValueMap, Context);
+ ValueMap);
assert(InVal && "Unknown input value?");
PN->setIncomingValue(pred, InVal);
PN->setIncomingBlock(pred, MappedBlock);
Modified: llvm/trunk/lib/Transforms/Utils/CloneModule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneModule.cpp?rev=85020&r1=85019&r2=85020&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CloneModule.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CloneModule.cpp Sat Oct 24 18:37:16 2009
@@ -89,8 +89,7 @@
GlobalVariable *GV = cast<GlobalVariable>(ValueMap[I]);
if (I->hasInitializer())
GV->setInitializer(cast<Constant>(MapValue(I->getInitializer(),
- ValueMap,
- M->getContext())));
+ ValueMap)));
GV->setLinkage(I->getLinkage());
GV->setThreadLocal(I->isThreadLocal());
GV->setConstant(I->isConstant());
@@ -121,7 +120,7 @@
GlobalAlias *GA = cast<GlobalAlias>(ValueMap[I]);
GA->setLinkage(I->getLinkage());
if (const Constant* C = I->getAliasee())
- GA->setAliasee(cast<Constant>(MapValue(C, ValueMap, M->getContext())));
+ GA->setAliasee(cast<Constant>(MapValue(C, ValueMap)));
}
return New;
Modified: llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp?rev=85020&r1=85019&r2=85020&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp Sat Oct 24 18:37:16 2009
@@ -18,13 +18,12 @@
#include "llvm/Constants.h"
#include "llvm/GlobalValue.h"
#include "llvm/Instruction.h"
-#include "llvm/LLVMContext.h"
#include "llvm/Metadata.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/ErrorHandling.h"
using namespace llvm;
-Value *llvm::MapValue(const Value *V, ValueMapTy &VM, LLVMContext &Context) {
+Value *llvm::MapValue(const Value *V, ValueMapTy &VM) {
Value *&VMSlot = VM[V];
if (VMSlot) return VMSlot; // Does it exist in the map yet?
@@ -44,7 +43,7 @@
else if (ConstantArray *CA = dyn_cast<ConstantArray>(C)) {
for (User::op_iterator b = CA->op_begin(), i = b, e = CA->op_end();
i != e; ++i) {
- Value *MV = MapValue(*i, VM, Context);
+ Value *MV = MapValue(*i, VM);
if (MV != *i) {
// This array must contain a reference to a global, make a new array
// and return it.
@@ -55,7 +54,7 @@
Values.push_back(cast<Constant>(*j));
Values.push_back(cast<Constant>(MV));
for (++i; i != e; ++i)
- Values.push_back(cast<Constant>(MapValue(*i, VM, Context)));
+ Values.push_back(cast<Constant>(MapValue(*i, VM)));
return VM[V] = ConstantArray::get(CA->getType(), Values);
}
}
@@ -64,7 +63,7 @@
} else if (ConstantStruct *CS = dyn_cast<ConstantStruct>(C)) {
for (User::op_iterator b = CS->op_begin(), i = b, e = CS->op_end();
i != e; ++i) {
- Value *MV = MapValue(*i, VM, Context);
+ Value *MV = MapValue(*i, VM);
if (MV != *i) {
// This struct must contain a reference to a global, make a new struct
// and return it.
@@ -75,7 +74,7 @@
Values.push_back(cast<Constant>(*j));
Values.push_back(cast<Constant>(MV));
for (++i; i != e; ++i)
- Values.push_back(cast<Constant>(MapValue(*i, VM, Context)));
+ Values.push_back(cast<Constant>(MapValue(*i, VM)));
return VM[V] = ConstantStruct::get(CS->getType(), Values);
}
}
@@ -84,12 +83,12 @@
} else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
std::vector<Constant*> Ops;
for (User::op_iterator i = CE->op_begin(), e = CE->op_end(); i != e; ++i)
- Ops.push_back(cast<Constant>(MapValue(*i, VM, Context)));
+ Ops.push_back(cast<Constant>(MapValue(*i, VM)));
return VM[V] = CE->getWithOperands(Ops);
} else if (ConstantVector *CP = dyn_cast<ConstantVector>(C)) {
for (User::op_iterator b = CP->op_begin(), i = b, e = CP->op_end();
i != e; ++i) {
- Value *MV = MapValue(*i, VM, Context);
+ Value *MV = MapValue(*i, VM);
if (MV != *i) {
// This vector value must contain a reference to a global, make a new
// vector constant and return it.
@@ -100,7 +99,7 @@
Values.push_back(cast<Constant>(*j));
Values.push_back(cast<Constant>(MV));
for (++i; i != e; ++i)
- Values.push_back(cast<Constant>(MapValue(*i, VM, Context)));
+ Values.push_back(cast<Constant>(MapValue(*i, VM)));
return VM[V] = ConstantVector::get(Values);
}
}
@@ -118,7 +117,7 @@
///
void llvm::RemapInstruction(Instruction *I, ValueMapTy &ValueMap) {
for (User::op_iterator op = I->op_begin(), E = I->op_end(); op != E; ++op) {
- Value *V = MapValue(*op, ValueMap, I->getParent()->getContext());
+ Value *V = MapValue(*op, ValueMap);
assert(V && "Referenced value not in value map!");
*op = V;
}
More information about the llvm-commits
mailing list