[llvm] [indvars] Missing variables at Og: (PR #69920)
Stephen Tozer via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 15 09:33:32 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(
----------------
SLTozer wrote:
```suggestion
cast<DbgVariableIntrinsic>(DebugUser)->replaceVariableLocationOp(
```
This should just be a normal `cast` - the idea of `dyn_cast` is that it can return `nullptr` if the cast is unsuccessful, unlike `cast` which just asserts; if you aren't checking the result for `nullptr`, then there's no value in using `dyn_cast` over `cast`. I think in this case, you just want `cast`, since the check above already verifies that the value has not been deleted.
https://github.com/llvm/llvm-project/pull/69920
More information about the llvm-commits
mailing list