[llvm] [DebugInfo][ConstraintElimination] Fix debug value loss in replacing comparisons with the speculated constants (PR #136839)
Shan Huang via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 23 19:22:23 PDT 2025
================
@@ -1454,8 +1455,20 @@ static bool checkAndReplaceCondition(
return ShouldReplace;
});
NumCondsRemoved++;
- if (Cmp->use_empty())
+ if (Cmp->use_empty()) {
----------------
Apochens wrote:
🤔 It seems that this is the right way. The condition in `replaceUesWithIf` specifies where we can use the speculated constant, so there could be cases that non-dbg uses still exist after the optimization. I have modified the return value to `%t.1` in test `salvage-dbg-values-replaced-by-constant.ll` to demostrate such a case.
https://github.com/llvm/llvm-project/pull/136839
More information about the llvm-commits
mailing list