[X86] For 32-bit targets, emit two-byte NOP when possible
authorAlexandre Ganea <alexandre.ganea@ubisoft.com>
Wed, 17 Jun 2020 17:26:10 +0000 (13:26 -0400)
committerAlexandre Ganea <alexandre.ganea@ubisoft.com>
Wed, 17 Jun 2020 17:44:38 +0000 (13:44 -0400)
commitacb30f6856c34b929b30bfd76dc938a1087af0a9
tree34b4210438728093b01cbf21f83421839480250a
parentad879b31f054116a9df4efceddee967a2b6247bb
[X86] For 32-bit targets, emit two-byte NOP when possible

In order to support hot-patching, we need to make sure the first emitted instruction in a function is a two-byte+ op. This is already the case on x86_64, which seems to always emit two-byte+ ops. However on 32-bit targets this wasn't the case.

PATCHABLE_OP now lowers to a XCHG AX, AX, (66 90) like MSVC does. However when targetting pentium3 (/arch:SSE) or i386 (/arch:IA32) targets, we generate MOV EDI,EDI (8B FF) like MSVC does. This is for compatiblity reasons with older tools that rely on this two byte pattern.

Differential Revision: https://reviews.llvm.org/D81301
llvm/lib/Target/X86/X86MCInstLower.cpp
llvm/test/CodeGen/X86/patchable-function-entry.ll
llvm/test/CodeGen/X86/patchable-prologue.ll