[clang] [llvm] [clang][WebAssembly] Fix Wasm Vararg pointer width (PR #173580)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 1 20:08:25 PST 2026


================

----------------
daxpedda wrote:

Not that I can tell.

I've tried simply adding a calling function but that doesn't work either:
```c
__attribute__((import_module("env"), import_name("test_slot")))
extern void test_slot(unsigned int foo, ...);

void test_u32(void) {
    test_slot(123u, 456u, 789u);
}
```
generates the following input:
```llvm
entry:
  call void (i32, ...) @test_slot(i32 noundef 123, i32 noundef 456, i32 noundef 789)
  ret void
```

AFAICT we can't properly test it via LLVM IR. The way I tested it and confirmed it works is by compiling the same code via Clang and then using `wasm-tools parse -t` to look at the WAT output:
```wat
  (func $test_u32 (;2;) (type 1)
    (local i64)
    global.get $__stack_pointer
    i64.const 16
    i64.sub
    local.set 0
    local.get 0
    global.set $__stack_pointer
    local.get 0
    i32.const 789
    i32.store offset=8
    local.get 0
    i32.const 456
    i32.store
    i32.const 123
    local.get 0
    call $test_slot
    local.get 0
    i64.const 16
    i64.add
    global.set $__stack_pointer
    return
  )
```
With this patch the `offset` is correctly `8`. Just to make sure I tested it without the patch which produces an offset of `4`.

If you have any idea how I can test this with the existing LLVM infrastructure please let me know!

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


More information about the llvm-commits mailing list