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

via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 25 13:52:46 PST 2025


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

Vararg on Wasm64 was using 4 bytes for the pointer instead of 8 bytes.

I checked the C ABI in the Wasm tool conventions just to make sure there isn't anything strange going on there, but there wasn't. Would still appreciate somebody double-checking this.

>From eb7c600cc69ad67259282f106e49ab28d11f47f1 Mon Sep 17 00:00:00 2001
From: daxpedda <daxpedda at gmail.com>
Date: Thu, 25 Dec 2025 22:44:33 +0100
Subject: [PATCH] [clang][WebAssembly] Fix Wasm Vararg pointer width

---
 clang/lib/CodeGen/Targets/WebAssembly.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/clang/lib/CodeGen/Targets/WebAssembly.cpp b/clang/lib/CodeGen/Targets/WebAssembly.cpp
index ebe996a4edd8d..ce97884fa57c4 100644
--- a/clang/lib/CodeGen/Targets/WebAssembly.cpp
+++ b/clang/lib/CodeGen/Targets/WebAssembly.cpp
@@ -160,10 +160,11 @@ RValue WebAssemblyABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
   bool IsIndirect = isAggregateTypeForABI(Ty) &&
                     !isEmptyRecord(getContext(), Ty, true) &&
                     !isSingleElementStruct(Ty, getContext());
-  return emitVoidPtrVAArg(CGF, VAListAddr, Ty, IsIndirect,
-                          getContext().getTypeInfoInChars(Ty),
-                          CharUnits::fromQuantity(4),
-                          /*AllowHigherAlign=*/true, Slot);
+  return emitVoidPtrVAArg(
+      CGF, VAListAddr, Ty, IsIndirect, getContext().getTypeInfoInChars(Ty),
+      CharUnits::fromQuantity(
+          getContext().getTargetInfo().getTriple().isArch64Bit() ? 8 : 4),
+      /*AllowHigherAlign=*/true, Slot);
 }
 
 std::unique_ptr<TargetCodeGenInfo>



More information about the cfe-commits mailing list