summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp28
-rw-r--r--llvm/lib/Transforms/Scalar/JumpThreading.cpp2
-rw-r--r--llvm/lib/Transforms/Scalar/LICM.cpp5
-rw-r--r--llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp2
-rw-r--r--llvm/lib/Transforms/Scalar/Reg2Mem.cpp4
-rw-r--r--llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp11
-rw-r--r--llvm/lib/Transforms/Scalar/TailDuplication.cpp2
7 files changed, 33 insertions, 21 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index f42827cbbd6..4160ee7dc1e 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -1756,8 +1756,10 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts,
Value *LHS = II->getOperand(1);
Value *RHS = II->getOperand(2);
// Extract the element as scalars.
- LHS = InsertNewInstBefore(new ExtractElementInst(LHS, 0U,"tmp"), *II);
- RHS = InsertNewInstBefore(new ExtractElementInst(RHS, 0U,"tmp"), *II);
+ LHS = InsertNewInstBefore(new ExtractElementInst(LHS,
+ Context->getConstantInt(Type::Int32Ty, 0U, false), "tmp"), *II);
+ RHS = InsertNewInstBefore(new ExtractElementInst(RHS,
+ Context->getConstantInt(Type::Int32Ty, 0U, false), "tmp"), *II);
switch (II->getIntrinsicID()) {
default: llvm_unreachable("Case stmts out of sync!");
@@ -1775,7 +1777,8 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts,
Instruction *New =
InsertElementInst::Create(
- Context->getUndef(II->getType()), TmpV, 0U, II->getName());
+ Context->getUndef(II->getType()), TmpV,
+ Context->getConstantInt(Type::Int32Ty, 0U, false), II->getName());
InsertNewInstBefore(New, *II);
AddSoonDeadInstToWorklist(*II, 0);
return New;
@@ -7888,9 +7891,9 @@ Instruction *InstCombiner::PromoteCastOfAllocation(BitCastInst &CI,
AllocationInst *New;
if (isa<MallocInst>(AI))
- New = new MallocInst(CastElTy, Amt, AI.getAlignment());
+ New = new MallocInst(*Context, CastElTy, Amt, AI.getAlignment());
else
- New = new AllocaInst(CastElTy, Amt, AI.getAlignment());
+ New = new AllocaInst(*Context, CastElTy, Amt, AI.getAlignment());
InsertNewInstBefore(New, AI);
New->takeName(&AI);
@@ -9974,14 +9977,16 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
if (ExtractedElts[Idx] == 0) {
Instruction *Elt =
- new ExtractElementInst(Idx < 16 ? Op0 : Op1, Idx&15, "tmp");
+ new ExtractElementInst(Idx < 16 ? Op0 : Op1,
+ Context->getConstantInt(Type::Int32Ty, Idx&15, false), "tmp");
InsertNewInstBefore(Elt, CI);
ExtractedElts[Idx] = Elt;
}
// Insert this value into the result vector.
Result = InsertElementInst::Create(Result, ExtractedElts[Idx],
- i, "tmp");
+ Context->getConstantInt(Type::Int32Ty, i, false),
+ "tmp");
InsertNewInstBefore(cast<Instruction>(Result), CI);
}
return CastInst::Create(Instruction::BitCast, Result, CI.getType());
@@ -11363,10 +11368,12 @@ Instruction *InstCombiner::visitAllocationInst(AllocationInst &AI) {
// Create and insert the replacement instruction...
if (isa<MallocInst>(AI))
- New = new MallocInst(NewTy, 0, AI.getAlignment(), AI.getName());
+ New = new MallocInst(*Context, NewTy, 0,
+ AI.getAlignment(), AI.getName());
else {
assert(isa<AllocaInst>(AI) && "Unknown type of allocation inst!");
- New = new AllocaInst(NewTy, 0, AI.getAlignment(), AI.getName());
+ New = new AllocaInst(*Context, NewTy, 0,
+ AI.getAlignment(), AI.getName());
}
InsertNewInstBefore(New, AI);
@@ -12475,7 +12482,8 @@ Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) {
} else {
return ReplaceInstUsesWith(EI, Context->getUndef(EI.getType()));
}
- return new ExtractElementInst(Src, SrcIdx);
+ return new ExtractElementInst(Src,
+ Context->getConstantInt(Type::Int32Ty, SrcIdx, false));
}
}
}
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index f3536c10c57..86e03c47f6a 100644
--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -912,7 +912,7 @@ bool JumpThreading::ThreadEdge(BasicBlock *BB, BasicBlock *PredBB,
// We found a use of I outside of BB. Create a new stack slot to
// break this inter-block usage pattern.
- DemoteRegToStack(*I);
+ DemoteRegToStack(*Context, *I);
}
// We are going to have to map operands from the original BB block to the new
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index 52dd06affe5..aa49b24aba9 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -508,7 +508,7 @@ void LICM::sink(Instruction &I) {
AllocaInst *AI = 0;
if (I.getType() != Type::VoidTy) {
- AI = new AllocaInst(I.getType(), 0, I.getName(),
+ AI = new AllocaInst(*Context, I.getType(), 0, I.getName(),
I.getParent()->getParent()->getEntryBlock().begin());
CurAST->add(AI);
}
@@ -853,7 +853,8 @@ void LICM::FindPromotableValuesInLoop(
continue;
const Type *Ty = cast<PointerType>(V->getType())->getElementType();
- AllocaInst *AI = new AllocaInst(Ty, 0, V->getName()+".tmp", FnStart);
+ AllocaInst *AI = new AllocaInst(*Context, Ty, 0,
+ V->getName()+".tmp", FnStart);
PromotedValues.push_back(std::make_pair(AI, V));
// Update the AST and alias analysis.
diff --git a/llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp b/llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
index 4116c66dbaf..50d606311a1 100644
--- a/llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
+++ b/llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
@@ -1891,7 +1891,7 @@ namespace {
assert(!Ty->isFPOrFPVector() && "Float in work queue!");
Constant *Zero = Context->getNullValue(Ty);
- Constant *One = ConstantInt::get(Ty, 1);
+ Constant *One = Context->getConstantInt(Ty, 1);
ConstantInt *AllOnes = cast<ConstantInt>(Context->getAllOnesValue(Ty));
switch (Opcode) {
diff --git a/llvm/lib/Transforms/Scalar/Reg2Mem.cpp b/llvm/lib/Transforms/Scalar/Reg2Mem.cpp
index ac95d25b7f7..289f08c9475 100644
--- a/llvm/lib/Transforms/Scalar/Reg2Mem.cpp
+++ b/llvm/lib/Transforms/Scalar/Reg2Mem.cpp
@@ -89,7 +89,7 @@ namespace {
NumRegsDemoted += worklist.size();
for (std::list<Instruction*>::iterator ilb = worklist.begin(),
ile = worklist.end(); ilb != ile; ++ilb)
- DemoteRegToStack(**ilb, false, AllocaInsertionPoint);
+ DemoteRegToStack(*Context, **ilb, false, AllocaInsertionPoint);
worklist.clear();
@@ -105,7 +105,7 @@ namespace {
NumPhisDemoted += worklist.size();
for (std::list<Instruction*>::iterator ilb = worklist.begin(),
ile = worklist.end(); ilb != ile; ++ilb)
- DemotePHIToStack(cast<PHINode>(*ilb), AllocaInsertionPoint);
+ DemotePHIToStack(*Context, cast<PHINode>(*ilb), AllocaInsertionPoint);
return true;
}
diff --git a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
index 83db90da763..d999f9d8a94 100644
--- a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
+++ b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
@@ -302,14 +302,16 @@ bool SROA::performScalarRepl(Function &F) {
DOUT << "CONVERT TO VECTOR: " << *AI << " TYPE = " << *VectorTy <<"\n";
// Create and insert the vector alloca.
- NewAI = new AllocaInst(VectorTy, 0, "", AI->getParent()->begin());
+ NewAI = new AllocaInst(*Context, VectorTy, 0, "",
+ AI->getParent()->begin());
ConvertUsesToScalar(AI, NewAI, 0);
} else {
DOUT << "CONVERT TO SCALAR INTEGER: " << *AI << "\n";
// Create and insert the integer alloca.
const Type *NewTy = Context->getIntegerType(AllocaSize*8);
- NewAI = new AllocaInst(NewTy, 0, "", AI->getParent()->begin());
+ NewAI = new AllocaInst(*Context, NewTy, 0, "",
+ AI->getParent()->begin());
ConvertUsesToScalar(AI, NewAI, 0);
}
NewAI->takeName(AI);
@@ -334,7 +336,8 @@ void SROA::DoScalarReplacement(AllocationInst *AI,
if (const StructType *ST = dyn_cast<StructType>(AI->getAllocatedType())) {
ElementAllocas.reserve(ST->getNumContainedTypes());
for (unsigned i = 0, e = ST->getNumContainedTypes(); i != e; ++i) {
- AllocaInst *NA = new AllocaInst(ST->getContainedType(i), 0,
+ AllocaInst *NA = new AllocaInst(*Context,
+ ST->getContainedType(i), 0,
AI->getAlignment(),
AI->getName() + "." + utostr(i), AI);
ElementAllocas.push_back(NA);
@@ -345,7 +348,7 @@ void SROA::DoScalarReplacement(AllocationInst *AI,
ElementAllocas.reserve(AT->getNumElements());
const Type *ElTy = AT->getElementType();
for (unsigned i = 0, e = AT->getNumElements(); i != e; ++i) {
- AllocaInst *NA = new AllocaInst(ElTy, 0, AI->getAlignment(),
+ AllocaInst *NA = new AllocaInst(*Context, ElTy, 0, AI->getAlignment(),
AI->getName() + "." + utostr(i), AI);
ElementAllocas.push_back(NA);
WorkList.push_back(NA); // Add to worklist for recursive processing
diff --git a/llvm/lib/Transforms/Scalar/TailDuplication.cpp b/llvm/lib/Transforms/Scalar/TailDuplication.cpp
index 684b0963456..5f7221051c2 100644
--- a/llvm/lib/Transforms/Scalar/TailDuplication.cpp
+++ b/llvm/lib/Transforms/Scalar/TailDuplication.cpp
@@ -285,7 +285,7 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) {
if (I->isUsedOutsideOfBlock(DestBlock)) {
// We found a use outside of the tail. Create a new stack slot to
// break this inter-block usage pattern.
- DemoteRegToStack(*I);
+ DemoteRegToStack(*Context, *I);
}
// We are going to have to map operands from the original block B to the new
OpenPOWER on IntegriCloud