[llvm] [indvars] Missing variables at Og: (PR #69920)

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 12 10:56:36 PST 2024


================
@@ -1540,11 +1590,22 @@ 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);
       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.
+  if (RewritePhiSet.empty()) {
+    // The loop exit value has been updated; insert the debug location
+    // for the given the induction variable with its final value.
----------------
jmorse wrote:

"for the given induction..."

https://github.com/llvm/llvm-project/pull/69920


More information about the llvm-commits mailing list