Description
When activating -fms-hotpatch
in clang, the "patchable-function"
pass replaces the first machine instruction with a wrapper PATCHABLE_OP
.
This wrapping loses some information about the wrapped instruction: when a PATCHABLE_OP
instruction is handled by X86AsmPrinter::emitInstruction
, the wrapped instruction simply gets lowered without going through X86AsmPrinter::emitInstruction
itself.
Here is an example in C/C++, where a tail call doesn't get lowered properly: https://godbolt.org/z/1Pjcbx87n
The source of the issue seems to be the loss of information in PatchableFunction::runOnMachineFunction
when replacing a MachineInstr
with the PATCHABLE_OP
one: It only keeps the OpCode and operands of the wrapped instruction, and X86AsmPrinter::emitInstruction
can't be called from it.
We are looking for a clean way to achieve this. Any suggestions?