[clang] [Clang][Wasm] Set __float128 alignment to 64 for emscripten (PR #146494)
Nikita Popov via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 1 02:29:05 PDT 2025
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/146494
https://reviews.llvm.org/D104808 set the alignment of long double to 64 bits. This is also the alignment specified in the LLVM data layout. However, the alignment of __float128 was left at 128 bits.
I assume that this was just an oversight, rather than an intentional divergence. The C ABI document currently does not make any statement about `__float128`: https://github.com/WebAssembly/tool-conventions/blob/main/BasicCABI.md
>From 3588d824c944aeaca1e0ce2bd170b60bf08ecad4 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Tue, 1 Jul 2025 10:44:06 +0200
Subject: [PATCH] [Clang][Wasm] Set __float128 alignment to 64 for emscripten
https://reviews.llvm.org/D104808 set the alignment of long double
to 64 bits. This is also the alignment specified in the LLVM data
layout. However, the alignment of __float128 was left at 128 bits.
I assume that this was just an oversight, rather than an intentional
divergence. The C ABI document currently does not make any statement
about `__float128`:
https://github.com/WebAssembly/tool-conventions/blob/main/BasicCABI.md
---
clang/lib/Basic/Targets/OSTargets.h | 1 +
clang/lib/CodeGen/CodeGenModule.cpp | 3 +--
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h
index 5dac699c2bb45..30d861a7ca605 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -1002,6 +1002,7 @@ class LLVM_LIBRARY_VISIBILITY EmscriptenTargetInfo
// Emscripten's ABI is unstable and we may change this back to 128 to match
// the WebAssembly default in the future.
this->LongDoubleAlign = 64;
+ this->Float128Align = 64;
}
};
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index e6d150f7e13d6..c8866f15745c2 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -388,8 +388,7 @@ static void checkDataLayoutConsistency(const TargetInfo &Target,
llvm::Type::getFloatingPointTy(Context, *Target.LongDoubleFormat),
Target.LongDoubleAlign);
}
- // FIXME: Wasm has a mismatch in f128 alignment between Clang and LLVM.
- if (Target.hasFloat128Type() && !Triple.isWasm())
+ if (Target.hasFloat128Type())
Check("__float128", llvm::Type::getFP128Ty(Context), Target.Float128Align);
if (Target.hasIbm128Type())
Check("__ibm128", llvm::Type::getPPC_FP128Ty(Context), Target.Ibm128Align);
More information about the cfe-commits
mailing list