Skip to content

Commit b0c8ec6

Browse files
committed
[DebugInfo] Remove getPrevNonDebugInstruction
With the advent of intrinsic-less debug-info, we no longer need to scatter calls to getPrevNonDebugInstruction around the codebase. Remove most of them -- however there are one or two that have the "SkipPseudoOp" flag turned on, indicating that those call-sites are intended to skip more than just debug-info intrinsics. To avoid making a functional change, I've renamed the method to getPrevNonPseudoOpInstruction and left it in the positions that request that behaviour using the SkipPseudoOp flag.
1 parent de4b458 commit b0c8ec6

File tree

13 files changed

+19
-20
lines changed

13 files changed

+19
-20
lines changed

llvm/include/llvm/IR/Instruction.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -902,11 +902,10 @@ class Instruction : public User,
902902
/// block as 'this', or nullptr if no such instruction exists. Skip any pseudo
903903
/// operations if \c SkipPseudoOp is true.
904904
LLVM_ABI const Instruction *
905-
getPrevNonDebugInstruction(bool SkipPseudoOp = false) const;
906-
Instruction *getPrevNonDebugInstruction(bool SkipPseudoOp = false) {
905+
getPrevNonPseudoOpInstruction() const;
906+
Instruction *getPrevNonPseudoOpInstruction() {
907907
return const_cast<Instruction *>(
908-
static_cast<const Instruction *>(this)->getPrevNonDebugInstruction(
909-
SkipPseudoOp));
908+
static_cast<const Instruction *>(this)->getPrevNonPseudoOpInstruction());
910909
}
911910

912911
/// Create a copy of 'this' instruction that is identical in all ways except

