[clang] [llvm] Implement `preserve_none` for 32-bit x86 (PR #150106)

Brandt Bucher via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 23 09:29:57 PDT 2025


brandtbucher wrote:

Thanks @efriedma-quic, I missed that the base pointer is `ESI` (not `EBX`) on 32-bit targets. I forgot about the "nest" parameter (`ECX`), and the GOT pointer (`EBX`) too.

How's this for the new parameter list?

```diff
diff --git a/llvm/lib/Target/X86/X86CallingConv.td b/llvm/lib/Target/X86/X86CallingConv.td
index 6a8599a6c7c1..32eedcb9ca79 100644
--- a/llvm/lib/Target/X86/X86CallingConv.td
+++ b/llvm/lib/Target/X86/X86CallingConv.td
@@ -1052,8 +1052,12 @@ def CC_X86_64_Preserve_None : CallingConv<[
 ]>;
 
 def CC_X86_32_Preserve_None : CallingConv<[
-  // 32-bit variant of CC_X86_64_Preserve_None, above.
-  CCIfType<[i32], CCAssignToReg<[EDI, ESI, EDX, ECX, EAX]>>,
+  // 32-bit variant of CC_X86_64_Preserve_None, above. Use everything except:
+  //   - EBP        frame pointer
+  //   - ECX        'nest' parameter
+  //   - ESI        base pointer
+  //   - EBX        GOT pointer for PLT calls
+  CCIfType<[i32], CCAssignToReg<[EDI, EDX, EAX]>>,
   CCDelegateTo<CC_X86_32_C>
 ]>;
```



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


More information about the llvm-commits mailing list