aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/CodeGenPrepare.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index aa5cdd2..f9e791c 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -1384,7 +1384,8 @@ static bool SinkCast(CastInst *CI) {
BasicBlock::iterator InsertPt = UserBB->getFirstInsertionPt();
assert(InsertPt != UserBB->end());
InsertedCast = CastInst::Create(CI->getOpcode(), CI->getOperand(0),
- CI->getType(), "", &*InsertPt);
+ CI->getType(), "");
+ InsertedCast->insertBefore(*UserBB, InsertPt);
InsertedCast->setDebugLoc(CI->getDebugLoc());
}
@@ -2058,12 +2059,13 @@ SinkShiftAndTruncate(BinaryOperator *ShiftI, Instruction *User, ConstantInt *CI,
assert(InsertPt != TruncUserBB->end());
// Sink the shift
if (ShiftI->getOpcode() == Instruction::AShr)
- InsertedShift = BinaryOperator::CreateAShr(ShiftI->getOperand(0), CI,
- "", &*InsertPt);
+ InsertedShift =
+ BinaryOperator::CreateAShr(ShiftI->getOperand(0), CI, "");
else
- InsertedShift = BinaryOperator::CreateLShr(ShiftI->getOperand(0), CI,
- "", &*InsertPt);
+ InsertedShift =
+ BinaryOperator::CreateLShr(ShiftI->getOperand(0), CI, "");
InsertedShift->setDebugLoc(ShiftI->getDebugLoc());
+ InsertedShift->insertBefore(*TruncUserBB, InsertPt);
// Sink the trunc
BasicBlock::iterator TruncInsertPt = TruncUserBB->getFirstInsertionPt();
@@ -2162,11 +2164,12 @@ static bool OptimizeExtractBits(BinaryOperator *ShiftI, ConstantInt *CI,
assert(InsertPt != UserBB->end());
if (ShiftI->getOpcode() == Instruction::AShr)
- InsertedShift = BinaryOperator::CreateAShr(ShiftI->getOperand(0), CI,
- "", &*InsertPt);
+ InsertedShift =
+ BinaryOperator::CreateAShr(ShiftI->getOperand(0), CI, "");
else
- InsertedShift = BinaryOperator::CreateLShr(ShiftI->getOperand(0), CI,
- "", &*InsertPt);
+ InsertedShift =
+ BinaryOperator::CreateLShr(ShiftI->getOperand(0), CI, "");
+ InsertedShift->insertBefore(*UserBB, InsertPt);
InsertedShift->setDebugLoc(ShiftI->getDebugLoc());
MadeChange = true;
@@ -6628,7 +6631,8 @@ bool CodeGenPrepare::optimizeExtUses(Instruction *I) {
if (!InsertedTrunc) {
BasicBlock::iterator InsertPt = UserBB->getFirstInsertionPt();
assert(InsertPt != UserBB->end());
- InsertedTrunc = new TruncInst(I, Src->getType(), "", &*InsertPt);
+ InsertedTrunc = new TruncInst(I, Src->getType(), "");
+ InsertedTrunc->insertBefore(*UserBB, InsertPt);
InsertedInsts.insert(InsertedTrunc);
}