[PATCH] D63068: [AVR] Fix incorrect stack parameter push order

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 19 12:18:24 PDT 2019


efriedma added a comment.

> In AVR, it uses push instruction to store arguments. Therefore. the order of store(push) instruction can't be changed.

During isel, the stores are modeled using regular store instructions.  And it should be possible (although maybe not efficient) to lower those stores into regular store instructions, which don't modify the stack pointer.

It looks like AVRFrameLowering::eliminateCallFramePseudoInstr has a bug: it assumes that the store instructions that are used to store arguments exist in some specific order.  The target-independent backend code does not guarantee that; the stores can be rearranged during or after isel.  If the stores need to be in a specific order for the store->push optimization, the AVR backend needs to rearrange them into the correct order explicitly.

x86 has a similar "push" instruction, and a specialized transform pass dedicated to optimizing store instructions to push instructions. See lib/Target/X86/X86CallFrameOptimization.cpp .


Repository:
  rL LLVM

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

https://reviews.llvm.org/D63068





More information about the llvm-commits mailing list