You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the -fms-hotpatch option (which is a requirement for Live++), the tailcall/sibling call optimizations will lead to clang miscompiling function calls.
…77245)
Previously, tail jump pseudo-opcodes were skipped by the
`encodeInstruction()` call inside `X86AsmPrinter::LowerPATCHABLE_OP`.
This caused emission of a 2-byte NOP and dropping of the tail jump.
With this PR, we change `PATCHABLE_OP` to not wrap the first
`MachineInstr` anymore, but inserting itself before,
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. That
way, now the first `MachineInstr` is always lowered as usual even if
`"patchable-function"="prologue-short-redirect"` is used.
Fixes#76879,
#76958 and
#59039
When using the -fms-hotpatch option (which is a requirement for Live++), the tailcall/sibling call optimizations will lead to clang miscompiling function calls.
Example code:
Using -O1, the code will compile to the following:
However, adding -fms-hotpatch, the code will miscompile to this:
As a workaround, specifying -fno-optimize-sibling-calls will produce the correct (but suboptimal) following code:
Please refer to this godbolt compiler explorer repro: https://gcc.godbolt.org/z/r86nYbqvo
The text was updated successfully, but these errors were encountered: