From 3feb72b6bc99206da0895fbf42b9a774be335f61 Mon Sep 17 00:00:00 2001 From: Carlos Alberto Enciso Date: Tue, 16 Jan 2024 12:10:46 +0000 Subject: [PATCH] [indvars] Missing variables at Og: https://bugs.llvm.org/show_bug.cgi?id=51735 https://github.com/llvm/llvm-project/issues/51077 Addressed the upstream feedback in relation to: - Remove the introduced 'ExitBlock' field. - Update some comments. --- llvm/lib/Transforms/Utils/LoopUtils.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp index 420c99775a6e67..5887ac27bfa94c 100644 --- a/llvm/lib/Transforms/Utils/LoopUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp @@ -1267,12 +1267,11 @@ struct RewritePhi { const SCEV *ExpansionSCEV; // The SCEV of the incoming value we are rewriting. Instruction *ExpansionPoint; // Where we'd like to expand that SCEV? bool HighCost; // Is this expansion a high-cost? - BasicBlock *ExitBlock; // Exit block for PHI node. RewritePhi(PHINode *P, unsigned I, const SCEV *Val, Instruction *ExpansionPt, - bool H, BasicBlock *Exit) + bool H) : PN(P), Ith(I), ExpansionSCEV(Val), ExpansionPoint(ExpansionPt), - HighCost(H), ExitBlock(Exit) {} + HighCost(H) {} }; // Check whether it is possible to delete the loop after rewriting exit @@ -1523,8 +1522,7 @@ int llvm::rewriteLoopExitValues(Loop *L, LoopInfo *LI, TargetLibraryInfo *TLI, Instruction *InsertPt = (isa(Inst) || isa(Inst)) ? &*Inst->getParent()->getFirstInsertionPt() : Inst; - RewritePhiSet.emplace_back(PN, i, ExitValue, InsertPt, HighCost, - ExitBB); + RewritePhiSet.emplace_back(PN, i, ExitValue, InsertPt, HighCost); // Add debug values if the PN is a induction variable. PHINode *IndVar = L->getInductionVariable(*SE); @@ -1590,19 +1588,19 @@ 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(Phi.ExitBlock, ExitVal, PN); + addDebugValuesToLoopVariable(PN->getParent(), ExitVal, PN); PN->replaceAllUsesWith(ExitVal); PN->eraseFromParent(); } } // If there are no PHIs to be rewritten then there are no loop live-out - // values, try to rewrite variables corresponding to the induction variable - // with their constant exit-values if we computed any. Otherwise debug-info - // will completely forget that this loop happened. + // values, try to rewrite debug variables corresponding to the induction + // variable with their constant exit-values if we computed any. Otherwise + // debug-info will completely forget that this loop happened. if (RewritePhiSet.empty()) { // The loop exit value has been updated; insert the debug location - // for the given the induction variable with its final value. + // for the given induction variable with its final value. addDebugValuesToLoopVariable(L, SE, L->getInductionVariable(*SE)); }