[clang] [llvm] Fix Windows EH IP2State tables (remove +1 bias) (PR #144745)

Kimhak Kimho via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 29 16:40:14 PDT 2025


kimhak168 wrote:

SllfjhvmSSllf

On Mon, Jun 30, 2025, 5:31 AM sivadeilra ***@***.***> wrote:

> ***@***.**** commented on this pull request.
> ------------------------------
>
> In llvm/lib/Target/X86/X86MCInstLower.cpp
> <https://github.com/llvm/llvm-project/pull/144745#discussion_r2173977583>:
>
> > +// To achieve this, ICO also inserts NOPs after the CALL instruction. If the
> +// end of the CALL is aligned with an EH state transition, we *also* insert
> +// a single-byte NOP.  **Both forms of NOPs must be preserved.**  They cannot
> +// be combined into a single larger NOP; nor can the second NOP be removed.
> +//
> +// This is necessary because, if ICO is active and the call site is modified
> +// by the loader, the loader will end up overwriting the NOPs that were inserted
> +// for ICO. That means that those NOPs cannot be used for the correct
> +// termination of the exception handling region (the IP2State transition),
> +// so we still need an additional NOP instruction.  The NOPs cannot be combined
> +// into a longer NOP (which is ordinarily desirable) because then ICO would
> +// split one instruction, producing a malformed instruction after the ICO call.
> +bool X86AsmPrinter::needsNopAfterCallForWindowsEH(const MachineInstr *MI) {
> +  // We only need to insert NOPs after CALLs when targeting Windows on AMD64.
> +  // Since this code is already restricted to X86, we just test for Win64.
> +  if (!this->Subtarget->isTargetWin64()) {
>
> Ok. What should that look like? I looked at a few variants and it wasn't
> obvious how they were different from using the subtarget.
>
>> Reply to this email directly, view it on GitHub
> <https://github.com/llvm/llvm-project/pull/144745#discussion_r2173977583>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/BMTQUFSDA3KPV7DATAF5SML3GBSM5AVCNFSM6AAAAAB7TTSKNKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDSNRZGU2DMMJZGQ>
> .
> You are receiving this because you are subscribed to this thread.Message
> ID: ***@***.***>
>


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


More information about the llvm-commits mailing list