Skip to content

Commit ba4f980

Browse files
committed
[AMDGPU] Fix warnings in AMDGPUConditionalDiscard
Use iterators instead of instructions as the insertion point for new instructions. This fixes warnings like: lib/Target/AMDGPU/AMDGPUConditionalDiscard.cpp:169:52: warning: 'InsertPosition' is deprecated: Use BasicBlock::iterators for insertion instead [-Wdeprecated-declarations] Change-Id: I1e4681a43fe7be55ec9e9575d1d2ac9b356e50f4
1 parent f467673 commit ba4f980

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

llvm/lib/Target/AMDGPU/AMDGPUConditionalDiscard.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,15 @@ void AMDGPUConditionalDiscard::optimizeBlock(BasicBlock &BB, bool ConvertToDemot
159159

160160
bool FirstPred = true;
161161
for (auto PredBlock : make_early_inc_range(predecessors(&BB))) {
162-
auto *PredTerminator = PredBlock->getTerminator();
163-
auto *PredBranchInst = cast<BranchInst>(PredTerminator);
162+
auto *PredBranchInst = cast<BranchInst>(PredBlock->getTerminator());
164163

165164
BasicBlock *LiveBlock = nullptr;
166165
auto *Cond = PredBranchInst->getCondition();
167166
if (PredBranchInst->getSuccessor(0) == &BB) {
168167
// The old kill block could only be reached if
169168
// the condition was true - negate the condition.
170-
Cond = BinaryOperator::CreateNot(Cond, "", PredTerminator);
169+
Cond =
170+
BinaryOperator::CreateNot(Cond, "", PredBranchInst->getIterator());
171171
LiveBlock = PredBranchInst->getSuccessor(1);
172172
} else {
173173
LiveBlock = PredBranchInst->getSuccessor(0);
@@ -176,7 +176,7 @@ void AMDGPUConditionalDiscard::optimizeBlock(BasicBlock &BB, bool ConvertToDemot
176176
auto *NewKill = cast<CallInst>(KillCand->clone());
177177

178178
NewKill->setArgOperand(0, Cond);
179-
NewKill->insertBefore(PredTerminator);
179+
NewKill->insertBefore(PredBranchInst);
180180

181181
if (ConvertToDemote) {
182182
NewKill->setCalledFunction(Intrinsic::getDeclaration(
@@ -187,7 +187,8 @@ void AMDGPUConditionalDiscard::optimizeBlock(BasicBlock &BB, bool ConvertToDemot
187187
KillBlocksToRemove.push_back(&BB);
188188

189189
// Change the branch to an unconditional one, targeting the live block.
190-
auto *NewBranchInst = BranchInst::Create(LiveBlock, PredBranchInst);
190+
auto *NewBranchInst =
191+
BranchInst::Create(LiveBlock, PredBranchInst->getIterator());
191192
NewBranchInst->copyMetadata(*PredBranchInst);
192193
PredBranchInst->eraseFromParent();
193194
} else {
@@ -214,8 +215,8 @@ void AMDGPUConditionalDiscard::optimizeBlock(BasicBlock &BB, bool ConvertToDemot
214215
// It's possible that the branch became unconditional.
215216
if (PredBranchInst->getSuccessor(0) ==
216217
PredBranchInst->getSuccessor(1)) {
217-
auto *NewBranchInst =
218-
BranchInst::Create(OldKillBlockSucc, PredBranchInst);
218+
auto *NewBranchInst = BranchInst::Create(
219+
OldKillBlockSucc, PredBranchInst->getIterator());
219220
NewBranchInst->copyMetadata(*PredBranchInst);
220221
PredBranchInst->eraseFromParent();
221222
}

0 commit comments

Comments
 (0)