[llvm] [MachineScheduler] Fix physreg dependencies of ExitSU (PR #123541)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 19 23:53:46 PST 2025
================
@@ -209,13 +209,25 @@ void ScheduleDAGInstrs::addSchedBarrierDeps() {
ExitSU.setInstr(ExitMI);
// Add dependencies on the defs and uses of the instruction.
if (ExitMI) {
+ const MCInstrDesc &MIDesc = ExitMI->getDesc();
for (const MachineOperand &MO : ExitMI->all_uses()) {
+ unsigned OpIdx = MO.getOperandNo();
Register Reg = MO.getReg();
if (Reg.isPhysical()) {
+ // addPhysRegDataDeps uses the provided operand index to retrieve
+ // the operand use cycle from the scheduling model. If the operand
+ // is "fake" (e.g., an operand of a call instruction used to pass
+ // an argument to the called function.), the scheduling model may not
+ // have an entry for it. If this is the case, pass -1 as operand index,
+ // which will cause addPhysRegDataDeps to add an artificial dependency.
+ // FIXME: Using hasImplicitUseOfPhysReg here is inaccurate as it misses
+ // aliases. When fixing, make sure to update addPhysRegDataDeps, too.
+ bool IsRealUse = OpIdx < MIDesc.getNumOperands() ||
+ MIDesc.hasImplicitUseOfPhysReg(Reg);
for (MCRegUnit Unit : TRI->regunits(Reg))
- Uses.insert(PhysRegSUOper(&ExitSU, -1, Unit));
+ Uses.insert(PhysRegSUOper(&ExitSU, IsRealUse ? OpIdx : -1, Unit));
----------------
s-barannikov wrote:
This is where an operand index gets a negative value. There is one more place at the end of this function.
https://github.com/llvm/llvm-project/pull/123541
More information about the llvm-commits
mailing list