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

Carlos Alberto Enciso via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 17 23:18:10 PDT 2024


================
@@ -607,6 +608,17 @@ void llvm::deleteDeadLoop(Loop *L, DominatorTree *DT, ScalarEvolution *SE,
   llvm::SmallVector<DPValue *, 4> DeadDPValues;
 
   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)
+          dyn_cast<DbgVariableIntrinsic>(DebugUser)->replaceVariableLocationOp(
----------------
CarlosAlbertoEnciso wrote:

Thanks for the additional information on `dyn_cast`. Changed to `cast`.

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


More information about the llvm-commits mailing list