diff options
author | Jeremy Morse <jeremy.morse@sony.com> | 2023-12-13 14:04:35 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-13 14:04:35 +0000 |
commit | 4b64138ba485fd0fca69613e429e585ee4b67575 (patch) | |
tree | 35d5d8efcfe7660266ef6a85118c30268a0f551c /llvm/lib/CodeGen/CodeGenPrepare.cpp | |
parent | 7f55d7de1a7511dcfaa37c9f1665bfd8aea5f764 (diff) | |
download | llvm-4b64138ba485fd0fca69613e429e585ee4b67575.zip llvm-4b64138ba485fd0fca69613e429e585ee4b67575.tar.gz llvm-4b64138ba485fd0fca69613e429e585ee4b67575.tar.bz2 |
[DebugInfo][RemoveDIs] Switch some insertion routines to use iterators (#75330)
As part of RemoveDIs, we need instruction insertion to be done with
iterators rather than instruction pointers, so that we can communicate
some debug-info facts about the position. This patch is an entirely
mechanical replacement of Instruction * with BasicBlock::iterator, plus
using insertBefore to insert some instructions because we don't have
iterator-taking constructors yet.
Sadly it's not NFC because it causes dbg.value intrinsics / their
DPValue equivalents to shift location.
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 24 |
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); } |