[llvm] [X86] Add MI-layer routine for getting the index of the first address operand. NFC (PR #78019)

Nicholas Mosier via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 15 13:33:15 PST 2024


nmosier wrote:

I think that it does in principle allow more optimizations, for example in the x86-optimize-LEAs pass. However, I found that there need to be a couple tweaks in the x86-optimize-LEAs implementation to ensure that it doesn't introduce anti-optimizations as well.

For example, some pseudo-instructions like `VASTART_SAVE_XMM_REGS` are expanded to multiple memory accesses at different displacements, which x86-optimize-LEAs does not realize and naively inserts a LEA instruction that doesn't actually help in the end. This should be easy to fix, but I am not planning on addressing it in this patch.

Therefore, I'm reverting all uses of `X86II::getMemoryOperandNo()` in optimization passes. However, I'm keeping `X86::getFirstAddrOperandIdx()` in all mitigation passes, since this is necessary for their security guarantees.

I've updated the PR comment to reflect this and just pushed a new commit with these changes.

I am planning on later submitting some follow-up patches to migrate uses of X86II::getMemoryOperandNo() to X86::getFirstAddrOperandIdx() where appropriate in x86 optimization passes. I'll include new tests for those.


https://github.com/llvm/llvm-project/pull/78019


More information about the llvm-commits mailing list