[llvm] [CodeGen][X86] Fix lowering of tailcalls when `-ms-hotpatch` is used (PR #77245)

Alexandre Ganea via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 10 05:43:04 PST 2024


aganea wrote:

So I did something different to address the points raised. Instead of `PATCHABLE_OP` wrapping the first `MachineInstr`, it now inserts itself before it, leaving the instruction unaltered. At lowering time in `X86AsmPrinter`, we now "look ahead" for the next non-pseudo `MachineInstr` and lower+encode it, to inspect its size. If the size is below what `PATCHABLE_OP` expects, it inserts NOPs; otherwise it does nothing. I think this should address @sylvain-audi 's concerns. PTAL.

If we wanted in a future PR we could change the attribute `"patchable-function"="prologue-short-redirect"` to `"patchable-function"="2"`. That would make `PATCHABLE_OP` more flexible, and the X86 backend already supports large sizez NOPs (up to 15, if the target CPU supports it).

Also, I've removed the `X86::PUSH64r` optimization which cannot be applied anymore in this situation. Thus the change in the `patchable-prologue.ll` test. + at sanjoy 

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


More information about the llvm-commits mailing list