[llvm] [NFC][Sink] Change runtime checks to asserts (PR #137354)

via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 25 12:46:24 PDT 2025


================
@@ -144,9 +145,10 @@ static bool SinkInstruction(Instruction *Inst,
       SuccToSinkTo = DT.findNearestCommonDominator(SuccToSinkTo, UseBlock);
     else
       SuccToSinkTo = UseBlock;
-    // The current basic block needs to dominate the candidate.
-    if (!DT.dominates(BB, SuccToSinkTo))
-      return false;
+    // The current basic block dominates all uses, thus it must dominate
+    // SuccToSinkTo, the nearest common dominator of all uses.
+    assert(DT.dominates(BB, SuccToSinkTo) &&
+           "SuccToSinkTo must be dominated by current basic block!");
----------------
LU-JOHN wrote:

I've replaced the two asserts with one assert, but I've put the assert at the beginning of the function since it is already true at that point.

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


More information about the llvm-commits mailing list