diff options
author | Carlos Alberto Enciso <Carlos.Enciso@sony.com> | 2024-05-22 11:36:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-22 11:36:10 +0100 |
commit | 3c5738f3ec185fbf56da2c18929f5b33126cd98b (patch) | |
tree | a01c433132f66748a204aceda87e2d766b182130 /llvm/lib/Transforms/Utils/LoopUtils.cpp | |
parent | 9807f25baa98be3bcce579302b2348b8abaf5cbd (diff) | |
download | llvm-3c5738f3ec185fbf56da2c18929f5b33126cd98b.zip llvm-3c5738f3ec185fbf56da2c18929f5b33126cd98b.tar.gz llvm-3c5738f3ec185fbf56da2c18929f5b33126cd98b.tar.bz2 |
Revert "[indvars] Missing variables at Og (#88270)" (#93016)
This reverts commit 89e1f7784be40bea96d5e65919ce8d34151c1d69.
https://github.com/llvm/llvm-project/pull/88270#discussion_r1609559724
https://github.com/llvm/llvm-project/pull/88270#discussion_r1609552972
Main concerns from @nikic are the interaction between the
'IndVars' and 'LoopDeletion' passes, increasing build times
and adding extra complexity.
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUtils.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopUtils.cpp | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp index 0bd1e8a..cc883a7 100644 --- a/llvm/lib/Transforms/Utils/LoopUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp @@ -31,7 +31,6 @@ #include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h" #include "llvm/Analysis/ScalarEvolutionExpressions.h" #include "llvm/IR/DIBuilder.h" -#include "llvm/IR/DebugInfo.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/IntrinsicInst.h" @@ -609,17 +608,6 @@ void llvm::deleteDeadLoop(Loop *L, DominatorTree *DT, ScalarEvolution *SE, llvm::SmallVector<DbgVariableRecord *, 4> DeadDbgVariableRecords; if (ExitBlock) { - if (ExitBlock->phis().empty()) { - // As the loop is deleted, replace the debug users with the preserved - // induction variable final value recorded by the 'indvar' pass. - Value *FinalValue = L->getDebugInductionVariableFinalValue(); - SmallVector<WeakVH> &DbgUsers = L->getDebugInductionVariableDebugUsers(); - for (WeakVH &DebugUser : DbgUsers) - if (DebugUser) - cast<DbgVariableIntrinsic>(DebugUser)->replaceVariableLocationOp( - 0u, FinalValue); - } - // Given LCSSA form is satisfied, we should not have users of instructions // within the dead loop outside of the loop. However, LCSSA doesn't take // unreachable uses into account. We handle them here. @@ -1413,36 +1401,6 @@ static bool checkIsIndPhi(PHINode *Phi, Loop *L, ScalarEvolution *SE, return InductionDescriptor::isInductionPHI(Phi, L, SE, ID); } -void llvm::addDebugValuesToIncomingValue(BasicBlock *Successor, Value *IndVar, - PHINode *PN) { - SmallVector<DbgVariableIntrinsic *> DbgUsers; - findDbgUsers(DbgUsers, IndVar); - for (auto *DebugUser : DbgUsers) { - // Skip debug-users with variadic variable locations; they will not, - // get updated, which is fine as that is the existing behaviour. - if (DebugUser->hasArgList()) - continue; - auto *Cloned = cast<DbgVariableIntrinsic>(DebugUser->clone()); - Cloned->replaceVariableLocationOp(0u, PN); - Cloned->insertBefore(*Successor, Successor->getFirstNonPHIIt()); - } -} - -void llvm::addDebugValuesToLoopVariable(BasicBlock *Successor, Value *ExitValue, - PHINode *PN) { - SmallVector<DbgVariableIntrinsic *> DbgUsers; - findDbgUsers(DbgUsers, PN); - for (auto *DebugUser : DbgUsers) { - // Skip debug-users with variadic variable locations; they will not, - // get updated, which is fine as that is the existing behaviour. - if (DebugUser->hasArgList()) - continue; - auto *Cloned = cast<DbgVariableIntrinsic>(DebugUser->clone()); - Cloned->replaceVariableLocationOp(0u, ExitValue); - Cloned->insertBefore(*Successor, Successor->getFirstNonPHIIt()); - } -} - int llvm::rewriteLoopExitValues(Loop *L, LoopInfo *LI, TargetLibraryInfo *TLI, ScalarEvolution *SE, const TargetTransformInfo *TTI, @@ -1584,10 +1542,6 @@ int llvm::rewriteLoopExitValues(Loop *L, LoopInfo *LI, TargetLibraryInfo *TLI, (isa<PHINode>(Inst) || isa<LandingPadInst>(Inst)) ? &*Inst->getParent()->getFirstInsertionPt() : Inst; RewritePhiSet.emplace_back(PN, i, ExitValue, InsertPt, HighCost); - - // Add debug values for the candidate PHINode incoming value. - if (BasicBlock *Successor = ExitBB->getSingleSuccessor()) - addDebugValuesToIncomingValue(Successor, PN->getIncomingValue(i), PN); } } } @@ -1646,30 +1600,11 @@ int llvm::rewriteLoopExitValues(Loop *L, LoopInfo *LI, TargetLibraryInfo *TLI, // Replace PN with ExitVal if that is legal and does not break LCSSA. if (PN->getNumIncomingValues() == 1 && LI->replacementPreservesLCSSAForm(PN, ExitVal)) { - addDebugValuesToLoopVariable(PN->getParent(), ExitVal, PN); PN->replaceAllUsesWith(ExitVal); PN->eraseFromParent(); } } - // If the loop can be deleted and there are no PHIs to be rewritten (there - // are no loop live-out values), record debug variables corresponding to the - // induction variable with their constant exit-values. Those values will be - // inserted by the 'deletion loop' logic. - if (LoopCanBeDel && RewritePhiSet.empty()) { - if (auto *IndVar = L->getInductionVariable(*SE)) { - const SCEV *PNSCEV = SE->getSCEVAtScope(IndVar, L->getParentLoop()); - if (auto *Const = dyn_cast<SCEVConstant>(PNSCEV)) { - Value *FinalIVValue = Const->getValue(); - if (L->getUniqueExitBlock()) { - SmallVector<DbgVariableIntrinsic *> DbgUsers; - findDbgUsers(DbgUsers, IndVar); - L->preserveDebugInductionVariableInfo(FinalIVValue, DbgUsers); - } - } - } - } - // The insertion point instruction may have been deleted; clear it out // so that the rewriter doesn't trip over it later. Rewriter.clearInsertPoint(); |