[PATCH] D79785: [ARM] Register pressure with -mthumb forces register reload before each call

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 19 12:52:13 PDT 2020


dmgreen added a comment.

Yeah sorry for the delay. I had to go and look up where this function was actually being used. It appears to be during registry allocation, it folds as opposed to spilling. That actually seems to work quite well, except that it won't remove the last constant pool load and the cpe entry. Like others have said it does seem a little odd to create these indirect loads just to undo them again, but coming up with a decent heuristic during ISel lowering sounds tricky too. If you can make this a bit more resilient, it sounds like an OK way to go to me.



================
Comment at: llvm/lib/Target/ARM/Thumb1InstrInfo.cpp:173
+    const Constant *Callee = cast<Constant>(CPE.Val.ConstVal);
+    const char *FuncName = MF.createExternalSymbolName(Callee->getName());
+    MachineInstrBuilder MIB =
----------------
I don't think you can use the name of any old Constant. Consider something like this, but it could be any other form of indirect call:
```
void test(int *p, int x, int y, int z) {
   ((void (*) (int*, int, int, int))0x1234567)(p, x, y, z);
   ((void (*) (int*, int, int, int))0x1234567)(p, x, y, z);
   ((void (*) (int*, int, int, int))0x1234567)(p, x, y, z);
   ((void (*) (int*, int, int, int))0x1234567)(p, x, y, z);
}
```
You can maybe try and dyn_cast the CPE.Val.ConstVal (providing you know it's not a MachineCPVal) into a Function* and use that. But it would be good to check all these things are definitely true for the instructions we have.


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

https://reviews.llvm.org/D79785



More information about the llvm-commits mailing list