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

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 25 12:55:41 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!");
----------------
nikic wrote:

The reason why I suggest to put it at the end is that SuccToSinkTo is changed in the function. So we are asserting that the property still holds after these adjustments.

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


More information about the llvm-commits mailing list