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
This commit is contained in:
Owen Anderson
2009-07-06 18:42:36 +00:00
parent e034393b15
commit 508955156a
21 changed files with 256 additions and 195 deletions

View File

@ -3420,6 +3420,7 @@ static Constant *EvaluateExpression(Value *V, Constant *PHIVal) {
if (Constant *C = dyn_cast<Constant>(V)) return C;
if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) return GV;
Instruction *I = cast<Instruction>(V);
LLVMContext* Context = I->getParent()->getContext();
std::vector<Constant*> Operands;
Operands.resize(I->getNumOperands());
@ -3431,10 +3432,12 @@ static Constant *EvaluateExpression(Value *V, Constant *PHIVal) {
if (const CmpInst *CI = dyn_cast<CmpInst>(I))
return ConstantFoldCompareInstOperands(CI->getPredicate(),
&Operands[0], Operands.size());
&Operands[0], Operands.size(),
Context);
else
return ConstantFoldInstOperands(I->getOpcode(), I->getType(),
&Operands[0], Operands.size());
&Operands[0], Operands.size(),
Context);
}
/// getConstantEvolutionLoopExitValue - If we know that the specified Phi is
@ -3636,10 +3639,11 @@ const SCEV* ScalarEvolution::getSCEVAtScope(const SCEV *V, const Loop *L) {
Constant *C;
if (const CmpInst *CI = dyn_cast<CmpInst>(I))
C = ConstantFoldCompareInstOperands(CI->getPredicate(),
&Operands[0], Operands.size());
&Operands[0], Operands.size(),
Context);
else
C = ConstantFoldInstOperands(I->getOpcode(), I->getType(),
&Operands[0], Operands.size());
&Operands[0], Operands.size(), Context);
Pair.first->second = C;
return getSCEV(C);
}