[clang] [clang] Add clang::debug_info_type attribute for bitfields (PR #69104)

2023-10-19 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

@erichkeane I guess you'd be pretty happy if our enums were declared the 
following way:
```cpp
enum E : unsigned _BitInt(4) {
  e0 = 16,
};
```
Then you'd be warned on the spot if you have more values than bits can hold, 
and bit-fields side check would be trivial to implement:
```
:3:8: error: enumerator value evaluates to 16, which cannot be narrowed 
to type 'unsigned _BitInt(4)' [-Wc++11-narrowing]
  e0 = 16,
```
Unfortunately, Clang 14+ is the only major implementation that accepts this: 
https://godbolt.org/z/9rn87d8hc

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


[clang] [Docs][LTO] Updated HowToSubmitABug.rst for LTO crashes (PR #68389)

2023-10-19 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/68389

>From bdf991f4563e3aa840bec35b1678ad4fe8f9fbb6 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Fri, 6 Oct 2023 12:32:24 +0530
Subject: [PATCH 1/2] [Docs][LTO] Update HowToSubmitABug.rst for LTO crashes

---
 llvm/docs/HowToSubmitABug.rst | 51 +++
 1 file changed, 51 insertions(+)

diff --git a/llvm/docs/HowToSubmitABug.rst b/llvm/docs/HowToSubmitABug.rst
index 733dae6c928d098..88f9af44add7c64 100644
--- a/llvm/docs/HowToSubmitABug.rst
+++ b/llvm/docs/HowToSubmitABug.rst
@@ -153,6 +153,57 @@ Please run this, then file a bug with the instructions and 
reduced .bc file
 that bugpoint emits.  If something goes wrong with bugpoint, please submit
 the "foo.bc" file and the option that llc crashes with.
 
+​.. _lto-crash:
+
+LTO bugs
+---
+
+If you find a bug that crashes llvm in LTO phase (by using -flto option),
+compile your source file to a .bc file by passing
+"``-flto -fuse-ld=lld -Wl,-plugin-opt=save-temps``"
+to clang (in addition to the options you already pass). If you are building
+a project, pass the appropriate CFLAGS, CXXFLAG​S and LDFLAGS for example -
+
+.. code-block:: bash
+
+   export CFLAGS="-flto -fuse-ld=lld" CXXFLAGS="-flto -fuse-ld=lld" 
LDFLAGS="-Wl,-plugin-opt=save-temps"
+
+This will generate four intermediate bytecode files:
+
+1. a.out.0.0.preopt.bc  (Before any link-time optimizations (LTO) are 
applied)
+2. a.out.0.2.internalize.bc (After initial optimizations applied)
+3. a.out.0.4.opt.bc (After the more extensive set of optimizations has 
been applied)
+4. a.out.0.5.precodegen.bc  (After LTO but before it's translated into machine 
code)
+
+Once you have these, one of the following commands should fail:
+
+#. ``opt "-passes=lto" a.out.0.0.preopt.bc``
+#. ``opt "-passes=lto" a.out.0.2.internalize.bc``
+#. ``opt "-passes=lto" a.out.0.4.opt.bc``
+#. ``llc a.out.0.5.precodegen.bc``
+
+If one of these do crash, you should be able to reduce
+this with :program:`llvm-reduce`
+command line (use the bc file corresponding to the command above that failed):
+
+#. ``llvm-reduce --test llvm-reduce.sh a.out.0.2.internalize.bc``
+
+An example of ``llvm-reduce.sh`` script
+
+.. code-block:: bash
+
+   $ cat llvm-reduce.sh
+   #!/usr/bin/env bash
+
+   $HOME/llvm/llvm-project/build/bin/opt "-passes=lto" $1 -o temp.bc  2>&1 
| tee err.log
+   grep "It->second == &Insn" err.log
+   exit $?
+
+Here we have grepped the failed assert message.
+
+Please run this, then file a bug with the instructions and reduced .bc file
+that llvm-reduce emits.
+
 .. _miscompiling:
 
 Miscompilations

>From 1823285171ddbefc49065c4995e9c33bee7b952a Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 10:57:25 +0530
Subject: [PATCH 2/2] address review comment

---
 llvm/docs/HowToSubmitABug.rst | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/llvm/docs/HowToSubmitABug.rst b/llvm/docs/HowToSubmitABug.rst
index 88f9af44add7c64..197ed3e0fde6893 100644
--- a/llvm/docs/HowToSubmitABug.rst
+++ b/llvm/docs/HowToSubmitABug.rst
@@ -168,6 +168,12 @@ a project, pass the appropriate CFLAGS, CXXFLAG​S and 
LDFLAGS for example -
 
export CFLAGS="-flto -fuse-ld=lld" CXXFLAGS="-flto -fuse-ld=lld" 
LDFLAGS="-Wl,-plugin-opt=save-temps"
 
+On Windows, you should use lld-link as the linker.
+
+.. code-block:: bash
+
+   export CFLAGS="-flto -fuse-ld=lld-link" CXXFLAGS="-flto -fuse-ld=lld-link" 
LDFLAGS="-Wl,-plugin-opt=save-temps"
+
 This will generate four intermediate bytecode files:
 
 1. a.out.0.0.preopt.bc  (Before any link-time optimizations (LTO) are 
applied)

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


[clang-tools-extra] [Docs][LTO] Updated HowToSubmitABug.rst for LTO crashes (PR #68389)

2023-10-19 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/68389

>From bdf991f4563e3aa840bec35b1678ad4fe8f9fbb6 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Fri, 6 Oct 2023 12:32:24 +0530
Subject: [PATCH 1/3] [Docs][LTO] Update HowToSubmitABug.rst for LTO crashes

---
 llvm/docs/HowToSubmitABug.rst | 51 +++
 1 file changed, 51 insertions(+)

diff --git a/llvm/docs/HowToSubmitABug.rst b/llvm/docs/HowToSubmitABug.rst
index 733dae6c928d098..88f9af44add7c64 100644
--- a/llvm/docs/HowToSubmitABug.rst
+++ b/llvm/docs/HowToSubmitABug.rst
@@ -153,6 +153,57 @@ Please run this, then file a bug with the instructions and 
reduced .bc file
 that bugpoint emits.  If something goes wrong with bugpoint, please submit
 the "foo.bc" file and the option that llc crashes with.
 
+​.. _lto-crash:
+
+LTO bugs
+---
+
+If you find a bug that crashes llvm in LTO phase (by using -flto option),
+compile your source file to a .bc file by passing
+"``-flto -fuse-ld=lld -Wl,-plugin-opt=save-temps``"
+to clang (in addition to the options you already pass). If you are building
+a project, pass the appropriate CFLAGS, CXXFLAG​S and LDFLAGS for example -
+
+.. code-block:: bash
+
+   export CFLAGS="-flto -fuse-ld=lld" CXXFLAGS="-flto -fuse-ld=lld" 
LDFLAGS="-Wl,-plugin-opt=save-temps"
+
+This will generate four intermediate bytecode files:
+
+1. a.out.0.0.preopt.bc  (Before any link-time optimizations (LTO) are 
applied)
+2. a.out.0.2.internalize.bc (After initial optimizations applied)
+3. a.out.0.4.opt.bc (After the more extensive set of optimizations has 
been applied)
+4. a.out.0.5.precodegen.bc  (After LTO but before it's translated into machine 
code)
+
+Once you have these, one of the following commands should fail:
+
+#. ``opt "-passes=lto" a.out.0.0.preopt.bc``
+#. ``opt "-passes=lto" a.out.0.2.internalize.bc``
+#. ``opt "-passes=lto" a.out.0.4.opt.bc``
+#. ``llc a.out.0.5.precodegen.bc``
+
+If one of these do crash, you should be able to reduce
+this with :program:`llvm-reduce`
+command line (use the bc file corresponding to the command above that failed):
+
+#. ``llvm-reduce --test llvm-reduce.sh a.out.0.2.internalize.bc``
+
+An example of ``llvm-reduce.sh`` script
+
+.. code-block:: bash
+
+   $ cat llvm-reduce.sh
+   #!/usr/bin/env bash
+
+   $HOME/llvm/llvm-project/build/bin/opt "-passes=lto" $1 -o temp.bc  2>&1 
| tee err.log
+   grep "It->second == &Insn" err.log
+   exit $?
+
+Here we have grepped the failed assert message.
+
+Please run this, then file a bug with the instructions and reduced .bc file
+that llvm-reduce emits.
+
 .. _miscompiling:
 
 Miscompilations

>From 1823285171ddbefc49065c4995e9c33bee7b952a Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 10:57:25 +0530
Subject: [PATCH 2/3] address review comment

---
 llvm/docs/HowToSubmitABug.rst | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/llvm/docs/HowToSubmitABug.rst b/llvm/docs/HowToSubmitABug.rst
index 88f9af44add7c64..197ed3e0fde6893 100644
--- a/llvm/docs/HowToSubmitABug.rst
+++ b/llvm/docs/HowToSubmitABug.rst
@@ -168,6 +168,12 @@ a project, pass the appropriate CFLAGS, CXXFLAG​S and 
LDFLAGS for example -
 
export CFLAGS="-flto -fuse-ld=lld" CXXFLAGS="-flto -fuse-ld=lld" 
LDFLAGS="-Wl,-plugin-opt=save-temps"
 
+On Windows, you should use lld-link as the linker.
+
+.. code-block:: bash
+
+   export CFLAGS="-flto -fuse-ld=lld-link" CXXFLAGS="-flto -fuse-ld=lld-link" 
LDFLAGS="-Wl,-plugin-opt=save-temps"
+
 This will generate four intermediate bytecode files:
 
 1. a.out.0.0.preopt.bc  (Before any link-time optimizations (LTO) are 
applied)

>From 0e19d37bf4eb9a312b4989fe941837e285f92a97 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 12:29:23 +0530
Subject: [PATCH 3/3] rebase and improve some wording

---
 llvm/docs/HowToSubmitABug.rst | 36 ---
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/llvm/docs/HowToSubmitABug.rst b/llvm/docs/HowToSubmitABug.rst
index 197ed3e0fde6893..7e9ac089a0f70a1 100644
--- a/llvm/docs/HowToSubmitABug.rst
+++ b/llvm/docs/HowToSubmitABug.rst
@@ -158,30 +158,34 @@ the "foo.bc" file and the option that llc crashes with.
 LTO bugs
 ---
 
-If you find a bug that crashes llvm in LTO phase (by using -flto option),
-compile your source file to a .bc file by passing
-"``-flto -fuse-ld=lld -Wl,-plugin-opt=save-temps``"
-to clang (in addition to the options you already pass). If you are building
-a project, pass the appropriate CFLAGS, CXXFLAG​S and LDFLAGS for example -
+If you encounter a bug that leads to crashes in the LLVM LTO phase when using
+the `-flto` option, follow these steps to diagnose and report the issue:
+
+Compile your source file to a .bc (Bitcode) file with the following flags,
+in addition to your existing compilation options:
 
 .. code-block:: bash
 
export CFLAGS="-flto -fuse-ld=lld" CXXFLAGS=

[clang-tools-extra] [X86] Support -march=pantherlake, clearwaterforest (PR #69277)

2023-10-19 Thread Freddy Ye via cfe-commits

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


[clang-tools-extra] [clangd] Disable crashy unchecked-optional-access tidy check (PR #69427)

2023-10-19 Thread Nathan Ridge via cfe-commits


@@ -219,6 +219,9 @@ TidyProvider 
disableUnusableChecks(llvm::ArrayRef ExtraBadChecks) {
   "-bugprone-use-after-move",
   // Alias for bugprone-use-after-move.
   "-hicpp-invalid-access-moved",
+  // Check uses dataflow analysis, which might hang/crash unexpectedly on
+  // incomplete code.
+  "-bugprone-unchecked-optional-access",

HighCommander4 wrote:

Thanks. I commented in 
https://github.com/clangd/clangd/issues/1337#issuecomment-1770201400 about 
users maybe asking for an override in the future, but for now, avoiding the 
much more common case of users who don't care about this crash being burned by 
its brittleness is definitely the more pressing concern.

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


[clang-tools-extra] [clangd] Disable crashy unchecked-optional-access tidy check (PR #69427)

2023-10-19 Thread Nathan Ridge via cfe-commits

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


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


[clang-tools-extra] [clangd] Disable crashy unchecked-optional-access tidy check (PR #69427)

2023-10-19 Thread Nathan Ridge via cfe-commits

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


[clang] [clang][index] Fix processing of CompoundAssignOperator at setting up reference roles (PR #69370)

2023-10-19 Thread Haojian Wu via cfe-commits

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


[clang] [clang][index] Fix processing of CompoundAssignOperator at setting up reference roles (PR #69370)

2023-10-19 Thread Haojian Wu via cfe-commits


@@ -77,9 +77,15 @@ class BodyIndexer : public RecursiveASTVisitor {
 const Stmt *Parent = *It;
 
 if (auto BO = dyn_cast(Parent)) {
-  if (BO->getOpcode() == BO_Assign && BO->getLHS()->IgnoreParenCasts() == 
E)
-Roles |= (unsigned)SymbolRole::Write;
-
+  if (BO->getOpcode() == BO_Assign) {
+if (BO->getLHS()->IgnoreParenCasts() == E)

hokein wrote:

nit: consider inlining this `if` to the one above (like the original code) to 
the code less nested.

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


[clang] [clang][index] Fix processing of CompoundAssignOperator at setting up reference roles (PR #69370)

2023-10-19 Thread Haojian Wu via cfe-commits

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

good catch.

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


[clang-tools-extra] [clangd] Disable crashy unchecked-optional-access tidy check (PR #69427)

2023-10-19 Thread kadir çetinkaya via cfe-commits

kadircet wrote:

thanks for the pointers @HighCommander4 !

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


[clang-tools-extra] e63ab13 - [clangd] Disable crashy unchecked-optional-access tidy check (#69427)

2023-10-19 Thread via cfe-commits

Author: kadir çetinkaya
Date: 2023-10-19T09:24:22+02:00
New Revision: e63ab13c82e78f65baca48d5b5e4f6ea8d55dbc7

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

LOG: [clangd] Disable crashy unchecked-optional-access tidy check (#69427)

Fixes https://github.com/llvm/llvm-project/issues/69369.
Fixes https://github.com/clangd/clangd/issues/1700.

Added: 


Modified: 
clang-tools-extra/clangd/TidyProvider.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/TidyProvider.cpp 
b/clang-tools-extra/clangd/TidyProvider.cpp
index f101199a20cebf9..2a6fba52e29bf43 100644
--- a/clang-tools-extra/clangd/TidyProvider.cpp
+++ b/clang-tools-extra/clangd/TidyProvider.cpp
@@ -219,6 +219,9 @@ TidyProvider 
disableUnusableChecks(llvm::ArrayRef ExtraBadChecks) {
   "-bugprone-use-after-move",
   // Alias for bugprone-use-after-move.
   "-hicpp-invalid-access-moved",
+  // Check uses dataflow analysis, which might hang/crash unexpectedly on
+  // incomplete code.
+  "-bugprone-unchecked-optional-access",
 
   // - Performance problems -
 



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


[clang-tools-extra] [clangd] Disable crashy unchecked-optional-access tidy check (PR #69427)

2023-10-19 Thread kadir çetinkaya via cfe-commits

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


[clang] [AMDGPU] Lower __builtin_read_exec_hi to use amdgcn_ballot (PR #69567)

2023-10-19 Thread Rana Pratap Reddy via cfe-commits

https://github.com/ranapratap55 created 
https://github.com/llvm/llvm-project/pull/69567

Currently __builtin_read_exec_hi lowers to llvm.read_register, this patch 
lowers it to use amdgcn_ballot.

>From 340e633da9e3ab10efc0c0d430b9546cd2f19cfe Mon Sep 17 00:00:00 2001
From: ranapratap55 
Date: Thu, 19 Oct 2023 12:52:13 +0530
Subject: [PATCH] [AMDGPU] Lower __builtin_read_exec_hi to use amdgcn_ballot

---
 clang/lib/CodeGen/CGBuiltin.cpp | 27 +++--
 clang/test/CodeGenOpenCL/builtins-amdgcn.cl |  4 ++-
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index db9f354fa8386d3..d60826f293f0c46 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -7997,14 +7997,26 @@ enum SpecialRegisterAccessKind {
 
 static Value *EmitAMDGCNBallotForExec(CodeGenFunction &CGF, const CallExpr *E,
   llvm::Type *RegisterType,
-  llvm::Type *ValueType) {
+  llvm::Type *ValueType, bool isExecHi) {
   CodeGen::CGBuilderTy &Builder = CGF.Builder;
   CodeGen::CodeGenModule &CGM = CGF.CGM;
 
   llvm::Type *ResultType = CGF.ConvertType(E->getType());
-  Function *F = CGM.getIntrinsic(Intrinsic::amdgcn_ballot, {ResultType});
-  llvm::Value *Call = Builder.CreateCall(F, {Builder.getInt1(true)});
-  return Call;
+  llvm::Value *Call;
+  Function *F;
+  
+  if (isExecHi) {
+F = CGM.getIntrinsic(Intrinsic::amdgcn_ballot, {RegisterType});
+Call = Builder.CreateCall(F, {Builder.getInt1(true)});
+Value *C1 = llvm::ConstantInt::get(ValueType, 32);
+Value *Rt2 = Builder.CreateLShr(Call, C1);
+Rt2 = Builder.CreateTruncOrBitCast(Rt2, CGF.Int32Ty);
+return Rt2;
+  } else {
+F = CGM.getIntrinsic(Intrinsic::amdgcn_ballot, {ResultType});
+Call = Builder.CreateCall(F, {Builder.getInt1(true)});
+return Call;
+  }
 }
 
 // Generates the IR for the read/write special register builtin,
@@ -17837,10 +17849,11 @@ Value 
*CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID,
 return Builder.CreateCall(F, {Addr, Val, ZeroI32, ZeroI32, ZeroI1});
   }
   case AMDGPU::BI__builtin_amdgcn_read_exec:
+return EmitAMDGCNBallotForExec(*this, E, Int64Ty, Int64Ty, false);
   case AMDGPU::BI__builtin_amdgcn_read_exec_lo:
-  case AMDGPU::BI__builtin_amdgcn_read_exec_hi: {
-return EmitAMDGCNBallotForExec(*this, E, Int64Ty, Int64Ty);
-  }
+return EmitAMDGCNBallotForExec(*this, E, Int32Ty, Int32Ty, false);
+  case AMDGPU::BI__builtin_amdgcn_read_exec_hi:
+return EmitAMDGCNBallotForExec(*this, E, Int64Ty, Int64Ty, true);
   case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray:
   case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray_h:
   case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray_l:
diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
index 8938642e3b19f8c..0bc9a54682d3e31 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -526,7 +526,9 @@ void test_read_exec_lo(global uint* out) {
 // CHECK: declare i32 @llvm.amdgcn.ballot.i32(i1) 
#[[$NOUNWIND_READONLY:[0-9]+]]
 
 // CHECK-LABEL: @test_read_exec_hi(
-// CHECK: call i32 @llvm.amdgcn.ballot.i32(i1 true)
+// CHECK: call i64 @llvm.amdgcn.ballot.i64(i1 true)
+// CHECK: lshr i64 [[A:%.*]], 32
+// CHECK: trunc i64 [[B:%.*]] to i32
 void test_read_exec_hi(global uint* out) {
   *out = __builtin_amdgcn_read_exec_hi();
 }

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


[clang] [AMDGPU] Lower __builtin_read_exec_hi to use amdgcn_ballot (PR #69567)

2023-10-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Rana Pratap Reddy (ranapratap55)


Changes

Currently __builtin_read_exec_hi lowers to llvm.read_register, this patch 
lowers it to use amdgcn_ballot.

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


2 Files Affected:

- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+20-7) 
- (modified) clang/test/CodeGenOpenCL/builtins-amdgcn.cl (+3-1) 


``diff
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index db9f354fa8386d3..d60826f293f0c46 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -7997,14 +7997,26 @@ enum SpecialRegisterAccessKind {
 
 static Value *EmitAMDGCNBallotForExec(CodeGenFunction &CGF, const CallExpr *E,
   llvm::Type *RegisterType,
-  llvm::Type *ValueType) {
+  llvm::Type *ValueType, bool isExecHi) {
   CodeGen::CGBuilderTy &Builder = CGF.Builder;
   CodeGen::CodeGenModule &CGM = CGF.CGM;
 
   llvm::Type *ResultType = CGF.ConvertType(E->getType());
-  Function *F = CGM.getIntrinsic(Intrinsic::amdgcn_ballot, {ResultType});
-  llvm::Value *Call = Builder.CreateCall(F, {Builder.getInt1(true)});
-  return Call;
+  llvm::Value *Call;
+  Function *F;
+  
+  if (isExecHi) {
+F = CGM.getIntrinsic(Intrinsic::amdgcn_ballot, {RegisterType});
+Call = Builder.CreateCall(F, {Builder.getInt1(true)});
+Value *C1 = llvm::ConstantInt::get(ValueType, 32);
+Value *Rt2 = Builder.CreateLShr(Call, C1);
+Rt2 = Builder.CreateTruncOrBitCast(Rt2, CGF.Int32Ty);
+return Rt2;
+  } else {
+F = CGM.getIntrinsic(Intrinsic::amdgcn_ballot, {ResultType});
+Call = Builder.CreateCall(F, {Builder.getInt1(true)});
+return Call;
+  }
 }
 
 // Generates the IR for the read/write special register builtin,
@@ -17837,10 +17849,11 @@ Value 
*CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID,
 return Builder.CreateCall(F, {Addr, Val, ZeroI32, ZeroI32, ZeroI1});
   }
   case AMDGPU::BI__builtin_amdgcn_read_exec:
+return EmitAMDGCNBallotForExec(*this, E, Int64Ty, Int64Ty, false);
   case AMDGPU::BI__builtin_amdgcn_read_exec_lo:
-  case AMDGPU::BI__builtin_amdgcn_read_exec_hi: {
-return EmitAMDGCNBallotForExec(*this, E, Int64Ty, Int64Ty);
-  }
+return EmitAMDGCNBallotForExec(*this, E, Int32Ty, Int32Ty, false);
+  case AMDGPU::BI__builtin_amdgcn_read_exec_hi:
+return EmitAMDGCNBallotForExec(*this, E, Int64Ty, Int64Ty, true);
   case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray:
   case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray_h:
   case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray_l:
diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
index 8938642e3b19f8c..0bc9a54682d3e31 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -526,7 +526,9 @@ void test_read_exec_lo(global uint* out) {
 // CHECK: declare i32 @llvm.amdgcn.ballot.i32(i1) 
#[[$NOUNWIND_READONLY:[0-9]+]]
 
 // CHECK-LABEL: @test_read_exec_hi(
-// CHECK: call i32 @llvm.amdgcn.ballot.i32(i1 true)
+// CHECK: call i64 @llvm.amdgcn.ballot.i64(i1 true)
+// CHECK: lshr i64 [[A:%.*]], 32
+// CHECK: trunc i64 [[B:%.*]] to i32
 void test_read_exec_hi(global uint* out) {
   *out = __builtin_amdgcn_read_exec_hi();
 }

``




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


[clang-tools-extra] [clangd] Disable crashy unchecked-optional-access tidy check (PR #69427)

2023-10-19 Thread Nathan Ridge via cfe-commits

HighCommander4 wrote:

This may be a good candidate for a 17.0.x backport.

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


[clang-tools-extra] [clangd] Disable crashy unchecked-optional-access tidy check (PR #69427)

2023-10-19 Thread kadir çetinkaya via cfe-commits

kadircet wrote:

yeah, initiated that (i think) already in 
https://github.com/llvm/llvm-project/issues/69568

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


[clang] [C++20] [Modules] Warn if we found #include in module purview (PR #69555)

2023-10-19 Thread Iain Sandoe via cfe-commits


@@ -922,6 +922,10 @@ def err_header_import_semi_in_macro : Error<
 def err_header_import_not_header_unit : Error<
   "header file %0 (aka '%1') cannot be imported because "
   "it is not known to be a header unit">;
+def warn_pp_include_angled_in_module_purview : Warning<
+  "'#include ' in the module purview appears to be erroneous; "

iains wrote:

'appears to be erroneous' seems a bit strong (since we know there are valid 
cases to do this).  Maybe we can think of a way to explain the actual problem 
without ending up with too many words (or perhaps have a short warning message 
and attach a note with explanation)?

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


[clang] [AMDGPU] Lower __builtin_read_exec_hi to use amdgcn_ballot (PR #69567)

2023-10-19 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff e63ab13c82e78f65baca48d5b5e4f6ea8d55dbc7 
340e633da9e3ab10efc0c0d430b9546cd2f19cfe -- clang/lib/CodeGen/CGBuiltin.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index d60826f293f0..4c167fccb619 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -8004,7 +8004,7 @@ static Value *EmitAMDGCNBallotForExec(CodeGenFunction 
&CGF, const CallExpr *E,
   llvm::Type *ResultType = CGF.ConvertType(E->getType());
   llvm::Value *Call;
   Function *F;
-  
+
   if (isExecHi) {
 F = CGM.getIntrinsic(Intrinsic::amdgcn_ballot, {RegisterType});
 Call = Builder.CreateCall(F, {Builder.getInt1(true)});

``




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


[clang] [clang][index] Fix processing of CompoundAssignOperator at setting up reference roles (PR #69370)

2023-10-19 Thread Aleksandr Platonov via cfe-commits


@@ -77,9 +77,15 @@ class BodyIndexer : public RecursiveASTVisitor {
 const Stmt *Parent = *It;
 
 if (auto BO = dyn_cast(Parent)) {
-  if (BO->getOpcode() == BO_Assign && BO->getLHS()->IgnoreParenCasts() == 
E)
-Roles |= (unsigned)SymbolRole::Write;
-
+  if (BO->getOpcode() == BO_Assign) {
+if (BO->getLHS()->IgnoreParenCasts() == E)

ArcsinX wrote:

I split this `if` to avoid this check `else if (auto CA = 
dyn_cast(Parent))`  if `BO->getOpcode() == BO_Assign && 
BO->getLHS()->IgnoreParenCasts() != E`

I.e. if `BO->getOpcode() == BO_Assign` then `Parent` is not a  
`CompoundAssignOperator` and we don't need to check this

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


[clang] [C++20] [Modules] Warn if we found #include in module purview (PR #69555)

2023-10-19 Thread Iain Sandoe via cfe-commits

https://github.com/iains commented:

When I suggested this, it was an intention to limit it to C++ std library 
headers.  Do we not have some existing mechanism that knows which headers are 
in this category (for typo correction etc?)

My concern with making it more general is that it then covers things like 
frameworks which are also included like `` (of course, it's 
also probably not what was intended there as well)

Let's add @Bigcheese to the reviewers, for an opinion on Frameworks


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


[clang] [C++20] [Modules] Warn if we found #include in module purview (PR #69555)

2023-10-19 Thread Chuanqi Xu via cfe-commits


@@ -922,6 +922,10 @@ def err_header_import_semi_in_macro : Error<
 def err_header_import_not_header_unit : Error<
   "header file %0 (aka '%1') cannot be imported because "
   "it is not known to be a header unit">;
+def warn_pp_include_angled_in_module_purview : Warning<
+  "'#include ' in the module purview appears to be erroneous; "

ChuanqiXu9 wrote:

My thoughts are that all the known valid use cases should use the form 
`#include "filename"` instead of `#include `. The angle or the quote 
matters here. I think it may be a general sense that the headers in the `<>` 
should be a system header and other things should be put in quotes `""` (I know 
this is not strictly true). How do you think about this?

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


[clang] [C++20] [Modules] [Driver] Don't enable -fdelayed-template-parsing by default on windows with C++20 modules (PR #69431)

2023-10-19 Thread Iain Sandoe via cfe-commits

https://github.com/iains commented:

Is delayed template parsing an optimisation or a correctness measure?
If it's an optimisation, then it seems that we should disable it for modules 
(because that then makes the modules cases correct).  If it's needed for 
correctness, then we have more of a problem - do we know how MSVC makes the two 
interact?


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


[clang] [X86][AMX] remove related code of X86PreAMXConfigPass (PR #69569)

2023-10-19 Thread via cfe-commits

https://github.com/yubingex007-a11y created 
https://github.com/llvm/llvm-project/pull/69569

None

>From de699709ee73acf9f04a02471255bffdde9bd0cf Mon Sep 17 00:00:00 2001
From: Bing1 Yu 
Date: Thu, 19 Oct 2023 15:42:02 +0800
Subject: [PATCH] [X86][AMX] remove related code of X86PreAMXConfigPass

---
 clang/docs/tools/clang-formatted-files.txt|   1 -
 llvm/include/llvm/CodeGen/Passes.h|   3 -
 llvm/lib/Target/X86/CMakeLists.txt|   1 -
 llvm/lib/Target/X86/X86.h |   1 -
 llvm/lib/Target/X86/X86PreAMXConfig.cpp   | 415 --
 llvm/lib/Target/X86/X86TargetMachine.cpp  |   1 -
 .../X86/AMX/amx-configO2toO0-precfg.ll| 178 
 llvm/tools/opt/opt.cpp|   1 -
 .../gn/secondary/llvm/lib/Target/X86/BUILD.gn |   1 -
 9 files changed, 602 deletions(-)
 delete mode 100644 llvm/lib/Target/X86/X86PreAMXConfig.cpp
 delete mode 100644 llvm/test/CodeGen/X86/AMX/amx-configO2toO0-precfg.ll

diff --git a/clang/docs/tools/clang-formatted-files.txt 
b/clang/docs/tools/clang-formatted-files.txt
index 16f84727117e28d..48cd800bffd0046 100644
--- a/clang/docs/tools/clang-formatted-files.txt
+++ b/clang/docs/tools/clang-formatted-files.txt
@@ -6813,7 +6813,6 @@ llvm/lib/Target/X86/X86LoadValueInjectionRetHardening.cpp
 llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
 llvm/lib/Target/X86/X86LowerAMXType.cpp
 llvm/lib/Target/X86/X86LowerTileCopy.cpp
-llvm/lib/Target/X86/X86PreAMXConfig.cpp
 llvm/lib/Target/X86/X86PreTileConfig.cpp
 llvm/lib/Target/X86/X86RegisterBankInfo.h
 llvm/lib/Target/X86/X86ShuffleDecodeConstantPool.cpp
diff --git a/llvm/include/llvm/CodeGen/Passes.h 
b/llvm/include/llvm/CodeGen/Passes.h
index 598c0b838c1b97d..8d14eef949e91b4 100644
--- a/llvm/include/llvm/CodeGen/Passes.h
+++ b/llvm/include/llvm/CodeGen/Passes.h
@@ -584,9 +584,6 @@ namespace llvm {
   /// or split the data to two <128 x i32>.
   FunctionPass *createX86LowerAMXTypePass();
 
-  /// The pass insert tile config intrinsics for AMX fast register allocation.
-  FunctionPass *createX86PreAMXConfigPass();
-
   /// The pass transforms amx intrinsics to scalar operation if the function 
has
   /// optnone attribute or it is O0.
   FunctionPass *createX86LowerAMXIntrinsicsPass();
diff --git a/llvm/lib/Target/X86/CMakeLists.txt 
b/llvm/lib/Target/X86/CMakeLists.txt
index c387d59ea981a52..0b7a98ad6341dde 100644
--- a/llvm/lib/Target/X86/CMakeLists.txt
+++ b/llvm/lib/Target/X86/CMakeLists.txt
@@ -33,7 +33,6 @@ set(sources
   X86DiscriminateMemOps.cpp
   X86LowerTileCopy.cpp
   X86LowerAMXType.cpp
-  X86PreAMXConfig.cpp
   X86LowerAMXIntrinsics.cpp
   X86TileConfig.cpp
   X86FastPreTileConfig.cpp
diff --git a/llvm/lib/Target/X86/X86.h b/llvm/lib/Target/X86/X86.h
index 3c5ca0788498032..485afbc1dfbc241 100644
--- a/llvm/lib/Target/X86/X86.h
+++ b/llvm/lib/Target/X86/X86.h
@@ -194,7 +194,6 @@ void initializeX86LowerAMXTypeLegacyPassPass(PassRegistry 
&);
 void initializeX86LowerTileCopyPass(PassRegistry &);
 void initializeX86OptimizeLEAPassPass(PassRegistry &);
 void initializeX86PartialReductionPass(PassRegistry &);
-void initializeX86PreAMXConfigPassPass(PassRegistry &);
 void initializeX86PreTileConfigPass(PassRegistry &);
 void initializeX86ReturnThunksPass(PassRegistry &);
 void initializeX86SpeculativeExecutionSideEffectSuppressionPass(PassRegistry 
&);
diff --git a/llvm/lib/Target/X86/X86PreAMXConfig.cpp 
b/llvm/lib/Target/X86/X86PreAMXConfig.cpp
deleted file mode 100644
index 7872a64061d438c..000
--- a/llvm/lib/Target/X86/X86PreAMXConfig.cpp
+++ /dev/null
@@ -1,415 +0,0 @@
-//===- Target/X86/X86PreAMXConfig.cpp - *- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-//
-/// Insert tilecfg for each area of key AMX intrinsic.
-/// All the key AMX intrinsic's tile operand must come from tileload. And the
-/// def tile of key AMX intrinsic must be tilestored.
-/// take tdpbssd for example:
-/// --
-/// %t1 = call x86_amx @llvm.x86.tileloadd64.internal(...)key
-/// %t2 = call x86_amx @llvm.x86.tileloadd64.internal(...) |
-/// %t3 = call x86_amx @llvm.x86.tileloadd64.internal(...)amx
-/// %td = tail call x86_amx @llvm.x86.tdpbssd.internal(t1, t2, t3) |
-/// call void @llvm.x86.tilestored64.internal(... td) area
-/// --
-/// This pass will insert tilecfg before every key-amx-area, some like:
-/// --
-/// %cfgmem = alloca <16 x i32>, align 4* allocate mem
-/// s

[clang] [C++20] [Modules] Warn if we found #include in module purview (PR #69555)

2023-10-19 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

> When I suggested this, it was an intention to limit it to C++ std library 
> headers. Do we not have some existing mechanism that knows which headers are 
> in this category (for typo correction etc?)

As far as I can reach, we don't have such a mechanism. I was wondering if we 
can do this by using `#  pragma GCC system_header`. But it shows that the 
libcxx don't always use this pragma.

Also I feel it makes sense to not include other system headers. e.g., in our 
coding standards, we need `<>` to include boost headers and the sys headers 
(e.g., #include )

> 
> My concern with making it more general is that it then covers things like 
> frameworks which are also included like `` (of course, it's 
> also probably not what was intended there as well)
> 
> Let's add @Bigcheese to the reviewers, for an opinion on Frameworks

What do you mean by frameworks? Do you mean something used in apple modules? If 
yes, the current implementation shouldn't cover that. Since I add this warning 
only after we handled import.

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


[clang] [AMDGPU] Lower __builtin_read_exec_hi to use amdgcn_ballot (PR #69567)

2023-10-19 Thread Rana Pratap Reddy via cfe-commits

https://github.com/ranapratap55 updated 
https://github.com/llvm/llvm-project/pull/69567

>From 19582446dbabffb0b25f9fa8b8b62a06ce6a4c66 Mon Sep 17 00:00:00 2001
From: ranapratap55 
Date: Thu, 19 Oct 2023 12:52:13 +0530
Subject: [PATCH] [AMDGPU] Lower __builtin_read_exec_hi to use amdgcn_ballot

---
 clang/lib/CodeGen/CGBuiltin.cpp | 27 +++--
 clang/test/CodeGenOpenCL/builtins-amdgcn.cl |  4 ++-
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index db9f354fa8386d3..4c167fccb619288 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -7997,14 +7997,26 @@ enum SpecialRegisterAccessKind {
 
 static Value *EmitAMDGCNBallotForExec(CodeGenFunction &CGF, const CallExpr *E,
   llvm::Type *RegisterType,
-  llvm::Type *ValueType) {
+  llvm::Type *ValueType, bool isExecHi) {
   CodeGen::CGBuilderTy &Builder = CGF.Builder;
   CodeGen::CodeGenModule &CGM = CGF.CGM;
 
   llvm::Type *ResultType = CGF.ConvertType(E->getType());
-  Function *F = CGM.getIntrinsic(Intrinsic::amdgcn_ballot, {ResultType});
-  llvm::Value *Call = Builder.CreateCall(F, {Builder.getInt1(true)});
-  return Call;
+  llvm::Value *Call;
+  Function *F;
+
+  if (isExecHi) {
+F = CGM.getIntrinsic(Intrinsic::amdgcn_ballot, {RegisterType});
+Call = Builder.CreateCall(F, {Builder.getInt1(true)});
+Value *C1 = llvm::ConstantInt::get(ValueType, 32);
+Value *Rt2 = Builder.CreateLShr(Call, C1);
+Rt2 = Builder.CreateTruncOrBitCast(Rt2, CGF.Int32Ty);
+return Rt2;
+  } else {
+F = CGM.getIntrinsic(Intrinsic::amdgcn_ballot, {ResultType});
+Call = Builder.CreateCall(F, {Builder.getInt1(true)});
+return Call;
+  }
 }
 
 // Generates the IR for the read/write special register builtin,
@@ -17837,10 +17849,11 @@ Value 
*CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID,
 return Builder.CreateCall(F, {Addr, Val, ZeroI32, ZeroI32, ZeroI1});
   }
   case AMDGPU::BI__builtin_amdgcn_read_exec:
+return EmitAMDGCNBallotForExec(*this, E, Int64Ty, Int64Ty, false);
   case AMDGPU::BI__builtin_amdgcn_read_exec_lo:
-  case AMDGPU::BI__builtin_amdgcn_read_exec_hi: {
-return EmitAMDGCNBallotForExec(*this, E, Int64Ty, Int64Ty);
-  }
+return EmitAMDGCNBallotForExec(*this, E, Int32Ty, Int32Ty, false);
+  case AMDGPU::BI__builtin_amdgcn_read_exec_hi:
+return EmitAMDGCNBallotForExec(*this, E, Int64Ty, Int64Ty, true);
   case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray:
   case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray_h:
   case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray_l:
diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
index 8938642e3b19f8c..0bc9a54682d3e31 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -526,7 +526,9 @@ void test_read_exec_lo(global uint* out) {
 // CHECK: declare i32 @llvm.amdgcn.ballot.i32(i1) 
#[[$NOUNWIND_READONLY:[0-9]+]]
 
 // CHECK-LABEL: @test_read_exec_hi(
-// CHECK: call i32 @llvm.amdgcn.ballot.i32(i1 true)
+// CHECK: call i64 @llvm.amdgcn.ballot.i64(i1 true)
+// CHECK: lshr i64 [[A:%.*]], 32
+// CHECK: trunc i64 [[B:%.*]] to i32
 void test_read_exec_hi(global uint* out) {
   *out = __builtin_amdgcn_read_exec_hi();
 }

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


[clang] [C++20] [Modules] Warn if we found #include in module purview (PR #69555)

2023-10-19 Thread Iain Sandoe via cfe-commits


@@ -922,6 +922,10 @@ def err_header_import_semi_in_macro : Error<
 def err_header_import_not_header_unit : Error<
   "header file %0 (aka '%1') cannot be imported because "
   "it is not known to be a header unit">;
+def warn_pp_include_angled_in_module_purview : Warning<
+  "'#include ' in the module purview appears to be erroneous; "

iains wrote:

I agree in general that limiting it to '<...>' seems a reasonable filter; 
either people should be `import`-ing or `#include "..." ` - but let's also get 
Michael's opinion.

text-wise - maybe something like:
`#include  attaches the declarations to the named module 'M', which is 
not usually intended;` (where we can name M in the message).


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


[clang-tools-extra] [Docs][LTO] Updated HowToSubmitABug.rst for LTO crashes (PR #68389)

2023-10-19 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/68389

>From bdf991f4563e3aa840bec35b1678ad4fe8f9fbb6 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Fri, 6 Oct 2023 12:32:24 +0530
Subject: [PATCH 1/4] [Docs][LTO] Update HowToSubmitABug.rst for LTO crashes

---
 llvm/docs/HowToSubmitABug.rst | 51 +++
 1 file changed, 51 insertions(+)

diff --git a/llvm/docs/HowToSubmitABug.rst b/llvm/docs/HowToSubmitABug.rst
index 733dae6c928d098..88f9af44add7c64 100644
--- a/llvm/docs/HowToSubmitABug.rst
+++ b/llvm/docs/HowToSubmitABug.rst
@@ -153,6 +153,57 @@ Please run this, then file a bug with the instructions and 
reduced .bc file
 that bugpoint emits.  If something goes wrong with bugpoint, please submit
 the "foo.bc" file and the option that llc crashes with.
 
+​.. _lto-crash:
+
+LTO bugs
+---
+
+If you find a bug that crashes llvm in LTO phase (by using -flto option),
+compile your source file to a .bc file by passing
+"``-flto -fuse-ld=lld -Wl,-plugin-opt=save-temps``"
+to clang (in addition to the options you already pass). If you are building
+a project, pass the appropriate CFLAGS, CXXFLAG​S and LDFLAGS for example -
+
+.. code-block:: bash
+
+   export CFLAGS="-flto -fuse-ld=lld" CXXFLAGS="-flto -fuse-ld=lld" 
LDFLAGS="-Wl,-plugin-opt=save-temps"
+
+This will generate four intermediate bytecode files:
+
+1. a.out.0.0.preopt.bc  (Before any link-time optimizations (LTO) are 
applied)
+2. a.out.0.2.internalize.bc (After initial optimizations applied)
+3. a.out.0.4.opt.bc (After the more extensive set of optimizations has 
been applied)
+4. a.out.0.5.precodegen.bc  (After LTO but before it's translated into machine 
code)
+
+Once you have these, one of the following commands should fail:
+
+#. ``opt "-passes=lto" a.out.0.0.preopt.bc``
+#. ``opt "-passes=lto" a.out.0.2.internalize.bc``
+#. ``opt "-passes=lto" a.out.0.4.opt.bc``
+#. ``llc a.out.0.5.precodegen.bc``
+
+If one of these do crash, you should be able to reduce
+this with :program:`llvm-reduce`
+command line (use the bc file corresponding to the command above that failed):
+
+#. ``llvm-reduce --test llvm-reduce.sh a.out.0.2.internalize.bc``
+
+An example of ``llvm-reduce.sh`` script
+
+.. code-block:: bash
+
+   $ cat llvm-reduce.sh
+   #!/usr/bin/env bash
+
+   $HOME/llvm/llvm-project/build/bin/opt "-passes=lto" $1 -o temp.bc  2>&1 
| tee err.log
+   grep "It->second == &Insn" err.log
+   exit $?
+
+Here we have grepped the failed assert message.
+
+Please run this, then file a bug with the instructions and reduced .bc file
+that llvm-reduce emits.
+
 .. _miscompiling:
 
 Miscompilations

>From 1823285171ddbefc49065c4995e9c33bee7b952a Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 10:57:25 +0530
Subject: [PATCH 2/4] address review comment

---
 llvm/docs/HowToSubmitABug.rst | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/llvm/docs/HowToSubmitABug.rst b/llvm/docs/HowToSubmitABug.rst
index 88f9af44add7c64..197ed3e0fde6893 100644
--- a/llvm/docs/HowToSubmitABug.rst
+++ b/llvm/docs/HowToSubmitABug.rst
@@ -168,6 +168,12 @@ a project, pass the appropriate CFLAGS, CXXFLAG​S and 
LDFLAGS for example -
 
export CFLAGS="-flto -fuse-ld=lld" CXXFLAGS="-flto -fuse-ld=lld" 
LDFLAGS="-Wl,-plugin-opt=save-temps"
 
+On Windows, you should use lld-link as the linker.
+
+.. code-block:: bash
+
+   export CFLAGS="-flto -fuse-ld=lld-link" CXXFLAGS="-flto -fuse-ld=lld-link" 
LDFLAGS="-Wl,-plugin-opt=save-temps"
+
 This will generate four intermediate bytecode files:
 
 1. a.out.0.0.preopt.bc  (Before any link-time optimizations (LTO) are 
applied)

>From 0e19d37bf4eb9a312b4989fe941837e285f92a97 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 12:29:23 +0530
Subject: [PATCH 3/4] rebase and improve some wording

---
 llvm/docs/HowToSubmitABug.rst | 36 ---
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/llvm/docs/HowToSubmitABug.rst b/llvm/docs/HowToSubmitABug.rst
index 197ed3e0fde6893..7e9ac089a0f70a1 100644
--- a/llvm/docs/HowToSubmitABug.rst
+++ b/llvm/docs/HowToSubmitABug.rst
@@ -158,30 +158,34 @@ the "foo.bc" file and the option that llc crashes with.
 LTO bugs
 ---
 
-If you find a bug that crashes llvm in LTO phase (by using -flto option),
-compile your source file to a .bc file by passing
-"``-flto -fuse-ld=lld -Wl,-plugin-opt=save-temps``"
-to clang (in addition to the options you already pass). If you are building
-a project, pass the appropriate CFLAGS, CXXFLAG​S and LDFLAGS for example -
+If you encounter a bug that leads to crashes in the LLVM LTO phase when using
+the `-flto` option, follow these steps to diagnose and report the issue:
+
+Compile your source file to a .bc (Bitcode) file with the following flags,
+in addition to your existing compilation options:
 
 .. code-block:: bash
 
export CFLAGS="-flto -fuse-ld=lld" CXXFLAGS=

[clang] [AMDGPU] Lower __builtin_amdgcn_read_exec_hi to use amdgcn_ballot (PR #69567)

2023-10-19 Thread Rana Pratap Reddy via cfe-commits

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


[clang] [AMDGPU] Lower __builtin_amdgcn_read_exec_hi to use amdgcn_ballot (PR #69567)

2023-10-19 Thread Rana Pratap Reddy via cfe-commits

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


[clang] [C++20] [Modules] [Driver] Don't enable -fdelayed-template-parsing by default on windows with C++20 modules (PR #69431)

2023-10-19 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

> Is delayed template parsing an optimisation or a correctness measure? If it's 
> an optimisation, then it seems that we should disable it for modules (because 
> that then makes the modules cases correct).  If it's needed for correctness, 
> then we have more of a problem - do we know how MSVC makes the two interact?

According to my readings, this is about the correctness for the extensions in 
**older** Windows SDK. The comment for `-fdelayed-template-parsing` is:

> // Many old Windows SDK versions require this to parse.
> // FIXME: MSVC introduced /Zc:twoPhase- to disable this behavior in their
> // compiler. We should be able to disable this by default at some point.

So while it is about the correctness for some legacy cases, it should be 
disabled by default at some point according to our plan. (Although I am not 
sure if any one is watching on this).

>  If it's needed for correctness, then we have more of a problem - do we know 
> how MSVC makes the two interact?

I think we can only achieve this by reaching out Cameron.


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


[clang] [X86][AMX] remove related code of X86PreAMXConfigPass (PR #69569)

2023-10-19 Thread via cfe-commits

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


[clang] [X86][AMX] remove related code of X86PreAMXConfigPass (PR #69569)

2023-10-19 Thread via cfe-commits

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


[clang] [C++20] [Modules] Warn if we found #include in module purview (PR #69555)

2023-10-19 Thread Iain Sandoe via cfe-commits

iains wrote:

> > When I suggested this, it was an intention to limit it to C++ std library 
> > headers. Do we not have some existing mechanism that knows which headers 
> > are in this category (for typo correction etc?)
> 
> As far as I can reach, we don't have such a mechanism. 

Ah, that's unfortunate, if we could limit the initial warning to items within 
the language and only expand it if there are reported problems elsewhere it 
would be easier.

>I was wondering if we can do this by using `# pragma GCC system_header`. But 
>it shows that the libcxx don't always use this pragma.

agree that this would seem unreliable/unusable.

> Also I feel it makes sense to not include other system headers. e.g., in our 
> coding standards, we need `<>` to include boost headers and the sys headers 
> (e.g., #include )

yeah - that is both a good case for making it more general and also a warning 
that project policies could do something unexpected.

> > My concern with making it more general is that it then covers things like 
> > frameworks which are also included like `` (of course, it's 
> > also probably not what was intended there as well)
> > Let's add @Bigcheese to the reviewers, for an opinion on Frameworks
> 
> What do you mean by frameworks? Do you mean something used in apple modules? 
> If yes, the current implementation shouldn't cover that. Since I add this 
> warning only after we handled import.

(in this context) Framework headers are like system (or user headers) but 
searched by a different mechanism (so they are `#include-`ed).In principle, 
the same constraints should apply - `` indicates a "system" 
header and _**probably**_ should not be included in the module purview.


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


[clang] [X86][AMX] remove related code of X86PreAMXConfigPass (PR #69569)

2023-10-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-x86

Author: None (yubingex007-a11y)


Changes

In https://reviews.llvm.org/D125075, we switched to use FastPreTileConfig in O0 
and abandoned X86PreAMXConfigPass.

---

Patch is 34.12 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/69569.diff


9 Files Affected:

- (modified) clang/docs/tools/clang-formatted-files.txt (-1) 
- (modified) llvm/include/llvm/CodeGen/Passes.h (-3) 
- (modified) llvm/lib/Target/X86/CMakeLists.txt (-1) 
- (modified) llvm/lib/Target/X86/X86.h (-1) 
- (removed) llvm/lib/Target/X86/X86PreAMXConfig.cpp (-415) 
- (modified) llvm/lib/Target/X86/X86TargetMachine.cpp (-1) 
- (removed) llvm/test/CodeGen/X86/AMX/amx-configO2toO0-precfg.ll (-178) 
- (modified) llvm/tools/opt/opt.cpp (-1) 
- (modified) llvm/utils/gn/secondary/llvm/lib/Target/X86/BUILD.gn (-1) 


``diff
diff --git a/clang/docs/tools/clang-formatted-files.txt 
b/clang/docs/tools/clang-formatted-files.txt
index 16f84727117e28d..48cd800bffd0046 100644
--- a/clang/docs/tools/clang-formatted-files.txt
+++ b/clang/docs/tools/clang-formatted-files.txt
@@ -6813,7 +6813,6 @@ llvm/lib/Target/X86/X86LoadValueInjectionRetHardening.cpp
 llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
 llvm/lib/Target/X86/X86LowerAMXType.cpp
 llvm/lib/Target/X86/X86LowerTileCopy.cpp
-llvm/lib/Target/X86/X86PreAMXConfig.cpp
 llvm/lib/Target/X86/X86PreTileConfig.cpp
 llvm/lib/Target/X86/X86RegisterBankInfo.h
 llvm/lib/Target/X86/X86ShuffleDecodeConstantPool.cpp
diff --git a/llvm/include/llvm/CodeGen/Passes.h 
b/llvm/include/llvm/CodeGen/Passes.h
index 598c0b838c1b97d..8d14eef949e91b4 100644
--- a/llvm/include/llvm/CodeGen/Passes.h
+++ b/llvm/include/llvm/CodeGen/Passes.h
@@ -584,9 +584,6 @@ namespace llvm {
   /// or split the data to two <128 x i32>.
   FunctionPass *createX86LowerAMXTypePass();
 
-  /// The pass insert tile config intrinsics for AMX fast register allocation.
-  FunctionPass *createX86PreAMXConfigPass();
-
   /// The pass transforms amx intrinsics to scalar operation if the function 
has
   /// optnone attribute or it is O0.
   FunctionPass *createX86LowerAMXIntrinsicsPass();
diff --git a/llvm/lib/Target/X86/CMakeLists.txt 
b/llvm/lib/Target/X86/CMakeLists.txt
index c387d59ea981a52..0b7a98ad6341dde 100644
--- a/llvm/lib/Target/X86/CMakeLists.txt
+++ b/llvm/lib/Target/X86/CMakeLists.txt
@@ -33,7 +33,6 @@ set(sources
   X86DiscriminateMemOps.cpp
   X86LowerTileCopy.cpp
   X86LowerAMXType.cpp
-  X86PreAMXConfig.cpp
   X86LowerAMXIntrinsics.cpp
   X86TileConfig.cpp
   X86FastPreTileConfig.cpp
diff --git a/llvm/lib/Target/X86/X86.h b/llvm/lib/Target/X86/X86.h
index 3c5ca0788498032..485afbc1dfbc241 100644
--- a/llvm/lib/Target/X86/X86.h
+++ b/llvm/lib/Target/X86/X86.h
@@ -194,7 +194,6 @@ void initializeX86LowerAMXTypeLegacyPassPass(PassRegistry 
&);
 void initializeX86LowerTileCopyPass(PassRegistry &);
 void initializeX86OptimizeLEAPassPass(PassRegistry &);
 void initializeX86PartialReductionPass(PassRegistry &);
-void initializeX86PreAMXConfigPassPass(PassRegistry &);
 void initializeX86PreTileConfigPass(PassRegistry &);
 void initializeX86ReturnThunksPass(PassRegistry &);
 void initializeX86SpeculativeExecutionSideEffectSuppressionPass(PassRegistry 
&);
diff --git a/llvm/lib/Target/X86/X86PreAMXConfig.cpp 
b/llvm/lib/Target/X86/X86PreAMXConfig.cpp
deleted file mode 100644
index 7872a64061d438c..000
--- a/llvm/lib/Target/X86/X86PreAMXConfig.cpp
+++ /dev/null
@@ -1,415 +0,0 @@
-//===- Target/X86/X86PreAMXConfig.cpp - *- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-//
-/// Insert tilecfg for each area of key AMX intrinsic.
-/// All the key AMX intrinsic's tile operand must come from tileload. And the
-/// def tile of key AMX intrinsic must be tilestored.
-/// take tdpbssd for example:
-/// --
-/// %t1 = call x86_amx @llvm.x86.tileloadd64.internal(...)key
-/// %t2 = call x86_amx @llvm.x86.tileloadd64.internal(...) |
-/// %t3 = call x86_amx @llvm.x86.tileloadd64.internal(...)amx
-/// %td = tail call x86_amx @llvm.x86.tdpbssd.internal(t1, t2, t3) |
-/// call void @llvm.x86.tilestored64.internal(... td) area
-/// --
-/// This pass will insert tilecfg before every key-amx-area, some like:
-/// --
-/// %cfgmem = alloca <16 x i32>, align 4* allocate mem
-/// store <16 x i32> zeroinitializer, <16 x i32>* %cfgmem   * zero init
-/// ...
-/// ... pre-c

[clang] Support target names with dots in more utilities (PR #65812)

2023-10-19 Thread James Henderson via cfe-commits

jh7370 wrote:

@dankm, is there a particular reason you haven't merged this change in yet?

FWIW, the formatter check failed for some reason, but I'm not sure it's related 
to any formatting issue. Please verify by running clang-format on your changes 
before merging.

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


[clang] [C++20] [Modules] Warn if we found #include in module purview (PR #69555)

2023-10-19 Thread Iain Sandoe via cfe-commits

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


[clang] [X86][AMX] remove related code of X86PreAMXConfigPass (PR #69569)

2023-10-19 Thread via cfe-commits

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


[clang] [X86][AMX] remove related code of X86PreAMXConfigPass (PR #69569)

2023-10-19 Thread via cfe-commits

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


[clang] [clang] Implement constexpr bit_cast for vectors (PR #66894)

2023-10-19 Thread via cfe-commits

https://github.com/DaMatrix updated 
https://github.com/llvm/llvm-project/pull/66894

>From 72f63b695c9ebd9c7032c4b754ff7965c28fad5c Mon Sep 17 00:00:00 2001
From: DaPorkchop_ 
Date: Sun, 13 Aug 2023 22:39:12 +0200
Subject: [PATCH] [clang] Implement constexpr bit_cast for vectors

---
 .../include/clang/Basic/DiagnosticASTKinds.td |   3 +
 clang/lib/AST/ExprConstant.cpp| 269 --
 clang/lib/CodeGen/CGExprConstant.cpp  |   3 +
 clang/test/CodeGen/const-init.c   |   9 +-
 .../constexpr-builtin-bit-cast-fp80.cpp   |  48 
 .../SemaCXX/constexpr-builtin-bit-cast.cpp|  44 +++
 6 files changed, 278 insertions(+), 98 deletions(-)
 create mode 100644 clang/test/SemaCXX/constexpr-builtin-bit-cast-fp80.cpp

diff --git a/clang/include/clang/Basic/DiagnosticASTKinds.td 
b/clang/include/clang/Basic/DiagnosticASTKinds.td
index d2656310e79c9b8..3f06e18783dd558 100644
--- a/clang/include/clang/Basic/DiagnosticASTKinds.td
+++ b/clang/include/clang/Basic/DiagnosticASTKinds.td
@@ -326,6 +326,9 @@ def note_constexpr_bit_cast_invalid_type : Note<
   "%select{type|member}1 is not allowed in a constant expression">;
 def note_constexpr_bit_cast_invalid_subtype : Note<
   "invalid type %0 is a %select{member|base}1 of %2">;
+def note_constexpr_bit_cast_invalid_vector : Note<
+  "bit_cast involving type %0 is not allowed in a constant expression; "
+  "element size %1 * element count %2 is not a multiple of the byte size %3">;
 def note_constexpr_bit_cast_indet_dest : Note<
   "indeterminate value can only initialize an object of type 'unsigned char'"
   "%select{, 'char',|}1 or 'std::byte'; %0 is invalid">;
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 5a33e918db8e8c0..bb8222caec8c7de 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -2732,53 +2732,6 @@ static bool truncateBitfieldValue(EvalInfo &Info, const 
Expr *E,
   return true;
 }
 
-static bool EvalAndBitcastToAPInt(EvalInfo &Info, const Expr *E,
-  llvm::APInt &Res) {
-  APValue SVal;
-  if (!Evaluate(SVal, Info, E))
-return false;
-  if (SVal.isInt()) {
-Res = SVal.getInt();
-return true;
-  }
-  if (SVal.isFloat()) {
-Res = SVal.getFloat().bitcastToAPInt();
-return true;
-  }
-  if (SVal.isVector()) {
-QualType VecTy = E->getType();
-unsigned VecSize = Info.Ctx.getTypeSize(VecTy);
-QualType EltTy = VecTy->castAs()->getElementType();
-unsigned EltSize = Info.Ctx.getTypeSize(EltTy);
-bool BigEndian = Info.Ctx.getTargetInfo().isBigEndian();
-Res = llvm::APInt::getZero(VecSize);
-for (unsigned i = 0; i < SVal.getVectorLength(); i++) {
-  APValue &Elt = SVal.getVectorElt(i);
-  llvm::APInt EltAsInt;
-  if (Elt.isInt()) {
-EltAsInt = Elt.getInt();
-  } else if (Elt.isFloat()) {
-EltAsInt = Elt.getFloat().bitcastToAPInt();
-  } else {
-// Don't try to handle vectors of anything other than int or float
-// (not sure if it's possible to hit this case).
-Info.FFDiag(E, diag::note_invalid_subexpr_in_const_expr);
-return false;
-  }
-  unsigned BaseEltSize = EltAsInt.getBitWidth();
-  if (BigEndian)
-Res |= EltAsInt.zextOrTrunc(VecSize).rotr(i*EltSize+BaseEltSize);
-  else
-Res |= EltAsInt.zextOrTrunc(VecSize).rotl(i*EltSize);
-}
-return true;
-  }
-  // Give up if the input isn't an int, float, or vector.  For example, we
-  // reject "(v4i16)(intptr_t)&a".
-  Info.FFDiag(E, diag::note_invalid_subexpr_in_const_expr);
-  return false;
-}
-
 /// Perform the given integer operation, which is known to need at most 
BitWidth
 /// bits, and check for overflow in the original type (if that type was not an
 /// unsigned type).
@@ -7011,10 +6964,11 @@ class APValueToBufferConverter {
   return visitArray(Val, Ty, Offset);
 case APValue::Struct:
   return visitRecord(Val, Ty, Offset);
+case APValue::Vector:
+  return visitVector(Val, Ty, Offset);
 
 case APValue::ComplexInt:
 case APValue::ComplexFloat:
-case APValue::Vector:
 case APValue::FixedPoint:
   // FIXME: We should support these.
 
@@ -7101,6 +7055,72 @@ class APValueToBufferConverter {
 return true;
   }
 
+  bool visitVector(const APValue &Val, QualType Ty, CharUnits Offset) {
+const VectorType *VTy = Ty->castAs();
+QualType EltTy = VTy->getElementType();
+unsigned NElts = VTy->getNumElements();
+unsigned EltSize =
+VTy->isExtVectorBoolType() ? 1 : Info.Ctx.getTypeSize(EltTy);
+
+if ((NElts * EltSize) % Info.Ctx.getCharWidth() != 0) {
+  // The vector's size in bits is not a multiple of the target's byte size,
+  // so its layout is unspecified. For now, we'll simply treat these cases
+  // as unsupported (this should only be possible with OpenCL bool vectors
+  // whose element count isn't a multiple of the byte size).
+  

[clang] [C++20] [Modules] [Driver] Don't enable -fdelayed-template-parsing by default on windows with C++20 modules (PR #69431)

2023-10-19 Thread Markus Böck via cfe-commits

zero9178 wrote:

According to the docs [0], MSVC actually defaults to 
`-fno-delayed-template-parsing` (`/Zc:twoPhase-` with MSVC CLI) if using C++20. 
This is due to `-std:c++20` implying `/permissive-` which implies 
`/Zc:twoPhase-`. We could therefore just disable it based on language version 
alone, not just based on whether we are using modules.

I previously tried to make it the default everywhere in 
https://reviews.llvm.org/D103772. @rnk argued we could always make it the 
default. Given that MSVC is essentially phasing it out and making all their 
headers compatible with `/Zc:twoPhase-` for the sake of C++20 support, it 
should be more feasible than previously. 

[0] 
https://learn.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=msvc-170

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


[clang] [C++20] [Modules] Warn if we found #include in module purview (PR #69555)

2023-10-19 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 updated 
https://github.com/llvm/llvm-project/pull/69555

>From 86663a35a7af039f9440af2cc1896e8b4cf33310 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Thu, 19 Oct 2023 11:28:01 +0800
Subject: [PATCH 1/2] [C++20] [Modules] Warn if we found #include  in
 module purview

Address https://github.com/llvm/llvm-project/issues/68615.

It is generally wrong to include  in the module purview.
Although there are cases to include files in the module purview,
generally these use cases should include files by quotes instead of by
angles. Here we think the files got included by angles are the system
headers.
---
 .../include/clang/Basic/DiagnosticLexKinds.td |  4 ++
 clang/lib/Lex/PPDirectives.cpp|  3 +
 .../include-in-module-purview.cppm| 60 +++
 3 files changed, 67 insertions(+)
 create mode 100644 clang/test/Preprocessor/include-in-module-purview.cppm

diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 940cca67368492f..5d96bcb9359951f 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -922,6 +922,10 @@ def err_header_import_semi_in_macro : Error<
 def err_header_import_not_header_unit : Error<
   "header file %0 (aka '%1') cannot be imported because "
   "it is not known to be a header unit">;
+def warn_pp_include_angled_in_module_purview : Warning<
+  "'#include ' in the module purview appears to be erroneous; "
+  "consider moving that directive before the module declaration">,
+  InGroup>;
 
 def warn_header_guard : Warning<
   "%0 is used as a header guard here, followed by #define of a different 
macro">,
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 2892d4b777846ff..243f7a729681ce9 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -2530,6 +2530,9 @@ Preprocessor::ImportAction 
Preprocessor::HandleHeaderIncludeOrImport(
 return {ImportAction::None};
   }
 
+  if (isAngled && isInNamedModule())
+Diag(FilenameTok, diag::warn_pp_include_angled_in_module_purview);
+
   // Look up the file, create a File ID for it.
   SourceLocation IncludePos = FilenameTok.getLocation();
   // If the filename string was the result of macro expansions, set the include
diff --git a/clang/test/Preprocessor/include-in-module-purview.cppm 
b/clang/test/Preprocessor/include-in-module-purview.cppm
new file mode 100644
index 000..9ad66953f7dc31d
--- /dev/null
+++ b/clang/test/Preprocessor/include-in-module-purview.cppm
@@ -0,0 +1,60 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/a.cppm -E -P -I%t -o %t/tmp 2>&1 | FileCheck 
%t/a.cppm
+// RUN: %clang_cc1 -std=c++20 %t/a.cppm -E -P -I%t -o - 2>&1 \
+// RUN: -Wno-include-angled-in-module-purview | FileCheck %t/a.cppm 
--check-prefix=CHECK-NO-WARN
+
+//--- a.h
+// left empty
+
+//--- b.h
+#include 
+// The headers not get included shouldn't be affected.
+#ifdef WHATEVER
+#include 
+#endif
+
+//--- a.cppm
+module;
+#include 
+#include 
+#include 
+#include "a.h"
+#include "b.h"
+export module a;
+
+#include 
+#include 
+#include 
+#include "a.h"
+#include "b.h"
+
+// CHECK: a.cppm:9:10: warning: '#include ' in the module purview 
appears to be erroneous;
+// CHECK: a.cppm:10:10: warning: '#include ' in the module purview 
appears to be erroneous;
+// CHECK: a.cppm:11:10: warning: '#include ' in the module purview 
appears to be erroneous;
+// CHECK: In file included from {{.*}}/a.cppm:11
+// CHECK-NEXT: b.h:1:10: warning: '#include ' in the module purview 
appears to be erroneous;
+// CHECK: In file included from {{.*}}/a.cppm:13
+// CHECK-NEXT: b.h:1:10: warning: '#include ' in the module purview 
appears to be erroneous;
+
+module :private;
+#include 
+#include 
+#include 
+#include "a.h"
+#include "b.h"
+
+// CHECK: a.cppm:24:10: warning: '#include ' in the module purview 
appears to be erroneous;
+// CHECK: a.cppm:25:10: warning: '#include ' in the module purview 
appears to be erroneous;
+// CHECK: a.cppm:26:10: warning: '#include ' in the module purview 
appears to be erroneous;
+// CHECK: In file included from {{.*}}/a.cppm:26
+// CHECK-NEXT: b.h:1:10: warning: '#include ' in the module purview 
appears to be erroneous;
+// CHECK: In file included from {{.*}}/a.cppm:28
+// CHECK-NEXT: b.h:1:10: warning: '#include ' in the module purview 
appears to be erroneous;
+
+// We should have catched all warnings.
+// CHECK: 10 warnings generated.
+
+// CHECK-NO-WARN-NOT: warning

>From 49ead327fec98f5276a9667414668a05fb03c705 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Thu, 19 Oct 2023 16:25:34 +0800
Subject: [PATCH 2/2] Address comments.

---
 .../include/clang/Basic/DiagnosticLexKinds.td |  5 +++--
 clang/lib/Lex/PPDirectives.cpp|  3 ++-
 .../include-in-module-purview.cppm| 20 +--
 3 files c

[clang] [C++20] [Modules] Warn if we found #include in module purview (PR #69555)

2023-10-19 Thread Chuanqi Xu via cfe-commits


@@ -922,6 +922,10 @@ def err_header_import_semi_in_macro : Error<
 def err_header_import_not_header_unit : Error<
   "header file %0 (aka '%1') cannot be imported because "
   "it is not known to be a header unit">;
+def warn_pp_include_angled_in_module_purview : Warning<
+  "'#include ' in the module purview appears to be erroneous; "

ChuanqiXu9 wrote:

Done

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


[clang] [C++20] [Modules] Warn if we found #include in module purview (PR #69555)

2023-10-19 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

> (in this context) Framework headers are like system (or user headers) but 
> searched by a different mechanism (so they are #include-ed). In principle, 
> the same constraints should apply -  indicates a "system" 
> header and probably should not be included in the module purview.

Got it. Then it looks like not a problem for Frameworks. Let's wait for the 
opinion from @Bigcheese 

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


[clang] [Clang] Add __builtin_vectorelements to get number of elements in vector (PR #69010)

2023-10-19 Thread Lawrence Benson via cfe-commits

lawben wrote:

As nobody has come forward in the the last two days, I'm gonna merge this now. 
I'll have a look a mangling this for Microsoft in a follow-up, as this may 
require a few changes. I'm not yet sure what has to be changed for mangling.

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


[clang] [C++20] [Modules] Warn if we found #include in module purview (PR #69555)

2023-10-19 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff b858309ddc977d5e70de54f3fa3888915b5fbc0c 
49ead327fec98f5276a9667414668a05fb03c705 -- clang/lib/Lex/PPDirectives.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 93b05c3443e5..85cc7b364205 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -2532,7 +2532,7 @@ Preprocessor::ImportAction 
Preprocessor::HandleHeaderIncludeOrImport(
 
   if (isAngled && isInNamedModule())
 Diag(FilenameTok, diag::warn_pp_include_angled_in_module_purview)
-  << getNamedModuleName();
+<< getNamedModuleName();
 
   // Look up the file, create a File ID for it.
   SourceLocation IncludePos = FilenameTok.getLocation();

``




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


[clang] [C++20] [Modules] [Driver] Don't enable -fdelayed-template-parsing by default on windows with C++20 modules (PR #69431)

2023-10-19 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

> According to the docs [0], MSVC actually defaults to 
> `-fno-delayed-template-parsing` (`/Zc:twoPhase-` with MSVC CLI) if using 
> C++20. This is due to `-std:c++20` implying `/permissive-` which implies 
> `/Zc:twoPhase-`. We could therefore just disable it based on language version 
> alone, not just based on whether we are using modules.
> 
> I previously tried to make it the default everywhere in 
> https://reviews.llvm.org/D103772. @rnk argued we could always make it the 
> default. Given that MSVC is essentially phasing it out and making all their 
> headers compatible with `/Zc:twoPhase-` for the sake of C++20 support, it 
> should be more feasible than previously.
> 
> [0] 
> https://learn.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=msvc-170

Thanks for the info! It looks like your patch can cover this patch. And we can 
be sure that this patch itself is correct. 

Would you like to send that patch itself soon? If not, I'd like to land the 
patch soon to give better user experience. Then you can revert this. If you 
plan to send that patch soon, I'd like to discard the patch itself.

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


[clang] de65b6b - [Clang] Add __builtin_vectorelements to get number of elements in vector (#69010)

2023-10-19 Thread via cfe-commits

Author: Lawrence Benson
Date: 2023-10-19T10:45:08+02:00
New Revision: de65b6bec6771fe50f3aa73fdb79594f675be456

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

LOG: [Clang] Add __builtin_vectorelements to get number of elements in vector 
(#69010)

Adds a new `__builtin_vectorelements()` function which returns the
number of elements for a given vector either at compile-time for
fixed-sized vectors, e.g., created via `__attribute__((vector_size(N)))`
or at runtime via a call to `@llvm.vscale.i32()` for scalable vectors,
e.g., SVE or RISCV V.

The new builtin follows a similar path as `sizeof()`, as it essentially
does the same thing but for the number of elements in vector instead of
the number of bytes. This allows us to re-use a lot of the existing
logic to handle types etc.

A small side addition is `Type::isSizelessVectorType()`, which we need
to distinguish between sizeless vectors (SVE, RISCV V) and sizeless
types (WASM).

This is the [corresponding
discussion](https://discourse.llvm.org/t/new-builtin-function-to-get-number-of-lanes-in-simd-vectors/73911).

Added: 
clang/test/CodeGen/builtin_vectorelements.c
clang/test/Sema/builtin_vectorelements.c
clang/test/SemaCXX/builtin_vectorelements.cpp

Modified: 
clang/docs/LanguageExtensions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/Type.h
clang/include/clang/Basic/Builtins.def
clang/include/clang/Basic/DiagnosticASTKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/TokenKinds.def
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/Type.cpp
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/Sema/convertvector.c

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index b9466b5a0bc2087..30e288f986782fd 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -619,6 +619,14 @@ Let ``T`` be one of the following types:
 
 For scalar types, consider the operation applied to a vector with a single 
element.
 
+*Vector Size*
+To determine the number of elements in a vector, use 
``__builtin_vectorelements()``.
+For fixed-sized vectors, e.g., defined via ``__attribute__((vector_size(N)))`` 
or ARM
+NEON's vector types (e.g., ``uint16x8_t``), this returns the constant number of
+elements at compile-time. For scalable vectors, e.g., SVE or RISC-V V, the 
number of
+elements is not known at compile-time and is determined at runtime. This 
builtin can
+be used, e.g., to increment the loop-counter in vector-type agnostic loops.
+
 *Elementwise Builtins*
 
 Each builtin returns a vector equivalent to applying the specified operation

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e782c944dbe7bbb..eee48431d716878 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -182,6 +182,12 @@ C23 Feature Support
 Non-comprehensive list of changes in this release
 -
 
+* Clang now has a ``__builtin_vectorelements()`` function that determines the 
number of elements in a vector.
+  For fixed-sized vectors, e.g., defined via 
``__attribute__((vector_size(N)))`` or ARM NEON's vector types
+  (e.g., ``uint16x8_t``), this returns the constant number of elements at 
compile-time.
+  For scalable vectors, e.g., SVE or RISC-V V, the number of elements is not 
known at compile-time and is
+  determined at runtime.
+
 New Compiler Flags
 --
 

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 3e7e4f4f75b58b1..e3dbe3b8a45cc3e 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2060,6 +2060,9 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   bool isSizelessType() const;
   bool isSizelessBuiltinType() const;
 
+  /// Returns true for all scalable vector types.
+  bool isSizelessVectorType() const;
+
   /// Returns true for SVE scalable vector types.
   bool isSVESizelessBuiltinType() const;
 

diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 6ea8484606cfd5d..6033e8a955fb8bd 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -674,6 +674,7 @@ BUILTIN(__builtin_debugtrap, "v", "n")
 BUILTIN(__builtin_unreachable, "v", "nr")
 BUILTIN(__builtin_shufflevector, "v."   , "nct")
 BUILTIN(__builtin_convertvector, "v."   , "nct")
+BUILTIN(__builtin_vectorelements, "v."  , "nct")
 BUILTIN(__builtin_alloca, "v*z"   , "Fn")
 BUILTIN(__builtin_alloca_uninitialized, "v*z", "Fn")

[clang] [C++20] [Modules] Warn if we found #include in module purview (PR #69555)

2023-10-19 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 updated 
https://github.com/llvm/llvm-project/pull/69555

>From 86663a35a7af039f9440af2cc1896e8b4cf33310 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Thu, 19 Oct 2023 11:28:01 +0800
Subject: [PATCH 1/3] [C++20] [Modules] Warn if we found #include  in
 module purview

Address https://github.com/llvm/llvm-project/issues/68615.

It is generally wrong to include  in the module purview.
Although there are cases to include files in the module purview,
generally these use cases should include files by quotes instead of by
angles. Here we think the files got included by angles are the system
headers.
---
 .../include/clang/Basic/DiagnosticLexKinds.td |  4 ++
 clang/lib/Lex/PPDirectives.cpp|  3 +
 .../include-in-module-purview.cppm| 60 +++
 3 files changed, 67 insertions(+)
 create mode 100644 clang/test/Preprocessor/include-in-module-purview.cppm

diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 940cca67368492f..5d96bcb9359951f 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -922,6 +922,10 @@ def err_header_import_semi_in_macro : Error<
 def err_header_import_not_header_unit : Error<
   "header file %0 (aka '%1') cannot be imported because "
   "it is not known to be a header unit">;
+def warn_pp_include_angled_in_module_purview : Warning<
+  "'#include ' in the module purview appears to be erroneous; "
+  "consider moving that directive before the module declaration">,
+  InGroup>;
 
 def warn_header_guard : Warning<
   "%0 is used as a header guard here, followed by #define of a different 
macro">,
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 2892d4b777846ff..243f7a729681ce9 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -2530,6 +2530,9 @@ Preprocessor::ImportAction 
Preprocessor::HandleHeaderIncludeOrImport(
 return {ImportAction::None};
   }
 
+  if (isAngled && isInNamedModule())
+Diag(FilenameTok, diag::warn_pp_include_angled_in_module_purview);
+
   // Look up the file, create a File ID for it.
   SourceLocation IncludePos = FilenameTok.getLocation();
   // If the filename string was the result of macro expansions, set the include
diff --git a/clang/test/Preprocessor/include-in-module-purview.cppm 
b/clang/test/Preprocessor/include-in-module-purview.cppm
new file mode 100644
index 000..9ad66953f7dc31d
--- /dev/null
+++ b/clang/test/Preprocessor/include-in-module-purview.cppm
@@ -0,0 +1,60 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/a.cppm -E -P -I%t -o %t/tmp 2>&1 | FileCheck 
%t/a.cppm
+// RUN: %clang_cc1 -std=c++20 %t/a.cppm -E -P -I%t -o - 2>&1 \
+// RUN: -Wno-include-angled-in-module-purview | FileCheck %t/a.cppm 
--check-prefix=CHECK-NO-WARN
+
+//--- a.h
+// left empty
+
+//--- b.h
+#include 
+// The headers not get included shouldn't be affected.
+#ifdef WHATEVER
+#include 
+#endif
+
+//--- a.cppm
+module;
+#include 
+#include 
+#include 
+#include "a.h"
+#include "b.h"
+export module a;
+
+#include 
+#include 
+#include 
+#include "a.h"
+#include "b.h"
+
+// CHECK: a.cppm:9:10: warning: '#include ' in the module purview 
appears to be erroneous;
+// CHECK: a.cppm:10:10: warning: '#include ' in the module purview 
appears to be erroneous;
+// CHECK: a.cppm:11:10: warning: '#include ' in the module purview 
appears to be erroneous;
+// CHECK: In file included from {{.*}}/a.cppm:11
+// CHECK-NEXT: b.h:1:10: warning: '#include ' in the module purview 
appears to be erroneous;
+// CHECK: In file included from {{.*}}/a.cppm:13
+// CHECK-NEXT: b.h:1:10: warning: '#include ' in the module purview 
appears to be erroneous;
+
+module :private;
+#include 
+#include 
+#include 
+#include "a.h"
+#include "b.h"
+
+// CHECK: a.cppm:24:10: warning: '#include ' in the module purview 
appears to be erroneous;
+// CHECK: a.cppm:25:10: warning: '#include ' in the module purview 
appears to be erroneous;
+// CHECK: a.cppm:26:10: warning: '#include ' in the module purview 
appears to be erroneous;
+// CHECK: In file included from {{.*}}/a.cppm:26
+// CHECK-NEXT: b.h:1:10: warning: '#include ' in the module purview 
appears to be erroneous;
+// CHECK: In file included from {{.*}}/a.cppm:28
+// CHECK-NEXT: b.h:1:10: warning: '#include ' in the module purview 
appears to be erroneous;
+
+// We should have catched all warnings.
+// CHECK: 10 warnings generated.
+
+// CHECK-NO-WARN-NOT: warning

>From 49ead327fec98f5276a9667414668a05fb03c705 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Thu, 19 Oct 2023 16:25:34 +0800
Subject: [PATCH 2/3] Address comments.

---
 .../include/clang/Basic/DiagnosticLexKinds.td |  5 +++--
 clang/lib/Lex/PPDirectives.cpp|  3 ++-
 .../include-in-module-purview.cppm| 20 +--
 3 files c

[clang] [Clang] Add __builtin_vectorelements to get number of elements in vector (PR #69010)

2023-10-19 Thread Lawrence Benson via cfe-commits

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


[libunwind] [Clang] Add __builtin_vectorelements to get number of elements in vector (PR #69010)

2023-10-19 Thread Lawrence Benson via cfe-commits

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


[clang-tools-extra] [Clang] Add __builtin_vectorelements to get number of elements in vector (PR #69010)

2023-10-19 Thread Lawrence Benson via cfe-commits

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


[clang] 9f0f606 - [clang] Provide an SSE4.2 implementation of identifier token lexer (#68962)

2023-10-19 Thread via cfe-commits

Author: serge-sans-paille
Date: 2023-10-19T08:45:54Z
New Revision: 9f0f6060810ebd3006f62149d4739fc54af68536

URL: 
https://github.com/llvm/llvm-project/commit/9f0f6060810ebd3006f62149d4739fc54af68536
DIFF: 
https://github.com/llvm/llvm-project/commit/9f0f6060810ebd3006f62149d4739fc54af68536.diff

LOG: [clang] Provide an SSE4.2 implementation of identifier token lexer (#68962)

The _mm_cmpistri instruction can be used to quickly parse identifiers.

With this patch activated, clang pre-processes  1.8% faster,
and sqlite3.c amalgametion 1.5% faster, based on time measurements and
number of executed instructions as measured by valgrind.

The introduction of an extra helper function in the regular case has no
impact on performance, see


https://llvm-compile-time-tracker.com/compare.php?from=30240e428f0ec7d4a6d1b84f9f807ce12b46cfd1&to=12bcb016cde4579ca7b75397762098c03eb4f264&stat=instructions:u

-

Co-authored-by: serge-sans-paille 

Added: 


Modified: 
clang/lib/Lex/Lexer.cpp

Removed: 




diff  --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index feed1b9ecd71a8d..675ec28e514797e 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -47,6 +47,10 @@
 #include 
 #include 
 
+#ifdef __SSE4_2__
+#include 
+#endif
+
 using namespace clang;
 
 
//===--===//
@@ -1847,19 +1851,47 @@ bool Lexer::LexUnicodeIdentifierStart(Token &Result, 
uint32_t C,
   return true;
 }
 
+static const char *
+fastParseASCIIIdentifier(const char *CurPtr,
+ [[maybe_unused]] const char *BufferEnd) {
+#ifdef __SSE4_2__
+  alignas(16) static constexpr char AsciiIdentifierRange[16] = {
+  '_', '_', 'A', 'Z', 'a', 'z', '0', '9',
+  };
+  constexpr ssize_t BytesPerRegister = 16;
+
+  __m128i AsciiIdentifierRangeV =
+  _mm_load_si128((const __m128i *)AsciiIdentifierRange);
+
+  while (LLVM_LIKELY(BufferEnd - CurPtr >= BytesPerRegister)) {
+__m128i Cv = _mm_loadu_si128((const __m128i *)(CurPtr));
+
+int Consumed = _mm_cmpistri(AsciiIdentifierRangeV, Cv,
+_SIDD_LEAST_SIGNIFICANT | _SIDD_CMP_RANGES |
+_SIDD_UBYTE_OPS | _SIDD_NEGATIVE_POLARITY);
+CurPtr += Consumed;
+if (Consumed == BytesPerRegister)
+  continue;
+return CurPtr;
+  }
+#endif
+
+  unsigned char C = *CurPtr;
+  while (isAsciiIdentifierContinue(C))
+C = *++CurPtr;
+  return CurPtr;
+}
+
 bool Lexer::LexIdentifierContinue(Token &Result, const char *CurPtr) {
   // Match [_A-Za-z0-9]*, we have already matched an identifier start.
+
   while (true) {
-unsigned char C = *CurPtr;
-// Fast path.
-if (isAsciiIdentifierContinue(C)) {
-  ++CurPtr;
-  continue;
-}
+
+CurPtr = fastParseASCIIIdentifier(CurPtr, BufferEnd);
 
 unsigned Size;
 // Slow path: handle trigraph, unicode codepoints, UCNs.
-C = getCharAndSize(CurPtr, Size);
+unsigned char C = getCharAndSize(CurPtr, Size);
 if (isAsciiIdentifierContinue(C)) {
   CurPtr = ConsumeChar(CurPtr, Size, Result);
   continue;



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


[clang] [clang] Provide an SSE4.2 implementation of identifier token lexer (PR #68962)

2023-10-19 Thread via cfe-commits

https://github.com/serge-sans-paille closed 
https://github.com/llvm/llvm-project/pull/68962
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ba47bc7 - [Clang][SVE2.1] Add pfalse builtin

2023-10-19 Thread Caroline Concatto via cfe-commits

Author: Caroline Concatto
Date: 2023-10-19T08:55:32Z
New Revision: ba47bc7fd41278926552becca758d42cf4f793c1

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

LOG: [Clang][SVE2.1] Add pfalse builtin

As described in: https://github.com/ARM-software/acle/pull/257

Patch by : Sander de Smalen

Reviewed By: dtemirbulatov

Differential Revision: https://reviews.llvm.org/D151199

Added: 
clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_pfalse.c

Modified: 
clang/include/clang/Basic/arm_sve.td
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index 25a28052ed0d97f..8034cc0c2f04a2b 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -1862,6 +1862,7 @@ def SVBGRP_N : SInst<"svbgrp[_n_{d}]", "dda", "UcUsUiUl", 
MergeNone, "aarch64_sv
 let TargetGuard = "sve2p1" in {
 def SVFCLAMP   : SInst<"svclamp[_{d}]", "", "hfd", MergeNone, 
"aarch64_sve_fclamp", [], []>;
 def SVPTRUE_COUNT  : SInst<"svptrue_{d}", "}v", "QcQsQiQl", MergeNone, 
"aarch64_sve_ptrue_{d}", [IsOverloadNone], []>;
+def SVPFALSE_COUNT_ALIAS : SInst<"svpfalse_c", "}v", "", MergeNone, "", 
[IsOverloadNone]>;
 
 def SVPEXT_SINGLE : SInst<"svpext_lane_{d}", "P}i", "QcQsQiQl", MergeNone, 
"aarch64_sve_pext", [], [ImmCheck<1, ImmCheck0_3>]>;
 def SVPEXT_X2 : SInst<"svpext_lane_{d}_x2", "2.P}i", "QcQsQiQl", 
MergeNone, "aarch64_sve_pext_x2", [], [ImmCheck<1, ImmCheck0_1>]>;

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index db9f354fa8386d3..2b341b8090fad7d 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -10160,6 +10160,13 @@ Value 
*CodeGenFunction::EmitAArch64SVEBuiltinExpr(unsigned BuiltinID,
   case SVE::BI__builtin_sve_svpfalse_b:
 return ConstantInt::getFalse(Ty);
 
+  case SVE::BI__builtin_sve_svpfalse_c: {
+auto SVBoolTy = ScalableVectorType::get(Builder.getInt1Ty(), 16);
+Function *CastToSVCountF =
+CGM.getIntrinsic(Intrinsic::aarch64_sve_convert_from_svbool, Ty);
+return Builder.CreateCall(CastToSVCountF, ConstantInt::getFalse(SVBoolTy));
+  }
+
   case SVE::BI__builtin_sve_svlen_bf16:
   case SVE::BI__builtin_sve_svlen_f16:
   case SVE::BI__builtin_sve_svlen_f32:

diff  --git a/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_pfalse.c 
b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_pfalse.c
new file mode 100644
index 000..5432862dcf52734
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_pfalse.c
@@ -0,0 +1,30 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S 
-disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S 
-passes=mem2reg,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S 
-disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S 
-passes=mem2reg,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s 
| opt -S -passes=mem2reg,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - -x 
c++ %s | opt -S -passes=mem2reg,tailcallelim | FileCheck %s 
-check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S 
-disable-O0-optnone -Werror -Wall -o /dev/null %s
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+// CHECK-LABEL: @test_svpfalse_c(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call target("aarch64.svcount") 
@llvm.aarch64.sve.convert.from.svbool.taarch64.svcountt( 
zeroinitializer)
+// CHECK-NEXT:ret target("aarch64.svcount") [[TMP0]]
+//
+// CPP-CHECK-LABEL: @_Z15test_svpfalse_cv(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call target("aarch64.svcount") 
@llvm.aarch64.sve.convert.from.svbool.taarch64.svcountt( 
zeroinitializer)
+// CPP-CHECK-NEXT:ret target("aarch64.svcount") [[TMP0]]
+//
+svcount_t test_svpfalse_c()
+{
+  return SVE_ACLE_FUNC(svpfalse_c,,,)();
+}



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

[PATCH] D151199: [Clang][SVE2.1] Add pfalse builtin

2023-10-19 Thread Caroline via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGba47bc7fd412: [Clang][SVE2.1] Add pfalse builtin (authored 
by CarolineConcatto).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151199/new/

https://reviews.llvm.org/D151199

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_pfalse.c


Index: clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_pfalse.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_pfalse.c
@@ -0,0 +1,30 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S 
-disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S 
-passes=mem2reg,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S 
-disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S 
-passes=mem2reg,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s 
| opt -S -passes=mem2reg,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - -x 
c++ %s | opt -S -passes=mem2reg,tailcallelim | FileCheck %s 
-check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S 
-disable-O0-optnone -Werror -Wall -o /dev/null %s
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+// CHECK-LABEL: @test_svpfalse_c(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call target("aarch64.svcount") 
@llvm.aarch64.sve.convert.from.svbool.taarch64.svcountt( 
zeroinitializer)
+// CHECK-NEXT:ret target("aarch64.svcount") [[TMP0]]
+//
+// CPP-CHECK-LABEL: @_Z15test_svpfalse_cv(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call target("aarch64.svcount") 
@llvm.aarch64.sve.convert.from.svbool.taarch64.svcountt( 
zeroinitializer)
+// CPP-CHECK-NEXT:ret target("aarch64.svcount") [[TMP0]]
+//
+svcount_t test_svpfalse_c()
+{
+  return SVE_ACLE_FUNC(svpfalse_c,,,)();
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -10160,6 +10160,13 @@
   case SVE::BI__builtin_sve_svpfalse_b:
 return ConstantInt::getFalse(Ty);
 
+  case SVE::BI__builtin_sve_svpfalse_c: {
+auto SVBoolTy = ScalableVectorType::get(Builder.getInt1Ty(), 16);
+Function *CastToSVCountF =
+CGM.getIntrinsic(Intrinsic::aarch64_sve_convert_from_svbool, Ty);
+return Builder.CreateCall(CastToSVCountF, ConstantInt::getFalse(SVBoolTy));
+  }
+
   case SVE::BI__builtin_sve_svlen_bf16:
   case SVE::BI__builtin_sve_svlen_f16:
   case SVE::BI__builtin_sve_svlen_f32:
Index: clang/include/clang/Basic/arm_sve.td
===
--- clang/include/clang/Basic/arm_sve.td
+++ clang/include/clang/Basic/arm_sve.td
@@ -1862,6 +1862,7 @@
 let TargetGuard = "sve2p1" in {
 def SVFCLAMP   : SInst<"svclamp[_{d}]", "", "hfd", MergeNone, 
"aarch64_sve_fclamp", [], []>;
 def SVPTRUE_COUNT  : SInst<"svptrue_{d}", "}v", "QcQsQiQl", MergeNone, 
"aarch64_sve_ptrue_{d}", [IsOverloadNone], []>;
+def SVPFALSE_COUNT_ALIAS : SInst<"svpfalse_c", "}v", "", MergeNone, "", 
[IsOverloadNone]>;
 
 def SVPEXT_SINGLE : SInst<"svpext_lane_{d}", "P}i", "QcQsQiQl", MergeNone, 
"aarch64_sve_pext", [], [ImmCheck<1, ImmCheck0_3>]>;
 def SVPEXT_X2 : SInst<"svpext_lane_{d}_x2", "2.P}i", "QcQsQiQl", 
MergeNone, "aarch64_sve_pext_x2", [], [ImmCheck<1, ImmCheck0_1>]>;


Index: clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_pfalse.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_pfalse.c
@@ -0,0 +1,30 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -passes=mem2reg,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -passes=mem2reg,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
+// 

[clang] [AMDGPU] Remove Code Object V3 (PR #67118)

2023-10-19 Thread Andrew Stubbs via cfe-commits

ams-cs wrote:

GCC deprecation done: [commit 
details](https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=56ed1055b2f40ac162ae8d382280ac07a33f789f;hp=8f4bbdc28df6e87a7ad5ec5ca191a7a836a4f016).

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


[clang] 7338eb5 - Reapply "[dataflow] use true/false literals in formulas, rather than variables"

2023-10-19 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2023-10-19T11:34:08+02:00
New Revision: 7338eb561c48803ec244cd6116154163f56e9717

URL: 
https://github.com/llvm/llvm-project/commit/7338eb561c48803ec244cd6116154163f56e9717
DIFF: 
https://github.com/llvm/llvm-project/commit/7338eb561c48803ec244cd6116154163f56e9717.diff

LOG: Reapply "[dataflow] use true/false literals in formulas, rather than 
variables"

This reverts commit 3353f7dd3d91c9b2b6a15ba9229bee53e0cb8196.

Fixed test bug (unspecified order of arg evaluation)

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/Arena.h
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/include/clang/Analysis/FlowSensitive/Formula.h
clang/lib/Analysis/FlowSensitive/Arena.cpp
clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
clang/lib/Analysis/FlowSensitive/Formula.cpp
clang/lib/Analysis/FlowSensitive/WatchedLiteralsSolver.cpp
clang/unittests/Analysis/FlowSensitive/ArenaTest.cpp
clang/unittests/Analysis/FlowSensitive/DebugSupportTest.cpp
clang/unittests/Analysis/FlowSensitive/TestingSupport.h
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/Arena.h 
b/clang/include/clang/Analysis/FlowSensitive/Arena.h
index 4e07053aae1af53..4be308c43fb7675 100644
--- a/clang/include/clang/Analysis/FlowSensitive/Arena.h
+++ b/clang/include/clang/Analysis/FlowSensitive/Arena.h
@@ -20,7 +20,9 @@ namespace clang::dataflow {
 /// For example, `Value`, `StorageLocation`, `Atom`, and `Formula`.
 class Arena {
 public:
-  Arena() : True(makeAtom()), False(makeAtom()) {}
+  Arena()
+  : True(Formula::create(Alloc, Formula::Literal, {}, 1)),
+False(Formula::create(Alloc, Formula::Literal, {}, 0)) {}
   Arena(const Arena &) = delete;
   Arena &operator=(const Arena &) = delete;
 
@@ -106,9 +108,7 @@ class Arena {
   const Formula &makeAtomRef(Atom A);
 
   /// Returns a formula for a literal true/false.
-  const Formula &makeLiteral(bool Value) {
-return makeAtomRef(Value ? True : False);
-  }
+  const Formula &makeLiteral(bool Value) { return Value ? True : False; }
 
   // Parses a formula from its textual representation.
   // This may refer to atoms that were not produced by makeAtom() yet!
@@ -144,7 +144,7 @@ class Arena {
   llvm::DenseMap FormulaValues;
   unsigned NextAtom = 0;
 
-  Atom True, False;
+  const Formula &True, &False;
 };
 
 } // namespace clang::dataflow

diff  --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index 56d647f35b08430..9ac2cb90ccc4d4a 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -473,9 +473,8 @@ class Environment {
 
   /// Returns a symbolic boolean value that models a boolean literal equal to
   /// `Value`
-  AtomicBoolValue &getBoolLiteralValue(bool Value) const {
-return cast(
-arena().makeBoolValue(arena().makeLiteral(Value)));
+  BoolValue &getBoolLiteralValue(bool Value) const {
+return arena().makeBoolValue(arena().makeLiteral(Value));
   }
 
   /// Returns an atomic boolean value.

diff  --git a/clang/include/clang/Analysis/FlowSensitive/Formula.h 
b/clang/include/clang/Analysis/FlowSensitive/Formula.h
index 9a6c6d2b2f45f58..982e400c1deff1f 100644
--- a/clang/include/clang/Analysis/FlowSensitive/Formula.h
+++ b/clang/include/clang/Analysis/FlowSensitive/Formula.h
@@ -52,7 +52,8 @@ class alignas(const Formula *) Formula {
 /// A reference to an atomic boolean variable.
 /// We name these e.g. "V3", where 3 == atom identity == Value.
 AtomRef,
-// FIXME: add const true/false rather than modeling them as variables
+/// Constant true or false.
+Literal,
 
 Not, /// True if its only operand is false
 
@@ -69,6 +70,11 @@ class alignas(const Formula *) Formula {
 return static_cast(Value);
   }
 
+  bool literal() const {
+assert(kind() == Literal);
+return static_cast(Value);
+  }
+
   ArrayRef operands() const {
 return ArrayRef(reinterpret_cast(this + 1),
 numOperands(kind()));
@@ -81,9 +87,9 @@ class alignas(const Formula *) Formula {
   void print(llvm::raw_ostream &OS, const AtomNames * = nullptr) const;
 
   // Allocate Formulas using Arena rather than calling this function directly.
-  static Formula &create(llvm::BumpPtrAllocator &Alloc, Kind K,
- ArrayRef Operands,
- unsigned Value = 0);
+  static const Formula &create(llvm::BumpPtrAllocator &Alloc, Kind K,
+   ArrayRef Operands,
+   unsigned Value = 0);
 
 private:
   Formula() = default;
@@ -93,6 +99,7 @@ class alignas(const Formula *) Formula {
   static unsigned numOperands(

[clang] [clang] Add clang::debug_info_type attribute for bitfields (PR #69104)

2023-10-19 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/69104

>From 976aa5c8f3d936a15e7123069a49d97ad3bf7a05 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Sun, 15 Oct 2023 13:14:55 +0300
Subject: [PATCH 1/4] [clang] Add clang::debug_info_type attribute

---
 clang/include/clang/Basic/Attr.td | 11 
 clang/include/clang/Basic/AttrDocs.td | 12 +
 .../clang/Basic/DiagnosticSemaKinds.td|  2 ++
 clang/lib/CodeGen/CGDebugInfo.cpp |  2 ++
 clang/lib/Sema/SemaDeclAttr.cpp   | 26 +++
 .../CodeGen/debug-info-debug-info-type.cpp| 14 ++
 6 files changed, 67 insertions(+)
 create mode 100644 clang/test/CodeGen/debug-info-debug-info-type.cpp

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 5c9eb7b8a981037..024421c0583c019 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -107,6 +107,10 @@ def NonBitField : SubsetSubjectisBitField()}],
 "non-bit-field non-static data members">;
 
+def BitField : SubsetSubjectisBitField()}],
+ "bit-field non-static data members">;
+
 def NonStaticCXXMethod : SubsetSubjectisStatic()}],
"non-static member functions">;
@@ -4264,3 +4268,10 @@ def CountedBy : InheritableAttr {
   void setCountedByFieldLoc(SourceRange Loc) { CountedByFieldLoc = Loc; }
   }];
 }
+
+def DebugInfoType: InheritableAttr {
+  let Spellings = [Clang<"debug_info_type">];
+  let Subjects = SubjectList<[BitField], ErrorDiag>;
+  let Args = [TypeArgument<"Type", 1>];
+  let Documentation = [DebugInfoTypeDocumentation];
+}
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 9f9991bdae36155..6cceba1e0e0ad01 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -7219,6 +7219,18 @@ its underlying representation to be a WebAssembly 
``funcref``.
   }];
 }
 
+def DebugInfoTypeDocumentation : Documentation {
+  let Category = DocCatField;
+  let Content = [{
+This attribute allows to alter type of a bitfield in debug information.
+Such a need might arise when bitfield is intended to store an enumeration 
value,
+but has to be specified as having enumeration's underlying type, in order to
+facilitate compiler optimizations. But this also causes underlying type to be
+emitted in debug information, making it hard for debuggers to map bitfield's
+value back to enumeration. This attribute helps with this.
+  }];
+}
+
 def CleanupDocs : Documentation {
   let Category = DocCatType;
   let Content = [{
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e85cd4d1a1ddc0d..b5c73494df367a6 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3153,6 +3153,8 @@ def err_invalid_branch_protection_spec : Error<
   "invalid or misplaced branch protection specification '%0'">;
 def warn_unsupported_branch_protection_spec : Warning<
   "unsupported branch protection specification '%0'">, 
InGroup;
+def warn_attribute_underlying_type_mismatch : Warning<
+  "underlying type %0 of enumeration %1 doesn't match bitfield type %2">;
 
 def warn_unsupported_target_attribute
 : Warning<"%select{unsupported|duplicate|unknown}0%select{| CPU|"
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index c73a63e12f03aab..85aedd87b21d41e 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1497,6 +1497,8 @@ CGDebugInfo::createBitFieldType(const FieldDecl 
*BitFieldDecl,
 llvm::DIScope *RecordTy, const RecordDecl *RD) 
{
   StringRef Name = BitFieldDecl->getName();
   QualType Ty = BitFieldDecl->getType();
+  if (BitFieldDecl->hasAttr())
+Ty = BitFieldDecl->getAttr()->getType();
   SourceLocation Loc = BitFieldDecl->getLocation();
   llvm::DIFile *VUnit = getOrCreateFile(Loc);
   llvm::DIType *DebugType = getOrCreateType(Ty, VUnit);
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index feb02cad9080e3e..8d58968b7f985c8 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -5910,6 +5910,28 @@ static void handleBuiltinAliasAttr(Sema &S, Decl *D,
   D->addAttr(::new (S.Context) BuiltinAliasAttr(S.Context, AL, Ident));
 }
 
+static void handleDebugInfoTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  if (!AL.hasParsedType()) {
+S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
+return;
+  }
+
+  TypeSourceInfo *ParmTSI = nullptr;
+  QualType type = S.GetTypeFromParser(AL.getTypeArg(), &ParmTSI);
+  assert(ParmTSI && "no type source info for attribute argument");
+
+  if (type->isEnumeralType()) {
+QualType BitfieldType = llvm::

[clang] [clang] Add clang::debug_info_type attribute for bitfields (PR #69104)

2023-10-19 Thread Vlad Serebrennikov via cfe-commits


@@ -107,6 +107,10 @@ def NonBitField : SubsetSubjectisBitField()}],
 "non-bit-field non-static data members">;
 
+def BitField : SubsetSubjectisBitField()}],
+ "bit-field non-static data members">;

Endilll wrote:

Fixed

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


[clang] [clang] Add clang::debug_info_type attribute for bitfields (PR #69104)

2023-10-19 Thread Vlad Serebrennikov via cfe-commits


@@ -7219,6 +7219,18 @@ its underlying representation to be a WebAssembly 
``funcref``.
   }];
 }
 
+def DebugInfoTypeDocumentation : Documentation {
+  let Category = DocCatField;
+  let Content = [{
+This attribute allows to alter type of a bitfield in debug information.
+Such a need might arise when bitfield is intended to store an enumeration 
value,
+but has to be specified as having enumeration's underlying type, in order to
+facilitate compiler optimizations. But this also causes underlying type to be
+emitted in debug information, making it hard for debuggers to map bitfield's
+value back to enumeration. This attribute helps with this.
+  }];

Endilll wrote:

Applied the text suggested by Aaron

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


[clang] [clang] Add clang::debug_info_type attribute for bitfields (PR #69104)

2023-10-19 Thread Vlad Serebrennikov via cfe-commits


@@ -7219,6 +7219,18 @@ its underlying representation to be a WebAssembly 
``funcref``.
   }];
 }
 
+def DebugInfoTypeDocumentation : Documentation {
+  let Category = DocCatField;
+  let Content = [{
+This attribute allows to alter type of a bitfield in debug information.
+Such a need might arise when bitfield is intended to store an enumeration 
value,
+but has to be specified as having enumeration's underlying type, in order to
+facilitate compiler optimizations. But this also causes underlying type to be
+emitted in debug information, making it hard for debuggers to map bitfield's
+value back to enumeration. This attribute helps with this.
+  }];

Endilll wrote:

Thank you very much for rewriting it!

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


[clang] [clang] Add clang::debug_info_type attribute for bitfields (PR #69104)

2023-10-19 Thread Vlad Serebrennikov via cfe-commits


@@ -3153,6 +3153,8 @@ def err_invalid_branch_protection_spec : Error<
   "invalid or misplaced branch protection specification '%0'">;
 def warn_unsupported_branch_protection_spec : Warning<
   "unsupported branch protection specification '%0'">, 
InGroup;
+def warn_attribute_underlying_type_mismatch : Warning<
+  "underlying type %0 of enumeration %1 doesn't match bitfield type %2">;

Endilll wrote:

Fixed

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


[clang] [clang] Add clang::debug_info_type attribute for bitfields (PR #69104)

2023-10-19 Thread Vlad Serebrennikov via cfe-commits


@@ -5910,6 +5910,30 @@ static void handleBuiltinAliasAttr(Sema &S, Decl *D,
   D->addAttr(::new (S.Context) BuiltinAliasAttr(S.Context, AL, Ident));
 }
 
+static void handleDebugInfoTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  if (!AL.hasParsedType()) {
+S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
+return;
+  }

Endilll wrote:

I don't know what do we do in generated boilerplate, but without this check, 
test that pass no arguments crashes the compiler in this function.

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


[clang] [clang] Add clang::debug_info_type attribute for bitfields (PR #69104)

2023-10-19 Thread Vlad Serebrennikov via cfe-commits


@@ -5910,6 +5910,30 @@ static void handleBuiltinAliasAttr(Sema &S, Decl *D,
   D->addAttr(::new (S.Context) BuiltinAliasAttr(S.Context, AL, Ident));
 }
 
+static void handleDebugInfoTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  if (!AL.hasParsedType()) {
+S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
+return;
+  }
+
+  TypeSourceInfo *ParmTSI = nullptr;
+  QualType type = S.GetTypeFromParser(AL.getTypeArg(), &ParmTSI);

Endilll wrote:

Fixed

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


[clang] [clang] Add clang::debug_info_type attribute for bitfields (PR #69104)

2023-10-19 Thread Vlad Serebrennikov via cfe-commits


@@ -0,0 +1,14 @@
+// RUN: %clang -target x86_64-linux -g -S -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -verify -DMISMATCH %s

Endilll wrote:

Tests are split now. `const` case is now checked and working as expected 
(qualifiers are ignored).

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


[clang] [clang] Add clang::debug_info_type attribute for bitfields (PR #69104)

2023-10-19 Thread Vlad Serebrennikov via cfe-commits


@@ -5910,6 +5910,30 @@ static void handleBuiltinAliasAttr(Sema &S, Decl *D,
   D->addAttr(::new (S.Context) BuiltinAliasAttr(S.Context, AL, Ident));
 }
 
+static void handleDebugInfoTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  if (!AL.hasParsedType()) {
+S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
+return;
+  }
+
+  TypeSourceInfo *ParmTSI = nullptr;
+  QualType type = S.GetTypeFromParser(AL.getTypeArg(), &ParmTSI);
+  assert(ParmTSI && "no type source info for attribute argument");
+
+  if (type->isEnumeralType()) {
+QualType BitfieldType = llvm::cast(D)->getType();

Endilll wrote:

Fixed

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


[clang] [clang] Add clang::debug_info_type attribute for bitfields (PR #69104)

2023-10-19 Thread Vlad Serebrennikov via cfe-commits


@@ -5910,6 +5910,28 @@ static void handleBuiltinAliasAttr(Sema &S, Decl *D,
   D->addAttr(::new (S.Context) BuiltinAliasAttr(S.Context, AL, Ident));
 }
 
+static void handleDebugInfoTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  if (!AL.hasParsedType()) {
+S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
+return;
+  }
+
+  TypeSourceInfo *ParmTSI = nullptr;
+  QualType type = S.GetTypeFromParser(AL.getTypeArg(), &ParmTSI);
+  assert(ParmTSI && "no type source info for attribute argument");
+
+  if (type->isEnumeralType()) {
+QualType BitfieldType = llvm::cast(D)->getType();
+QualType EnumUnderlyingType = 
type->getAs()->getDecl()->getIntegerType();
+if (EnumUnderlyingType != BitfieldType) {
+  S.Diag(AL.getLoc(), diag::warn_attribute_underlying_type_mismatch) << 
EnumUnderlyingType << type << BitfieldType;

Endilll wrote:

@AaronBallman @erichkeane Can I request some attention here?

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


[clang] 2b97fe2 - [clang][Interp][NFC] Add more tests for bitfield initializers

2023-10-19 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-10-19T11:46:43+02:00
New Revision: 2b97fe2e5158d3803c6d45a38e72c9cd308e2daf

URL: 
https://github.com/llvm/llvm-project/commit/2b97fe2e5158d3803c6d45a38e72c9cd308e2daf
DIFF: 
https://github.com/llvm/llvm-project/commit/2b97fe2e5158d3803c6d45a38e72c9cd308e2daf.diff

LOG: [clang][Interp][NFC] Add more tests for bitfield initializers

Added: 


Modified: 
clang/test/AST/Interp/bitfields.cpp

Removed: 




diff  --git a/clang/test/AST/Interp/bitfields.cpp 
b/clang/test/AST/Interp/bitfields.cpp
index 9a144e2f0d9610e..d3a8a083063ab47 100644
--- a/clang/test/AST/Interp/bitfields.cpp
+++ b/clang/test/AST/Interp/bitfields.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter 
-Wno-bitfield-constant-conversion -verify %s
 // RUN: %clang_cc1 -verify=ref -Wno-bitfield-constant-conversion %s
+// RUN: %clang_cc1 -std=c++20 -fexperimental-new-constant-interpreter 
-Wno-bitfield-constant-conversion -verify %s
+// RUN: %clang_cc1 -std=c++20 -verify=ref -Wno-bitfield-constant-conversion %s
 
 // expected-no-diagnostics
 // ref-no-diagnostics
@@ -31,6 +33,27 @@ namespace Basic {
 return a.a = 10;
   }
   static_assert(storeA2() == 2, "");
+
+#if __cplusplus >= 202002
+  struct Init1 {
+unsigned a : 2 = 1;
+  };
+  constexpr Init1 I1{};
+  static_assert(I1.a == 1, "");
+
+  struct Init2 {
+unsigned a : 2 = 100;
+  };
+  constexpr Init2 I2{};
+  static_assert(I2.a == 0, "");
+#endif
+
+  struct Init3 {
+unsigned a : 2;
+constexpr Init3() : a(100) {}
+  };
+  constexpr Init3 I3{};
+  static_assert(I3.a == 0, "");
 }
 
 namespace Overflow {



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


[clang] [clang] Add clang::debug_info_type attribute for bitfields (PR #69104)

2023-10-19 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/69104

>From 976aa5c8f3d936a15e7123069a49d97ad3bf7a05 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Sun, 15 Oct 2023 13:14:55 +0300
Subject: [PATCH 1/5] [clang] Add clang::debug_info_type attribute

---
 clang/include/clang/Basic/Attr.td | 11 
 clang/include/clang/Basic/AttrDocs.td | 12 +
 .../clang/Basic/DiagnosticSemaKinds.td|  2 ++
 clang/lib/CodeGen/CGDebugInfo.cpp |  2 ++
 clang/lib/Sema/SemaDeclAttr.cpp   | 26 +++
 .../CodeGen/debug-info-debug-info-type.cpp| 14 ++
 6 files changed, 67 insertions(+)
 create mode 100644 clang/test/CodeGen/debug-info-debug-info-type.cpp

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 5c9eb7b8a981037..024421c0583c019 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -107,6 +107,10 @@ def NonBitField : SubsetSubjectisBitField()}],
 "non-bit-field non-static data members">;
 
+def BitField : SubsetSubjectisBitField()}],
+ "bit-field non-static data members">;
+
 def NonStaticCXXMethod : SubsetSubjectisStatic()}],
"non-static member functions">;
@@ -4264,3 +4268,10 @@ def CountedBy : InheritableAttr {
   void setCountedByFieldLoc(SourceRange Loc) { CountedByFieldLoc = Loc; }
   }];
 }
+
+def DebugInfoType: InheritableAttr {
+  let Spellings = [Clang<"debug_info_type">];
+  let Subjects = SubjectList<[BitField], ErrorDiag>;
+  let Args = [TypeArgument<"Type", 1>];
+  let Documentation = [DebugInfoTypeDocumentation];
+}
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 9f9991bdae36155..6cceba1e0e0ad01 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -7219,6 +7219,18 @@ its underlying representation to be a WebAssembly 
``funcref``.
   }];
 }
 
+def DebugInfoTypeDocumentation : Documentation {
+  let Category = DocCatField;
+  let Content = [{
+This attribute allows to alter type of a bitfield in debug information.
+Such a need might arise when bitfield is intended to store an enumeration 
value,
+but has to be specified as having enumeration's underlying type, in order to
+facilitate compiler optimizations. But this also causes underlying type to be
+emitted in debug information, making it hard for debuggers to map bitfield's
+value back to enumeration. This attribute helps with this.
+  }];
+}
+
 def CleanupDocs : Documentation {
   let Category = DocCatType;
   let Content = [{
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e85cd4d1a1ddc0d..b5c73494df367a6 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3153,6 +3153,8 @@ def err_invalid_branch_protection_spec : Error<
   "invalid or misplaced branch protection specification '%0'">;
 def warn_unsupported_branch_protection_spec : Warning<
   "unsupported branch protection specification '%0'">, 
InGroup;
+def warn_attribute_underlying_type_mismatch : Warning<
+  "underlying type %0 of enumeration %1 doesn't match bitfield type %2">;
 
 def warn_unsupported_target_attribute
 : Warning<"%select{unsupported|duplicate|unknown}0%select{| CPU|"
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index c73a63e12f03aab..85aedd87b21d41e 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1497,6 +1497,8 @@ CGDebugInfo::createBitFieldType(const FieldDecl 
*BitFieldDecl,
 llvm::DIScope *RecordTy, const RecordDecl *RD) 
{
   StringRef Name = BitFieldDecl->getName();
   QualType Ty = BitFieldDecl->getType();
+  if (BitFieldDecl->hasAttr())
+Ty = BitFieldDecl->getAttr()->getType();
   SourceLocation Loc = BitFieldDecl->getLocation();
   llvm::DIFile *VUnit = getOrCreateFile(Loc);
   llvm::DIType *DebugType = getOrCreateType(Ty, VUnit);
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index feb02cad9080e3e..8d58968b7f985c8 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -5910,6 +5910,28 @@ static void handleBuiltinAliasAttr(Sema &S, Decl *D,
   D->addAttr(::new (S.Context) BuiltinAliasAttr(S.Context, AL, Ident));
 }
 
+static void handleDebugInfoTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  if (!AL.hasParsedType()) {
+S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
+return;
+  }
+
+  TypeSourceInfo *ParmTSI = nullptr;
+  QualType type = S.GetTypeFromParser(AL.getTypeArg(), &ParmTSI);
+  assert(ParmTSI && "no type source info for attribute argument");
+
+  if (type->isEnumeralType()) {
+QualType BitfieldType = llvm::

[clang] [Clang] Add __builtin_vectorelements to get number of elements in vector (PR #69010)

2023-10-19 Thread Timm Baeder via cfe-commits

tbaederr wrote:

Have you seen the failing buildbots?

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


[libunwind] [Clang] Add __builtin_vectorelements to get number of elements in vector (PR #69010)

2023-10-19 Thread Timm Baeder via cfe-commits

tbaederr wrote:

Have you seen the failing buildbots?

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


[clang-tools-extra] [Clang] Add __builtin_vectorelements to get number of elements in vector (PR #69010)

2023-10-19 Thread Timm Baeder via cfe-commits

tbaederr wrote:

Have you seen the failing buildbots?

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


[clang] Fix __builtin_vectorelements tests with REQUIRES (PR #69582)

2023-10-19 Thread Lawrence Benson via cfe-commits

https://github.com/lawben created 
https://github.com/llvm/llvm-project/pull/69582

Small fix for failing tests after merge of #69010. The tests need `REQUIRES` to 
ensure that the correct headers are available. I've also added a generic x86 
build which does not need headers, so there is at least one run per test.

Side note: I'm still quite new to the LLVM test setup. _a)_ Is this the correct 
way to do this and _b)_ canI trigger the full tests before merging to main to 
avoid a second set of failed buildbots?

>From 3718ce234c07f433264798d5459e3f4787235d1e Mon Sep 17 00:00:00 2001
From: Lawrence Benson 
Date: Thu, 19 Oct 2023 11:59:33 +0200
Subject: [PATCH] Fix builtin_vectorelements tests with REQUIRES

---
 clang/test/CodeGen/builtin_vectorelements.c   | 20 ---
 clang/test/SemaCXX/builtin_vectorelements.cpp |  3 +++
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/clang/test/CodeGen/builtin_vectorelements.c 
b/clang/test/CodeGen/builtin_vectorelements.c
index a825ab2b7273d52..06d9ee7e056a83e 100644
--- a/clang/test/CodeGen/builtin_vectorelements.c
+++ b/clang/test/CodeGen/builtin_vectorelements.c
@@ -1,10 +1,17 @@
-// RUN: %clang_cc1 -O1 -triple aarch64 -target-feature +neon %s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,NEON %s
-// RUN: %clang_cc1 -O1 -triple aarch64 -target-feature +sve  %s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,SVE  %s
-// RUN: %clang_cc1 -O1 -triple riscv64 -target-feature +v%s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,RISCV  %s
+// RUN: %clang_cc1 -O1 -triple x86_64%s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK   %s
 
-// Note that this does not make sense to check for x86 SIMD types, because
-// __m128i, __m256i, and __m512i do not specify the element type. There are no
-// "logical" number of elements in them.
+// REQUIRES: target=aarch64-{{.*}}
+// RUN: %clang_cc1 -O1 -triple aarch64 -target-feature +neon %s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,NEON  %s
+
+// REQUIRES: target=aarch64-{{.*}}
+// RUN: %clang_cc1 -O1 -triple aarch64 -target-feature +sve  %s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,SVE   %s
+
+// REQUIRES: target=riscv64{{.*}}
+// RUN: %clang_cc1 -O1 -triple riscv64 -target-feature +v%s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,RISCV %s
+
+/// Note that this does not make sense to check for x86 SIMD types, because
+/// __m128i, __m256i, and __m512i do not specify the element type. There are no
+/// "logical" number of elements in them.
 
 typedef int int1 __attribute__((vector_size(4)));
 typedef int int4 __attribute__((vector_size(16)));
@@ -56,7 +63,6 @@ int test_builtin_vectorelements_multiply_constant() {
   return __builtin_vectorelements(int16) * 2;
 }
 
-
 #if defined(__ARM_NEON)
 #include 
 
diff --git a/clang/test/SemaCXX/builtin_vectorelements.cpp 
b/clang/test/SemaCXX/builtin_vectorelements.cpp
index 423051def7f7c29..f40ba2a902cb5fc 100644
--- a/clang/test/SemaCXX/builtin_vectorelements.cpp
+++ b/clang/test/SemaCXX/builtin_vectorelements.cpp
@@ -1,3 +1,6 @@
+// RUN: %clang_cc1 -triple x86_64   -std=c++20 
-fsyntax-only -verify -disable-llvm-passes %s
+
+// REQUIRES: target=aarch64-{{.*}}
 // RUN: %clang_cc1 -triple aarch64 -target-feature +sve -std=c++20 
-fsyntax-only -verify -disable-llvm-passes %s
 
 template 

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


[clang] [Clang] Add __builtin_vectorelements to get number of elements in vector (PR #69010)

2023-10-19 Thread Lawrence Benson via cfe-commits

lawben wrote:

@tbaederr Jupp, I'm on it. I was not aware that I had to add `REQUIRES` to all 
the tests for it to find the header files. I assumed they are always available. 
See #69582.

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


[clang] Fix __builtin_vectorelements tests with REQUIRES (PR #69582)

2023-10-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Lawrence Benson (lawben)


Changes

Small fix for failing tests after merge of #69010. The tests need 
`REQUIRES` to ensure that the correct headers are available. I've also added a 
generic x86 build which does not need headers, so there is at least one run per 
test.

Side note: I'm still quite new to the LLVM test setup. _a)_ Is this the correct 
way to do this and _b)_ canI trigger the full tests before merging to main to 
avoid a second set of failed buildbots?

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


2 Files Affected:

- (modified) clang/test/CodeGen/builtin_vectorelements.c (+13-7) 
- (modified) clang/test/SemaCXX/builtin_vectorelements.cpp (+3) 


``diff
diff --git a/clang/test/CodeGen/builtin_vectorelements.c 
b/clang/test/CodeGen/builtin_vectorelements.c
index a825ab2b7273d52..06d9ee7e056a83e 100644
--- a/clang/test/CodeGen/builtin_vectorelements.c
+++ b/clang/test/CodeGen/builtin_vectorelements.c
@@ -1,10 +1,17 @@
-// RUN: %clang_cc1 -O1 -triple aarch64 -target-feature +neon %s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,NEON %s
-// RUN: %clang_cc1 -O1 -triple aarch64 -target-feature +sve  %s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,SVE  %s
-// RUN: %clang_cc1 -O1 -triple riscv64 -target-feature +v%s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,RISCV  %s
+// RUN: %clang_cc1 -O1 -triple x86_64%s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK   %s
 
-// Note that this does not make sense to check for x86 SIMD types, because
-// __m128i, __m256i, and __m512i do not specify the element type. There are no
-// "logical" number of elements in them.
+// REQUIRES: target=aarch64-{{.*}}
+// RUN: %clang_cc1 -O1 -triple aarch64 -target-feature +neon %s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,NEON  %s
+
+// REQUIRES: target=aarch64-{{.*}}
+// RUN: %clang_cc1 -O1 -triple aarch64 -target-feature +sve  %s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,SVE   %s
+
+// REQUIRES: target=riscv64{{.*}}
+// RUN: %clang_cc1 -O1 -triple riscv64 -target-feature +v%s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,RISCV %s
+
+/// Note that this does not make sense to check for x86 SIMD types, because
+/// __m128i, __m256i, and __m512i do not specify the element type. There are no
+/// "logical" number of elements in them.
 
 typedef int int1 __attribute__((vector_size(4)));
 typedef int int4 __attribute__((vector_size(16)));
@@ -56,7 +63,6 @@ int test_builtin_vectorelements_multiply_constant() {
   return __builtin_vectorelements(int16) * 2;
 }
 
-
 #if defined(__ARM_NEON)
 #include 
 
diff --git a/clang/test/SemaCXX/builtin_vectorelements.cpp 
b/clang/test/SemaCXX/builtin_vectorelements.cpp
index 423051def7f7c29..f40ba2a902cb5fc 100644
--- a/clang/test/SemaCXX/builtin_vectorelements.cpp
+++ b/clang/test/SemaCXX/builtin_vectorelements.cpp
@@ -1,3 +1,6 @@
+// RUN: %clang_cc1 -triple x86_64   -std=c++20 
-fsyntax-only -verify -disable-llvm-passes %s
+
+// REQUIRES: target=aarch64-{{.*}}
 // RUN: %clang_cc1 -triple aarch64 -target-feature +sve -std=c++20 
-fsyntax-only -verify -disable-llvm-passes %s
 
 template 

``




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


[clang] Fix __builtin_vectorelements tests with REQUIRES (PR #69582)

2023-10-19 Thread Timm Baeder via cfe-commits

tbaederr wrote:

> _a)_ Is this the correct way to do this

You don't need review for this I think. I can't review this patch. If it takes 
a while you should rather revert your original patch.


> _b)_ can I trigger the full tests before merging to main to avoid a second 
> set of failed buildbots?

Not that I know of.

If you think this is the right way forward, you can merge this as-is, I don't 
know if this is correct. If this patch still doesn't fix the failing build 
bots, you should probably revert the original patch for the time being.

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


[clang] Correctly compute conversion seq for args to fn with reversed param order (PR #68999)

2023-10-19 Thread Utkarsh Saxena via cfe-commits

usx95 wrote:

I think this is important that clang chooses not to error but only warn here as 
a clang extension (it already chooses to do so in cases when it the can match 
the function 
params([1](https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaOverload.cpp#L10274-L10290)
 and 
[2](https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaOverload.cpp#L14415-L14476))
Now that we correctly handle templated `operator==` in this PR, should we also 
relax the error here as well to a warning ? WDYT @zygoloid 

[GCC does the same](https://godbolt.org/z/Knrv66rd3).

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


[PATCH] D153769: [clangd] Implement the 'Organize Imports' source action. Fix include-cleaner findings in batch.

2023-10-19 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 557771.
VitaNuo marked 10 inline comments as done.
VitaNuo added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153769/new/

https://reviews.llvm.org/D153769

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/ParsedAST.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/refactor/Tweak.cpp
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/OrganizeImports.cpp
  clang-tools-extra/clangd/test/code-action-request.test
  clang-tools-extra/clangd/test/include-cleaner-batch-fix.test
  clang-tools-extra/clangd/test/request-reply.test
  clang-tools-extra/clangd/test/tweaks-format.test
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp
  clang-tools-extra/clangd/unittests/tweaks/OrganizeImportsTests.cpp
  clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
  clang-tools-extra/clangd/unittests/tweaks/TweakTesting.h

Index: clang-tools-extra/clangd/unittests/tweaks/TweakTesting.h
===
--- clang-tools-extra/clangd/unittests/tweaks/TweakTesting.h
+++ clang-tools-extra/clangd/unittests/tweaks/TweakTesting.h
@@ -18,6 +18,7 @@
 #include "gtest/gtest.h"
 #include 
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -88,13 +89,17 @@
   //  - if the tweak produces a message, returns "message:\n"
   //  - if prepare() returns false, returns "unavailable"
   //  - if apply() returns an error, returns "fail: "
-  std::string apply(llvm::StringRef MarkedCode,
-llvm::StringMap *EditedFiles = nullptr) const;
+  std::string
+  apply(llvm::StringRef MarkedCode,
+llvm::StringMap *EditedFiles = nullptr,
+const std::vector &RequestedActionKinds = {}) const;
 
   // Helpers for EXPECT_AVAILABLE/EXPECT_UNAVAILABLE macros.
   using WrappedAST = std::pair;
   WrappedAST build(llvm::StringRef) const;
-  bool isAvailable(WrappedAST &, llvm::Annotations::Range) const;
+  bool
+  isAvailable(WrappedAST &, llvm::Annotations::Range,
+  const std::vector &RequestedActionKinds = {}) const;
   // Return code re-decorated with a single point/range.
   static std::string decorate(llvm::StringRef, unsigned);
   static std::string decorate(llvm::StringRef, llvm::Annotations::Range);
@@ -116,9 +121,10 @@
 auto AST = build(A.code());\
 assert(!A.points().empty() || !A.ranges().empty());\
 for (const auto &P : A.points())   \
-  EXPECT_EQ(Available, isAvailable(AST, {P, P})) << decorate(A.code(), P); \
+  EXPECT_EQ(Available, isAvailable(AST, {P, P}, {}))   \
+  << decorate(A.code(), P);\
 for (const auto &R : A.ranges())   \
-  EXPECT_EQ(Available, isAvailable(AST, R)) << decorate(A.code(), R);  \
+  EXPECT_EQ(Available, isAvailable(AST, R, {})) << decorate(A.code(), R);  \
   } while (0)
 #define EXPECT_AVAILABLE(MarkedCode) EXPECT_AVAILABLE_(MarkedCode, true)
 #define EXPECT_UNAVAILABLE(MarkedCode) EXPECT_AVAILABLE_(MarkedCode, false)
Index: clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
@@ -8,6 +8,7 @@
 
 #include "TweakTesting.h"
 
+#include "Protocol.h"
 #include "SourceCode.h"
 #include "TestTU.h"
 #include "refactor/Tweak.h"
@@ -16,6 +17,7 @@
 #include "gtest/gtest.h"
 #include 
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -63,12 +65,14 @@
 // Returns std::nullopt if and only if prepare() failed.
 std::optional>
 applyTweak(ParsedAST &AST, llvm::Annotations::Range Range, StringRef TweakID,
-   const SymbolIndex *Index, llvm::vfs::FileSystem *FS) {
+   const SymbolIndex *Index, llvm::vfs::FileSystem *FS,
+   const std::vector &RequestedActionKinds) {
   std::optional> Result;
   SelectionTree::createEach(AST.getASTContext(), AST.getTokens(), Range.Begin,
 Range.End, [&](SelectionTree ST) {
   Tweak::Selection S(Index, AST, Range.Begin,
- Range.End, std::move(ST), FS);
+ Range.End, std::move(ST)

[PATCH] D153769: [clangd] Implement the 'Organize Imports' source action. Fix include-cleaner findings in batch.

2023-10-19 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo added a comment.

Thanks!




Comment at: 
clang-tools-extra/clangd/unittests/tweaks/OrganizeImportsTests.cpp:35-41
+   {
+   R"cpp(
+#include "Te^stTU.h"
+)cpp",
+   true,
+   {}},
+   {"void foo(^) {}", false, {}}};

kadircet wrote:
> nit: you can use EXPECT_AVAILABLE and EXPECT_UNAVAILABLE directly for these 
> two cases
I think it's the other way around. I can use the macros directly when I don't 
need to pass specific requested action kinds, which is the last (third) case. 
So it's probably not worth it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153769/new/

https://reviews.llvm.org/D153769

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


[clang] 202de4a - Fix __builtin_vectorelements tests with REQUIRES (#69582)

2023-10-19 Thread via cfe-commits

Author: Lawrence Benson
Date: 2023-10-19T12:14:25+02:00
New Revision: 202de4a5c6edb82d50d4bd7586c4b1db5f51073d

URL: 
https://github.com/llvm/llvm-project/commit/202de4a5c6edb82d50d4bd7586c4b1db5f51073d
DIFF: 
https://github.com/llvm/llvm-project/commit/202de4a5c6edb82d50d4bd7586c4b1db5f51073d.diff

LOG: Fix __builtin_vectorelements tests with REQUIRES (#69582)

Small fix for failing tests after merge of #69010. The tests need
`REQUIRES` to ensure that the correct headers are available. I've also
added a generic x86 build which does not need headers, so there is at
least one run per test.

Added: 


Modified: 
clang/test/CodeGen/builtin_vectorelements.c
clang/test/SemaCXX/builtin_vectorelements.cpp

Removed: 




diff  --git a/clang/test/CodeGen/builtin_vectorelements.c 
b/clang/test/CodeGen/builtin_vectorelements.c
index a825ab2b7273d52..06d9ee7e056a83e 100644
--- a/clang/test/CodeGen/builtin_vectorelements.c
+++ b/clang/test/CodeGen/builtin_vectorelements.c
@@ -1,10 +1,17 @@
-// RUN: %clang_cc1 -O1 -triple aarch64 -target-feature +neon %s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,NEON %s
-// RUN: %clang_cc1 -O1 -triple aarch64 -target-feature +sve  %s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,SVE  %s
-// RUN: %clang_cc1 -O1 -triple riscv64 -target-feature +v%s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,RISCV  %s
+// RUN: %clang_cc1 -O1 -triple x86_64%s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK   %s
 
-// Note that this does not make sense to check for x86 SIMD types, because
-// __m128i, __m256i, and __m512i do not specify the element type. There are no
-// "logical" number of elements in them.
+// REQUIRES: target=aarch64-{{.*}}
+// RUN: %clang_cc1 -O1 -triple aarch64 -target-feature +neon %s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,NEON  %s
+
+// REQUIRES: target=aarch64-{{.*}}
+// RUN: %clang_cc1 -O1 -triple aarch64 -target-feature +sve  %s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,SVE   %s
+
+// REQUIRES: target=riscv64{{.*}}
+// RUN: %clang_cc1 -O1 -triple riscv64 -target-feature +v%s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,RISCV %s
+
+/// Note that this does not make sense to check for x86 SIMD types, because
+/// __m128i, __m256i, and __m512i do not specify the element type. There are no
+/// "logical" number of elements in them.
 
 typedef int int1 __attribute__((vector_size(4)));
 typedef int int4 __attribute__((vector_size(16)));
@@ -56,7 +63,6 @@ int test_builtin_vectorelements_multiply_constant() {
   return __builtin_vectorelements(int16) * 2;
 }
 
-
 #if defined(__ARM_NEON)
 #include 
 

diff  --git a/clang/test/SemaCXX/builtin_vectorelements.cpp 
b/clang/test/SemaCXX/builtin_vectorelements.cpp
index 423051def7f7c29..f40ba2a902cb5fc 100644
--- a/clang/test/SemaCXX/builtin_vectorelements.cpp
+++ b/clang/test/SemaCXX/builtin_vectorelements.cpp
@@ -1,3 +1,6 @@
+// RUN: %clang_cc1 -triple x86_64   -std=c++20 
-fsyntax-only -verify -disable-llvm-passes %s
+
+// REQUIRES: target=aarch64-{{.*}}
 // RUN: %clang_cc1 -triple aarch64 -target-feature +sve -std=c++20 
-fsyntax-only -verify -disable-llvm-passes %s
 
 template 



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


[clang] Fix __builtin_vectorelements tests with REQUIRES (PR #69582)

2023-10-19 Thread Lawrence Benson via cfe-commits

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


[clang] Fix __builtin_vectorelements tests with REQUIRES (PR #69582)

2023-10-19 Thread Nikita Popov via cfe-commits

nikic wrote:

The correct check is `REQUIRES: aarch64-registered-target`, not `REQUIRES: 
target=aarch64`.

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


[clang] [clang] Add clang::debug_info_type attribute for bitfields (PR #69104)

2023-10-19 Thread Vlad Serebrennikov via cfe-commits


@@ -5910,6 +5910,30 @@ static void handleBuiltinAliasAttr(Sema &S, Decl *D,
   D->addAttr(::new (S.Context) BuiltinAliasAttr(S.Context, AL, Ident));
 }
 
+static void handleDebugInfoTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  if (!AL.hasParsedType()) {
+S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
+return;
+  }
+
+  TypeSourceInfo *ParmTSI = nullptr;
+  QualType type = S.GetTypeFromParser(AL.getTypeArg(), &ParmTSI);
+  assert(ParmTSI && "no type source info for attribute argument");
+
+  if (type->isEnumeralType()) {
+QualType BitfieldType = llvm::cast(D)->getType();
+QualType EnumUnderlyingType =
+type->getAs()->getDecl()->getIntegerType();
+if (EnumUnderlyingType != BitfieldType) {

Endilll wrote:

> and only prevent situations where the specified type is not an enumeration or 
> integral type.

> This ALSO makes me wonder if forcing it to be an enum type is necessary.

I intentionally haven't been restricting the set of types that can be passed as 
the argument to `preferred_type`. This makes even more sense now that we are 
going with more generic name. I'm just making sure that enum-related 
diagnostics are triggered only when enum was passed by the user.

> Another case we should consider would be whether we want to allow signed 
> unsigned mismatches:

> I think in the signed/unsigned mismatch, we should allow it (thanks to the 
> layout rules)

> 1 enum that can represent a negative value

I disagree. We shouldn't pretend that our enums can hold negative values, while 
we store them in unsigned bit-fields (save for rare exceptions, if any). Now 
that we are not bound by C++98 compilers, I believe we should propagate 
underlying type of our enums from bit-field type they are stored in (usually 
`unsigned`, `uint64_t` for `DeclBase.h`), and deal with negative values at 
enumerator declaration (I guess we'll have to explicitly cast them to the 
underlying type). I can do that while adding `clang::preferred_type` to 
bit-fields.

Ideally I'd propagate bit-field width as well, but that doesn't seem possible 
at the moment: 
https://github.com/llvm/llvm-project/pull/69104#issuecomment-1770189229

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


[clang] [clang] Add clang::debug_info_type attribute for bitfields (PR #69104)

2023-10-19 Thread Vlad Serebrennikov via cfe-commits


@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -verify %s
+
+struct A {
+  enum E : unsigned {};
+  [[clang::preferred_type(E)]] unsigned b : 2;
+  [[clang::preferred_type(E)]] int b2 : 2;
+  // expected-warning@-1 {{underlying type 'unsigned int' of enumeration 'E' 
doesn't match bit-field type 'int'}}
+  [[clang::preferred_type(E)]] const unsigned b3 : 2;
+  [[clang::preferred_type(bool)]] unsigned b4 : 1;
+  [[clang::preferred_type(bool)]] unsigned b5 : 2;
+  // expected-warning@-1 {{bit-field that holds a boolean value should have 
width of 1 instead of 2}}
+  [[clang::preferred_type()]] unsigned b6 : 2;
+  // expected-error@-1 {{'preferred_type' attribute takes one argument}}
+  [[clang::preferred_type]] unsigned b7 : 2;
+  // expected-error@-1 {{'preferred_type' attribute takes one argument}}
+  [[clang::preferred_type(E, int)]] unsigned b8 : 2;

Endilll wrote:

@AaronBallman On the topic of automatically-generated diagnostics:
```
/home/user/endill/llvm-project/clang/test/Sema/attr-preferred-type.cpp:16:28: 
error: expected ')'
   16 |   [[clang::preferred_type(E, int)]] unsigned b8 : 2;
  |^
  |)
/home/user/endill/llvm-project/clang/test/Sema/attr-preferred-type.cpp:16:33: 
error: expected ','
   16 |   [[clang::preferred_type(E, int)]] unsigned b8 : 2;
  | ^
  | ,
/home/user/endill/llvm-project/clang/test/Sema/attr-preferred-type.cpp:16:30: 
warning: unknown attribute 'int' ignored [-Wunknown-attributes]
   16 |   [[clang::preferred_type(E, int)]] unsigned b8 : 2;
  |  ^~~
```
3 diagnostics are issued, 0 says that wrong number of attribute arguments is 
passed.

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


[clang] [NFC] Remove unused variable "AOBFileNames" (PR #69463)

2023-10-19 Thread Juan Manuel Martinez Caamaño via cfe-commits

https://github.com/jmmartinez updated 
https://github.com/llvm/llvm-project/pull/69463

From aff47154ae4d45c2852382aed034ea44df4886d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juan=20Manuel=20MARTINEZ=20CAAMA=C3=91O?= 
Date: Wed, 18 Oct 2023 15:45:07 +0200
Subject: [PATCH 1/3] [NFC][Clang] Remove unused variable "AOBFileNames"

---
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 25fd940584624ee..66790508274ab8b 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2144,7 +2144,6 @@ bool tools::GetSDLFromOffloadArchive(
   Lib = Lib.drop_front(2);
 for (auto LPath : LibraryPaths) {
   ArchiveOfBundles.clear();
-  SmallVector AOBFileNames;
   auto LibFile =
   (Lib.startswith(":") ? Lib.drop_front()
: IsMSVC ? Lib + Ext : "lib" + Lib + Ext)

From 45aad919ed102933fd4810d98ab1e219bf4a660f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juan=20Manuel=20MARTINEZ=20CAAMA=C3=91O?= 
Date: Thu, 19 Oct 2023 12:17:29 +0200
Subject: [PATCH 2/3] [NFC][Clang] Make GetSDLFromOffloadArchive and SDLSearch
 static

---
 clang/lib/Driver/ToolChains/CommonArgs.cpp |  4 ++--
 clang/lib/Driver/ToolChains/CommonArgs.h   | 13 -
 2 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 66790508274ab8b..4f1a87617516317 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2041,7 +2041,7 @@ void tools::addX86AlignBranchArgs(const Driver &D, const 
ArgList &Args,
 /// convention has been to use the prefix “lib”. To avoid confusion with host
 /// archive libraries, we use prefix "libbc-" for the bitcode SDL archives.
 ///
-bool tools::SDLSearch(const Driver &D, const llvm::opt::ArgList &DriverArgs,
+static bool SDLSearch(const Driver &D, const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args,
   SmallVector LibraryPaths, std::string 
Lib,
   StringRef Arch, StringRef Target, bool isBitCodeSDL) {
@@ -2118,7 +2118,7 @@ bool tools::SDLSearch(const Driver &D, const 
llvm::opt::ArgList &DriverArgs,
 /// the library paths. If so, add a new command to clang-offload-bundler to
 /// unbundle this archive and create a temporary device specific archive. Name
 /// of this SDL is passed to the llvm-link tool.
-bool tools::GetSDLFromOffloadArchive(
+static bool GetSDLFromOffloadArchive(
 Compilation &C, const Driver &D, const Tool &T, const JobAction &JA,
 const InputInfoList &Inputs, const llvm::opt::ArgList &DriverArgs,
 llvm::opt::ArgStringList &CC1Args, SmallVector 
LibraryPaths,
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.h 
b/clang/lib/Driver/ToolChains/CommonArgs.h
index 096152bfbdcf68a..f364c9793c9be62 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.h
+++ b/clang/lib/Driver/ToolChains/CommonArgs.h
@@ -66,19 +66,6 @@ void AddStaticDeviceLibs(Compilation *C, const Tool *T, 
const JobAction *JA,
  llvm::opt::ArgStringList &CmdArgs, StringRef Arch,
  StringRef Target, bool isBitCodeSDL);
 
-bool SDLSearch(const Driver &D, const llvm::opt::ArgList &DriverArgs,
-   llvm::opt::ArgStringList &CmdArgs,
-   SmallVector LibraryPaths, std::string Lib,
-   StringRef Arch, StringRef Target, bool isBitCodeSDL);
-
-bool GetSDLFromOffloadArchive(Compilation &C, const Driver &D, const Tool &T,
-  const JobAction &JA, const InputInfoList &Inputs,
-  const llvm::opt::ArgList &DriverArgs,
-  llvm::opt::ArgStringList &CC1Args,
-  SmallVector LibraryPaths,
-  StringRef Lib, StringRef Arch, StringRef Target,
-  bool isBitCodeSDL);
-
 const char *SplitDebugName(const JobAction &JA, const llvm::opt::ArgList &Args,
const InputInfo &Input, const InputInfo &Output);
 

From 4b547dd3e01c8b2ea8a09e466f69c9f9630318d1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juan=20Manuel=20MARTINEZ=20CAAMA=C3=91O?= 
Date: Thu, 19 Oct 2023 12:20:38 +0200
Subject: [PATCH 3/3] [NFC][Clang] Make read-only arguments of
 GetSDLFromOffloadArchive and SDLSearch read-only references instead of
 copying them

---
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 4f1a87617516317..6c553a713c1b973 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2043,7 +2043,7 @@ void tools::addX86AlignBranchArgs(c

[clang] [ARM] fix "+fp.dp" in multilib selection (PR #67412)

2023-10-19 Thread via cfe-commits
Dominik =?utf-8?q?Wójt?= 
Message-ID:
In-Reply-To: 


https://github.com/john-brawn-arm closed 
https://github.com/llvm/llvm-project/pull/67412
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b3c4f64 - [ARM] fix "+fp.dp" in multilib selection (#67412)

2023-10-19 Thread via cfe-commits

Author: Dominik Wójt
Date: 2023-10-19T11:27:33+01:00
New Revision: b3c4f64943dcabe990c8d23c90de5e8c2cd199d0

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

LOG: [ARM] fix "+fp.dp" in multilib selection (#67412)

When the FPU was selected with "+(no)fp(.dp)" extensions in "-march" or
"-mcpu" options, the FPU used for multilib selection was still the
default one for given architecture or CPU.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/ARM.cpp
clang/test/Driver/print-multi-selection-flags.c
llvm/include/llvm/TargetParser/ARMTargetParser.h
llvm/lib/TargetParser/ARMTargetParser.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 8e1cff0b443eeeb..f1d7aeb555f8bd0 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -627,6 +627,11 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver 
&D,
 if (!llvm::ARM::getFPUFeatures(FPUKind, Features))
   D.Diag(clang::diag::err_drv_clang_unsupported)
   << std::string("-mfpu=") + AndroidFPU;
+  } else if (ArchArgFPUKind != llvm::ARM::FK_INVALID ||
+ CPUArgFPUKind != llvm::ARM::FK_INVALID) {
+FPUKind =
+CPUArgFPUKind != llvm::ARM::FK_INVALID ? CPUArgFPUKind : 
ArchArgFPUKind;
+(void)llvm::ARM::getFPUFeatures(FPUKind, Features);
   } else {
 if (!ForAS) {
   std::string CPU = arm::getARMTargetCPU(CPUName, ArchName, Triple);

diff  --git a/clang/test/Driver/print-multi-selection-flags.c 
b/clang/test/Driver/print-multi-selection-flags.c
index 819ff242ced0026..248d9a3cdf49b22 100644
--- a/clang/test/Driver/print-multi-selection-flags.c
+++ b/clang/test/Driver/print-multi-selection-flags.c
@@ -35,6 +35,21 @@
 // CHECK-MVENOFP-NOT: -march=thumbv8.1m.main{{.*}}+mve.fp{{.*}}
 // CHECK-MVENOFP: -mfpu=none
 
+// RUN: %clang -print-multi-flags-experimental --target=arm-none-eabihf 
-march=armv8.1m.main+fp.dp | FileCheck --check-prefix=CHECK-V8_1_FP_DP %s
+// CHECK-V8_1_FP_DP: -march=thumbv8.1m.main{{.*}}
+// CHECK-V8_1_FP_DP: -mfloat-abi=hard
+// CHECK-V8_1_FP_DP: -mfpu=fp-armv8-fullfp16-d16
+
+// RUN: %clang -print-multi-flags-experimental --target=arm-none-eabihf 
-march=armv8.1m.main+nofp+fp+nofp.dp | FileCheck 
--check-prefix=CHECK-V8_1_NO_FP_DP %s
+// CHECK-V8_1_NO_FP_DP: -march=thumbv8.1m.main{{.*}}
+// CHECK-V8_1_NO_FP_DP: -mfloat-abi=hard
+// CHECK-V8_1_NO_FP_DP: -mfpu=fp-armv8-fullfp16-sp-d16
+
+// RUN: %clang -print-multi-flags-experimental --target=arm-none-eabihf 
-mcpu=cortex-m85+nofp.dp | FileCheck --check-prefix=CHECK-M85_NO_FP_DP %s
+// CHECK-M85_NO_FP_DP: -march=thumbv8.1m.main{{.*}}
+// CHECK-M85_NO_FP_DP: -mfloat-abi=hard
+// CHECK-M85_NO_FP_DP: -mfpu=fp-armv8-fullfp16-sp-d16
+
 // RUN: %clang -print-multi-flags-experimental --target=aarch64-none-elf 
-march=armv8-a+lse | FileCheck --check-prefix=CHECK-LSE %s
 // CHECK-LSE: -march=aarch64{{.*}}+lse{{.*}}
 

diff  --git a/llvm/include/llvm/TargetParser/ARMTargetParser.h 
b/llvm/include/llvm/TargetParser/ARMTargetParser.h
index b893eab1902f81b..c42d66f048fccc0 100644
--- a/llvm/include/llvm/TargetParser/ARMTargetParser.h
+++ b/llvm/include/llvm/TargetParser/ARMTargetParser.h
@@ -143,6 +143,14 @@ enum class FPURestriction {
   SP_D16///< Only single-precision instructions, with 16 D registers
 };
 
+inline bool isDoublePrecision(const FPURestriction restriction) {
+  return restriction != FPURestriction::SP_D16;
+}
+
+inline bool has32Regs(const FPURestriction restriction) {
+  return restriction == FPURestriction::None;
+}
+
 // An FPU name implies one of three levels of Neon support:
 enum class NeonSupportLevel {
   None = 0, ///< No Neon

diff  --git a/llvm/lib/TargetParser/ARMTargetParser.cpp 
b/llvm/lib/TargetParser/ARMTargetParser.cpp
index 20225232b3cccb7..4517f714527db15 100644
--- a/llvm/lib/TargetParser/ARMTargetParser.cpp
+++ b/llvm/lib/TargetParser/ARMTargetParser.cpp
@@ -366,26 +366,51 @@ StringRef ARM::getArchExtFeature(StringRef ArchExt) {
 }
 
 static ARM::FPUKind findDoublePrecisionFPU(ARM::FPUKind InputFPUKind) {
+  if (InputFPUKind == ARM::FK_INVALID || InputFPUKind == ARM::FK_NONE)
+return ARM::FK_INVALID;
+
   const ARM::FPUName &InputFPU = ARM::FPUNames[InputFPUKind];
 
   // If the input FPU already supports double-precision, then there
   // isn't any 
diff erent FPU we can return here.
-  //
-  // The current available FPURestriction values are None (no
-  // restriction), D16 (only 16 d-regs) and SP_D16 (16 d-regs
-  // and single precision only); there's no value representing
-  // SP restriction without D16. So this test just means 'is it
-  // SP only?'.
-  if (InputFPU.Restriction != ARM::FPURestriction::SP_D16)
+  if (ARM::isDoublePrecision(InputFPU

[clang] [NFC] Remove unused variable "AOBFileNames" (PR #69463)

2023-10-19 Thread Juan Manuel Martinez Caamaño via cfe-commits

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


[clang] [NFC][Clang] GetSDLFromOffloadArchive and SDLSearch (PR #69463)

2023-10-19 Thread Juan Manuel Martinez Caamaño via cfe-commits

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


[clang] [NFC][Clang] Make GetSDLFromOffloadArchive and SDLSearch static and avoid useless copies in their arguments (PR #69463)

2023-10-19 Thread Juan Manuel Martinez Caamaño via cfe-commits

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


[clang] 0e1d723 - [clang][Interp][NFC] Use an APInt instead of APSint

2023-10-19 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-10-19T12:29:42+02:00
New Revision: 0e1d7239d6fddebdaf39e58eb931ff4916306b23

URL: 
https://github.com/llvm/llvm-project/commit/0e1d7239d6fddebdaf39e58eb931ff4916306b23
DIFF: 
https://github.com/llvm/llvm-project/commit/0e1d7239d6fddebdaf39e58eb931ff4916306b23.diff

LOG: [clang][Interp][NFC] Use an APInt instead of APSint

We already save the information about signedness ourselves.

Added: 


Modified: 
clang/lib/AST/Interp/IntegralAP.h

Removed: 




diff  --git a/clang/lib/AST/Interp/IntegralAP.h 
b/clang/lib/AST/Interp/IntegralAP.h
index ebf362238ba09d5..45e5b49546270aa 100644
--- a/clang/lib/AST/Interp/IntegralAP.h
+++ b/clang/lib/AST/Interp/IntegralAP.h
@@ -33,9 +33,9 @@ template  class Integral;
 template  class IntegralAP final {
 private:
   friend IntegralAP;
-  APSInt V;
+  APInt V;
 
-  template  static T truncateCast(const APSInt &V) {
+  template  static T truncateCast(const APInt &V) {
 constexpr unsigned BitSize = sizeof(T) * 8;
 if (BitSize >= V.getBitWidth())
   return std::is_signed_v ? V.getSExtValue() : V.getZExtValue();
@@ -48,23 +48,37 @@ template  class IntegralAP final {
   using AsUnsigned = IntegralAP;
 
   template 
-  IntegralAP(T Value)
-  : V(APInt(sizeof(T) * 8, static_cast(Value),
-std::is_signed_v)) {}
+  IntegralAP(T Value, unsigned BitWidth)
+  : V(APInt(BitWidth, static_cast(Value), Signed)) {}
 
   IntegralAP(APInt V) : V(V) {}
-  IntegralAP(APSInt V) : V(V) {}
   /// Arbitrary value for uninitialized variables.
-  IntegralAP() : V(APSInt::getMaxValue(1024, Signed)) {}
+  IntegralAP() : IntegralAP(-1, 1024) {}
 
   IntegralAP operator-() const { return IntegralAP(-V); }
   IntegralAP operator-(const IntegralAP &Other) const {
 return IntegralAP(V - Other.V);
   }
-  bool operator>(IntegralAP RHS) const { return V > RHS.V; }
-  bool operator>=(IntegralAP RHS) const { return V >= RHS.V; }
-  bool operator<(IntegralAP RHS) const { return V < RHS.V; }
-  bool operator<=(IntegralAP RHS) const { return V <= RHS.V; }
+  bool operator>(const IntegralAP &RHS) const {
+if constexpr (Signed)
+  return V.ugt(RHS.V);
+return V.sgt(RHS.V);
+  }
+  bool operator>=(IntegralAP RHS) const {
+if constexpr (Signed)
+  return V.uge(RHS.V);
+return V.sge(RHS.V);
+  }
+  bool operator<(IntegralAP RHS) const {
+if constexpr (Signed)
+  return V.slt(RHS.V);
+return V.slt(RHS.V);
+  }
+  bool operator<=(IntegralAP RHS) const {
+if constexpr (Signed)
+  return V.ult(RHS.V);
+return V.ult(RHS.V);
+  }
 
   explicit operator bool() const { return !V.isZero(); }
   explicit operator int8_t() const { return truncateCast(V); }
@@ -78,42 +92,32 @@ template  class IntegralAP final {
 
   template  static IntegralAP from(T Value, unsigned NumBits = 0) {
 assert(NumBits > 0);
-APSInt Copy =
-APSInt(APInt(NumBits, static_cast(Value), Signed), !Signed);
+APInt Copy = APInt(NumBits, static_cast(Value), Signed);
 
 return IntegralAP(Copy);
   }
 
   template 
   static IntegralAP from(IntegralAP V, unsigned NumBits = 0) {
-if constexpr (Signed == InputSigned)
-  return V;
-
-APSInt Copy = V.V;
-Copy.setIsSigned(Signed);
-
-return IntegralAP(Copy);
+return IntegralAP(V.V);
   }
 
   template 
   static IntegralAP from(Integral I, unsigned BitWidth) {
-APSInt Copy =
-APSInt(APInt(BitWidth, static_cast(I), InputSigned), 
!Signed);
-Copy.setIsSigned(Signed);
+APInt Copy = APInt(BitWidth, static_cast(I), InputSigned);
 
-assert(Copy.isSigned() == Signed);
 return IntegralAP(Copy);
   }
 
   static IntegralAP zero(int32_t BitWidth) {
-APSInt V = APSInt(APInt(BitWidth, 0LL, Signed), !Signed);
+APInt V = APInt(BitWidth, 0LL, Signed);
 return IntegralAP(V);
   }
 
   constexpr unsigned bitWidth() const { return V.getBitWidth(); }
 
-  APSInt toAPSInt(unsigned Bits = 0) const { return V; }
-  APValue toAPValue() const { return APValue(V); }
+  APSInt toAPSInt(unsigned Bits = 0) const { return APSInt(V, Signed); }
+  APValue toAPValue() const { return APValue(APSInt(V, Signed)); }
 
   bool isZero() const { return V.isZero(); }
   bool isPositive() const { return V.isNonNegative(); }
@@ -139,22 +143,38 @@ template  class IntegralAP final {
   }
 
   IntegralAP toUnsigned() const {
-APSInt Copy = V;
-Copy.setIsSigned(false);
+APInt Copy = V;
 return IntegralAP(Copy);
   }
 
   ComparisonCategoryResult compare(const IntegralAP &RHS) const {
-return Compare(V, RHS.V);
+assert(Signed == RHS.isSigned());
+assert(bitWidth() == RHS.bitWidth());
+if constexpr (Signed) {
+  if (V.slt(RHS.V))
+return ComparisonCategoryResult::Less;
+  if (V.sgt(RHS.V))
+return ComparisonCategoryResult::Greater;
+  return ComparisonCategoryResult::Equal;
+}
+
+assert(!Signed);
+if (V.

[clang] Fix __builtin_vectorelements tests with REQUIRES (PR #69582)

2023-10-19 Thread Lawrence Benson via cfe-commits

lawben wrote:

@nikic Sorry for the mess :/ 

I took the `target=` approach from 
[here](https://llvm.org/docs/TestingGuide.html#constraining-test-execution). 
Following the current buildbot status, this also does not seem to crash. Does 
this mean the rests are still incorrect and are not being executed at all? My 
local setup has all targets enabled, so it's hard for me to reproduce this 
locally. 

If this is still incorrect, I'd kindly ask you to point out the correct way of 
doing this across all tests. I guess it would have `REQUIRES: 
aarch64-registered-target` for AArch64 and `REQUIRES: 
riscv64-registered-target` for RISCV?

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


[clang] Fix __builtin_vectorelements tests with REQUIRES (PR #69582)

2023-10-19 Thread Nikita Popov via cfe-commits

nikic wrote:

> @nikic Sorry for the mess :/
> 
> I took the `target=` approach from 
> [here](https://llvm.org/docs/TestingGuide.html#constraining-test-execution). 
> Following the current buildbot status, this also does not seem to crash. Does 
> this mean the rests are still incorrect and are not being executed at all? My 
> local setup has all targets enabled, so it's hard for me to reproduce this 
> locally.

I expect the tests just don't run at all now.

> If this is still incorrect, I'd kindly ask you to point out the correct way 
> of doing this across all tests. I guess it would have `REQUIRES: 
> aarch64-registered-target` for AArch64 and `REQUIRES: 
> riscv64-registered-target` for RISCV?

The RISCV check would be `REQUIRES: riscv-registered-target`.

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


[clang] [NFC][Clang] Make GetSDLFromOffloadArchive and SDLSearch static and avoid useless copies in their arguments (PR #69463)

2023-10-19 Thread via cfe-commits
Juan Manuel MARTINEZ =?utf-8?q?CAAMAÑO?= ,
Juan Manuel MARTINEZ =?utf-8?q?CAAMAÑO?= 
Message-ID:
In-Reply-To: 


github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 202de4a5c6edb82d50d4bd7586c4b1db5f51073d 
4b547dd3e01c8b2ea8a09e466f69c9f9630318d1 -- 
clang/lib/Driver/ToolChains/CommonArgs.cpp 
clang/lib/Driver/ToolChains/CommonArgs.h
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 6c553a713c1b..018f708be031 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2043,8 +2043,9 @@ void tools::addX86AlignBranchArgs(const Driver &D, const 
ArgList &Args,
 ///
 static bool SDLSearch(const Driver &D, const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args,
-  const SmallVectorImpl &LibraryPaths, 
StringRef Lib,
-  StringRef Arch, StringRef Target, bool isBitCodeSDL) {
+  const SmallVectorImpl &LibraryPaths,
+  StringRef Lib, StringRef Arch, StringRef Target,
+  bool isBitCodeSDL) {
   SmallVector SDLs;
 
   std::string LibDeviceLoc = "/libdevice";
@@ -2121,8 +2122,9 @@ static bool SDLSearch(const Driver &D, const 
llvm::opt::ArgList &DriverArgs,
 static bool GetSDLFromOffloadArchive(
 Compilation &C, const Driver &D, const Tool &T, const JobAction &JA,
 const InputInfoList &Inputs, const llvm::opt::ArgList &DriverArgs,
-llvm::opt::ArgStringList &CC1Args, const SmallVectorImpl 
&LibraryPaths,
-StringRef Lib, StringRef Arch, StringRef Target, bool isBitCodeSDL) {
+llvm::opt::ArgStringList &CC1Args,
+const SmallVectorImpl &LibraryPaths, StringRef Lib,
+StringRef Arch, StringRef Target, bool isBitCodeSDL) {
 
   // We don't support bitcode archive bundles for nvptx
   if (isBitCodeSDL && Arch.contains("nvptx"))

``




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


[clang] [AST] Use explicit type erasure in TypeSourceInfo constructor (PR #68435)

2023-10-19 Thread via cfe-commits

bonktree wrote:

Ping.
Is there something to be done next to get this merged? Thanks.

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


[clang] [NFC][Clang] Make GetSDLFromOffloadArchive and SDLSearch static and avoid useless copies in their arguments (PR #69463)

2023-10-19 Thread Juan Manuel Martinez Caamaño via cfe-commits

https://github.com/jmmartinez updated 
https://github.com/llvm/llvm-project/pull/69463

From aff47154ae4d45c2852382aed034ea44df4886d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juan=20Manuel=20MARTINEZ=20CAAMA=C3=91O?= 
Date: Wed, 18 Oct 2023 15:45:07 +0200
Subject: [PATCH 1/3] [NFC][Clang] Remove unused variable "AOBFileNames"

---
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 25fd940584624ee..66790508274ab8b 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2144,7 +2144,6 @@ bool tools::GetSDLFromOffloadArchive(
   Lib = Lib.drop_front(2);
 for (auto LPath : LibraryPaths) {
   ArchiveOfBundles.clear();
-  SmallVector AOBFileNames;
   auto LibFile =
   (Lib.startswith(":") ? Lib.drop_front()
: IsMSVC ? Lib + Ext : "lib" + Lib + Ext)

From 45aad919ed102933fd4810d98ab1e219bf4a660f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juan=20Manuel=20MARTINEZ=20CAAMA=C3=91O?= 
Date: Thu, 19 Oct 2023 12:17:29 +0200
Subject: [PATCH 2/3] [NFC][Clang] Make GetSDLFromOffloadArchive and SDLSearch
 static

---
 clang/lib/Driver/ToolChains/CommonArgs.cpp |  4 ++--
 clang/lib/Driver/ToolChains/CommonArgs.h   | 13 -
 2 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 66790508274ab8b..4f1a87617516317 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2041,7 +2041,7 @@ void tools::addX86AlignBranchArgs(const Driver &D, const 
ArgList &Args,
 /// convention has been to use the prefix “lib”. To avoid confusion with host
 /// archive libraries, we use prefix "libbc-" for the bitcode SDL archives.
 ///
-bool tools::SDLSearch(const Driver &D, const llvm::opt::ArgList &DriverArgs,
+static bool SDLSearch(const Driver &D, const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args,
   SmallVector LibraryPaths, std::string 
Lib,
   StringRef Arch, StringRef Target, bool isBitCodeSDL) {
@@ -2118,7 +2118,7 @@ bool tools::SDLSearch(const Driver &D, const 
llvm::opt::ArgList &DriverArgs,
 /// the library paths. If so, add a new command to clang-offload-bundler to
 /// unbundle this archive and create a temporary device specific archive. Name
 /// of this SDL is passed to the llvm-link tool.
-bool tools::GetSDLFromOffloadArchive(
+static bool GetSDLFromOffloadArchive(
 Compilation &C, const Driver &D, const Tool &T, const JobAction &JA,
 const InputInfoList &Inputs, const llvm::opt::ArgList &DriverArgs,
 llvm::opt::ArgStringList &CC1Args, SmallVector 
LibraryPaths,
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.h 
b/clang/lib/Driver/ToolChains/CommonArgs.h
index 096152bfbdcf68a..f364c9793c9be62 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.h
+++ b/clang/lib/Driver/ToolChains/CommonArgs.h
@@ -66,19 +66,6 @@ void AddStaticDeviceLibs(Compilation *C, const Tool *T, 
const JobAction *JA,
  llvm::opt::ArgStringList &CmdArgs, StringRef Arch,
  StringRef Target, bool isBitCodeSDL);
 
-bool SDLSearch(const Driver &D, const llvm::opt::ArgList &DriverArgs,
-   llvm::opt::ArgStringList &CmdArgs,
-   SmallVector LibraryPaths, std::string Lib,
-   StringRef Arch, StringRef Target, bool isBitCodeSDL);
-
-bool GetSDLFromOffloadArchive(Compilation &C, const Driver &D, const Tool &T,
-  const JobAction &JA, const InputInfoList &Inputs,
-  const llvm::opt::ArgList &DriverArgs,
-  llvm::opt::ArgStringList &CC1Args,
-  SmallVector LibraryPaths,
-  StringRef Lib, StringRef Arch, StringRef Target,
-  bool isBitCodeSDL);
-
 const char *SplitDebugName(const JobAction &JA, const llvm::opt::ArgList &Args,
const InputInfo &Input, const InputInfo &Output);
 

From 7472c0506e4f58c95c7c3eec90dad00f29515f67 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juan=20Manuel=20MARTINEZ=20CAAMA=C3=91O?= 
Date: Thu, 19 Oct 2023 12:20:38 +0200
Subject: [PATCH 3/3] [NFC][Clang] Make read-only arguments of
 GetSDLFromOffloadArchive and SDLSearch read-only references instead of
 copying them

---
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 4f1a87617516317..018f708be031aa8 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2043,8 +2043,9 @@ void tools::addX86AlignBranc

[clang] 4ed0dfe - [Clang][SVE2.1] Add svwhile (predicate-as-counter) builtins

2023-10-19 Thread Caroline Concatto via cfe-commits

Author: Caroline Concatto
Date: 2023-10-19T10:47:32Z
New Revision: 4ed0dfe6adfe2a8b7b1420fec313c4250542747e

URL: 
https://github.com/llvm/llvm-project/commit/4ed0dfe6adfe2a8b7b1420fec313c4250542747e
DIFF: 
https://github.com/llvm/llvm-project/commit/4ed0dfe6adfe2a8b7b1420fec313c4250542747e.diff

LOG: [Clang][SVE2.1] Add svwhile (predicate-as-counter) builtins

As described in: https://github.com/ARM-software/acle/pull/257

Patch by : David Sherwood 

Reviewed By: kmclaughlin

Differential Revision: https://reviews.llvm.org/D151307

Added: 
clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_while_pn.c

Modified: 
clang/include/clang/Basic/arm_sve.td
clang/test/Sema/aarch64-sve2p1-intrinsics/acle_sve2p1_imm.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index 8034cc0c2f04a2b..8f9bdd18829ff6b 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -1871,6 +1871,15 @@ def SVPSEL_COUNT_ALIAS_B : SInst<"svpsel_lane_c8",  
"}}Pm", "Pc", MergeNone, "",
 def SVPSEL_COUNT_ALIAS_H : SInst<"svpsel_lane_c16", "}}Pm", "Ps", MergeNone, 
"", [], []>;
 def SVPSEL_COUNT_ALIAS_S : SInst<"svpsel_lane_c32", "}}Pm", "Pi", MergeNone, 
"", [], []>;
 def SVPSEL_COUNT_ALIAS_D : SInst<"svpsel_lane_c64", "}}Pm", "Pl", MergeNone, 
"", [], []>;
+
+def SVWHILEGE_COUNT  : SInst<"svwhilege_{d}",  "}lli", "QcQsQiQl", MergeNone, 
"aarch64_sve_whilege_{d}", [IsOverloadNone], [ImmCheck<2, ImmCheck2_4_Mul2>]>;
+def SVWHILEGT_COUNT  : SInst<"svwhilegt_{d}",  "}lli", "QcQsQiQl", MergeNone, 
"aarch64_sve_whilegt_{d}", [IsOverloadNone], [ImmCheck<2, ImmCheck2_4_Mul2>]>;
+def SVWHILELE_COUNT  : SInst<"svwhilele_{d}",  "}lli", "QcQsQiQl", MergeNone, 
"aarch64_sve_whilele_{d}", [IsOverloadNone], [ImmCheck<2, ImmCheck2_4_Mul2>]>;
+def SVWHILELT_COUNT  : SInst<"svwhilelt_{d}",  "}lli", "QcQsQiQl", MergeNone, 
"aarch64_sve_whilelt_{d}", [IsOverloadNone], [ImmCheck<2, ImmCheck2_4_Mul2>]>;
+def SVWHILELO_COUNT  : SInst<"svwhilelo_{d}",  "}nni", "QcQsQiQl", MergeNone, 
"aarch64_sve_whilelo_{d}", [IsOverloadNone], [ImmCheck<2, ImmCheck2_4_Mul2>]>;
+def SVWHILELS_COUNT  : SInst<"svwhilels_{d}",  "}nni", "QcQsQiQl", MergeNone, 
"aarch64_sve_whilels_{d}", [IsOverloadNone], [ImmCheck<2, ImmCheck2_4_Mul2>]>;
+def SVWHILEHI_COUNT  : SInst<"svwhilehi_{d}",  "}nni", "QcQsQiQl", MergeNone, 
"aarch64_sve_whilehi_{d}", [IsOverloadNone], [ImmCheck<2, ImmCheck2_4_Mul2>]>;
+def SVWHILEHS_COUNT  : SInst<"svwhilehs_{d}",  "}nni", "QcQsQiQl", MergeNone, 
"aarch64_sve_whilehs_{d}", [IsOverloadNone], [ImmCheck<2, ImmCheck2_4_Mul2>]>;
 }
 
 let TargetGuard = "sve2p1" in {

diff  --git 
a/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_while_pn.c 
b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_while_pn.c
new file mode 100644
index 000..3dbb38582b676c3
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_while_pn.c
@@ -0,0 +1,992 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S 
-O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S 
-O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s 
-check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S 
-disable-O0-optnone -Werror -Wall -o /dev/null %s
+
+// REQUIRES: aarch64-registered-target
+
+#include 
+
+
+// WHILEGE
+
+// CHECK-LABEL: @test_svwhilege_c8_vl2(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call target("aarch64.svcount") 
@llvm.aarch64.sve.whilege.c8(i64 [[OP1:%.*]], i64 [[OP2:%.*]], i32 2)
+// CHECK-NEXT:ret target("aarch64.svcount") [[TMP0]]
+//
+// CPP-CHECK-LABEL: @_Z21test_svwhilege_c8_vl2ll(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call target("aarch64.svcount") 
@llvm.aarch64.sve.whilege.c8(i64 [[OP1:%.*]], i64 [[OP2:%.*]], i32 2)
+// CPP-CHECK-NEXT:ret target("aarch64.svcount") [[TMP0]]
+//
+svcount_t test_svwhilege_c8_vl2(int64_t op1, int64_t op2)
+{
+  return svwhilege_c8(op1, op2, 2);
+}
+
+// CHECK-LABEL: @test_svwhilege_c8_vl4(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call target("aarch64.svcount") 
@llvm.aarch64.sve.whilege.c8(i64 [[OP1:%.*]], i64 [[OP2:%.*]], i32 4)
+// CHECK-NEXT:ret target("aarch64.svcount") [[TMP0]]
+//
+// CPP-CHECK-LABEL: @_Z21test_svwhilege_c8_vl4ll(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call target("aarch64.svcount") 
@llvm.aarch64.sve.whilege.c8(i64 [[OP1:%.*]], i64 [[OP2:%.*]], i32 4)
+// CPP-CHECK-NEXT:ret target("aarch64.svcount") [[TMP0]]
+//
+svcount_t test_svwhilege_c8_vl4(int64_t op1, int64_t op2)
+{
+  return svwhilege_c8(op1, op2, 4);
+}
+
+// CHECK-LABEL: @test_sv

[PATCH] D151307: [Clang][SVE2.1] Add svwhile (predicate-as-counter) builtins

2023-10-19 Thread Caroline via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4ed0dfe6adfe: [Clang][SVE2.1] Add svwhile 
(predicate-as-counter) builtins (authored by CarolineConcatto).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151307/new/

https://reviews.llvm.org/D151307

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_while_pn.c
  clang/test/Sema/aarch64-sve2p1-intrinsics/acle_sve2p1_imm.cpp

Index: clang/test/Sema/aarch64-sve2p1-intrinsics/acle_sve2p1_imm.cpp
===
--- clang/test/Sema/aarch64-sve2p1-intrinsics/acle_sve2p1_imm.cpp
+++ clang/test/Sema/aarch64-sve2p1-intrinsics/acle_sve2p1_imm.cpp
@@ -27,6 +27,74 @@
   svpext_lane_c64_x2(c, 2); // expected-error {{argument value 2 is outside the valid range [0, 1]}}
 }
 
+svcount_t test_svwhile_pn(int64_t op1, int64_t op2) {
+  svwhilege_c8(op1, op2, 6);  // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilege_c16(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilege_c32(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilege_c64(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilegt_c8(op1, op2, 6);  // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilegt_c16(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilegt_c32(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilegt_c64(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilehi_c8(op1, op2, 6);  // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilehi_c16(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilehi_c32(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilehi_c64(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilehs_c8(op1, op2, 6);  // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilehs_c16(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilehs_c32(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilehs_c64(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilele_c8(op1, op2, 6);  // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilele_c16(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilele_c32(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilele_c64(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilelo_c8(op1, op2, 6);  // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilelo_c16(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilelo_c32(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilelo_c64(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilels_c8(op1, op2, 6);  // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilels_c16(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilels_c32(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilels_c64(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilelt_c8(op1, op2, 6);  // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilelt_c16(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilelt_c32(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+  svwhilelt_c64(op1, op2, 6); // expected-error {{argument value 6 is outside the valid range [2, 4]}}
+
+  svwhilege_c8(op1, op2, 3);  // expected-error {{argument should be a multiple of 2}}
+  svwhilege_c16(op1, op2, 3); // expected-error {{argument should be a multiple of 2}}
+  svwhilege_c32(op1, op2, 3); // expected-error {{argument should be a multiple of 2}}
+  svwhilege_c64(op1, op2, 3); // expected-error {{argument should be a multiple of 2}}
+  svwhilegt_c8(op1, op2, 3);  // expected-error {{argument should be a multiple of 2}}
+  svwhilegt_c16(op1, op2, 3); // expected-error {{argument should be a multiple of 2}}
+  svwhilegt_c32(op1, op2, 3); // expected-error {{argument should be a multiple of 2}}
+  svwhilegt_c64(op1, op2

[clang] [Clang] Actually fix tests for __builtin_vectorelements (PR #69589)

2023-10-19 Thread Lawrence Benson via cfe-commits

https://github.com/lawben created 
https://github.com/llvm/llvm-project/pull/69589

In #69582, I accidentally disabled all tests for the changed introduced in 
#69010. This change should use the correct `REQUIRES` syntax to en-/disable 
target-specific tests.

>From 52c2267696651c533d9ffa8f511047960e459155 Mon Sep 17 00:00:00 2001
From: Lawrence Benson 
Date: Thu, 19 Oct 2023 12:45:57 +0200
Subject: [PATCH] Actually fix tests for __builtin_vectorelements

---
 clang/test/CodeGen/builtin_vectorelements.c   | 6 +++---
 clang/test/SemaCXX/builtin_vectorelements.cpp | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/test/CodeGen/builtin_vectorelements.c 
b/clang/test/CodeGen/builtin_vectorelements.c
index 06d9ee7e056a83e..b0ff6f83b1e4adb 100644
--- a/clang/test/CodeGen/builtin_vectorelements.c
+++ b/clang/test/CodeGen/builtin_vectorelements.c
@@ -1,12 +1,12 @@
 // RUN: %clang_cc1 -O1 -triple x86_64%s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK   %s
 
-// REQUIRES: target=aarch64-{{.*}}
+// REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -O1 -triple aarch64 -target-feature +neon %s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,NEON  %s
 
-// REQUIRES: target=aarch64-{{.*}}
+// REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -O1 -triple aarch64 -target-feature +sve  %s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,SVE   %s
 
-// REQUIRES: target=riscv64{{.*}}
+// REQUIRES: riscv-registered-target
 // RUN: %clang_cc1 -O1 -triple riscv64 -target-feature +v%s -emit-llvm 
-disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,RISCV %s
 
 /// Note that this does not make sense to check for x86 SIMD types, because
diff --git a/clang/test/SemaCXX/builtin_vectorelements.cpp 
b/clang/test/SemaCXX/builtin_vectorelements.cpp
index f40ba2a902cb5fc..59ff09ac72e42d7 100644
--- a/clang/test/SemaCXX/builtin_vectorelements.cpp
+++ b/clang/test/SemaCXX/builtin_vectorelements.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64   -std=c++20 
-fsyntax-only -verify -disable-llvm-passes %s
 
-// REQUIRES: target=aarch64-{{.*}}
+// REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -triple aarch64 -target-feature +sve -std=c++20 
-fsyntax-only -verify -disable-llvm-passes %s
 
 template 

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


  1   2   3   4   5   >