llvm/include/llvm/Transforms/Utils/LockstepReverseIterator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class LockstepReverseIterator
6161
}
6262
Insts.clear();
6363
for (BasicBlock *BB : Blocks) {
64-
Instruction *Prev = BB->getTerminator()->getPrevNonDebugInstruction();
64+
Instruction *Prev = BB->getTerminator()->getPrevNode();
6565
if (!Prev) {
6666
// Block wasn't big enough - only contained a terminator.
6767
if constexpr (EarlyFailure) {
@@ -108,7 +108,7 @@ class LockstepReverseIterator
108108
return *this;
109109
SmallVector<Instruction *, 4> NewInsts;
110110
for (Instruction *Inst : Insts) {
111-
Instruction *Prev = Inst->getPrevNonDebugInstruction();
111+
Instruction *Prev = Inst->getPrevNode();
112112
if (!Prev) {
113113
if constexpr (!EarlyFailure) {
114114
this->ActiveBlocks.remove(Inst->getParent());

llvm/lib/CodeGen/CodeGenPrepare.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3015,7 +3015,7 @@ bool CodeGenPrepare::dupRetToEnableTailCallOpts(BasicBlock *BB,
30153015
// %phi = phi ptr [ %0, %bb0 ], [ %2, %entry ]
30163016
if (PredBB && PredBB->getSingleSuccessor() == BB)
30173017
CI = dyn_cast_or_null<CallInst>(
3018-
PredBB->getTerminator()->getPrevNonDebugInstruction(true));
3018+
PredBB->getTerminator()->getPrevNonPseudoOpInstruction());
30193019

30203020
if (CI && CI->use_empty() &&
30213021
isIntrinsicOrLFToBeTailCalled(TLInfo, CI) &&
@@ -3032,7 +3032,7 @@ bool CodeGenPrepare::dupRetToEnableTailCallOpts(BasicBlock *BB,
30323032
for (BasicBlock *Pred : predecessors(BB)) {
30333033
if (!VisitedBBs.insert(Pred).second)
30343034
continue;
3035-
if (Instruction *I = Pred->rbegin()->getPrevNonDebugInstruction(true)) {
3035+
if (Instruction *I = Pred->rbegin()->getPrevNonPseudoOpInstruction()) {
30363036
CallInst *CI = dyn_cast<CallInst>(I);
30373037
if (CI && CI->use_empty() && TLI->mayBeEmittedAsTailCall(CI) &&
30383038
attributesPermitTailCall(F, CI, RetI, *TLI)) {

llvm/lib/CodeGen/StackProtector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ bool InsertStackProtectors(const TargetMachine *TM, Function *F,
626626

627627
// If we're instrumenting a block with a tail call, the check has to be
628628
// inserted before the call rather than between it and the return.
629-
Instruction *Prev = CheckLoc->getPrevNonDebugInstruction();
629+
Instruction *Prev = CheckLoc->getPrevNode();
630630
if (auto *CI = dyn_cast_if_present<CallInst>(Prev))
631631
if (CI->isTailCall() && isInTailCallPosition(*CI, *TM))
632632
CheckLoc = Prev;

llvm/lib/IR/Instruction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,9 +1236,9 @@ bool Instruction::isDebugOrPseudoInst() const {
12361236
}
12371237

12381238
const Instruction *
1239-
Instruction::getPrevNonDebugInstruction(bool SkipPseudoOp) const {
1239+
Instruction::getPrevNonPseudoOpInstruction() const {
12401240
for (const Instruction *I = getPrevNode(); I; I = I->getPrevNode())
1241-
if (!isa<DbgInfoIntrinsic>(I) && !(SkipPseudoOp && isa<PseudoProbeInst>(I)))
1241+
if (!isa<PseudoProbeInst>(I))
12421242
return I;
12431243
return nullptr;
12441244
}

llvm/lib/Transforms/IPO/OpenMPOpt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2875,7 +2875,7 @@ struct AAExecutionDomainFunction : public AAExecutionDomain {
28752875
if (It->getSecond().IsReachedFromAlignedBarrierOnly)
28762876
break;
28772877
return false;
2878-
} while ((CurI = CurI->getPrevNonDebugInstruction()));
2878+
} while ((CurI = CurI->getPrevNode()));
28792879

28802880
// Delayed decision on the forward pass to allow aligned barrier detection
28812881
// in the backwards traversal.

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3933,7 +3933,7 @@ Instruction *InstCombinerImpl::visitFenceInst(FenceInst &FI) {
39333933
if (NFI && isIdenticalOrStrongerFence(NFI, &FI))
39343934
return eraseInstFromFunction(FI);
39353935

3936-
if (auto *PFI = dyn_cast_or_null<FenceInst>(FI.getPrevNonDebugInstruction()))
3936+
if (auto *PFI = dyn_cast_or_null<FenceInst>(FI.getPrevNode()))
39373937
if (isIdenticalOrStrongerFence(PFI, &FI))
39383938
return eraseInstFromFunction(FI);
39393939
return nullptr;

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3890,7 +3890,7 @@ bool InstCombinerImpl::removeInstructionsBeforeUnreachable(Instruction &I) {
38903890
// This includes instructions like stores and "llvm.assume" that may not get
38913891
// removed by simple dead code elimination.
38923892
bool Changed = false;
3893-
while (Instruction *Prev = I.getPrevNonDebugInstruction()) {
3893+
while (Instruction *Prev = I.getPrevNode()) {
38943894
// While we theoretically can erase EH, that would result in a block that
38953895
// used to start with an EH no longer starting with EH, which is invalid.
38963896
// To make it valid, we'd need to fixup predecessors to no longer refer to

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3424,7 +3424,7 @@ static void findStoresToUninstrumentedArgAllocas(
34243424
isa<Argument>(cast<CastInst>(Val)->getOperand(0)) &&
34253425
// Check that the cast appears directly before the store. Otherwise
34263426
// moving the cast before InsBefore may break the IR.
3427-
Val == It->getPrevNonDebugInstruction();
3427+
Val == It->getPrevNode();
34283428
bool IsArgInit = IsDirectArgInit || IsArgInitViaCast;
34293429
if (!IsArgInit)
34303430
continue;

llvm/lib/Transforms/Scalar/GVN.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,7 @@ static Value *findDominatingValue(const MemoryLocation &Loc, Type *LoadTy,
13101310
BatchAAResults BatchAA(*AA);
13111311
for (BasicBlock *BB = FromBB; BB; BB = BB->getSinglePredecessor())
13121312
for (auto *Inst = BB == FromBB ? From : BB->getTerminator();
1313-
Inst != nullptr; Inst = Inst->getPrevNonDebugInstruction()) {
1313+
Inst != nullptr; Inst = Inst->getPrevNode()) {
13141314
// Stop the search if limit is reached.
13151315
if (++NumVisitedInsts > MaxNumVisitedInsts)
13161316
return nullptr;

0 commit comments

Comments
 (0)