[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-12-16 Thread via cfe-commits

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


[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-12-16 Thread via cfe-commits


@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -fenable-matrix -std=c++11 -verify %s
+// expected-no-diagnostics
+
+template 
+void f() {
+  T().~T();
+}
+
+template 
+void f1(T *f) {

Sirraide wrote:

#120167

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


[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-12-16 Thread via cfe-commits

https://github.com/Sirraide updated 
https://github.com/llvm/llvm-project/pull/117483

>From 4eff78b4f8404217cecf254227bc79dcc11d2f36 Mon Sep 17 00:00:00 2001
From: Sirraide 
Date: Sun, 24 Nov 2024 13:43:02 +0100
Subject: [PATCH 1/4] [Clang] [Sema] Support matrix types in pseudo-destructor
 expressions

---
 clang/docs/ReleaseNotes.rst   |  3 +++
 clang/lib/Sema/SemaExprCXX.cpp|  2 +-
 .../matrix-types-pseudo-destructor.cpp| 19 +++
 3 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8bd06fadfdc984..ad3c0d3e67f031 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -371,6 +371,9 @@ Non-comprehensive list of changes in this release
 - ``__builtin_reduce_and`` function can now be used in constant expressions.
 - ``__builtin_reduce_or`` and ``__builtin_reduce_xor`` functions can now be 
used in constant expressions.
 
+- Matrix types (a Clang extension) can now be used in pseudo-destructor 
expressions,
+  which allows them to be stored in STL containers.
+
 New Compiler Flags
 --
 
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index d85819b21c8265..d440755ee70665 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -8189,7 +8189,7 @@ ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base,
 return ExprError();
 
   if (!ObjectType->isDependentType() && !ObjectType->isScalarType() &&
-  !ObjectType->isVectorType()) {
+  !ObjectType->isVectorType() && !ObjectType->isMatrixType()) {
 if (getLangOpts().MSVCCompat && ObjectType->isVoidType())
   Diag(OpLoc, diag::ext_pseudo_dtor_on_void) << Base->getSourceRange();
 else {
diff --git a/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp 
b/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp
new file mode 100644
index 00..f0ee953ad2557c
--- /dev/null
+++ b/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -fenable-matrix -std=c++11 -verify %s
+// expected-no-diagnostics
+
+template 
+void f() {
+  T().~T();
+}
+
+using mat4 = float __attribute__((matrix_type(4, 4)));
+using mat4i = int __attribute__((matrix_type(4, 4)));
+
+template 
+using mat4_t = T __attribute__((matrix_type(4, 4)));
+
+void g() {
+  f();
+  f();
+  f>();
+}

>From 748f28ec638d5344c7e83dd42cc7945fa58d2341 Mon Sep 17 00:00:00 2001
From: Sirraide 
Date: Wed, 4 Dec 2024 09:44:28 +0100
Subject: [PATCH 2/4] Add some codegen tests

---
 clang/test/CodeGenCXX/matrix-type.cpp | 33 +++
 1 file changed, 33 insertions(+)

diff --git a/clang/test/CodeGenCXX/matrix-type.cpp 
b/clang/test/CodeGenCXX/matrix-type.cpp
index 1a5e5dba2978c8..c3a299e7feee82 100644
--- a/clang/test/CodeGenCXX/matrix-type.cpp
+++ b/clang/test/CodeGenCXX/matrix-type.cpp
@@ -368,3 +368,36 @@ void test_use_matrix_2() {
 
   selector<2> r5 = use_matrix_3(m1);
 }
+
+// CHECK-LABEL: define void @_Z22test_pseudo_destructorv()
+// CHECK-NEXT: entry:
+// CHECK-NEXT:   %a = alloca [25 x double], align 8
+// CHECK-NEXT:   %b = alloca [12 x float], align 4
+// CHECK-NEXT:   %0 = load <25 x double>, ptr %a, align 8
+// CHECK-NEXT:   call void 
@_Z17pseudo_destructorIu11matrix_typeILm5ELm5EdEEvT_(<25 x double> %0)
+// CHECK-NEXT:   %1 = load <12 x float>, ptr %b, align 4
+// CHECK-NEXT:   call void 
@_Z17pseudo_destructorIu11matrix_typeILm3ELm4EfEEvT_(<12 x float> %1)
+// CHECK-NEXT:   ret void
+
+// CHECK-LABEL: define linkonce_odr void 
@_Z17pseudo_destructorIu11matrix_typeILm5ELm5EdEEvT_(<25 x double> %t)
+// CHECK-NEXT: entry:
+// CHECK-NEXT:   %t.addr = alloca [25 x double], align 8
+// CHECK-NEXT:   store <25 x double> %t, ptr %t.addr, align 8
+// CHECK-NEXT:   ret void
+
+// CHECK-LABEL: define linkonce_odr void 
@_Z17pseudo_destructorIu11matrix_typeILm3ELm4EfEEvT_(<12 x float> %t)
+// CHECK-NEXT: entry:
+// CHECK-NEXT:   %t.addr = alloca [12 x float], align 4
+// CHECK-NEXT:   store <12 x float> %t, ptr %t.addr, align 4
+// CHECK-NEXT:   ret void
+template 
+void pseudo_destructor(T t) {
+  t.~T();
+}
+
+void test_pseudo_destructor() {
+  dx5x5_t a;
+  fx3x4_t b;
+  pseudo_destructor(a);
+  pseudo_destructor(b);
+}

>From 91c768d80f9b4736360656f45c7beb6653d90e9a Mon Sep 17 00:00:00 2001
From: Sirraide 
Date: Wed, 4 Dec 2024 09:51:06 +0100
Subject: [PATCH 3/4] Add more sema tests

---
 .../test/SemaCXX/matrix-types-pseudo-destructor.cpp  | 12 
 1 file changed, 12 insertions(+)

diff --git a/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp 
b/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp
index f0ee953ad2557c..86fef1338955e1 100644
--- a/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp
+++ b/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp
@@ -6,6 +6,12 @@ void f() {
   T().~T();
 }
 
+tem

[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-12-16 Thread via cfe-commits


@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -fenable-matrix -std=c++11 -verify %s
+// expected-no-diagnostics
+
+template 
+void f() {
+  T().~T();
+}
+
+template 
+void f1(T *f) {

Sirraide wrote:

Well, it turns out we currently don’t support matrix types in constant 
expressions, so, er, I’ll open a separate issue about that.

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


[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-12-04 Thread via cfe-commits


@@ -368,3 +368,36 @@ void test_use_matrix_2() {
 
   selector<2> r5 = use_matrix_3(m1);
 }
+
+// CHECK-LABEL: define void @_Z22test_pseudo_destructorv()
+// CHECK-NEXT: entry:
+// CHECK-NEXT:   %a = alloca [25 x double], align 8

Sirraide wrote:

> I see the rest of the test doesn't

This is generally my excuse for not using `[[]]` because it’s a bit tedious to 
do that if there are a lot of tests ;Þ

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


[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-12-04 Thread Aaron Ballman via cfe-commits


@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -fenable-matrix -std=c++11 -verify %s
+// expected-no-diagnostics
+
+template 
+void f() {
+  T().~T();
+}
+
+template 
+void f1(T *f) {

AaronBallman wrote:

Should we have a `constexpr` test to ensure that this noop works fine in a 
constant expression too?

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


[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-12-04 Thread Erich Keane via cfe-commits


@@ -368,3 +368,36 @@ void test_use_matrix_2() {
 
   selector<2> r5 = use_matrix_3(m1);
 }
+
+// CHECK-LABEL: define void @_Z22test_pseudo_destructorv()
+// CHECK-NEXT: entry:
+// CHECK-NEXT:   %a = alloca [25 x double], align 8

erichkeane wrote:

I'm kinda sad/kinda glad that the bot went away.  The strip-names bot always 
caught people doing this :D 

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


[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-12-04 Thread Erich Keane via cfe-commits

https://github.com/erichkeane approved this pull request.


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


[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-12-04 Thread Erich Keane via cfe-commits


@@ -368,3 +368,36 @@ void test_use_matrix_2() {
 
   selector<2> r5 = use_matrix_3(m1);
 }
+
+// CHECK-LABEL: define void @_Z22test_pseudo_destructorv()
+// CHECK-NEXT: entry:
+// CHECK-NEXT:   %a = alloca [25 x double], align 8

erichkeane wrote:

probably want to use matches/etc for the local variables here, they aren't 
reliable (the %a, %b, %0, and %1).  Though, I see the rest of the test doesn't, 
so everyone will be burned if someone runs them with the 'strip names' flag :D 

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


[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-12-04 Thread via cfe-commits


@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -fenable-matrix -std=c++11 -verify %s
+// expected-no-diagnostics
+
+template 
+void f() {
+  T().~T();
+}
+
+template 
+void f1(T *f) {

Sirraide wrote:

Probably a good idea

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


[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-12-04 Thread via cfe-commits


@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -fenable-matrix -std=c++11 -verify %s

Sirraide wrote:

I think I copied that from one of the other tests, but I don’t think it’s 
needed; I’ll remove it

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


[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-12-04 Thread Aaron Ballman via cfe-commits


@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -fenable-matrix -std=c++11 -verify %s

AaronBallman wrote:

Does this need to be in C++11 mode explicitly?

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


[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-12-04 Thread via cfe-commits


@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -fenable-matrix -std=c++11 -verify %s
+// expected-no-diagnostics
+
+template 
+void f() {
+  T().~T();
+}

Sirraide wrote:

Added a test for this too

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


[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-12-04 Thread via cfe-commits

https://github.com/Sirraide updated 
https://github.com/llvm/llvm-project/pull/117483

>From 4eff78b4f8404217cecf254227bc79dcc11d2f36 Mon Sep 17 00:00:00 2001
From: Sirraide 
Date: Sun, 24 Nov 2024 13:43:02 +0100
Subject: [PATCH 1/3] [Clang] [Sema] Support matrix types in pseudo-destructor
 expressions

---
 clang/docs/ReleaseNotes.rst   |  3 +++
 clang/lib/Sema/SemaExprCXX.cpp|  2 +-
 .../matrix-types-pseudo-destructor.cpp| 19 +++
 3 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8bd06fadfdc984..ad3c0d3e67f031 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -371,6 +371,9 @@ Non-comprehensive list of changes in this release
 - ``__builtin_reduce_and`` function can now be used in constant expressions.
 - ``__builtin_reduce_or`` and ``__builtin_reduce_xor`` functions can now be 
used in constant expressions.
 
+- Matrix types (a Clang extension) can now be used in pseudo-destructor 
expressions,
+  which allows them to be stored in STL containers.
+
 New Compiler Flags
 --
 
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index d85819b21c8265..d440755ee70665 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -8189,7 +8189,7 @@ ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base,
 return ExprError();
 
   if (!ObjectType->isDependentType() && !ObjectType->isScalarType() &&
-  !ObjectType->isVectorType()) {
+  !ObjectType->isVectorType() && !ObjectType->isMatrixType()) {
 if (getLangOpts().MSVCCompat && ObjectType->isVoidType())
   Diag(OpLoc, diag::ext_pseudo_dtor_on_void) << Base->getSourceRange();
 else {
diff --git a/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp 
b/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp
new file mode 100644
index 00..f0ee953ad2557c
--- /dev/null
+++ b/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -fenable-matrix -std=c++11 -verify %s
+// expected-no-diagnostics
+
+template 
+void f() {
+  T().~T();
+}
+
+using mat4 = float __attribute__((matrix_type(4, 4)));
+using mat4i = int __attribute__((matrix_type(4, 4)));
+
+template 
+using mat4_t = T __attribute__((matrix_type(4, 4)));
+
+void g() {
+  f();
+  f();
+  f>();
+}

>From 748f28ec638d5344c7e83dd42cc7945fa58d2341 Mon Sep 17 00:00:00 2001
From: Sirraide 
Date: Wed, 4 Dec 2024 09:44:28 +0100
Subject: [PATCH 2/3] Add some codegen tests

---
 clang/test/CodeGenCXX/matrix-type.cpp | 33 +++
 1 file changed, 33 insertions(+)

diff --git a/clang/test/CodeGenCXX/matrix-type.cpp 
b/clang/test/CodeGenCXX/matrix-type.cpp
index 1a5e5dba2978c8..c3a299e7feee82 100644
--- a/clang/test/CodeGenCXX/matrix-type.cpp
+++ b/clang/test/CodeGenCXX/matrix-type.cpp
@@ -368,3 +368,36 @@ void test_use_matrix_2() {
 
   selector<2> r5 = use_matrix_3(m1);
 }
+
+// CHECK-LABEL: define void @_Z22test_pseudo_destructorv()
+// CHECK-NEXT: entry:
+// CHECK-NEXT:   %a = alloca [25 x double], align 8
+// CHECK-NEXT:   %b = alloca [12 x float], align 4
+// CHECK-NEXT:   %0 = load <25 x double>, ptr %a, align 8
+// CHECK-NEXT:   call void 
@_Z17pseudo_destructorIu11matrix_typeILm5ELm5EdEEvT_(<25 x double> %0)
+// CHECK-NEXT:   %1 = load <12 x float>, ptr %b, align 4
+// CHECK-NEXT:   call void 
@_Z17pseudo_destructorIu11matrix_typeILm3ELm4EfEEvT_(<12 x float> %1)
+// CHECK-NEXT:   ret void
+
+// CHECK-LABEL: define linkonce_odr void 
@_Z17pseudo_destructorIu11matrix_typeILm5ELm5EdEEvT_(<25 x double> %t)
+// CHECK-NEXT: entry:
+// CHECK-NEXT:   %t.addr = alloca [25 x double], align 8
+// CHECK-NEXT:   store <25 x double> %t, ptr %t.addr, align 8
+// CHECK-NEXT:   ret void
+
+// CHECK-LABEL: define linkonce_odr void 
@_Z17pseudo_destructorIu11matrix_typeILm3ELm4EfEEvT_(<12 x float> %t)
+// CHECK-NEXT: entry:
+// CHECK-NEXT:   %t.addr = alloca [12 x float], align 4
+// CHECK-NEXT:   store <12 x float> %t, ptr %t.addr, align 4
+// CHECK-NEXT:   ret void
+template 
+void pseudo_destructor(T t) {
+  t.~T();
+}
+
+void test_pseudo_destructor() {
+  dx5x5_t a;
+  fx3x4_t b;
+  pseudo_destructor(a);
+  pseudo_destructor(b);
+}

>From 91c768d80f9b4736360656f45c7beb6653d90e9a Mon Sep 17 00:00:00 2001
From: Sirraide 
Date: Wed, 4 Dec 2024 09:51:06 +0100
Subject: [PATCH 3/3] Add more sema tests

---
 .../test/SemaCXX/matrix-types-pseudo-destructor.cpp  | 12 
 1 file changed, 12 insertions(+)

diff --git a/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp 
b/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp
index f0ee953ad2557c..86fef1338955e1 100644
--- a/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp
+++ b/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp
@@ -6,6 +6,12 @@ void f() {
   T().~T();
 }
 
+tem

[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-12-04 Thread via cfe-commits

Sirraide wrote:

> I definitely agree with a need to test this/validate codegen to make sure the 
> destruciton 'looks' reasonable.

Done.

(And while adding the tests, I also discovered an unrelated bug: #118604)

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


[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-12-04 Thread via cfe-commits

https://github.com/Sirraide updated 
https://github.com/llvm/llvm-project/pull/117483

>From 4eff78b4f8404217cecf254227bc79dcc11d2f36 Mon Sep 17 00:00:00 2001
From: Sirraide 
Date: Sun, 24 Nov 2024 13:43:02 +0100
Subject: [PATCH 1/2] [Clang] [Sema] Support matrix types in pseudo-destructor
 expressions

---
 clang/docs/ReleaseNotes.rst   |  3 +++
 clang/lib/Sema/SemaExprCXX.cpp|  2 +-
 .../matrix-types-pseudo-destructor.cpp| 19 +++
 3 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8bd06fadfdc984..ad3c0d3e67f031 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -371,6 +371,9 @@ Non-comprehensive list of changes in this release
 - ``__builtin_reduce_and`` function can now be used in constant expressions.
 - ``__builtin_reduce_or`` and ``__builtin_reduce_xor`` functions can now be 
used in constant expressions.
 
+- Matrix types (a Clang extension) can now be used in pseudo-destructor 
expressions,
+  which allows them to be stored in STL containers.
+
 New Compiler Flags
 --
 
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index d85819b21c8265..d440755ee70665 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -8189,7 +8189,7 @@ ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base,
 return ExprError();
 
   if (!ObjectType->isDependentType() && !ObjectType->isScalarType() &&
-  !ObjectType->isVectorType()) {
+  !ObjectType->isVectorType() && !ObjectType->isMatrixType()) {
 if (getLangOpts().MSVCCompat && ObjectType->isVoidType())
   Diag(OpLoc, diag::ext_pseudo_dtor_on_void) << Base->getSourceRange();
 else {
diff --git a/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp 
b/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp
new file mode 100644
index 00..f0ee953ad2557c
--- /dev/null
+++ b/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -fenable-matrix -std=c++11 -verify %s
+// expected-no-diagnostics
+
+template 
+void f() {
+  T().~T();
+}
+
+using mat4 = float __attribute__((matrix_type(4, 4)));
+using mat4i = int __attribute__((matrix_type(4, 4)));
+
+template 
+using mat4_t = T __attribute__((matrix_type(4, 4)));
+
+void g() {
+  f();
+  f();
+  f>();
+}

>From 748f28ec638d5344c7e83dd42cc7945fa58d2341 Mon Sep 17 00:00:00 2001
From: Sirraide 
Date: Wed, 4 Dec 2024 09:44:28 +0100
Subject: [PATCH 2/2] Add some codegen tests

---
 clang/test/CodeGenCXX/matrix-type.cpp | 33 +++
 1 file changed, 33 insertions(+)

diff --git a/clang/test/CodeGenCXX/matrix-type.cpp 
b/clang/test/CodeGenCXX/matrix-type.cpp
index 1a5e5dba2978c8..c3a299e7feee82 100644
--- a/clang/test/CodeGenCXX/matrix-type.cpp
+++ b/clang/test/CodeGenCXX/matrix-type.cpp
@@ -368,3 +368,36 @@ void test_use_matrix_2() {
 
   selector<2> r5 = use_matrix_3(m1);
 }
+
+// CHECK-LABEL: define void @_Z22test_pseudo_destructorv()
+// CHECK-NEXT: entry:
+// CHECK-NEXT:   %a = alloca [25 x double], align 8
+// CHECK-NEXT:   %b = alloca [12 x float], align 4
+// CHECK-NEXT:   %0 = load <25 x double>, ptr %a, align 8
+// CHECK-NEXT:   call void 
@_Z17pseudo_destructorIu11matrix_typeILm5ELm5EdEEvT_(<25 x double> %0)
+// CHECK-NEXT:   %1 = load <12 x float>, ptr %b, align 4
+// CHECK-NEXT:   call void 
@_Z17pseudo_destructorIu11matrix_typeILm3ELm4EfEEvT_(<12 x float> %1)
+// CHECK-NEXT:   ret void
+
+// CHECK-LABEL: define linkonce_odr void 
@_Z17pseudo_destructorIu11matrix_typeILm5ELm5EdEEvT_(<25 x double> %t)
+// CHECK-NEXT: entry:
+// CHECK-NEXT:   %t.addr = alloca [25 x double], align 8
+// CHECK-NEXT:   store <25 x double> %t, ptr %t.addr, align 8
+// CHECK-NEXT:   ret void
+
+// CHECK-LABEL: define linkonce_odr void 
@_Z17pseudo_destructorIu11matrix_typeILm3ELm4EfEEvT_(<12 x float> %t)
+// CHECK-NEXT: entry:
+// CHECK-NEXT:   %t.addr = alloca [12 x float], align 4
+// CHECK-NEXT:   store <12 x float> %t, ptr %t.addr, align 4
+// CHECK-NEXT:   ret void
+template 
+void pseudo_destructor(T t) {
+  t.~T();
+}
+
+void test_pseudo_destructor() {
+  dx5x5_t a;
+  fx3x4_t b;
+  pseudo_destructor(a);
+  pseudo_destructor(b);
+}

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


[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-11-25 Thread Erich Keane via cfe-commits

https://github.com/erichkeane commented:

I've got no problem with this, but I definitely agree with a need to test 
this/validate codegen to make sure the destruciton 'looks' reasonable.

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


[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-11-25 Thread via cfe-commits

Sirraide wrote:

> Does it make sense to add a sanity test for codegen?

Probably; good idea

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


[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-11-25 Thread Mariya Podchishchaeva via cfe-commits

https://github.com/Fznamznon commented:

This looks reasonable.
Does it make sense to add a sanity test for codegen? I.e. so there is no 
crashes/assertions and no attempts to generate anything

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


[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-11-25 Thread Mariya Podchishchaeva via cfe-commits


@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -fenable-matrix -std=c++11 -verify %s
+// expected-no-diagnostics
+
+template 
+void f() {
+  T().~T();
+}

Fznamznon wrote:

Does that work too?
```
template 
void f1(T *f) {
  T->~T();
  (*T).~T();
}
void test(mat4 *m) {
 f1(m);
}
```

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


[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-11-25 Thread Mariya Podchishchaeva via cfe-commits

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


[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-11-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (Sirraide)


Changes

We already support vector types, and since matrix element types have to be 
scalar types, there should be no problem w/ just enabling this. 

This now also allows matrix types to be stored in STL containers.

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


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+3) 
- (modified) clang/lib/Sema/SemaExprCXX.cpp (+1-1) 
- (added) clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp (+19) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8bd06fadfdc984..ad3c0d3e67f031 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -371,6 +371,9 @@ Non-comprehensive list of changes in this release
 - ``__builtin_reduce_and`` function can now be used in constant expressions.
 - ``__builtin_reduce_or`` and ``__builtin_reduce_xor`` functions can now be 
used in constant expressions.
 
+- Matrix types (a Clang extension) can now be used in pseudo-destructor 
expressions,
+  which allows them to be stored in STL containers.
+
 New Compiler Flags
 --
 
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index d85819b21c8265..d440755ee70665 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -8189,7 +8189,7 @@ ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base,
 return ExprError();
 
   if (!ObjectType->isDependentType() && !ObjectType->isScalarType() &&
-  !ObjectType->isVectorType()) {
+  !ObjectType->isVectorType() && !ObjectType->isMatrixType()) {
 if (getLangOpts().MSVCCompat && ObjectType->isVoidType())
   Diag(OpLoc, diag::ext_pseudo_dtor_on_void) << Base->getSourceRange();
 else {
diff --git a/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp 
b/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp
new file mode 100644
index 00..f0ee953ad2557c
--- /dev/null
+++ b/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -fenable-matrix -std=c++11 -verify %s
+// expected-no-diagnostics
+
+template 
+void f() {
+  T().~T();
+}
+
+using mat4 = float __attribute__((matrix_type(4, 4)));
+using mat4i = int __attribute__((matrix_type(4, 4)));
+
+template 
+using mat4_t = T __attribute__((matrix_type(4, 4)));
+
+void g() {
+  f();
+  f();
+  f>();
+}

``




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


[clang] [Clang] [Sema] Support matrix types in pseudo-destructor expressions (PR #117483)

2024-11-24 Thread via cfe-commits

https://github.com/Sirraide created 
https://github.com/llvm/llvm-project/pull/117483

We already support vector types, and since matrix element types have to be 
scalar types, there should be no problem w/ just enabling this. 

This now also allows matrix types to be stored in STL containers.

>From 4eff78b4f8404217cecf254227bc79dcc11d2f36 Mon Sep 17 00:00:00 2001
From: Sirraide 
Date: Sun, 24 Nov 2024 13:43:02 +0100
Subject: [PATCH] [Clang] [Sema] Support matrix types in pseudo-destructor
 expressions

---
 clang/docs/ReleaseNotes.rst   |  3 +++
 clang/lib/Sema/SemaExprCXX.cpp|  2 +-
 .../matrix-types-pseudo-destructor.cpp| 19 +++
 3 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8bd06fadfdc984..ad3c0d3e67f031 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -371,6 +371,9 @@ Non-comprehensive list of changes in this release
 - ``__builtin_reduce_and`` function can now be used in constant expressions.
 - ``__builtin_reduce_or`` and ``__builtin_reduce_xor`` functions can now be 
used in constant expressions.
 
+- Matrix types (a Clang extension) can now be used in pseudo-destructor 
expressions,
+  which allows them to be stored in STL containers.
+
 New Compiler Flags
 --
 
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index d85819b21c8265..d440755ee70665 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -8189,7 +8189,7 @@ ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base,
 return ExprError();
 
   if (!ObjectType->isDependentType() && !ObjectType->isScalarType() &&
-  !ObjectType->isVectorType()) {
+  !ObjectType->isVectorType() && !ObjectType->isMatrixType()) {
 if (getLangOpts().MSVCCompat && ObjectType->isVoidType())
   Diag(OpLoc, diag::ext_pseudo_dtor_on_void) << Base->getSourceRange();
 else {
diff --git a/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp 
b/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp
new file mode 100644
index 00..f0ee953ad2557c
--- /dev/null
+++ b/clang/test/SemaCXX/matrix-types-pseudo-destructor.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -fenable-matrix -std=c++11 -verify %s
+// expected-no-diagnostics
+
+template 
+void f() {
+  T().~T();
+}
+
+using mat4 = float __attribute__((matrix_type(4, 4)));
+using mat4i = int __attribute__((matrix_type(4, 4)));
+
+template 
+using mat4_t = T __attribute__((matrix_type(4, 4)));
+
+void g() {
+  f();
+  f();
+  f>();
+}

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