[PATCH] D122615: Early return in constrainOperandRegClass()

Viacheslav Nikolaev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 30 13:39:25 PDT 2022


wvoquine added inline comments.


================
Comment at: llvm/include/llvm/CodeGen/RegisterBankInfo.h:644
+  /// false otherwise.
+  static bool needToConstrainGenericRegister(Register Reg,
+                                             const TargetRegisterClass &RC,
----------------
arsenm wrote:
> I don't see the point of having this be both a separate utility function and a static member. It should be either one or the other
I just followed the choices made for the corresponding utility functions/methods for `constrainGenericRegister()` and `constrainOperandRegClass()`.

There's no actual need for the latter to be around at the moment, I can remove the utility function.


================
Comment at: llvm/lib/CodeGen/GlobalISel/Utils.cpp:46
+                                     const TargetRegisterClass &RegClass) {
+  return RBI.needToConstrainGenericRegister(Reg, RegClass, MRI);
+}
----------------
arsenm wrote:
> Why call a static method through RBI?
Good point!
By the way, the same would apply to the `llvm::constrainRegToClass()` implementation below... I just replicated that sort of code without noticing it was actually a static method.

I guess, it really makes sense to remove this utility method right now, to avoid fixing the API some of the operands of which are not required...


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

https://reviews.llvm.org/D122615



More information about the llvm-commits mailing list