llvm-project
de1772a1 - [SelectionDAG] Do not treat variadic vreg results as physreg defs (#229847)

Commit
27 days ago
[SelectionDAG] Do not treat variadic vreg results as physreg defs (#229847) AddSchedEdges sets hasPhysRegDefs on a scheduling unit when a machine node has more used results than explicit defs. Later, in the list scheduler, canClobberPhysRegDefs assumes that each extra result is an implicit physical register def. It then indexes implicit_defs() by the result number. This assumption is wrong for instructions with variadicOpsAreDefs on targets where usesPhysRegsForValues returns false, such as WebAssembly. On these targets, the extra results are virtual registers, not physical ones. As a result, RegReductionPQBase::PrescheduleNodesWithMultipleUses reads past the end of the implicit def list. This change makes the scheduler check for this case. Now hasPhysRegDefs is set only when the extra results really are physical registers. Effect on WebAssembly code: Before this change, every WebAssembly call with a used result was marked as having physical register defs. The mark was wrong, but it had a side effect: BURRSort places a node with physical register defs right before the node that uses it. So each call was always placed directly before its user. Now the wrong mark is gone, and the scheduler orders these calls by its normal priority (the Sethi-Ullman number). A call can now be placed earlier, away from its user, and sometimes another call ends up in between. Nine tests are updated: - In five tests, only the order of a call and a constant changes, and the register numbers change. The final code is the same. - In four tests, a call moved past another call, and a new local appears. Fixes: https://github.com/llvm/llvm-project/issues/229844
Author
Parents
Loading