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

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-webassembly

@llvm/pr-subscribers-clang

Author: None (daxpedda)

<details>
<summary>Changes</summary>

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.

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


1 Files Affected:

- (modified) clang/lib/CodeGen/Targets/WebAssembly.cpp (+5-4) 


``````````diff
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>

``````````

</details>


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


More information about the cfe-commits mailing list