[clang] [clang][wasm] Resolve assertion errors caused by converting ComplexTy… (PR #70496)

2023-10-27 Thread via cfe-commits

https://github.com/knightXun created 
https://github.com/llvm/llvm-project/pull/70496

When a function parameter is of the built-in Complex type in Clang, the 
conversion from ComplexType to RecordType is not possible, resulting in a crash 
in Clang. RecordType is a helper class for structs, unions, and classes.

https://github.com/llvm/llvm-project/issues/70402

>From 1917fd0fe837b92e7f66c3c08c9d9cf3e69b9a07 Mon Sep 17 00:00:00 2001
From: xuknight 
Date: Sat, 28 Oct 2023 02:52:43 +0800
Subject: [PATCH] [clang][wasm] Resolve assertion errors caused by converting
 ComplexType to RecordType

When a function parameter is of the built-in Complex type in Clang,
the conversion from ComplexType to RecordType is not possible, resulting in a 
crash in Clang.
RecordType is a helper class for structs, unions, and classes.
---
 clang/lib/CodeGen/Targets/WebAssembly.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/lib/CodeGen/Targets/WebAssembly.cpp 
b/clang/lib/CodeGen/Targets/WebAssembly.cpp
index bd332228ce5bbe6..9c222c3e91a1867 100644
--- a/clang/lib/CodeGen/Targets/WebAssembly.cpp
+++ b/clang/lib/CodeGen/Targets/WebAssembly.cpp
@@ -114,6 +114,9 @@ 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) {
+  if (Ty->isComplexType()) {
+return ABIArgInfo::getDirect();
+  }
   const RecordType *RT = Ty->getAs();
   assert(RT);
   bool HasBitField = false;

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


[clang] [clang][wasm] Resolve assertion errors caused by converting ComplexTy… (PR #70496)

2023-10-27 Thread via cfe-commits

https://github.com/knightXun updated 
https://github.com/llvm/llvm-project/pull/70496

>From e0ce1bab37de863d32d5d2e9b97f8bc345ef9ad9 Mon Sep 17 00:00:00 2001
From: xuknight 
Date: Sat, 28 Oct 2023 02:52:43 +0800
Subject: [PATCH] [clang][wasm] Resolve assertion errors caused by converting
 ComplexType to RecordType

When a function parameter is of the built-in Complex type in Clang,
the conversion from ComplexType to RecordType is not possible, resulting in a 
crash in Clang.
RecordType is a helper class for structs, unions, and classes.
---
 clang/lib/CodeGen/Targets/WebAssembly.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/lib/CodeGen/Targets/WebAssembly.cpp 
b/clang/lib/CodeGen/Targets/WebAssembly.cpp
index bd332228ce5bbe6..b3f6473eb9bc74c 100644
--- a/clang/lib/CodeGen/Targets/WebAssembly.cpp
+++ b/clang/lib/CodeGen/Targets/WebAssembly.cpp
@@ -114,6 +114,9 @@ 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) {
+  if (Ty->getAs()) {
+return ABIArgInfo::getDirect();
+  }
   const RecordType *RT = Ty->getAs();
   assert(RT);
   bool HasBitField = false;

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


[clang] [clang][wasm] Resolve assertion errors caused by converting ComplexTy… (PR #70496)

2023-12-11 Thread via cfe-commits

knightXun wrote:

cc @Endilll @cor3ntin 

https://github.com/llvm/llvm-project/pull/70496
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][wasm] Resolve assertion errors caused by converting ComplexTy… (PR #70496)

2023-12-14 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

Can you add a test for this?

https://github.com/llvm/llvm-project/pull/70496
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][wasm] Resolve assertion errors caused by converting ComplexTy… (PR #70496)

2023-12-14 Thread via cfe-commits

knightXun wrote:

> Can you add a test for this?

oh, I'll write one.

https://github.com/llvm/llvm-project/pull/70496
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][wasm] Resolve assertion errors caused by converting ComplexTy… (PR #70496)

2023-12-14 Thread via cfe-commits

https://github.com/knightXun updated 
https://github.com/llvm/llvm-project/pull/70496

>From e0ce1bab37de863d32d5d2e9b97f8bc345ef9ad9 Mon Sep 17 00:00:00 2001
From: xuknight 
Date: Sat, 28 Oct 2023 02:52:43 +0800
Subject: [PATCH 1/2] [clang][wasm] Resolve assertion errors caused by
 converting ComplexType to RecordType

When a function parameter is of the built-in Complex type in Clang,
the conversion from ComplexType to RecordType is not possible, resulting in a 
crash in Clang.
RecordType is a helper class for structs, unions, and classes.
---
 clang/lib/CodeGen/Targets/WebAssembly.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/lib/CodeGen/Targets/WebAssembly.cpp 
b/clang/lib/CodeGen/Targets/WebAssembly.cpp
index bd332228ce5bbe..b3f6473eb9bc74 100644
--- a/clang/lib/CodeGen/Targets/WebAssembly.cpp
+++ b/clang/lib/CodeGen/Targets/WebAssembly.cpp
@@ -114,6 +114,9 @@ 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) {
+  if (Ty->getAs()) {
+return ABIArgInfo::getDirect();
+  }
   const RecordType *RT = Ty->getAs();
   assert(RT);
   bool HasBitField = false;

>From 9916e4e446f7e92f385ca49d6f0031f48350b767 Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Thu, 14 Dec 2023 21:25:14 +0800
Subject: [PATCH 2/2] add test case for pr70496

---
 clang/test/CodeGen/pr70496.c | 9 +
 1 file changed, 9 insertions(+)
 create mode 100644 clang/test/CodeGen/pr70496.c

diff --git a/clang/test/CodeGen/pr70496.c b/clang/test/CodeGen/pr70496.c
new file mode 100644
index 00..5075b1ae91a704
--- /dev/null
+++ b/clang/test/CodeGen/pr70496.c
@@ -0,0 +1,9 @@
+// RUN: %clang --target=wasm32 -mmultivalue -Xclang -target-abi -Xclang 
experimental-mv %s -Xclang -verify
+
+float crealf() { return 0;} // expected-no-diagnostics
+
+float cimagf() { return 0;} // expected-no-diagnostics
+
+float a(float _Complex b) { return 0;} // expected-no-diagnostics
+
+float b(float _Complex c, float _Complex d) { return 0;} // 
expected-no-diagnostics
\ No newline at end of file

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


[clang] [clang][wasm] Resolve assertion errors caused by converting ComplexTy… (PR #70496)

2023-12-14 Thread via cfe-commits

https://github.com/knightXun updated 
https://github.com/llvm/llvm-project/pull/70496

>From e09d1b428f0c3836e2b92df3c994375f4c946302 Mon Sep 17 00:00:00 2001
From: xuknight 
Date: Sat, 28 Oct 2023 02:52:43 +0800
Subject: [PATCH] [clang][wasm] Resolve assertion errors caused by converting
 ComplexType to RecordType

When a function parameter is of the built-in Complex type in Clang,
the conversion from ComplexType to RecordType is not possible, resulting in a 
crash in Clang.
RecordType is a helper class for structs, unions, and classes.
---
 clang/lib/CodeGen/Targets/WebAssembly.cpp | 3 +++
 clang/test/CodeGen/pr70496.c  | 9 +
 2 files changed, 12 insertions(+)
 create mode 100644 clang/test/CodeGen/pr70496.c

diff --git a/clang/lib/CodeGen/Targets/WebAssembly.cpp 
b/clang/lib/CodeGen/Targets/WebAssembly.cpp
index bd332228ce5bbe..b3f6473eb9bc74 100644
--- a/clang/lib/CodeGen/Targets/WebAssembly.cpp
+++ b/clang/lib/CodeGen/Targets/WebAssembly.cpp
@@ -114,6 +114,9 @@ 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) {
+  if (Ty->getAs()) {
+return ABIArgInfo::getDirect();
+  }
   const RecordType *RT = Ty->getAs();
   assert(RT);
   bool HasBitField = false;
diff --git a/clang/test/CodeGen/pr70496.c b/clang/test/CodeGen/pr70496.c
new file mode 100644
index 00..9eeef7b254d8cb
--- /dev/null
+++ b/clang/test/CodeGen/pr70496.c
@@ -0,0 +1,9 @@
+// RUN: %clang --target=wasm32 -mmultivalue -Xclang -target-abi -Xclang 
experimental-mv %s -S -Xclang -verify
+
+float crealf() { return 0;} // expected-no-diagnostics
+
+float cimagf() { return 0;} // expected-no-diagnostics
+
+float a(float _Complex b) { return 0;} // expected-no-diagnostics
+
+float b(float _Complex c, float _Complex d) { return 0;} // 
expected-no-diagnostics
\ No newline at end of file

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


[clang] [clang][wasm] Resolve assertion errors caused by converting ComplexTy… (PR #70496)

2023-12-15 Thread Vlad Serebrennikov via cfe-commits


@@ -0,0 +1,9 @@
+// RUN: %clang --target=wasm32 -mmultivalue -Xclang -target-abi -Xclang 
experimental-mv %s -S -Xclang -verify
+
+float crealf() { return 0;} // expected-no-diagnostics

Endilll wrote:

Single `expected-no-diagnostics` is sufficient for the whole file

https://github.com/llvm/llvm-project/pull/70496
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][wasm] Resolve assertion errors caused by converting ComplexTy… (PR #70496)

2023-12-15 Thread via cfe-commits


@@ -0,0 +1,9 @@
+// RUN: %clang --target=wasm32 -mmultivalue -Xclang -target-abi -Xclang 
experimental-mv %s -S -Xclang -verify
+
+float crealf() { return 0;} // expected-no-diagnostics

knightXun wrote:

ok, nice hit!

https://github.com/llvm/llvm-project/pull/70496
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][wasm] Resolve assertion errors caused by converting ComplexTy… (PR #70496)

2023-12-15 Thread via cfe-commits

https://github.com/knightXun updated 
https://github.com/llvm/llvm-project/pull/70496

>From d51afcd3e8f41bcf94259561e71fd10628fc78c3 Mon Sep 17 00:00:00 2001
From: xuknight 
Date: Sat, 28 Oct 2023 02:52:43 +0800
Subject: [PATCH] [clang][wasm] Resolve assertion errors caused by converting
 ComplexType to RecordType

When a function parameter is of the built-in Complex type in Clang,
the conversion from ComplexType to RecordType is not possible, resulting in a 
crash in Clang.
RecordType is a helper class for structs, unions, and classes.
---
 clang/lib/CodeGen/Targets/WebAssembly.cpp | 3 +++
 clang/test/CodeGen/pr70496.c  | 3 +++
 2 files changed, 6 insertions(+)
 create mode 100644 clang/test/CodeGen/pr70496.c

diff --git a/clang/lib/CodeGen/Targets/WebAssembly.cpp 
b/clang/lib/CodeGen/Targets/WebAssembly.cpp
index bd332228ce5bbe..b3f6473eb9bc74 100644
--- a/clang/lib/CodeGen/Targets/WebAssembly.cpp
+++ b/clang/lib/CodeGen/Targets/WebAssembly.cpp
@@ -114,6 +114,9 @@ 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) {
+  if (Ty->getAs()) {
+return ABIArgInfo::getDirect();
+  }
   const RecordType *RT = Ty->getAs();
   assert(RT);
   bool HasBitField = false;
diff --git a/clang/test/CodeGen/pr70496.c b/clang/test/CodeGen/pr70496.c
new file mode 100644
index 00..e5abf3e547ac27
--- /dev/null
+++ b/clang/test/CodeGen/pr70496.c
@@ -0,0 +1,3 @@
+// RUN: %clang --target=wasm32 -mmultivalue -Xclang -target-abi -Xclang 
experimental-mv %s -S -Xclang -verify
+
+float crealf() { return 0;} // expected-no-diagnostics
\ No newline at end of file

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


[clang] [clang][wasm] Resolve assertion errors caused by converting ComplexTy… (PR #70496)

2023-12-15 Thread Vlad Serebrennikov via cfe-commits


@@ -0,0 +1,9 @@
+// RUN: %clang --target=wasm32 -mmultivalue -Xclang -target-abi -Xclang 
experimental-mv %s -S -Xclang -verify
+
+float crealf() { return 0;} // expected-no-diagnostics

Endilll wrote:

Sorry, I actually meant that you can do like 
https://github.com/llvm/llvm-project/blob/main/clang/test/CXX/basic/basic.link/p6.cpp
 does, putting `// expected-no-diagnostics` after RUN lines. I didn't mean that 
you should reduce test coverage: I believe you had 4 cases, now you have just 
one.

https://github.com/llvm/llvm-project/pull/70496
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][wasm] Resolve assertion errors caused by converting ComplexTy… (PR #70496)

2023-12-19 Thread John McCall via cfe-commits

rjmccall wrote:

Have you verified that this is actually the ABI you want?  Is there a psABI for 
WASM?

https://github.com/llvm/llvm-project/pull/70496
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits