[MachineOutliner][AArch64] WA for multiple stack fixup cases in MachineOutliner.
authorPuyan Lotfi <puyan@puyan.org>
Mon, 10 Aug 2020 18:45:38 +0000 (14:45 -0400)
committerPuyan Lotfi <puyan@puyan.org>
Mon, 10 Aug 2020 19:43:30 +0000 (15:43 -0400)
commit7bc03f55539f7f081daea5363f2e4845b2e75f57
treed39e4e111b963549d4b679ba13bb68f88477f7e6
parent4cd8e9b169f4dc5dde19807585c86f6d6113d3ff
[MachineOutliner][AArch64] WA for multiple stack fixup cases in MachineOutliner.

In cases where MachineOutliner candidates either are:

  * noreturn
  * have calls with no available LR or free regs
  * Don't use SP

we can end up hitting stack fixup code for the caller and the callee for
a FrameID of MachineOutlinerDefault. This triggers the assert:

  `assert(OF.FrameConstructionID != MachineOutlinerDefault &&
          "Can only fix up stack references once");`

in AArch64InstrInfo.cpp. This assert exists for now because a lot of the
fixup code is not tested to handle fixing up more than once and needs
some better checks and enhancements to avoid potentially generating
illegal code.

I've filed a Bugzilla report to track this until these cases are handled
by the AArch64 MachineOutliner: https://bugs.llvm.org/show_bug.cgi?id=46767

This diff detects cases that will cause these multiple stack fixups and
prune the Candidates from `RepeatedSequenceLocs`.

    Differential Revision: https://reviews.llvm.org/D83923
llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
llvm/test/CodeGen/AArch64/machine-outliner-2fixup-blr-terminator.mir [new file with mode: 0644]
llvm/test/CodeGen/AArch64/machine-outliner-no-noreturn-no-stack.mir [new file with mode: 0644]
llvm/test/CodeGen/AArch64/machine-outliner-noreturn-no-stack.mir [new file with mode: 0644]