Author: Alex Crichton Date: 2026-06-04T16:07:20-07:00 New Revision: bb180dd616c61932a0000ff45cd5d69fc1195b87
URL: https://github.com/llvm/llvm-project/commit/bb180dd616c61932a0000ff45cd5d69fc1195b87 DIFF: https://github.com/llvm/llvm-project/commit/bb180dd616c61932a0000ff45cd5d69fc1195b87.diff LOG: [WebAssembly] Fix crash combining complex numbers and multivalue (#200514) This fixes a crash in Clang when the `experimental-mv` ABI is used on WebAssembly targets in conjunction with complex numbers as arguments. There's no strict definition for what the multivalue ABI is at this time, so the main goal is to just not crash for now. Closes #70402 Closes #153567 Added: Modified: clang/lib/CodeGen/Targets/WebAssembly.cpp clang/test/CodeGen/WebAssembly/wasm-arguments.c Removed: ################################################################################ diff --git a/clang/lib/CodeGen/Targets/WebAssembly.cpp b/clang/lib/CodeGen/Targets/WebAssembly.cpp index ebe996a4edd8d..71454982c4f82 100644 --- a/clang/lib/CodeGen/Targets/WebAssembly.cpp +++ b/clang/lib/CodeGen/Targets/WebAssembly.cpp @@ -115,16 +115,20 @@ ABIArgInfo WebAssemblyABIInfo::classifyArgumentType(QualType Ty) const { return ABIArgInfo::getDirect(CGT.ConvertType(QualType(SeltTy, 0))); // For the experimental multivalue ABI, fully expand all other aggregates if (Kind == WebAssemblyABIKind::ExperimentalMV) { - const auto *RD = Ty->castAsRecordDecl(); - bool HasBitField = false; - for (auto *Field : RD->fields()) { - if (Field->isBitField()) { - HasBitField = true; - break; + if (Ty->getAs<ComplexType>()) + return ABIArgInfo::getDirect(); + const auto *RD = Ty->getAsRecordDecl(); + if (RD) { + bool HasBitField = false; + for (auto *Field : RD->fields()) { + if (Field->isBitField()) { + HasBitField = true; + break; + } } + if (!HasBitField) + return ABIArgInfo::getExpand(); } - if (!HasBitField) - return ABIArgInfo::getExpand(); } } diff --git a/clang/test/CodeGen/WebAssembly/wasm-arguments.c b/clang/test/CodeGen/WebAssembly/wasm-arguments.c index a0914fc768809..4bb381ea7b89d 100644 --- a/clang/test/CodeGen/WebAssembly/wasm-arguments.c +++ b/clang/test/CodeGen/WebAssembly/wasm-arguments.c @@ -138,3 +138,13 @@ bitfield1 bitfield_ret(void) { bitfield1 baz; return baz; } + +// Complex numbers are expanded in parameter position for the multivalue +// experimental ABI. + +// WEBASSEMBLY32: define void @complex_double(ptr +// WEBASSEMBLY64: define void @complex_double(ptr +// EXPERIMENTAL-MV: define void @complex_double(double {{.*}}, double {{.*}}) +void complex_double(_Complex double a) { + // .. +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
