[PATCH] D122615: Early return in constrainOperandRegClass()

Daniel Sanders via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 30 14:32:18 PDT 2022


dsanders added inline comments.


================
Comment at: llvm/lib/CodeGen/MachineRegisterInfo.cpp:82
   if (NewRC->getNumRegs() < MinNumRegs)
     return nullptr;
   MRI.setRegClass(Reg, NewRC);
----------------
This is more of a naming nitpick but this path isn't constraining the reg class yet constraining is still needed. I believe the caller is expected to emit a copy instead and that caller should notify the observers correctly

FWIW, MinNumRegs is hardly ever used, I can only find a couple instances


================
Comment at: llvm/lib/CodeGen/RegisterBankInfo.cpp:131-132
+    Register Reg, const TargetRegisterClass &RC, MachineRegisterInfo &MRI) {
+  // If the register already has a class, there's a chance
+  // it's already constrained appropriately.
+  if (MRI.getRegClassOrNull(Reg) != nullptr)
----------------
There's also a chance it isn't and constrainGenericRegister() changes the class requiring that the observers be notified


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122615/new/

https://reviews.llvm.org/D122615



More information about the llvm-commits mailing list