summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-07-09 23:48:35 +0000
committerOwen Anderson <resistor@mac.com>2009-07-09 23:48:35 +0000
commit333c40096561218bc3597cf153c0a3895274414c (patch)
treebc6f5f739c43dec91104275aec30e16f30a7610e /lib/Transforms/Utils
parent53674361efd42f9dd7c4d293132106839ab3b893 (diff)
downloadllvm-333c40096561218bc3597cf153c0a3895274414c.tar.gz
llvm-333c40096561218bc3597cf153c0a3895274414c.tar.bz2
llvm-333c40096561218bc3597cf153c0a3895274414c.tar.xz
This started as a small change, I swear. Unfortunately, lots of things call the [I|F]CmpInst constructors. Who knew!?
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75200 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r--lib/Transforms/Utils/BasicBlockUtils.cpp2
-rw-r--r--lib/Transforms/Utils/CloneFunction.cpp6
-rw-r--r--lib/Transforms/Utils/InlineFunction.cpp2
-rw-r--r--lib/Transforms/Utils/Local.cpp4
-rw-r--r--lib/Transforms/Utils/LowerInvoke.cpp9
-rw-r--r--lib/Transforms/Utils/LowerSwitch.cpp19
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp8
7 files changed, 26 insertions, 24 deletions
diff --git a/lib/Transforms/Utils/BasicBlockUtils.cpp b/lib/Transforms/Utils/BasicBlockUtils.cpp
index 32eecb37aa..f52546ccc4 100644
--- a/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -618,7 +618,7 @@ void llvm::CopyPrecedingStopPoint(Instruction *I,
if (I != I->getParent()->begin()) {
BasicBlock::iterator BBI = I; --BBI;
if (DbgStopPointInst *DSPI = dyn_cast<DbgStopPointInst>(BBI)) {
- CallInst *newDSPI = DSPI->clone();
+ CallInst *newDSPI = DSPI->clone(*I->getParent()->getContext());
newDSPI->insertBefore(InsertPos);
}
}
diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp
index a820c9d3f5..f05c5dc8a7 100644
--- a/lib/Transforms/Utils/CloneFunction.cpp
+++ b/lib/Transforms/Utils/CloneFunction.cpp
@@ -43,7 +43,7 @@ BasicBlock *llvm::CloneBasicBlock(const BasicBlock *BB,
// Loop over all instructions, and copy them over.
for (BasicBlock::const_iterator II = BB->begin(), IE = BB->end();
II != IE; ++II) {
- Instruction *NewInst = II->clone();
+ Instruction *NewInst = II->clone(*BB->getContext());
if (II->hasName())
NewInst->setName(II->getName()+NameSuffix);
NewBB->getInstList().push_back(NewInst);
@@ -249,7 +249,7 @@ void PruningFunctionCloner::CloneBlock(const BasicBlock *BB,
continue;
}
- Instruction *NewInst = II->clone();
+ Instruction *NewInst = II->clone(*BB->getContext());
if (II->hasName())
NewInst->setName(II->getName()+NameSuffix);
NewBB->getInstList().push_back(NewInst);
@@ -297,7 +297,7 @@ void PruningFunctionCloner::CloneBlock(const BasicBlock *BB,
}
if (!TerminatorDone) {
- Instruction *NewInst = OldTI->clone();
+ Instruction *NewInst = OldTI->clone(*BB->getContext());
if (OldTI->hasName())
NewInst->setName(OldTI->getName()+NameSuffix);
NewBB->getInstList().push_back(NewInst);
diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp
index 06008b6349..0e50cd11de 100644
--- a/lib/Transforms/Utils/InlineFunction.cpp
+++ b/lib/Transforms/Utils/InlineFunction.cpp
@@ -361,7 +361,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
BE = TheCall->getParent()->end(); BI != BE; ++BI) {
if (DbgStopPointInst *DSPI = dyn_cast<DbgStopPointInst>(BI)) {
if (DbgRegionEndInst *NewDREI =
- dyn_cast<DbgRegionEndInst>(DREI->clone()))
+ dyn_cast<DbgRegionEndInst>(DREI->clone(*Context)))
NewDREI->insertAfter(DSPI);
break;
}
diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp
index 583b26ad87..0bb9614557 100644
--- a/lib/Transforms/Utils/Local.cpp
+++ b/lib/Transforms/Utils/Local.cpp
@@ -184,8 +184,8 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB) {
} else if (SI->getNumSuccessors() == 2) {
// Otherwise, we can fold this switch into a conditional branch
// instruction if it has only one non-default destination.
- Value *Cond = new ICmpInst(ICmpInst::ICMP_EQ, SI->getCondition(),
- SI->getSuccessorValue(1), "cond", SI);
+ Value *Cond = new ICmpInst(SI, ICmpInst::ICMP_EQ, SI->getCondition(),
+ SI->getSuccessorValue(1), "cond");
// Insert the new branch...
BranchInst::Create(SI->getSuccessor(1), SI->getSuccessor(0), Cond, SI);
diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp
index 8ef060a1f4..b8e0fd88f0 100644
--- a/lib/Transforms/Utils/LowerInvoke.cpp
+++ b/lib/Transforms/Utils/LowerInvoke.cpp
@@ -523,9 +523,10 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
EntryBB->getTerminator());
// Compare the return value to zero.
- Value *IsNormal = new ICmpInst(ICmpInst::ICMP_EQ, SJRet,
+ Value *IsNormal = new ICmpInst(EntryBB->getTerminator(),
+ ICmpInst::ICMP_EQ, SJRet,
Constant::getNullValue(SJRet->getType()),
- "notunwind", EntryBB->getTerminator());
+ "notunwind");
// Nuke the uncond branch.
EntryBB->getTerminator()->eraseFromParent();
@@ -557,9 +558,9 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
}
// Load the JBList, if it's null, then there was no catch!
- Value *NotNull = new ICmpInst(ICmpInst::ICMP_NE, BufPtr,
+ Value *NotNull = new ICmpInst(*UnwindHandler, ICmpInst::ICMP_NE, BufPtr,
Constant::getNullValue(BufPtr->getType()),
- "notnull", UnwindHandler);
+ "notnull");
BranchInst::Create(UnwindBlock, TermBlock, NotNull, UnwindHandler);
// Create the block to do the longjmp.
diff --git a/lib/Transforms/Utils/LowerSwitch.cpp b/lib/Transforms/Utils/LowerSwitch.cpp
index ed6eca6c15..2a7124c9aa 100644
--- a/lib/Transforms/Utils/LowerSwitch.cpp
+++ b/lib/Transforms/Utils/LowerSwitch.cpp
@@ -162,7 +162,8 @@ BasicBlock* LowerSwitch::switchConvert(CaseItr Begin, CaseItr End,
Function::iterator FI = OrigBlock;
F->getBasicBlockList().insert(++FI, NewNode);
- ICmpInst* Comp = new ICmpInst(ICmpInst::ICMP_SLT, Val, Pivot.Low, "Pivot");
+ ICmpInst* Comp = new ICmpInst(*Default->getContext(), ICmpInst::ICMP_SLT,
+ Val, Pivot.Low, "Pivot");
NewNode->getInstList().push_back(Comp);
BranchInst::Create(LBranch, RBranch, Comp, NewNode);
return NewNode;
@@ -187,18 +188,18 @@ BasicBlock* LowerSwitch::newLeafBlock(CaseRange& Leaf, Value* Val,
ICmpInst* Comp = NULL;
if (Leaf.Low == Leaf.High) {
// Make the seteq instruction...
- Comp = new ICmpInst(ICmpInst::ICMP_EQ, Val, Leaf.Low,
- "SwitchLeaf", NewLeaf);
+ Comp = new ICmpInst(*NewLeaf, ICmpInst::ICMP_EQ, Val,
+ Leaf.Low, "SwitchLeaf");
} else {
// Make range comparison
if (cast<ConstantInt>(Leaf.Low)->isMinValue(true /*isSigned*/)) {
// Val >= Min && Val <= Hi --> Val <= Hi
- Comp = new ICmpInst(ICmpInst::ICMP_SLE, Val, Leaf.High,
- "SwitchLeaf", NewLeaf);
+ Comp = new ICmpInst(*NewLeaf, ICmpInst::ICMP_SLE, Val, Leaf.High,
+ "SwitchLeaf");
} else if (cast<ConstantInt>(Leaf.Low)->isZero()) {
// Val >= 0 && Val <= Hi --> Val <=u Hi
- Comp = new ICmpInst(ICmpInst::ICMP_ULE, Val, Leaf.High,
- "SwitchLeaf", NewLeaf);
+ Comp = new ICmpInst(*NewLeaf, ICmpInst::ICMP_ULE, Val, Leaf.High,
+ "SwitchLeaf");
} else {
// Emit V-Lo <=u Hi-Lo
Constant* NegLo = Context->getConstantExprNeg(Leaf.Low);
@@ -206,8 +207,8 @@ BasicBlock* LowerSwitch::newLeafBlock(CaseRange& Leaf, Value* Val,
Val->getName()+".off",
NewLeaf);
Constant *UpperBound = Context->getConstantExprAdd(NegLo, Leaf.High);
- Comp = new ICmpInst(ICmpInst::ICMP_ULE, Add, UpperBound,
- "SwitchLeaf", NewLeaf);
+ Comp = new ICmpInst(*NewLeaf, ICmpInst::ICMP_ULE, Add, UpperBound,
+ "SwitchLeaf");
}
}
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index 9dccfe86f7..a898d2df2b 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -938,7 +938,7 @@ HoistTerminator:
return true;
// Okay, it is safe to hoist the terminator.
- Instruction *NT = I1->clone();
+ Instruction *NT = I1->clone(*BB1->getContext());
BIParent->getInstList().insert(BI, NT);
if (NT->getType() != Type::VoidTy) {
I1->replaceAllUsesWith(NT);
@@ -1231,7 +1231,7 @@ static bool FoldCondBranchOnPHI(BranchInst *BI) {
TranslateMap[PN] = PN->getIncomingValueForBlock(PredBB);
} else {
// Clone the instruction.
- Instruction *N = BBI->clone();
+ Instruction *N = BBI->clone(*Context);
if (BBI->hasName()) N->setName(BBI->getName()+".c");
// Update operands due to translation.
@@ -1581,7 +1581,7 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI) {
// Clone Cond into the predecessor basic block, and or/and the
// two conditions together.
- Instruction *New = Cond->clone();
+ Instruction *New = Cond->clone(*BB->getContext());
PredBlock->getInstList().insert(PBI, New);
New->takeName(Cond);
Cond->setName(New->getName()+".old");
@@ -1841,7 +1841,7 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
<< "INTO UNCOND BRANCH PRED: " << *Pred;
Instruction *UncondBranch = Pred->getTerminator();
// Clone the return and add it to the end of the predecessor.
- Instruction *NewRet = RI->clone();
+ Instruction *NewRet = RI->clone(*BB->getContext());
Pred->getInstList().push_back(NewRet);
BasicBlock::iterator BBI = RI;