[PATCH] D71350: [MachineScheduler] Reorder cfi to avoid PostRA scheduling differences

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 11 10:49:25 PST 2019


rnk added a comment.

+1 to what @Orlando said. I believe this is consistent with how epilogue CFI instructions were added, it was done late to avoid interfering with tail merging and other passes.

It is, however, easier said than done. Currently codegen works like this:

- Do prologue/epilogue insertion, insert CFI precisely next to CSR saves and SP adjustments
- Invariant: Later passes do not "mess" with prologue, but this is not well specified. The FrameSetup flags are one way we do this, this sched boundary marking seems like another.

A new model could be:

- Do PEI, do not insert CFI, record some key info, like hasFP, did stackalign, hasBP, etc.
- Invariant: Passes do not incorrectly reschedule instructions across prologue instrs (SP adjustments, CSR saves)
- Invariant: Passes do not break late CFI insertion
- Prior to, or concurrent with, AsmPrinter, reanalyze the prologue, insert CFI instructions precisely where necessary.

The challenge would be nailing down exactly what passes can and cannot do between PEI and AsmPrinter such that CFI can always be reliably inserted. Coping with multi-BB prologues from shrink wrapping is an example of such a challenge. This new design would also have the benefit that it would be truly asynchronous, meaning it is accurate at all instruction boundaries, not just after the prologue and around calls.


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

https://reviews.llvm.org/D71350





More information about the llvm-commits mailing list