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

via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 16 11:18:49 PDT 2025


================
@@ -37,9 +37,11 @@ cond.end:                                         ; preds = %entry, %cond.true
 ; CHECK: testq
 ; CHECK: je
 ; CHECK: callq alloc
+; CHECK-NEXT: nop
----------------
sivadeilra wrote:

I went further with more precise optimization around NOP insertion.  We should only be inserting NOPs when a function has an EH personality function (and thus has IP2State tables).  No IP2State table mean no need to insert NOPs at all, even for SEH, right?  The `WinException::beginFunction` computes `shouldEmitPersonality`, so I used that value to control whether we do any NOP insertion.

Some tests now fail due to differences.  I noticed in `llvm\test\CodeGen\X86\win64_call_epi.ll` that `foo1` looks correct (and still passes), but `foo2` appears to be incorrect.  `foo2` does not have an EH personality function, but it checks that ` nop` is inserted after `callq`.  After my changes (for using `shouldEmitPersonality`), the test for `foo2` fails.

What's the right thing to do here?  Should `foo2` be using `personality ptr @personality` and should its `call` be upgraded to `invoke`, or should `foo2` not expect to find a `nop`?

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


More information about the llvm-commits mailing list