[llvm] [DebugInfo][ConstraintElimination] Fix debug value loss in replacing comparisons with the speculated constants (PR #136839)

Orlando Cazalet-Hyams via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 23 07:34:01 PDT 2025


================
@@ -1454,8 +1455,20 @@ static bool checkAndReplaceCondition(
       return ShouldReplace;
     });
     NumCondsRemoved++;
-    if (Cmp->use_empty())
+    if (Cmp->use_empty()) {
----------------
OCHyams wrote:

Hmmm.. .I think we probably want to do the debug update outside of the `if (Cmp->use_empty())` block (unconditionally)? Otherwise we're only updating debug info if there are no other non-dbg uses. But IMO we should update the debug info regardless, because we know the value on this code path. 

(I'm not sure there's a clear correct answer, happy to discuss further).

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


More information about the llvm-commits mailing list