summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-07-06 18:42:36 +0000
committerOwen Anderson <resistor@mac.com>2009-07-06 18:42:36 +0000
commit508955156a25a9abc470a29e1760aa176d341cf9 (patch)
tree8b7b55caabc0fbb16b6025f38e84ebc4fbd79c31 /lib/Transforms/Scalar
parente034393b15bc9257314b0c7adfb778e0c504bed7 (diff)
downloadllvm-508955156a25a9abc470a29e1760aa176d341cf9.tar.gz
llvm-508955156a25a9abc470a29e1760aa176d341cf9.tar.bz2
llvm-508955156a25a9abc470a29e1760aa176d341cf9.tar.xz
Thread LLVMContext through the constant folding APIs, which touches a lot of files.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74844 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r--lib/Transforms/Scalar/ConstantProp.cpp2
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp10
-rw-r--r--lib/Transforms/Scalar/JumpThreading.cpp2
-rw-r--r--lib/Transforms/Scalar/LoopUnswitch.cpp2
-rw-r--r--lib/Transforms/Scalar/SCCP.cpp3
-rw-r--r--lib/Transforms/Scalar/TailDuplication.cpp2
6 files changed, 12 insertions, 9 deletions
diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp
index b933488cf6..d92ebdae66 100644
--- a/lib/Transforms/Scalar/ConstantProp.cpp
+++ b/lib/Transforms/Scalar/ConstantProp.cpp
@@ -67,7 +67,7 @@ bool ConstantPropagation::runOnFunction(Function &F) {
WorkList.erase(WorkList.begin()); // Get an element from the worklist...
if (!I->use_empty()) // Don't muck with dead instructions...
- if (Constant *C = ConstantFoldInstruction(I)) {
+ if (Constant *C = ConstantFoldInstruction(I, Context)) {
// Add all of the users of this instruction to the worklist, they might
// be constant propagatable now...
for (Value::use_iterator UI = I->use_begin(), UE = I->use_end();
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 59fbd396a3..46a7b4c30d 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -11598,7 +11598,8 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) {
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(CE->getOperand(0)))
if (GV->isConstant() && GV->hasDefinitiveInitializer())
if (Constant *V =
- ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE))
+ ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE,
+ Context))
return ReplaceInstUsesWith(LI, V);
if (CE->getOperand(0)->isNullValue()) {
// Insert a new store to null instruction before the load to indicate
@@ -12876,7 +12877,7 @@ static void AddReachableCodeToWorklist(BasicBlock *BB,
}
// ConstantProp instruction if trivially constant.
- if (Constant *C = ConstantFoldInstruction(Inst, TD)) {
+ if (Constant *C = ConstantFoldInstruction(Inst, BB->getContext(), TD)) {
DOUT << "IC: ConstFold to: " << *C << " from: " << *Inst;
Inst->replaceAllUsesWith(C);
++NumConstProp;
@@ -12991,7 +12992,7 @@ bool InstCombiner::DoOneIteration(Function &F, unsigned Iteration) {
}
// Instruction isn't dead, see if we can constant propagate it.
- if (Constant *C = ConstantFoldInstruction(I, TD)) {
+ if (Constant *C = ConstantFoldInstruction(I, F.getContext(), TD)) {
DOUT << "IC: ConstFold to: " << *C << " from: " << *I;
// Add operands to the worklist.
@@ -13011,7 +13012,8 @@ bool InstCombiner::DoOneIteration(Function &F, unsigned Iteration) {
// See if we can constant fold its operands.
for (User::op_iterator i = I->op_begin(), e = I->op_end(); i != e; ++i)
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(i))
- if (Constant *NewC = ConstantFoldConstantExpression(CE, TD))
+ if (Constant *NewC = ConstantFoldConstantExpression(CE,
+ F.getContext(), TD))
if (NewC != CE) {
i->set(NewC);
Changed = true;
diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp
index dee7bfba21..2252042320 100644
--- a/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/lib/Transforms/Scalar/JumpThreading.cpp
@@ -982,7 +982,7 @@ bool JumpThreading::ThreadEdge(BasicBlock *BB, BasicBlock *PredBB,
BI = NewBB->begin();
for (BasicBlock::iterator E = NewBB->end(); BI != E; ) {
Instruction *Inst = BI++;
- if (Constant *C = ConstantFoldInstruction(Inst, TD)) {
+ if (Constant *C = ConstantFoldInstruction(Inst, BB->getContext(), TD)) {
Inst->replaceAllUsesWith(C);
Inst->eraseFromParent();
continue;
diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp
index de5eedf1e8..b8e44799ba 100644
--- a/lib/Transforms/Scalar/LoopUnswitch.cpp
+++ b/lib/Transforms/Scalar/LoopUnswitch.cpp
@@ -986,7 +986,7 @@ void LoopUnswitch::SimplifyCode(std::vector<Instruction*> &Worklist, Loop *L) {
Worklist.pop_back();
// Simple constant folding.
- if (Constant *C = ConstantFoldInstruction(I)) {
+ if (Constant *C = ConstantFoldInstruction(I, Context)) {
ReplaceUsesOfWith(I, C, Worklist, L, LPM);
continue;
}
diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp
index f0bc127347..7363c71f7c 100644
--- a/lib/Transforms/Scalar/SCCP.cpp
+++ b/lib/Transforms/Scalar/SCCP.cpp
@@ -1158,7 +1158,8 @@ void SCCPSolver::visitLoadInst(LoadInst &I) {
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(CE->getOperand(0)))
if (GV->isConstant() && GV->hasDefinitiveInitializer())
if (Constant *V =
- ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE)) {
+ ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE,
+ Context)) {
markConstant(IV, &I, V);
return;
}
diff --git a/lib/Transforms/Scalar/TailDuplication.cpp b/lib/Transforms/Scalar/TailDuplication.cpp
index c037ee9603..06815d29b2 100644
--- a/lib/Transforms/Scalar/TailDuplication.cpp
+++ b/lib/Transforms/Scalar/TailDuplication.cpp
@@ -358,7 +358,7 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) {
Instruction *Inst = BI++;
if (isInstructionTriviallyDead(Inst))
Inst->eraseFromParent();
- else if (Constant *C = ConstantFoldInstruction(Inst)) {
+ else if (Constant *C = ConstantFoldInstruction(Inst, Context)) {
Inst->replaceAllUsesWith(C);
Inst->eraseFromParent();
}