Author: Nikita Popov
Date: 2025-07-08T10:20:43+02:00
New Revision: 18f7655178a69daa52f4d4ef56169b90efc7f601

URL: 
https://github.com/llvm/llvm-project/commit/18f7655178a69daa52f4d4ef56169b90efc7f601
DIFF: 
https://github.com/llvm/llvm-project/commit/18f7655178a69daa52f4d4ef56169b90efc7f601.diff

LOG: [Clang][Wasm] Set __float128 alignment to 64 for emscripten (#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

Added: 
    

Modified: 
    clang/lib/Basic/Targets/OSTargets.h
    clang/lib/CodeGen/CodeGenModule.cpp

Removed: 
    


################################################################################
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);


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to