[PATCH] D49364: [ARM] Add support for spilling high registers in Thumb1

Petr Pavlu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 14 02:38:18 PDT 2018


petpav01 updated this revision to Diff 160538.
petpav01 added a comment.
Herald added subscribers: eraman, MatzeB.

Thanks for the explanation of this idea. Updated patch goes in that direction and provides a prototype of this approach. The implementation is done in Fast Register Allocator (which has its own spiller code) and in InlineSpiller (used by the other LLVM allocators: Basic, Greedy, PBQP).

The implemented approach is to always make a complete spill of a high register to stack instead of initially moving it only to a low register and then spill the low register if actually needed. This allows to keep things a bit simpler to implement and reason about. InlineSpiller could be improved to implement only the mentioned "half-spills" but it does not appear necessary for now. With this problem currently being limited only to inline assembler, I think the Greedy production allocator should not get in a state where it would need to spill high registers.

The patch is not complete but I thought I would ask for feedback on it early, before I dive into solving remaining issues.

Known problems:

- Reloads of registers that require a COPY instruction should be done by RegAllocFast before other register uses try to get satisfied to provide better assignment possibilities for the temporary register.
- Helper registers used in high-register reloads should get properly removed from `UsedInInstr` in RegAllocFast so they can get used by the actual instruction.
- RegAllocFast uses one temporary virtual register for all COPY instructions that it needs to insert for high-register spills. This is a workaround for `LiveRegMap` (`SparseSet`) not being resizable when it is not empty.
- Operands of COPY instructions inserted by InlineSpiller can get inflated to GPR. This is visible in test `hgpr-spill-basic.mir` and would cause a problem if the inflated GRP register needed to get subsequently spilled.
- Interaction with snippets and hoisting in InlineSpiller is likely not really correct.


https://reviews.llvm.org/D49364

Files:
  include/llvm/CodeGen/LiveRangeEdit.h
  include/llvm/CodeGen/TargetInstrInfo.h
  lib/CodeGen/InlineSpiller.cpp
  lib/CodeGen/LiveRangeEdit.cpp
  lib/CodeGen/RegAllocFast.cpp
  lib/Target/ARM/Thumb1InstrInfo.cpp
  lib/Target/ARM/Thumb1InstrInfo.h
  test/CodeGen/Thumb/hgpr-spill-basic.mir
  test/CodeGen/Thumb/hgpr-spill-fast.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49364.160538.patch
Type: text/x-patch
Size: 20643 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180814/962d25de/attachment.bin>


More information about the llvm-commits mailing list