[PATCH] D152452: X86, PEI, WIP: Convert to backwards frame index elimination

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 8 09:04:10 PDT 2023


foad added reviewers: RKSimon, craig.topper, pengfei.
foad added a comment.

This is WIP. Some codegen tests fail. I need help on a couple of X86 things please:

1. `X86InstrInfo::getSPAdjust` gets information about the stack adjustment of a CALL by searching for the following ADJCALLSTACKUP. That doesn't work if you're processing the basic block backwards, since the ADJCALLSTACKUP will already have been eliminated. Can I somehow put the information in the preceding ADJCALLSTACKDOWN instead? I see that both opcodes take two immediate values but I have not found good documentation on what they mean.

2. When `PEI::replaceFrameIndicesBackward(MachineFunction &)` processes a basic block that ends with a return, it assumes that SPAdj is 0 at the end of the block. I think it needs to account for return instructions like "RET 4", which move SP by 4, but currently PEI only calls getSPAdjust on instructions which are "frame setup" or "frame destroy" or part of a call sequence - and RET is none of those things. Is there a clean way to handle this?



================
Comment at: llvm/lib/Target/X86/X86InstrInfo.cpp:427
 
-    return -(I->getOperand(1).getImm());
+    return I->getOperand(1).getImm();
   }
----------------
I now think that this is just wrong, since operand(1) of ADJCALLSTACKDOWN is a completely different thing from operand(1) of ADJCALLSTACKUP.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152452



More information about the llvm-commits mailing list