[llvm] [MachineScheduler] Fix physreg dependencies of ExitSU (PR #123541)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 20 01:22:20 PST 2025


================
@@ -263,6 +275,9 @@ void ScheduleDAGInstrs::addPhysRegDataDeps(SUnit *SU, unsigned OperIdx) {
       bool ImplicitPseudoUse = false;
       SDep Dep;
       if (UseOpIdx < 0) {
+        // FIXME: UseOpIdx can be passed to computeOperandLatency, which can
+        //   pass it to findUseIdx, which treats it as unsigned. If this is
+        //   the expected behavior, it should be commented.
----------------
s-barannikov wrote:

> This code should crash if `UseOperIdx == -1`, except it doesn't. This function is only called (under certain conditions) if the target uses SchedModel (not Itineraries). Probably this code is unreachable for in-tree models.

I did some debugging. It appears that when -1 is passed to `computeOperandLatency`, `UseInstr` is always nullptr. Operand index is only used if `UseInstr` is non-null, so strictly speaking there is no bug. I'm going to drop this comment.
(Let me know if I should do something different, like add a note or assertion somewhere.)


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


More information about the llvm-commits mailing list