[clang-tools-extra] [clang] [llvm] Add out-of-line-atomics support to GlobalISel (PR #74588)

2023-12-18 Thread Matt Arsenault via cfe-commits

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


[clang] [clang-tools-extra] [llvm] Add out-of-line-atomics support to GlobalISel (PR #74588)

2023-12-18 Thread Matt Arsenault via cfe-commits


@@ -765,6 +766,138 @@ llvm::createMemLibcall(MachineIRBuilder &MIRBuilder, 
MachineRegisterInfo &MRI,
   return LegalizerHelper::Legalized;
 }
 
+static RTLIB::Libcall getOutlineAtomicLibcall(MachineInstr &MI) {
+  unsigned Opc = MI.getOpcode();
+  auto &AtomicMI = cast(MI);
+  auto &MMO = AtomicMI.getMMO();
+  auto Ordering = MMO.getMergedOrdering();
+  LLT MemType = MMO.getMemoryType();
+  uint64_t MemSize = MemType.getSizeInBytes();
+  if (!MemType.isScalar())

arsenm wrote:

Probably should check isVector, this will incorrectly bail for pointers 

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


[clang-tools-extra] [clang] [llvm] Add out-of-line-atomics support to GlobalISel (PR #74588)

2023-12-18 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm commented:

Are pointer type xchg / cmpxchg already tested?

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


[clang] ca10343 - [clang][dataflow] Fix an issue with `Environment::getResultObjectLocation()`. (#75483)

2023-12-18 Thread via cfe-commits

Author: martinboehme
Date: 2023-12-18T09:10:03+01:00
New Revision: ca1034341cfec226c09ff0e473c6ecbcc2a1194c

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

LOG: [clang][dataflow] Fix an issue with 
`Environment::getResultObjectLocation()`. (#75483)

So far, if there was a chain of record type prvalues,
`getResultObjectLocation()` would assign a different result object
location to
each one. This makes no sense, of course, as all of these prvalues end
up
initializing the same result object.

This patch fixes this by propagating storage locations up through the
entire
chain of prvalues.

The new implementation also has the desirable effect of making it
possible to
make `getResultObjectLocation()` const, which seems appropriate given
that,
logically, it is just an accessor.

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Analysis/FlowSensitive/Transfer.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index d7e39ab2616fd9..5943af50b6ad8f 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -325,7 +325,8 @@ class Environment {
   ///
   /// Requirements:
   ///  `E` must be a prvalue of record type.
-  RecordStorageLocation &getResultObjectLocation(const Expr &RecordPRValue);
+  RecordStorageLocation &
+  getResultObjectLocation(const Expr &RecordPRValue) const;
 
   /// Returns the return value of the current function. This can be null if:
   /// - The function has a void return type
@@ -434,24 +435,14 @@ class Environment {
 
   /// Assigns `Val` as the value of the prvalue `E` in the environment.
   ///
-  /// If `E` is not yet associated with a storage location, associates it with
-  /// a newly created storage location. In any case, associates the storage
-  /// location of `E` with `Val`.
-  ///
-  /// Once the migration to strict handling of value categories is complete
-  /// (see https://discourse.llvm.org/t/70086), this function will be renamed 
to
-  /// `setValue()`. At this point, prvalue expressions will be associated
-  /// directly with `Value`s, and the legacy behavior of associating prvalue
-  /// expressions with storage locations (as described above) will be
-  /// eliminated.
-  ///
   /// Requirements:
   ///
-  ///  `E` must be a prvalue
-  ///  If `Val` is a `RecordValue`, its `RecordStorageLocation` must be the
-  ///  same as that of any `RecordValue` that has already been associated with
-  ///  `E`. This is to guarantee that the result object initialized by a 
prvalue
-  ///  `RecordValue` has a durable storage location.
+  ///  - `E` must be a prvalue
+  ///  - If `Val` is a `RecordValue`, its `RecordStorageLocation` must be
+  ///`getResultObjectLocation(E)`. An exception to this is if `E` is an
+  ///expression that originally creates a `RecordValue` (such as a
+  ///`CXXConstructExpr` or `CallExpr`), as these establish the location of
+  ///the result object in the first place.
   void setValue(const Expr &E, Value &Val);
 
   /// Returns the value assigned to `Loc` in the environment or null if `Loc`
@@ -608,14 +599,6 @@ class Environment {
   // The copy-constructor is for use in fork() only.
   Environment(const Environment &) = default;
 
-  /// Internal version of `setStorageLocation()` that doesn't check if the
-  /// expression is a prvalue.
-  void setStorageLocationInternal(const Expr &E, StorageLocation &Loc);
-
-  /// Internal version of `getStorageLocation()` that doesn't check if the
-  /// expression is a prvalue.
-  StorageLocation *getStorageLocationInternal(const Expr &E) const;
-
   /// Creates a value appropriate for `Type`, if `Type` is supported, otherwise
   /// return null.
   ///

diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index b98037b7364522..93919cd0243d0c 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -726,27 +726,70 @@ void Environment::setStorageLocation(const Expr &E, 
StorageLocation &Loc) {
   // so allow these as an exception.
   assert(E.isGLValue() ||
  E.getType()->isSpecificBuiltinType(BuiltinType::BuiltinFn));
-  setStorageLocationInternal(E, Loc);
+  const Expr &CanonE = ignoreCFGOmittedNodes(E);
+  assert(!ExprToLoc.contains(&CanonE));
+  ExprToLoc[&CanonE] = &Loc;
 }
 
 StorageLocation *Environment::getStorageLocation(const Expr 

[clang] [clang][dataflow] Fix an issue with `Environment::getResultObjectLocation()`. (PR #75483)

2023-12-18 Thread via cfe-commits

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


[clang] c7cdf3c - [clang] Use 'starts_with' instead of 'startswith' in Gnu.cpp (NFC)

2023-12-18 Thread Jie Fu via cfe-commits

Author: Jie Fu
Date: 2023-12-18T16:10:49+08:00
New Revision: c7cdf3cd5d748901e1370f1bfe803685ca658fb6

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

LOG: [clang] Use 'starts_with' instead of 'startswith' in Gnu.cpp (NFC)

llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp:1757:14:
 error: 'startswith' is deprecated: Use starts_with instead 
[-Werror,-Wdeprecated-declarations]
 1757 | if (Flag.startswith("!march=") || Flag.startswith("-march="))
  |  ^~
  |  starts_with

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 02228e19dcf2ea..7f463ddd17d3d6 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1754,7 +1754,7 @@ selectRISCVMultilib(const MultilibSet &RISCVMultilibSet, 
StringRef Arch,
 
   // Collect all flags except march=*
   for (StringRef Flag : Flags) {
-if (Flag.startswith("!march=") || Flag.startswith("-march="))
+if (Flag.starts_with("!march=") || Flag.starts_with("-march="))
   continue;
 
 NewFlags.push_back(Flag.str());



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


[clang-tools-extra] Allow to pass config file to clang-tidy-diff (PR #75457)

2023-12-18 Thread Michael Lettrich via cfe-commits

https://github.com/MichaelLettrich updated 
https://github.com/llvm/llvm-project/pull/75457

>From 382a8a5355b06f191941099c1eac029dbb9d4bb4 Mon Sep 17 00:00:00 2001
From: Michael Lettrich 
Date: Thu, 14 Dec 2023 11:31:28 +0100
Subject: [PATCH 1/2] Allow to pass config file to clang-tidy-diff

Adds a `-config-file` command line option that passes on the path of 
.`clang-tidy` or custom config file to the `clang-tidy` executable.
---
 clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py | 8 
 1 file changed, 8 insertions(+)

diff --git a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py 
b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
index 8817e2914f6e25..d96b3450fdbe81 100755
--- a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -173,6 +173,12 @@ def main():
 help="checks filter, when not specified, use clang-tidy " "default",
 default="",
 )
+parser.add_argument(
+"-config-file",
+dest="config_file",
+help="Specify the path of .clang-tidy or custom config file",
+default="",
+)
 parser.add_argument("-use-color", action="store_true", help="Use colors in 
output")
 parser.add_argument(
 "-path", dest="build_path", help="Path used to read a compile command 
database."
@@ -313,6 +319,8 @@ def main():
 common_clang_tidy_args.append("-fix")
 if args.checks != "":
 common_clang_tidy_args.append("-checks=" + args.checks)
+if args.config_file != "":
+common_clang_tidy_args.append("-config-file=" + args.config_file)
 if args.quiet:
 common_clang_tidy_args.append("-quiet")
 if args.build_path is not None:

>From 9ef2829e44f2b8ad27b58e74c4068f2c72aba69b Mon Sep 17 00:00:00 2001
From: Michael Lettrich 
Date: Mon, 18 Dec 2023 09:12:30 +0100
Subject: [PATCH 2/2] Add to ReleaseNotes.rst

Document changes to clang-tidy-diff in release notes.
---
 clang-tools-extra/docs/ReleaseNotes.rst | 5 +
 1 file changed, 5 insertions(+)

diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 6d91748e4cef18..7c568d1e94d9f4 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -128,6 +128,11 @@ Improvements to clang-tidy
   as a value for `-export-fixes` to export individual yaml files for each
   compilation unit.
 
+- Improved :program:`clang-tidy-diff.py` script. It now accepts a 
`-config-file` option
+  to pass in a configuration file to :program:`clang-tidy`. This option 
corresponds
+  to the `--config-file` option in :program:`clang-tidy`.
+
+
 New checks
 ^^
 

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


[clang-tools-extra] Allow to pass config file to clang-tidy-diff (PR #75457)

2023-12-18 Thread Michael Lettrich via cfe-commits

https://github.com/MichaelLettrich updated 
https://github.com/llvm/llvm-project/pull/75457

>From 64fbf57d93ef3569f89b3f4d770cc849bc4b3604 Mon Sep 17 00:00:00 2001
From: Michael Lettrich 
Date: Thu, 14 Dec 2023 11:31:28 +0100
Subject: [PATCH] Allow to pass config file to clang-tidy-diff

Adds a `-config-file` command line option that passes on the path of 
.`clang-tidy` or custom config file to the `clang-tidy` executable.
---
 clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py | 8 
 clang-tools-extra/docs/ReleaseNotes.rst  | 5 +
 2 files changed, 13 insertions(+)

diff --git a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py 
b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
index 8817e2914f6e25..d96b3450fdbe81 100755
--- a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -173,6 +173,12 @@ def main():
 help="checks filter, when not specified, use clang-tidy " "default",
 default="",
 )
+parser.add_argument(
+"-config-file",
+dest="config_file",
+help="Specify the path of .clang-tidy or custom config file",
+default="",
+)
 parser.add_argument("-use-color", action="store_true", help="Use colors in 
output")
 parser.add_argument(
 "-path", dest="build_path", help="Path used to read a compile command 
database."
@@ -313,6 +319,8 @@ def main():
 common_clang_tidy_args.append("-fix")
 if args.checks != "":
 common_clang_tidy_args.append("-checks=" + args.checks)
+if args.config_file != "":
+common_clang_tidy_args.append("-config-file=" + args.config_file)
 if args.quiet:
 common_clang_tidy_args.append("-quiet")
 if args.build_path is not None:
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 6d91748e4cef18..7c568d1e94d9f4 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -128,6 +128,11 @@ Improvements to clang-tidy
   as a value for `-export-fixes` to export individual yaml files for each
   compilation unit.
 
+- Improved :program:`clang-tidy-diff.py` script. It now accepts a 
`-config-file` option
+  to pass in a configuration file to :program:`clang-tidy`. This option 
corresponds
+  to the `--config-file` option in :program:`clang-tidy`.
+
+
 New checks
 ^^
 

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


[clang-tools-extra] Allow to pass config file to clang-tidy-diff (PR #75457)

2023-12-18 Thread Michael Lettrich via cfe-commits

MichaelLettrich wrote:

@PiotrZSL thanks for the review I  added the to the release notes as requested.

@cjappl thanks for mentioning. I copied and adapted your release notes into 
this branch.

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


[clang-tools-extra] [lld] [llvm] [clang] [compiler-rt] [flang] [libc] [lldb] [libcxx] Don't emit relax relocs like R_X86_64_REX_GOTPCRELX on X86 target for OPENMP internal vars. (PR #75564)

2023-12-18 Thread via cfe-commits

https://github.com/UmeshKalappa0 updated 
https://github.com/llvm/llvm-project/pull/75564

>From 4125e4a709c594562fa6c52f045ba7442e3cb523 Mon Sep 17 00:00:00 2001
From: Umesh Kalappa 
Date: Fri, 15 Dec 2023 11:52:52 +0530
Subject: [PATCH 1/2] Problem :For Kernel Modules ,emitting the relocs like
 R_X86_64_REX_GOTPCRELX  for the OPENMP internal vars like
 https://godbolt.org/z/hhh7ozojz.

Solution : Mark the OpenMP internal variables with dso_local
conditionally for no-pic and no-pie ,then
a)reset the dso_local for thread_local and weak linkage vars.
---
 .../test/OpenMP/gomp_critical_dso_local_var.c | 23 +++
 1 file changed, 23 insertions(+)
 create mode 100644 clang/test/OpenMP/gomp_critical_dso_local_var.c

diff --git a/clang/test/OpenMP/gomp_critical_dso_local_var.c 
b/clang/test/OpenMP/gomp_critical_dso_local_var.c
new file mode 100644
index 00..915f6773bf67bf
--- /dev/null
+++ b/clang/test/OpenMP/gomp_critical_dso_local_var.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s 
--check-prefix=DSO_LOCAL
+
+// DSO_LOCAL-DAG: @.gomp_critical_user_.var = common dso_local global [8 x 
i32] zeroinitializer, align 8
+int omp_critical_test()
+{
+  int sum;
+  int known_sum;
+
+  sum=0;
+#pragma omp parallel
+  {
+int mysum=0;
+int i;
+#pragma omp for
+for (i = 0; i < 1000; i++)
+  mysum = mysum + i;
+#pragma omp critical
+sum = mysum +sum;
+  }
+  known_sum = 999 * 1000 / 2;
+  return (known_sum == sum);
+}
+

>From 842245de490ab15f8a901b94576ae4539c760e1e Mon Sep 17 00:00:00 2001
From: Umesh Kalappa 
Date: Fri, 15 Dec 2023 12:49:48 +0530
Subject: [PATCH 2/2] testcases are changed accordignly.

---
 clang/lib/CodeGen/CGOpenMPRuntime.cpp   | 2 ++
 clang/test/OpenMP/critical_codegen.cpp  | 6 +++---
 clang/test/OpenMP/critical_codegen_attr.cpp | 6 +++---
 clang/test/OpenMP/for_reduction_codegen.cpp | 8 
 clang/test/OpenMP/gomp_critical_dso_local_var.c | 1 -
 clang/test/OpenMP/simd_codegen.cpp  | 4 ++--
 llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp   | 8 
 7 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 7f7e6f53066644..183c757d72b8a7 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1793,6 +1793,8 @@ Address 
CGOpenMPRuntime::getAddrOfArtificialThreadPrivate(CodeGenFunction &CGF,
   if (CGM.getLangOpts().OpenMP && CGM.getLangOpts().OpenMPUseTLS &&
   CGM.getTarget().isTLSSupported()) {
 GAddr->setThreadLocal(/*Val=*/true);
+/// reset the dso_local for thread_local.
+GAddr->setDSOLocal(/*Val=*/false);
 return Address(GAddr, GAddr->getValueType(),
CGM.getContext().getTypeAlignInChars(VarType));
   }
diff --git a/clang/test/OpenMP/critical_codegen.cpp 
b/clang/test/OpenMP/critical_codegen.cpp
index 24145d44d962e5..9a613161ac294a 100644
--- a/clang/test/OpenMP/critical_codegen.cpp
+++ b/clang/test/OpenMP/critical_codegen.cpp
@@ -16,9 +16,9 @@
 #define HEADER
 
 // ALL:   [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, ptr }
-// ALL:   [[UNNAMED_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK1:@.+]] = common global [8 x i32] zeroinitializer
+// ALL:   [[UNNAMED_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK1:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
 
 // ALL:   define {{.*}}void [[FOO:@.+]]()
 
diff --git a/clang/test/OpenMP/critical_codegen_attr.cpp 
b/clang/test/OpenMP/critical_codegen_attr.cpp
index 34d90a9e3a6e48..5f1a76e2ad0f1f 100644
--- a/clang/test/OpenMP/critical_codegen_attr.cpp
+++ b/clang/test/OpenMP/critical_codegen_attr.cpp
@@ -16,9 +16,9 @@
 #define HEADER
 
 // ALL:   [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, ptr }
-// ALL:   [[UNNAMED_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK1:@.+]] = common global [8 x i32] zeroinitializer
+// ALL:   [[UNNAMED_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK1:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
 
 // ALL:   define {{.*}}void [[FOO:@.+]]()
 
diff --git a/clang/test/OpenMP/for_reduction_codegen.cpp 
b/clang/test/OpenMP/for_reduction_codegen.cpp
index 893c606f8d7b9f..b128bd5d79c251 100644
--- a/clang/test/OpenMP/for_reduction_codegen.cpp
+++ b/clang/test/OpenMP/for_reduction_codegen.cpp
@@ -528,12 +528,12 @@ int main() {
 
 #endif
 //.
-// CHECK1: @.gomp_critical_user_.red

[clang-tools-extra] [clangd] Expand response files before CDB interpolation (PR #75753)

2023-12-18 Thread Nathan Ridge via cfe-commits

https://github.com/HighCommander4 requested changes to this pull request.

Thanks for having a look at this!

Instead of performing the "expand response files" operation twice for commands 
coming from a `compile_commands.json` source, what do you think about the 
following:

 * Restore the call in `parseJSON()` (i.e. what the patch is doing now), **and**
 * Move the call in `CommandMangler` to a place that is only used for commands 
coming from the LSP, such as around 
[here](https://searchfox.org/llvm/rev/b6cce87110072a2db19276e042cd40b06285abbc/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp#745)?
   * We could consider abstracting `OverlayCDB::Commands` into a dedicated 
`tooling::CompilationDatabase` implementation so that we can simply wrap it 
using `clang::tooling::expandResponseFiles()`, but feel free to leave that for 
later; a direct call to `tooling::addExpandedResponseFiles`, as we had in the 
mangler itself, is fine for now.

It would be nice to have a unit test for this regression as well. We have tests 
exercising `OverlayCDB` in 
[GlobalCompilationDatabaseTests.cpp](https://searchfox.org/llvm/source/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp),
 I think that should be suitable.

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


[clang] [AArch64][SME] Warn when using a streaming builtin from a non-streaming function (PR #75487)

2023-12-18 Thread Sam Tebbs via cfe-commits

SamTebbs33 wrote:

@nico I tried to cherry-pick your commit 
(c60663d128f8e0dccd418bdf16ecc403b96aa74a)  into my branch but for some reason 
it was always empty. It might be best for you to try recommitting it now.

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


[clang-tools-extra] [clangd] Add languages as server capabilities (PR #75633)

2023-12-18 Thread Nathan Ridge via cfe-commits

https://github.com/HighCommander4 commented:

Thanks for the patch!

I like the idea of having the server announce support for a list of languages, 
that seems nice and general and extensible.

A couple of thoughts:

 1. Since the key we're adding to the server capabilities is a non-standard 
extension, I'm a bit uneasy about giving it a general name like `"languages"`. 
If the LSP were to add a key with that name but a different format or 
interpretation, we could run into trouble. Can we name it `"clangdLanguages"` 
instead, thereby staying within our own (improvised) "namespace"?
 2. Given that the plan described by Sam in [this 
comment](https://github.com/clangd/vscode-clangd/pull/392#issuecomment-1285902875)
 is to enable vscode-clangd support for HLSL by default once clang's support 
for HLSL is a good enough state, what do you think about the following 
arrangement:
 * don't include `"hlsl"` in `"clangdLanguages"` yet
 * add `"hlsl"` to `"clangdLanguages"` once the "good enough" threshold is 
reached
 * on the client side, add HLSL to the document selector if the server 
announces support for `"hlsl"` in `"clangdLanguages"`, **or** a client-side 
preference (which we could name "experimental", e.g. 
`"clangd.experimentalHLSLSupport"`) is enabled?
 
 This way:
  * early adopters can set `"clangd.experimentalHLSLSupport"` with an 
up-to-date client paired even with a clangd 17 or older server, and get the 
corresponding level of support
 * once the implementation quality is good enough, the server can start 
announcing the support and all clients (not just early adopters who set the 
pref) will have it by default with newer server versions

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


[clang] [AArch64][SME] Warn when using a streaming builtin from a non-streaming function (PR #75487)

2023-12-18 Thread Sam Tebbs via cfe-commits

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


[llvm] [clang-tools-extra] [LoopVectorize] Enable hoisting of runtime checks by default (PR #71538)

2023-12-18 Thread David Sherwood via cfe-commits

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


[clang] [Clang][SVE2.1] Make a part of the name optional for `svwhileXX` builtins with predicate-as-counter (PR #75200)

2023-12-18 Thread Sander de Smalen via cfe-commits

https://github.com/sdesmalen-arm approved this pull request.

LGTM

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


[clang] [Clang][SVE2.1] Make a part of the name optional for `svwhileXX` builtins with predicate-as-counter (PR #75200)

2023-12-18 Thread Sander de Smalen via cfe-commits

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


[clang] [Clang][SVE2.1] Make a part of the name optional for `svwhileXX` builtins with predicate-as-counter (PR #75200)

2023-12-18 Thread Sander de Smalen via cfe-commits


@@ -1,12 +1,21 @@
 // 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 +sme2 -S -O1 
-Werror -Wall -emit-llvm -o - %s | FileCheck %s

sdesmalen-arm wrote:

very little nit: could you move this line after line 6?

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


[clang] [clang] Fix CTAD not work for C++ explicit type conversion (functional annotation). (PR #75779)

2023-12-18 Thread Haojian Wu via cfe-commits

https://github.com/hokein created 
https://github.com/llvm/llvm-project/pull/75779

Fixes https://github.com/llvm/llvm-project/issues/64347

>From 073f3d87bc9e22e3fb80ee9ab297e0bd6e4127f2 Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Mon, 18 Dec 2023 10:41:45 +0100
Subject: [PATCH] [clang] Fix CTAD not work for C++ explicit type conversion
 (functional annotation).

Fixes https://github.com/llvm/llvm-project/issues/64347
---
 clang/docs/ReleaseNotes.rst |  2 ++
 clang/lib/Sema/SemaDecl.cpp |  2 +-
 clang/lib/Sema/SemaInit.cpp | 11 +++
 clang/test/SemaCXX/ctad.cpp | 19 +++
 4 files changed, 29 insertions(+), 5 deletions(-)
 create mode 100644 clang/test/SemaCXX/ctad.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f5ae6bb8925202..0bb614c2237794 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -685,6 +685,8 @@ Bug Fixes in This Version
   (`#62157 `_) and
   (`#64885 `_) and
   (`#65568 `_)
+- Fix an issue where CTAD fails for explicit type conversion. Fixes
+  (#64347 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index be6a136ef37bc4..85e1d28b0e3fdd 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -12957,7 +12957,7 @@ QualType Sema::deduceVarTypeFromInitializer(VarDecl 
*VDecl,
 // FIXME: Initialization should not be taking a mutable list of inits.
 SmallVector InitsCopy(DeduceInits.begin(), DeduceInits.end());
 return DeduceTemplateSpecializationFromInitializer(TSI, Entity, Kind,
-   InitsCopy, PL);
+   InitsCopy);
   }
 
   if (DirectInit) {
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 4028b2d642b212..7036a88df6b90e 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -10573,7 +10573,7 @@ static bool 
isOrIsDerivedFromSpecializationOf(CXXRecordDecl *RD,
 
 QualType Sema::DeduceTemplateSpecializationFromInitializer(
 TypeSourceInfo *TSInfo, const InitializedEntity &Entity,
-const InitializationKind &Kind, MultiExprArg Inits, ParenListExpr *PL) {
+const InitializationKind &Kind, MultiExprArg Inits) {
   auto *DeducedTST = dyn_cast(
   TSInfo->getType()->getContainedDeducedType());
   assert(DeducedTST && "not a deduced template specialization type");
@@ -10804,9 +10804,12 @@ QualType 
Sema::DeduceTemplateSpecializationFromInitializer(
 if (getLangOpts().CPlusPlus20 && !HasAnyDeductionGuide) {
   if (ListInit && ListInit->getNumInits()) {
 SynthesizeAggrGuide(ListInit);
-  } else if (PL && PL->getNumExprs()) {
-InitListExpr TempListInit(getASTContext(), PL->getLParenLoc(),
-  PL->exprs(), PL->getRParenLoc());
+  } else if (Inits.size()) { // parenthesized expression-list
+// Inits are expressions inside the parentheses. We don't have
+// the parentheses source locaitons, use the begin/end of Inits as the
+// best heuristic.
+InitListExpr TempListInit(getASTContext(), 
Inits.front()->getBeginLoc(),
+  Inits, Inits.back()->getEndLoc());
 SynthesizeAggrGuide(&TempListInit);
   }
 }
diff --git a/clang/test/SemaCXX/ctad.cpp b/clang/test/SemaCXX/ctad.cpp
new file mode 100644
index 00..10806f107b4ee9
--- /dev/null
+++ b/clang/test/SemaCXX/ctad.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused-value -std=c++20 %s
+// expected-no-diagnostics
+
+namespace GH64347 {
+
+template struct A { X x; Y y;};
+void test() {
+   A(1, 2);
+   new A(1, 2);
+}
+
+template
+void f() { (void)a; }
+void k() {
+  // Test CTAD works for non-type template arguments.
+  f();
+}
+
+} // namespace GH64347

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


[clang] [clang] Fix CTAD not work for C++ explicit type conversion (functional annotation). (PR #75779)

2023-12-18 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Haojian Wu (hokein)


Changes

Fixes https://github.com/llvm/llvm-project/issues/64347

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


4 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaInit.cpp (+7-4) 
- (added) clang/test/SemaCXX/ctad.cpp (+19) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f5ae6bb8925202..0bb614c2237794 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -685,6 +685,8 @@ Bug Fixes in This Version
   (`#62157 `_) and
   (`#64885 `_) and
   (`#65568 `_)
+- Fix an issue where CTAD fails for explicit type conversion. Fixes
+  (#64347 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index be6a136ef37bc4..85e1d28b0e3fdd 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -12957,7 +12957,7 @@ QualType Sema::deduceVarTypeFromInitializer(VarDecl 
*VDecl,
 // FIXME: Initialization should not be taking a mutable list of inits.
 SmallVector InitsCopy(DeduceInits.begin(), DeduceInits.end());
 return DeduceTemplateSpecializationFromInitializer(TSI, Entity, Kind,
-   InitsCopy, PL);
+   InitsCopy);
   }
 
   if (DirectInit) {
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 4028b2d642b212..7036a88df6b90e 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -10573,7 +10573,7 @@ static bool 
isOrIsDerivedFromSpecializationOf(CXXRecordDecl *RD,
 
 QualType Sema::DeduceTemplateSpecializationFromInitializer(
 TypeSourceInfo *TSInfo, const InitializedEntity &Entity,
-const InitializationKind &Kind, MultiExprArg Inits, ParenListExpr *PL) {
+const InitializationKind &Kind, MultiExprArg Inits) {
   auto *DeducedTST = dyn_cast(
   TSInfo->getType()->getContainedDeducedType());
   assert(DeducedTST && "not a deduced template specialization type");
@@ -10804,9 +10804,12 @@ QualType 
Sema::DeduceTemplateSpecializationFromInitializer(
 if (getLangOpts().CPlusPlus20 && !HasAnyDeductionGuide) {
   if (ListInit && ListInit->getNumInits()) {
 SynthesizeAggrGuide(ListInit);
-  } else if (PL && PL->getNumExprs()) {
-InitListExpr TempListInit(getASTContext(), PL->getLParenLoc(),
-  PL->exprs(), PL->getRParenLoc());
+  } else if (Inits.size()) { // parenthesized expression-list
+// Inits are expressions inside the parentheses. We don't have
+// the parentheses source locaitons, use the begin/end of Inits as the
+// best heuristic.
+InitListExpr TempListInit(getASTContext(), 
Inits.front()->getBeginLoc(),
+  Inits, Inits.back()->getEndLoc());
 SynthesizeAggrGuide(&TempListInit);
   }
 }
diff --git a/clang/test/SemaCXX/ctad.cpp b/clang/test/SemaCXX/ctad.cpp
new file mode 100644
index 00..10806f107b4ee9
--- /dev/null
+++ b/clang/test/SemaCXX/ctad.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused-value -std=c++20 %s
+// expected-no-diagnostics
+
+namespace GH64347 {
+
+template struct A { X x; Y y;};
+void test() {
+   A(1, 2);
+   new A(1, 2);
+}
+
+template
+void f() { (void)a; }
+void k() {
+  // Test CTAD works for non-type template arguments.
+  f();
+}
+
+} // namespace GH64347

``




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


[clang] [clang] Fix CTAD not respect default template arguments that were added after the definition. (PR #75569)

2023-12-18 Thread Haojian Wu via cfe-commits

https://github.com/hokein updated 
https://github.com/llvm/llvm-project/pull/75569

>From 0f49d91b4a22944216cff8654f9c00f892bb02be Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Fri, 15 Dec 2023 08:44:57 +0100
Subject: [PATCH 1/2] [clang] Fix CTAD not respect default template arguments
 that were added after the definition.

Fixes https://github.com/llvm/llvm-project/issues/69987
---
 clang/docs/ReleaseNotes.rst  |  2 ++
 clang/lib/Sema/SemaTemplate.cpp  | 22 +-
 clang/test/SemaTemplate/ctad.cpp | 10 ++
 3 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f5ae6bb8925202..be826e6a44bfc7 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -685,6 +685,8 @@ Bug Fixes in This Version
   (`#62157 `_) and
   (`#64885 `_) and
   (`#65568 `_)
+- Fix an issue where clang doesn't respect detault template arguments that
+  are added in a later redeclaration for CTAD. (#69987 
`_)
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index f10abeaba0d451..450a1a1db0ba86 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -1824,6 +1824,15 @@ static void SetNestedNameSpecifier(Sema &S, TagDecl *T,
 T->setQualifierInfo(SS.getWithLocInContext(S.Context));
 }
 
+// Returns the template parameter list with all default template argument
+// information.
+static TemplateParameterList *GetTemplateParameterList(TemplateDecl *TD) {
+  // Make sure we get the template parameter list from the most
+  // recent declaration, since that is the only one that is guaranteed to
+  // have all the default template argument information.
+  return cast(TD->getMostRecentDecl())->getTemplateParameters();
+}
+
 DeclResult Sema::CheckClassTemplate(
 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
 CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc,
@@ -2062,7 +2071,7 @@ DeclResult Sema::CheckClassTemplate(
   CheckTemplateParameterList(
   TemplateParams,
   PrevClassTemplate
-  ? PrevClassTemplate->getMostRecentDecl()->getTemplateParameters()
+  ? GetTemplateParameterList(PrevClassTemplate)
   : nullptr,
   (SS.isSet() && SemanticContext && SemanticContext->isRecord() &&
SemanticContext->isDependentContext())
@@ -2298,7 +2307,7 @@ struct ConvertConstructorToDeductionGuideTransform {
 //-- The template parameters are the template parameters of the class
 //   template followed by the template parameters (including default
 //   template arguments) of the constructor, if any.
-TemplateParameterList *TemplateParams = Template->getTemplateParameters();
+TemplateParameterList *TemplateParams = GetTemplateParameterList(Template);
 if (FTD) {
   TemplateParameterList *InnerParams = FTD->getTemplateParameters();
   SmallVector AllParams;
@@ -2424,7 +2433,7 @@ struct ConvertConstructorToDeductionGuideTransform {
   Params.push_back(NewParam);
 }
 
-return buildDeductionGuide(Template->getTemplateParameters(), nullptr,
+return buildDeductionGuide(GetTemplateParameterList(Template), nullptr,
ExplicitSpecifier(), TSI, Loc, Loc, Loc);
   }
 
@@ -5956,12 +5965,7 @@ bool Sema::CheckTemplateArgumentList(
   // template.
   TemplateArgumentListInfo NewArgs = TemplateArgs;
 
-  // Make sure we get the template parameter list from the most
-  // recent declaration, since that is the only one that is guaranteed to
-  // have all the default template argument information.
-  TemplateParameterList *Params =
-  cast(Template->getMostRecentDecl())
-  ->getTemplateParameters();
+  TemplateParameterList *Params = GetTemplateParameterList(Template);
 
   SourceLocation RAngleLoc = NewArgs.getRAngleLoc();
 
diff --git a/clang/test/SemaTemplate/ctad.cpp b/clang/test/SemaTemplate/ctad.cpp
index 4d836839d8c346..388ed7d4cced18 100644
--- a/clang/test/SemaTemplate/ctad.cpp
+++ b/clang/test/SemaTemplate/ctad.cpp
@@ -44,3 +44,13 @@ namespace Access {
   };
   D z = {Z(), {}};
 }
+
+namespace GH69987 {
+template struct X {};
+template struct X;
+X x;
+
+template struct Y { Y(T); };
+template struct Y ;
+Y y(1);
+};

>From 87ad4508047f7be623871ca61967d3ff02313fcf Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Mon, 18 Dec 2023 10:53:55 +0100
Subject: [PATCH 2/2] Update the release doc and fix clang-format

---
 clang/docs/ReleaseNotes.rst | 3 ++-
 clang/lib/Sema/SemaTemplate.cpp | 8 
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/Releas

[clang] [clang] Fix CTAD not respect default template arguments that were added after the definition. (PR #75569)

2023-12-18 Thread Haojian Wu via cfe-commits


@@ -685,6 +685,8 @@ Bug Fixes in This Version
   (`#62157 `_) and
   (`#64885 `_) and
   (`#65568 `_)
+- Fix an issue where clang doesn't respect detault template arguments that
+  are added in a later redeclaration for CTAD. (#69987 
`_)

hokein wrote:

Done.

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


[llvm] [clang] [AMDGPU] Improve selection of ballot.i64 intrinsic in wave32 mode. (PR #71556)

2023-12-18 Thread Sebastian Neubauer via cfe-commits

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


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


[clang] [clang][Sema] Add -Wswitch-default warning option (PR #73077)

2023-12-18 Thread via cfe-commits

gendalph wrote:

`
enum class test
{
  err1,
  err2,
  ok
};

int check_err (test v)
{
  switch (v)
{
  case test::err1:
return 1;
  case test::err2:
return 2;
  case test::ok:
break;
}
  return 0;
}
`

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


[clang-tools-extra] [clang] [mlir] [llvm] [MLIR][Linalg] Support dynamic sizes in `lower_unpack` (PR #75494)

2023-12-18 Thread lorenzo chelini via cfe-commits

https://github.com/chelini commented:

Thanks!

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


[llvm] [clang] [clang-tools-extra] [mlir] [MLIR][Linalg] Support dynamic sizes in `lower_unpack` (PR #75494)

2023-12-18 Thread lorenzo chelini via cfe-commits

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


[clang] [llvm] [clang-tools-extra] [mlir] [MLIR][Linalg] Support dynamic sizes in `lower_unpack` (PR #75494)

2023-12-18 Thread lorenzo chelini via cfe-commits


@@ -434,8 +429,21 @@ FailureOr 
linalg::lowerUnPack(RewriterBase &rewriter,
   RankedTensorType::Builder(packedTensorType).setShape(stripMinedShape);
   RankedTensorType collapsedType = tensor::CollapseShapeOp::inferCollapsedType(
   stripMinedTensorType, packingMetadata.reassociations);
+
+  // Get dynamic dims from input tensor in order of stripMinedTensor

chelini wrote:

Not sure if I understand the comment. I would rephrase as: `Get dynamic dims 
from input tensor based on lastDimsToInsertPositionsPerm permutation`.

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


[clang-tools-extra] [clang] [mlir] [llvm] [MLIR][Linalg] Support dynamic sizes in `lower_unpack` (PR #75494)

2023-12-18 Thread lorenzo chelini via cfe-commits


@@ -434,8 +429,21 @@ FailureOr 
linalg::lowerUnPack(RewriterBase &rewriter,
   RankedTensorType::Builder(packedTensorType).setShape(stripMinedShape);
   RankedTensorType collapsedType = tensor::CollapseShapeOp::inferCollapsedType(
   stripMinedTensorType, packingMetadata.reassociations);
+
+  // Get dynamic dims from input tensor in order of stripMinedTensor
+  // `tensor.empty` op
+  SmallVector dims =
+  tensor::getMixedSizes(rewriter, loc, unPackOp.getSource());
+  applyPermutationToVector(dims, lastDimsToInsertPositionsPerm);
+  SmallVector dynDims;

chelini wrote:

We can avoid the loop using another builder method for emptyOp:

```
SmallVector dims =
  tensor::getMixedSizes(rewriter, loc, unPackOp.getSource());
applyPermutationToVector(dims, lastDimsToInsertPositionsPerm);

auto emptyOp = rewriter.create(
  loc, dims, stripMinedTensorType.getElementType());
```


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


[mlir] [clang-tools-extra] [llvm] [clang] [MLIR][Linalg] Support dynamic sizes in `lower_unpack` (PR #75494)

2023-12-18 Thread lorenzo chelini via cfe-commits


@@ -381,11 +381,6 @@ FailureOr 
linalg::lowerUnPack(RewriterBase &rewriter,
 return rewriter.notifyMatchFailure(unPackOp, "outer dims perm NYI");
 
   RankedTensorType packedTensorType = unPackOp.getSourceType();

chelini wrote:

nit: I would move this line after `rewriter.setInsertionPoint(unPackOp);` as it 
is used further down now.

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


[clang] [clang] Fix CTAD not work for C++ explicit type conversion (functional annotation). (PR #75779)

2023-12-18 Thread via cfe-commits


@@ -10804,9 +10804,12 @@ QualType 
Sema::DeduceTemplateSpecializationFromInitializer(
 if (getLangOpts().CPlusPlus20 && !HasAnyDeductionGuide) {
   if (ListInit && ListInit->getNumInits()) {
 SynthesizeAggrGuide(ListInit);
-  } else if (PL && PL->getNumExprs()) {
-InitListExpr TempListInit(getASTContext(), PL->getLParenLoc(),
-  PL->exprs(), PL->getRParenLoc());
+  } else if (Inits.size()) { // parenthesized expression-list
+// Inits are expressions inside the parentheses. We don't have
+// the parentheses source locaitons, use the begin/end of Inits as the

cor3ntin wrote:

```suggestion
// the parentheses source locations, use the begin/end of Inits as the
```

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


[clang] [clang] Fix CTAD not work for C++ explicit type conversion (functional annotation). (PR #75779)

2023-12-18 Thread via cfe-commits

https://github.com/cor3ntin commented:

Why remove the support for ParenListExpr entirely?
Could you not fallback on looking at the init list expression only when 
ParenListExpr is null?

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


[clang] [Concepts] Avoid substituting into constraints for invalid TemplateDecls (PR #75697)

2023-12-18 Thread via cfe-commits


@@ -353,6 +353,10 @@ static ExprResult calculateConstraintSatisfaction(
   if (Inst.isInvalid())
 return ExprError();
 
+  // An empty expression for substitution failure messages.
+  if (Template && Template->isInvalidDecl())
+return ExprEmpty();

cor3ntin wrote:

Can you explain why not return ExprError here? Does it just produce more 
diagnostics?

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


[flang] [llvm] [clang-tools-extra] [clang] [flang] Pass to add frame pointer attribute (PR #74598)

2023-12-18 Thread Kiran Chandramohan via cfe-commits

kiranchandramohan wrote:

> > llc has a --frame-pointer option, so there is likely a way to pass this 
> > option to the llvm codegen as a global option instead of setting it on all 
> > function at the MLIR level if the only goal is to propagate it to llvm 
> > backend.
> 
> I just discussed a bit with @vzakhari and one advantage of setting it per 
> function is to later be able to merge llvm IR files compiled with different 
> options. That would explain why clang does it. I would still add nothing if 
> the option is None since this is the default, but seems OK to me to decorate 
> the functions as you are doing based on this argument.

@jeanPerier just checking whether you are OK with this pass being here or would 
prefer it to be in LLVM dialect?

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


[clang] [clang][Interp] Implement integral->complex casts (PR #75590)

2023-12-18 Thread via cfe-commits

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


[clang] [clang][Interp] Implement integral->complex casts (PR #75590)

2023-12-18 Thread via cfe-commits

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


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


[clang] [clang][Interp] Implement integral->complex casts (PR #75590)

2023-12-18 Thread via cfe-commits


@@ -283,6 +283,28 @@ bool ByteCodeExprGen::VisitCastExpr(const 
CastExpr *CE) {
   case CK_ToVoid:
 return discard(SubExpr);
 
+  case CK_IntegralRealToComplex:
+  case CK_FloatingRealToComplex: {
+// We're creating a complex value here, so need to

cor3ntin wrote:

```suggestion
// We're creating a complex value here, so we need to
```

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


[clang] [RISCV] Implement multi-lib reuse rule for RISC-V bare-metal toolchain (PR #73765)

2023-12-18 Thread Jay Foad via cfe-commits

jayfoad wrote:

The new test is crashing in my Release+Asserts build:
```
FAIL: Clang :: Driver/riscv-toolchain-gcc-multilib-reuse.c (1081 of 1081)
 TEST 'Clang :: 
Driver/riscv-toolchain-gcc-multilib-reuse.c' FAILED 
Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: /home/jayfoad2/llvm-release/bin/clang 
/home/jayfoad2/git/llvm-project/clang/test/Driver/riscv-toolchain-gcc-multilib-reuse.c
-target riscv64-unknown-elf
--gcc-toolchain=/home/jayfoad2/git/llvm-project/clang/test/Driver/Inputs/multilib_riscv_elf_sdk
--print-multi-directory-march=rv32imc -mabi=ilp32| 
/home/jayfoad2/llvm-release/bin/FileCheck 
-check-prefix=GCC-MULTI-LIB-REUSE-RV32IMC-ILP32 
/home/jayfoad2/git/llvm-project/clang/test/Driver/riscv-toolchain-gcc-multilib-reuse.c
+ /home/jayfoad2/llvm-release/bin/FileCheck 
-check-prefix=GCC-MULTI-LIB-REUSE-RV32IMC-ILP32 
/home/jayfoad2/git/llvm-project/clang/test/Driver/riscv-toolchain-gcc-multilib-reuse.c
+ /home/jayfoad2/llvm-release/bin/clang 
/home/jayfoad2/git/llvm-project/clang/test/Driver/riscv-toolchain-gcc-multilib-reuse.c
 -target riscv64-unknown-elf 
--gcc-toolchain=/home/jayfoad2/git/llvm-project/clang/test/Driver/Inputs/multilib_riscv_elf_sdk
 --print-multi-directory -march=rv32imc -mabi=ilp32
clang: 
/home/jayfoad2/git/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.cpp:2189:
 void clang::driver::tools::addMultilibFlag(bool, const llvm::StringRef, 
Multilib::flags_list &): Assertion `Flag.front() == '-'' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and 
include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.  Program arguments: /home/jayfoad2/llvm-release/bin/clang 
/home/jayfoad2/git/llvm-project/clang/test/Driver/riscv-toolchain-gcc-multilib-reuse.c
 -target riscv64-unknown-elf 
--gcc-toolchain=/home/jayfoad2/git/llvm-project/clang/test/Driver/Inputs/multilib_riscv_elf_sdk
 --print-multi-directory -march=rv32imc -mabi=ilp32
1.  Compilation construction
 #0 0x070bfaf7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/home/jayfoad2/llvm-release/bin/clang+0x70bfaf7)
 #1 0x070bd6ae llvm::sys::RunSignalHandlers() 
(/home/jayfoad2/llvm-release/bin/clang+0x70bd6ae)
 #2 0x070c01ca SignalHandler(int) Signals.cpp:0:0
 #3 0x7fc909c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x7fc909c969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x7fc909c969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x7fc909c969fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x7fc909c42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x7fc909c287f3 abort ./stdlib/abort.c:81:7
 #9 0x7fc909c2871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x7fc909c39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x07b32257 clang::driver::tools::addMultilibFlag(bool, 
llvm::StringRef, std::vector, std::allocator>, 
std::allocator, 
std::allocator>>>&) (/home/jayfoad2/llvm-release/bin/clang+0x7b32257)
#12 0x07abb016 clang::driver::MultilibBuilder::flag(llvm::StringRef, 
bool) (/home/jayfoad2/llvm-release/bin/clang+0x7abb016)
#13 0x07b9ddbf findRISCVMultilibs(clang::driver::Driver const&, 
llvm::Triple const&, llvm::StringRef, llvm::opt::ArgList const&, 
clang::driver::DetectedMultilibs&) Gnu.cpp:0:0
#14 0x07b95459 
clang::driver::toolchains::Generic_GCC::GCCInstallationDetector::ScanGCCForMultilibs(llvm::Triple
 const&, llvm::opt::ArgList const&, llvm::StringRef, bool) Gnu.cpp:0:0
#15 0x07b9b164 
clang::driver::toolchains::Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(llvm::Triple
 const&, llvm::opt::ArgList const&, std::__cxx11::basic_string, std::allocator> const&, llvm::StringRef, bool, 
bool, bool) Gnu.cpp:0:0
#16 0x07b9324c 
clang::driver::toolchains::Generic_GCC::GCCInstallationDetector::init(llvm::Triple
 const&, llvm::opt::ArgList const&) Gnu.cpp:0:0
#17 0x07bf34ba 
clang::driver::toolchains::RISCVToolChain::RISCVToolChain(clang::driver::Driver 
const&, llvm::Triple const&, llvm::opt::ArgList const&) RISCVToolchain.cpp:0:0
#18 0x07a31458 clang::driver::Driver::getToolChain(llvm::opt::ArgList 
const&, llvm::Triple const&) const 
(/home/jayfoad2/llvm-release/bin/clang+0x7a31458)
#19 0x07a38bbe 
clang::driver::Driver::BuildCompilation(llvm::ArrayRef) 
(/home/jayfoad2/llvm-release/bin/clang+0x7a38bbe)
#20 0x04a8a25a clang_main(int, char**, llvm::ToolContext const&) 
(/home/jayfoad2/llvm-release/bin/clang+0x4a8a25a)
#21 0x04a9bb61 main (/home/jayfoad2/llvm-release/bin/clang+0x4a9bb61)
#22 0x7fc909c29d90 __libc_start_call_main 
./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#23 0x7fc909c29e40 call_init ./csu/../csu/libc-start.c:128:20
#24 0x7fc909c29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#25 0x04a875a5 _start (/home/jayfoad2/llvm-relea

[clang] [clang] Fix CTAD not respect default template arguments that were added after the definition. (PR #75569)

2023-12-18 Thread via cfe-commits

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

LGTM, thanks

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


[clang] [clang][Interp] Support __real/__imag on primitives (PR #75485)

2023-12-18 Thread via cfe-commits


@@ -2761,6 +2761,8 @@ bool ByteCodeExprGen::VisitUnaryOperator(const 
UnaryOperator *E) {
   return false;
 return DiscardResult ? this->emitPop(*T, E) : this->emitComp(*T, E);
   case UO_Real: { // __real x
+if (T)
+  return this->delegate(SubExpr);
 assert(!T);

cor3ntin wrote:

Not sure the assert adds anything now

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


[clang] [clang][Interp] Support __real/__imag on primitives (PR #75485)

2023-12-18 Thread via cfe-commits


@@ -2776,6 +2778,11 @@ bool ByteCodeExprGen::VisitUnaryOperator(const 
UnaryOperator *E) {
 return true;
   }
   case UO_Imag: { // __imag x
+if (T) {
+  if (!this->discard(SubExpr))
+return false;
+  return this->visitZeroInitializer(*T, SubExpr->getType(), SubExpr);
+}
 assert(!T);

cor3ntin wrote:

Ditto

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


[clang] [OpenACC] Add 'clause' parsing infrastructure plus a few clauses (PR #75052)

2023-12-18 Thread via cfe-commits


@@ -69,6 +69,29 @@ OpenACCDirectiveKindEx getOpenACCDirectiveKind(Token Tok) {
   .Default(OpenACCDirectiveKindEx::Invalid);
 }
 
+// Translate single-token string representations to the OpenCC Clause Kind.
+OpenACCClauseKind getOpenACCClauseKind(Token Tok) {

cor3ntin wrote:

I missed that!

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


[clang] [OpenACC] Add 'clause' parsing infrastructure plus a few clauses (PR #75052)

2023-12-18 Thread via cfe-commits

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


[clang] [OpenACC] Add 'clause' parsing infrastructure plus a few clauses (PR #75052)

2023-12-18 Thread via cfe-commits

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

LGTM

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


[clang] [OpenACC] Add 'clause' parsing infrastructure plus a few clauses (PR #75052)

2023-12-18 Thread via cfe-commits


@@ -262,12 +291,52 @@ OpenACCDirectiveKind ParseOpenACCDirectiveKind(Parser &P) 
{
   return DirKind;
 }
 
+bool ParseOpenACCClause(Parser &P) {

cor3ntin wrote:

Thanks

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


[clang] [RISCV] Implement multi-lib reuse rule for RISC-V bare-metal toolchain (PR #73765)

2023-12-18 Thread antoine moynault via cfe-commits

antmox wrote:

Hello, looks like it broke some bots too:
clang-aarch64-quick https://lab.llvm.org/buildbot/#/builders/188/builds/39436
clang-armv8-quick https://lab.llvm.org/buildbot/#/builders/245/builds/18162

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


[clang] [AArch64][SME] Warn when using a streaming builtin from a non-streaming function (PR #75487)

2023-12-18 Thread Nikita Popov via cfe-commits

nikic wrote:

When building clang with clang, the regression on SemaChecking.cpp is now 
"only" 60% in terms of instructions retired (plus 0.4% during thin link, which 
is another ~50% in terms of SemaChecking).

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


[clang-tools-extra] Allow to pass config file to clang-tidy-diff (PR #75457)

2023-12-18 Thread Piotr Zegar via cfe-commits


@@ -128,6 +128,11 @@ Improvements to clang-tidy
   as a value for `-export-fixes` to export individual yaml files for each
   compilation unit.
 
+- Improved :program:`clang-tidy-diff.py` script. It now accepts a 
`-config-file` option

PiotrZSL wrote:

There is already entry for clang-tidy-diff.py, this could be appended there & 
maybe refactored to avoid constant "It now".

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


[clang] 1faa1cd - [Clang][SVE2.1] Add intrinsics for `WHILEcc` resulting in predicate pair (#75107)

2023-12-18 Thread via cfe-commits

Author: Momchil Velikov
Date: 2023-12-18T11:03:39Z
New Revision: 1faa1cd02d569c1e58303ab4bd9d082aecda2a52

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

LOG: [Clang][SVE2.1] Add intrinsics for `WHILEcc` resulting in predicate pair 
(#75107)

Add intrinsics of the form:

svboolx2_t svwhile_b{8,16,32,64}_[{s,u}64]_x2([u]int64_t, [u]int64_t);

and their overloaded variants as specified in
https://github.com/ARM-software/acle/pull/257

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

Modified: 
clang/include/clang/Basic/arm_sve.td

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index 98434c5c53e28c..a429a3c5fe378a 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -1341,6 +1341,18 @@ def SVWHILEHS_U32 : SInst<"svwhilege_{d}[_{1}]", "Pmm", 
"PUcPUsPUiPUl", MergeNon
 def SVWHILEHS_U64 : SInst<"svwhilege_{d}[_{1}]", "Pnn", "PUcPUsPUiPUl", 
MergeNone, "aarch64_sve_whilehs", [IsOverloadWhile, IsStreamingCompatible]>;
 }
 
+let TargetGuard = "sve2p1|sme2"  in {
+  def SVWHILEGE_S64_X2 : SInst<"svwhilege_{d}[_{1}]_x2", "2ll", "PcPsPiPl",
 MergeNone, "aarch64_sve_whilege_x2">;
+  def SVWHILEGT_S64_X2 : SInst<"svwhilegt_{d}[_{1}]_x2", "2ll", "PcPsPiPl",
 MergeNone, "aarch64_sve_whilegt_x2">;
+  def SVWHILEHI_U64_X2 : SInst<"svwhilegt_{d}[_{1}]_x2", "2nn", "PcPsPiPl",
 MergeNone, "aarch64_sve_whilehi_x2">;
+  def SVWHILEHS_U64_X2 : SInst<"svwhilege_{d}[_{1}]_x2", "2nn", "PcPsPiPl",
 MergeNone, "aarch64_sve_whilehs_x2">;
+  def SVWHILELE_S64_X2 : SInst<"svwhilele_{d}[_{1}]_x2", "2ll", "PcPsPiPl",
 MergeNone, "aarch64_sve_whilele_x2">;
+  def SVWHILELT_S64_X2 : SInst<"svwhilelt_{d}[_{1}]_x2", "2ll", "PcPsPiPl",
 MergeNone, "aarch64_sve_whilelt_x2">;
+  def SVWHILELO_U64_X2 : SInst<"svwhilelt_{d}[_{1}]_x2", "2nn", "PcPsPiPl",
 MergeNone, "aarch64_sve_whilelo_x2">;
+  def SVWHILELS_U64_X2 : SInst<"svwhilele_{d}[_{1}]_x2", "2nn", "PcPsPiPl",
 MergeNone, "aarch64_sve_whilels_x2">;
+
+}
+
 

 // SVE2 - Uniform DSP operations
 

diff  --git 
a/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_while_x2.c 
b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_while_x2.c
new file mode 100644
index 00..acead9be3f01d2
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_while_x2.c
@@ -0,0 +1,879 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 4
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -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 -o /dev/null %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 -S 
-disable-O0-optnone -Werror -o /dev/null %s
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3) A1##A2##A3
+#endif
+
+// CHECK-LABEL: define dso_local  @test_svwhilege_b8_s64(
+// CHECK-SAME: i64 noundef [[OP1:%.*]], i64 noundef [[OP2:%.*]]) 
#[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call { ,  } @llvm.aarch64.sve.whilege.x2.nxv16i1(i64 [[OP1]], i64 [[OP2]])
+// CHECK-NEXT:[[TMP1:%.*]] = extractvalue { ,  } [[TMP0]], 0
+// CHECK-NEXT:[[TMP2:%.*]] = tail call  
@llvm.vector.insert.nxv32i1.nxv16i1( poison,  [[TMP1]], i64 0)
+// CHECK-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP0]], 1
+// CHECK-NEXT:[[TMP4:%.*]] = tail call  
@llvm.vector.insert.nxv32i1.nxv16i1( [[TMP2]],  [[TMP3]], i64 16)
+// CHECK-NEXT:ret  [[TMP4]]
+//
+// CPP-CHECK-LABEL: define dso_local  
@_Z21test_svwhilege_b8_s64ll(
+// CPP-CHECK-SAME: i64 noundef [[OP1:%.*]], i64 noundef [[OP2:%.*]]) 
#[[ATTR0:[0-9]+]] {
+// CPP-CHECK-NEXT:  entry:
+// CPP

[clang] [Clang][SVE2.1] Add intrinsics for `WHILEcc` resulting in predicate pair (PR #75107)

2023-12-18 Thread Momchil Velikov via cfe-commits

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


[clang] [AArch64][SME2] Enable bfm builtins for sme2 (PR #71927)

2023-12-18 Thread Sam Tebbs via cfe-commits

https://github.com/SamTebbs33 updated 
https://github.com/llvm/llvm-project/pull/71927

>From 93a02d9af1d7e4f1e23c252d72b20d292927a79f Mon Sep 17 00:00:00 2001
From: Samuel Tebbs 
Date: Thu, 9 Nov 2023 17:39:26 +
Subject: [PATCH 1/5] [AArch64][SME2] Enable bfm builtings for sme2

This patch enables the following builtins for SME2
svbfmlslb_f32
svbfmlslb_lane_f32
svbfmlslt_f32
svbfmlslt_lane_f32

Patch by: Kerry McLaughlin 
---
 clang/include/clang/Basic/arm_sve.td  | 15 +--
 .../acle_sve2p1_bfmlsl.c  |  5 +
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index 98434c5c53e28c..38437e98858b23 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -2057,12 +2057,6 @@ def SVDOT_X2_F : SInst<"svdot[_{d}_{2}_{3}]", "ddhh", 
"f",  MergeNone, "aarch64_
 def SVDOT_LANE_X2_S : SInst<"svdot_lane[_{d}_{2}_{3}]", "ddhhi", "i",  
MergeNone, "aarch64_sve_sdot_lane_x2", [], [ImmCheck<3, ImmCheck0_3>]>;
 def SVDOT_LANE_X2_U : SInst<"svdot_lane[_{d}_{2}_{3}]", "ddhhi", "Ui", 
MergeNone, "aarch64_sve_udot_lane_x2", [], [ImmCheck<3, ImmCheck0_3>]>;
 def SVDOT_LANE_X2_F : SInst<"svdot_lane[_{d}_{2}_{3}]", "ddhhi", "f",  
MergeNone, "aarch64_sve_fdot_lane_x2", [], [ImmCheck<3, ImmCheck0_3>]>;
-
-def SVBFMLSLB : SInst<"svbfmlslb[_{d}]", "dd$$", "f", MergeNone, 
"aarch64_sve_bfmlslb", [IsOverloadNone], []>;
-def SVBFMLSLT : SInst<"svbfmlslt[_{d}]", "dd$$", "f", MergeNone, 
"aarch64_sve_bfmlslt", [IsOverloadNone], []>;
-
-def SVBFMLSLB_LANE : SInst<"svbfmlslb_lane[_{d}]", "dd$$i", "f", MergeNone, 
"aarch64_sve_bfmlslb_lane", [IsOverloadNone], [ImmCheck<3, ImmCheck0_7>]>;
-def SVBFMLSLT_LANE : SInst<"svbfmlslt_lane[_{d}]", "dd$$i", "f", MergeNone, 
"aarch64_sve_bfmlslt_lane", [IsOverloadNone], [ImmCheck<3, ImmCheck0_7>]>;
 }
 
 let TargetGuard = "sve2p1" in {
@@ -2306,3 +2300,12 @@ let TargetGuard = "sme2" in {
   def SVSUNPK_X4 : SInst<"svunpk_{d}[_{3}_x4]", "42.h", "sil",MergeNone, 
"aarch64_sve_sunpk_x4", [IsStreaming], []>;
   def SVUUNPK_X4 : SInst<"svunpk_{d}[_{3}_x4]", "42.h", "UsUiUl", MergeNone, 
"aarch64_sve_uunpk_x4", [IsStreaming], []>;
 }
+
+let TargetGuard = "sve2p1|sme" in {
+// == BFloat16 multiply-subtract ==
+  def SVBFMLSLB : SInst<"svbfmlslb[_{d}]", "dd$$", "f", MergeNone, 
"aarch64_sve_bfmlslb", [IsOverloadNone], []>;
+  def SVBFMLSLT : SInst<"svbfmlslt[_{d}]", "dd$$", "f", MergeNone, 
"aarch64_sve_bfmlslt", [IsOverloadNone], []>;
+
+  def SVBFMLSLB_LANE : SInst<"svbfmlslb_lane[_{d}]", "dd$$i", "f", MergeNone, 
"aarch64_sve_bfmlslb_lane", [IsOverloadNone], [ImmCheck<3, ImmCheck0_7>]>;
+  def SVBFMLSLT_LANE : SInst<"svbfmlslt_lane[_{d}]", "dd$$i", "f", MergeNone, 
"aarch64_sve_bfmlslt_lane", [IsOverloadNone], [ImmCheck<3, ImmCheck0_7>]>;
+}
diff --git a/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_bfmlsl.c 
b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_bfmlsl.c
index 7e1763a63ec4e1..519bf019ff35ba 100644
--- a/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_bfmlsl.c
+++ b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_bfmlsl.c
@@ -2,10 +2,15 @@
 // REQUIRES: aarch64-registered-target
 
 // RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu 
-target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s 
| opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu 
-target-feature +sme2 -target-feature +sve -S -disable-O0-optnone -Werror -Wall 
-emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s
 // RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu 
-target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - -x 
c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s 
-check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu 
-target-feature +sme2 -target-feature +sve -S -disable-O0-optnone -Werror -Wall 
-emit-llvm -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | 
FileCheck %s -check-prefix=CPP-CHECK
 // RUN: %clang_cc1 -fclang-abi-compat=latest -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror 
-Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | 
FileCheck %s
+// RUN: %clang_cc1 -fclang-abi-compat=latest -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu -target-feature +sme2 -target-feature +sve -S 
-disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p 
mem2reg,instcombine,tailcallelim | FileCheck %s
 // RUN: %clang_cc1 -fclang-abi-compat=latest -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 -p mem2reg,instcombine,tail

[clang] [AArch64][SME2] Enable bfm builtins for sme2 (PR #71927)

2023-12-18 Thread Sam Tebbs via cfe-commits


@@ -1992,3 +1986,12 @@ let TargetGuard = "sme2" in {
   def SVADD_SINGLE_X2 : SInst<"svadd[_single_{d}_x2]", "22d", "cUcsUsiUilUl", 
MergeNone, "aarch64_sve_add_single_x2", [IsStreaming], []>;
   def SVADD_SINGLE_X4 : SInst<"svadd[_single_{d}_x4]", "44d", "cUcsUsiUilUl", 
MergeNone, "aarch64_sve_add_single_x4", [IsStreaming], []>;
 }
+
+let TargetGuard = "sve2p1|sme2" in {
+// == BFloat16 multiply-subtract ==
+  def SVBFMLSLB : SInst<"svbfmlslb[_{d}]", "dd$$", "f", MergeNone, 
"aarch64_sve_bfmlslb", [IsOverloadNone, IsStreaming], []>;
+  def SVBFMLSLT : SInst<"svbfmlslt[_{d}]", "dd$$", "f", MergeNone, 
"aarch64_sve_bfmlslt", [IsOverloadNone, IsStreaming], []>;
+
+  def SVBFMLSLB_LANE : SInst<"svbfmlslb_lane[_{d}]", "dd$$i", "f", MergeNone, 
"aarch64_sve_bfmlslb_lane", [IsOverloadNone, IsStreaming], [ImmCheck<3, 
ImmCheck0_7>]>;

SamTebbs33 wrote:

Thanks Sander. I've made these builtins use `IsStreamingCompatible`, which will 
be changed to `IsStreamingOrSVE2p1` once that is added.

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


[clang] [AArch64][SME2] Enable bfm builtins for sme2 (PR #71927)

2023-12-18 Thread Sam Tebbs via cfe-commits

SamTebbs33 wrote:

Rebased to fix a merge conflict and made the builtins temporarily 
`IsStreamingCompatible`.

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


[clang] [clang] Fix --entry command line option (PR #69114)

2023-12-18 Thread Tuur Martens via cfe-commits

JohnyTheCarrot wrote:

Heya @MaskRay 

If and when you get the chance, would you mind giving it another look?
I applied your requested changes. :)

Thanks!

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


[clang-tools-extra] [NFC][clang] add a clang tool for mlir refactor (PR #75279)

2023-12-18 Thread via cfe-commits

https://github.com/lipracer updated 
https://github.com/llvm/llvm-project/pull/75279

>From 71ae35b1538201790e5fc7a25d1d7aba7df7913d Mon Sep 17 00:00:00 2001
From: lipracer 
Date: Wed, 13 Dec 2023 11:37:12 +0800
Subject: [PATCH] [NFC][clang] add a clang tool for mlir refactor

---
 clang-tools-extra/CMakeLists.txt  |   1 +
 .../mlir-cast-refactor/CMakeLists.txt |  18 ++
 .../mlir-cast-refactor/MlirCastRefactor.cpp   | 172 ++
 3 files changed, 191 insertions(+)
 create mode 100644 clang-tools-extra/mlir-cast-refactor/CMakeLists.txt
 create mode 100644 clang-tools-extra/mlir-cast-refactor/MlirCastRefactor.cpp

diff --git a/clang-tools-extra/CMakeLists.txt b/clang-tools-extra/CMakeLists.txt
index 6a3f741721ee6c..44e4f02dca3326 100644
--- a/clang-tools-extra/CMakeLists.txt
+++ b/clang-tools-extra/CMakeLists.txt
@@ -27,6 +27,7 @@ add_subdirectory(include-cleaner)
 add_subdirectory(pp-trace)
 add_subdirectory(pseudo)
 add_subdirectory(tool-template)
+add_subdirectory(mlir-cast-refactor)
 
 option(CLANG_TOOLS_EXTRA_INCLUDE_DOCS "Generate build targets for the Clang 
Extra Tools docs."
   ${LLVM_INCLUDE_DOCS})
diff --git a/clang-tools-extra/mlir-cast-refactor/CMakeLists.txt 
b/clang-tools-extra/mlir-cast-refactor/CMakeLists.txt
new file mode 100644
index 00..ebdabf23fc53c3
--- /dev/null
+++ b/clang-tools-extra/mlir-cast-refactor/CMakeLists.txt
@@ -0,0 +1,18 @@
+set(LLVM_LINK_COMPONENTS support)
+
+add_clang_executable(mlirCastRefactor
+  MlirCastRefactor.cpp
+  )
+target_link_libraries(mlirCastRefactor
+  PRIVATE
+clangAST
+clangBasic
+clangFormat
+clangFrontend
+clangLex
+clangRewrite
+clangSerialization
+clangTooling
+clangToolingCore
+clangToolingRefactoring
+  )
\ No newline at end of file
diff --git a/clang-tools-extra/mlir-cast-refactor/MlirCastRefactor.cpp 
b/clang-tools-extra/mlir-cast-refactor/MlirCastRefactor.cpp
new file mode 100644
index 00..0ebb48b60940c7
--- /dev/null
+++ b/clang-tools-extra/mlir-cast-refactor/MlirCastRefactor.cpp
@@ -0,0 +1,172 @@
+//===-- MlirCastRefactor.cpp - mlir refactor implementation 
---===//
+//
+// 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
+//
+//===--===//
+
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+#include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/Refactoring/AtomicChange.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Support/CommandLine.h"
+
+using namespace clang::tooling;
+using namespace llvm;
+
+// Apply a custom category to all command-line options so that they are the
+// only ones displayed.
+static llvm::cl::OptionCategory MyToolCategory("my-tool options");
+static cl::opt target_type("target-type",
+cl::desc("refactoring type name"),
+cl::value_desc("type name"),
+cl::ValueRequired, cl::NotHidden,
+cl::cat(MyToolCategory));
+
+// CommonOptionsParser declares HelpMessage with a description of the common
+// command-line options related to the compilation database and input files.
+// It's nice to have this help message in all tools.
+static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
+
+// A help message for this specific tool can be added afterwards.
+static cl::extrahelp MoreHelp("\nMore help text...\n");
+
+using namespace clang;
+using namespace clang::ast_matchers;
+
+class MemberFunctionCallMatcher : public MatchFinder::MatchCallback {
+public:
+  void run(const MatchFinder::MatchResult &Result) override {
+if (const CXXMemberCallExpr *MemberCall =
+Result.Nodes.getNodeAs("memberCall")) {
+  auto objExpr = MemberCall->getImplicitObjectArgument();
+  auto endLoc = MemberCall->getExprLoc();
+
+  auto exprRange = objExpr->getSourceRange();
+
+  SourceLocation StartLoc = objExpr->getBeginLoc();
+
+  const SourceManager &SM = *Result.SourceManager;
+  const char *StartPtr = SM.getCharacterData(StartLoc);
+  const char *EndPtr = SM.getCharacterData(endLoc);
+
+  tooling::AtomicChange change(*Result.SourceManager,
+   MemberCall->getExprLoc());
+  const auto *ME = Result.Nodes.getNodeAs("member");
+  size_t dropbackCount = ME->isArrow() ? 2 : 1;
+
+  {
+auto length = EndPtr - StartPtr;
+objExprStrings.emplace_back(StartPtr, length);
+change.replace(*Result.SourceManager, StartLoc, EndPtr - StartPtr, "");
+  }
+
+  {
+// remove keyword template e.g. obj->tem

[openmp] [lldb] [mlir] [clang] [flang] [libcxx] [libc] [compiler-rt] [llvm] [clang-tools-extra] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-18 Thread Nikolas Klauser via cfe-commits


@@ -0,0 +1,136 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+constexpr void testSpanAt(auto span, int idx, int expectedValue) {
+  // non-const
+  {
+std::same_as decltype(auto) elem = 
span.at(idx);
+assert(elem == expectedValue);
+  }
+
+  // const
+  {
+std::same_as decltype(auto) elem = 
std::as_const(span).at(idx);
+assert(elem == expectedValue);
+  }
+}
+
+constexpr bool test() {
+  // With static extent
+  {
+std::array arr{0, 1, 2, 3, 4, 5, 9084};
+std::span arrSpan{arr};
+
+assert(std::dynamic_extent != arrSpan.extent);
+
+testSpanAt(arrSpan, 0, 0);
+testSpanAt(arrSpan, 1, 1);
+testSpanAt(arrSpan, 6, 9084);
+  }
+
+  // With dynamic extent
+  {
+std::vector vec{0, 1, 2, 3, 4, 5, 9084};
+std::span vecSpan{vec};
+
+assert(std::dynamic_extent == vecSpan.extent);
+
+testSpanAt(vecSpan, 0, 0);
+testSpanAt(vecSpan, 1, 1);
+testSpanAt(vecSpan, 6, 9084);
+  }
+
+  return true;
+}
+
+void test_exceptions() {

philnik777 wrote:

I meant that you should test `span.at(numeric_limits::max())`.

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


[clang] [clang][Sema] Add -Wswitch-default warning option (PR #73077)

2023-12-18 Thread dong jianqiang via cfe-commits

dongjianqiang2 wrote:

> ```
> enum class test
> {
>   err1,
>   err2,
>   ok
> };
> 
> int check_err (test v)
> {
>   switch (v)
> {
>   case test::err1:
> return 1;
>   case test::err2:
> return 2;
>   case test::ok:
> break;
> }
>   return 0;
> }
> ```
> 
> report: main.cxx:40:3: error: 'switch' missing 'default' label 
> [-Werror,-Wswitch-default]
> 
> how to solve for enum class? try to build libfmt project with 
> fmt/include/fmt/format.h:3878:3: error: 'switch' missing 'default' label 
> [-Werror,-Wswitch-default] and other errors

Hi, -Wswitch-default is a warning option on switch which don't have the default 
branch, the option is disabled by default, You can check whether 
-Wswitch-default is added in the build script.

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


[clang] [clang] Fix CTAD not work for C++ explicit type conversion (functional annotation). (PR #75779)

2023-12-18 Thread Haojian Wu via cfe-commits

hokein wrote:

> Why remove the support for ParenListExpr entirely? Could you not fallback on 
> looking at the init list expression only when ParenListExpr is null?

We could keep `ParenListExpr`,  but I'm not sure the benefit (IMO, removing it 
seems like an API improvement, and make code simpler). The `ParenListExpr` is 
redundant with the existing `Inits` parameter to some degree, the only benefit 
to use it is for the precise `()` location information (as we deduct the 
template type here, I think it is fine to use a less-precise source location).

Looking at all usages (total 4) of 
`DeduceTemplateSpecializationFromInitializer` in clang, only 1 
[place](https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaDecl.cpp#L12959)
 passes the `ParenListExpr`. 

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


[clang] [clang] Fix CTAD not respect default template arguments that were added after the definition. (PR #75569)

2023-12-18 Thread Haojian Wu via cfe-commits

hokein wrote:

Thanks for the review.

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


[clang] 42239d2 - [clang] Fix CTAD not respect default template arguments that were added after the definition. (#75569)

2023-12-18 Thread via cfe-commits

Author: Haojian Wu
Date: 2023-12-18T12:37:29+01:00
New Revision: 42239d2e96c5683a2973c39ea7ea20b616218b66

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

LOG: [clang] Fix CTAD not respect default template arguments that were added 
after the definition. (#75569)

Fixes https://github.com/llvm/llvm-project/issues/69987

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaTemplate.cpp
clang/test/SemaTemplate/ctad.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 26ba4f8f72508a..2e32f8b36d23de 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -688,6 +688,9 @@ Bug Fixes in This Version
   (`#62157 `_) and
   (`#64885 `_) and
   (`#65568 `_)
+- Fix an issue where clang doesn't respect detault template arguments that
+  are added in a later redeclaration for CTAD.
+  Fixes (#69987 `_)
 
 Bug Fixes to Compiler Builtins
 ^^

diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index f10abeaba0d451..5fcc39ec700522 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -1824,6 +1824,15 @@ static void SetNestedNameSpecifier(Sema &S, TagDecl *T,
 T->setQualifierInfo(SS.getWithLocInContext(S.Context));
 }
 
+// Returns the template parameter list with all default template argument
+// information.
+static TemplateParameterList *GetTemplateParameterList(TemplateDecl *TD) {
+  // Make sure we get the template parameter list from the most
+  // recent declaration, since that is the only one that is guaranteed to
+  // have all the default template argument information.
+  return cast(TD->getMostRecentDecl())->getTemplateParameters();
+}
+
 DeclResult Sema::CheckClassTemplate(
 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
 CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc,
@@ -2061,13 +2070,13 @@ DeclResult Sema::CheckClassTemplate(
   if (!(TUK == TUK_Friend && CurContext->isDependentContext()) &&
   CheckTemplateParameterList(
   TemplateParams,
-  PrevClassTemplate
-  ? PrevClassTemplate->getMostRecentDecl()->getTemplateParameters()
-  : nullptr,
+  PrevClassTemplate ? GetTemplateParameterList(PrevClassTemplate)
+: nullptr,
   (SS.isSet() && SemanticContext && SemanticContext->isRecord() &&
SemanticContext->isDependentContext())
   ? TPC_ClassTemplateMember
-  : TUK == TUK_Friend ? TPC_FriendClassTemplate : 
TPC_ClassTemplate,
+  : TUK == TUK_Friend ? TPC_FriendClassTemplate
+  : TPC_ClassTemplate,
   SkipBody))
 Invalid = true;
 
@@ -2298,7 +2307,7 @@ struct ConvertConstructorToDeductionGuideTransform {
 //-- The template parameters are the template parameters of the class
 //   template followed by the template parameters (including default
 //   template arguments) of the constructor, if any.
-TemplateParameterList *TemplateParams = Template->getTemplateParameters();
+TemplateParameterList *TemplateParams = GetTemplateParameterList(Template);
 if (FTD) {
   TemplateParameterList *InnerParams = FTD->getTemplateParameters();
   SmallVector AllParams;
@@ -2424,7 +2433,7 @@ struct ConvertConstructorToDeductionGuideTransform {
   Params.push_back(NewParam);
 }
 
-return buildDeductionGuide(Template->getTemplateParameters(), nullptr,
+return buildDeductionGuide(GetTemplateParameterList(Template), nullptr,
ExplicitSpecifier(), TSI, Loc, Loc, Loc);
   }
 
@@ -5956,12 +5965,7 @@ bool Sema::CheckTemplateArgumentList(
   // template.
   TemplateArgumentListInfo NewArgs = TemplateArgs;
 
-  // Make sure we get the template parameter list from the most
-  // recent declaration, since that is the only one that is guaranteed to
-  // have all the default template argument information.
-  TemplateParameterList *Params =
-  cast(Template->getMostRecentDecl())
-  ->getTemplateParameters();
+  TemplateParameterList *Params = GetTemplateParameterList(Template);
 
   SourceLocation RAngleLoc = NewArgs.getRAngleLoc();
 

diff  --git a/clang/test/SemaTemplate/ctad.cpp 
b/clang/test/SemaTemplate/ctad.cpp
index 4d836839d8c346..388ed7d4cced18 100644
--- a/clang/test/SemaTemplate/ctad.cpp
+++ b/clang/test/SemaTemplate/ctad.cpp
@@ -44,3 +44,13 @@ namespace Access {
   };
   D z = {Z(), {}};
 }
+
+namespace GH69987 {

[clang] [clang] Fix CTAD not respect default template arguments that were added after the definition. (PR #75569)

2023-12-18 Thread Haojian Wu via cfe-commits

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


[clang-tools-extra] [llvm] [clang] Add out-of-line-atomics support to GlobalISel (PR #74588)

2023-12-18 Thread Thomas Preud'homme via cfe-commits

RoboTux wrote:

> Not an expert on atomics, but why would we have a libcall for -O0 but not for 
> O1 in the tests?

I looked at it for the u?(min|max) and it seemed to boil down to the atomic 
expand pass being run at -O1 and above.

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


[clang] df3ddd7 - CGBuiltin - fix gcc Wunused-variable warning. NFC.

2023-12-18 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2023-12-18T11:51:24Z
New Revision: df3ddd78f640ebec74151028d919904c6cf9ecdd

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

LOG: CGBuiltin - fix gcc Wunused-variable warning. NFC.

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index c96f86a823a461..c42b885289c4c7 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -942,7 +942,7 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, 
unsigned Type,
  : Builder.CreateZExtOrTrunc(FAMSize, ResType);
   Value *Res = FAMSize;
 
-  if (const auto *DRE = dyn_cast(Base)) {
+  if (isa(Base)) {
 // The whole struct is specificed in the __bdos.
 const RecordDecl *OuterRD =
 CountedByFD->getDeclContext()->getOuterLexicalRecordContext();



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


[clang] [llvm] [clang-tools-extra] Add out-of-line-atomics support to GlobalISel (PR #74588)

2023-12-18 Thread Thomas Preud'homme via cfe-commits

RoboTux wrote:

> > Not an expert on atomics, but why would we have a libcall for -O0 but not 
> > for O1 in the tests?
> 
> I looked at it for the u?(min|max) and it seemed to boil down to the atomic 
> expand pass being run at -O1 and above.

No sorry, it's not that it's only run at O1 and above, it's that the output is 
different. At O0 it keeps the cmpxchg whereas at O1 it changes the cmpxchg into 
a ldxr + stlxr intrinsics.

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


[clang] dea16eb - [LLVM][IR] Replace ConstantInt's specialisation of getType() with getIntegerType(). (#75217)

2023-12-18 Thread via cfe-commits

Author: Paul Walker
Date: 2023-12-18T11:58:42Z
New Revision: dea16ebd2613a4a218c53045270fc4fcc9b427ad

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

LOG: [LLVM][IR] Replace ConstantInt's specialisation of getType() with 
getIntegerType(). (#75217)

The specialisation will not be valid when ConstantInt gains native
support for vector types.

This is largely a mechanical change but with extra attention paid to constant
folding, InstCombineVectorOps.cpp, LoopFlatten.cpp and Verifier.cpp to
remove the need to call `getIntegerType()`.

Co-authored-by: Nikita Popov 

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
llvm/include/llvm/IR/Constants.h
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/lib/IR/ConstantFold.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
llvm/lib/Transforms/Scalar/LoopFlatten.cpp
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
mlir/lib/Target/LLVMIR/ModuleImport.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index c42b885289c4c7..4eb1686f095062 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3214,7 +3214,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 Value *AlignmentValue = EmitScalarExpr(E->getArg(1));
 ConstantInt *AlignmentCI = cast(AlignmentValue);
 if (AlignmentCI->getValue().ugt(llvm::Value::MaximumAlignment))
-  AlignmentCI = ConstantInt::get(AlignmentCI->getType(),
+  AlignmentCI = ConstantInt::get(AlignmentCI->getIntegerType(),
  llvm::Value::MaximumAlignment);
 
 emitAlignmentAssumption(PtrValue, Ptr,
@@ -17034,7 +17034,7 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned 
BuiltinID,
 Value *Op1 = EmitScalarExpr(E->getArg(1));
 ConstantInt *AlignmentCI = cast(Op0);
 if (AlignmentCI->getValue().ugt(llvm::Value::MaximumAlignment))
-  AlignmentCI = ConstantInt::get(AlignmentCI->getType(),
+  AlignmentCI = ConstantInt::get(AlignmentCI->getIntegerType(),
  llvm::Value::MaximumAlignment);
 
 emitAlignmentAssumption(Op1, E->getArg(1),
@@ -17272,7 +17272,8 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned 
BuiltinID,
 Op0, llvm::FixedVectorType::get(ConvertType(E->getType()), 2));
 
 if (getTarget().isLittleEndian())
-  Index = ConstantInt::get(Index->getType(), 1 - Index->getZExtValue());
+  Index =
+  ConstantInt::get(Index->getIntegerType(), 1 - Index->getZExtValue());
 
 return Builder.CreateExtractElement(Unpacked, Index);
   }

diff  --git a/llvm/include/llvm/IR/Constants.h 
b/llvm/include/llvm/IR/Constants.h
index 0b9f89830b79c6..b5dcc7fbc1d929 100644
--- a/llvm/include/llvm/IR/Constants.h
+++ b/llvm/include/llvm/IR/Constants.h
@@ -171,10 +171,9 @@ class ConstantInt final : public ConstantData {
   /// Determine if this constant's value is same as an unsigned char.
   bool equalsInt(uint64_t V) const { return Val == V; }
 
-  /// getType - Specialize the getType() method to always return an 
IntegerType,
-  /// which reduces the amount of casting needed in parts of the compiler.
-  ///
-  inline IntegerType *getType() const {
+  /// Variant of the getType() method to always return an IntegerType, which
+  /// reduces the amount of casting needed in parts of the compiler.
+  inline IntegerType *getIntegerType() const {
 return cast(Value::getType());
   }
 

diff  --git a/llvm/lib/Analysis/InstructionSimplify.cpp 
b/llvm/lib/Analysis/InstructionSimplify.cpp
index 2a45acf63aa2ca..5beac5547d65e0 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -6079,7 +6079,7 @@ static Value *simplifyRelativeLoad(Constant *Ptr, 
Constant *Offset,
   Type *Int32Ty = Type::getInt32Ty(Ptr->getContext());
 
   auto *OffsetConstInt = dyn_cast(Offset);
-  if (!OffsetConstInt || OffsetConstInt->getType()->getBitWidth() > 64)
+  if (!OffsetConstInt || OffsetConstInt->getBitWidth() > 64)
 return nullptr;
 
   APInt OffsetInt = OffsetConstInt->getValue().sextOrTrunc(

diff  --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index d499d74f7ba010..7fdc35e7fca097 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -868,7 +868,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned 
Opcode, Constant *C1,
   }
 
   if (GVAlign > 1) {
-unsigned DstWidth = CI2->getType()->getBitWidth();
+unsigned DstWidth = CI2->getBitWidth();
  

[llvm] [mlir] [clang] [LLVM][IR] Replace ConstantInt's specialisation of getType() with getIntegerType(). (PR #75217)

2023-12-18 Thread Paul Walker via cfe-commits

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


[clang] [AArch64][SME2] Add builtins for FDOT, BFDOT, SUDOT, USDOT, SDOT, UDOT. (PR #75737)

2023-12-18 Thread via cfe-commits

CarolineConcatto wrote:

Hey Dinar,
I will leave the same comments Kerry left in the other one
Can you add check for the immediate in  acle_sme2_imm.cpp

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


[libcxx] [flang] [llvm] [mlir] [clang] [AsmWriter] Ensure getMnemonic doesn't return invalid pointers (PR #75783)

2023-12-18 Thread Lucas Duarte Prates via cfe-commits

https://github.com/pratlucas updated 
https://github.com/llvm/llvm-project/pull/75783

>From 62f4b5daeca0be5b463c5c42271a4b997f084523 Mon Sep 17 00:00:00 2001
From: Lucas Prates 
Date: Mon, 18 Dec 2023 10:49:25 +
Subject: [PATCH] [AsmWriter] Ensure getMnemonic doesn't return invalid
 pointers

For instructions that don't map to a mnemonic string, the implementation
of MCInstPrinter::getMnemonic would return an invalid pointer due to the
result of the calculation of the instruction's position in the `AsmStrs`
table. This patch fixes the issue by ensuring those cases return a
`nullptr` value instead.

Fixes #74177.
---
 llvm/lib/MC/MCAsmStreamer.cpp| 5 -
 llvm/utils/TableGen/AsmWriterEmitter.cpp | 4 
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp
index 9e1d108ac14dc5..532ac89bf9ff76 100644
--- a/llvm/lib/MC/MCAsmStreamer.cpp
+++ b/llvm/lib/MC/MCAsmStreamer.cpp
@@ -154,7 +154,10 @@ class MCAsmStreamer final : public MCStreamer {
   void emitGNUAttribute(unsigned Tag, unsigned Value) override;
 
   StringRef getMnemonic(MCInst &MI) override {
-return InstPrinter->getMnemonic(&MI).first;
+std::pair M = InstPrinter->getMnemonic(&MI);
+assert((M.second != 0 || M.first == nullptr) &&
+   "Invalid char pointer for instruction with no mnemonic");
+return M.first;
   }
 
   void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
diff --git a/llvm/utils/TableGen/AsmWriterEmitter.cpp 
b/llvm/utils/TableGen/AsmWriterEmitter.cpp
index 0220927295cf78..e0cd5fad3254de 100644
--- a/llvm/utils/TableGen/AsmWriterEmitter.cpp
+++ b/llvm/utils/TableGen/AsmWriterEmitter.cpp
@@ -438,6 +438,10 @@ void AsmWriterEmitter::EmitGetMnemonic(
   O << "  // Emit the opcode for the instruction.\n";
   O << BitsString;
 
+  // Make sure we don't return an invalid pointer if bits is 0
+  O << "  if (Bits == 0)\n"
+   "return {nullptr, Bits};\n";
+
   // Return mnemonic string and bits.
   O << "  return {AsmStrs+(Bits & " << (1 << AsmStrBits) - 1
 << ")-1, Bits};\n\n";

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


[libcxx] [flang] [llvm] [mlir] [clang] [AsmWriter] Ensure getMnemonic doesn't return invalid pointers (PR #75783)

2023-12-18 Thread Lucas Duarte Prates via cfe-commits

https://github.com/pratlucas updated 
https://github.com/llvm/llvm-project/pull/75783

>From 62f4b5daeca0be5b463c5c42271a4b997f084523 Mon Sep 17 00:00:00 2001
From: Lucas Prates 
Date: Mon, 18 Dec 2023 10:49:25 +
Subject: [PATCH 1/2] [AsmWriter] Ensure getMnemonic doesn't return invalid
 pointers

For instructions that don't map to a mnemonic string, the implementation
of MCInstPrinter::getMnemonic would return an invalid pointer due to the
result of the calculation of the instruction's position in the `AsmStrs`
table. This patch fixes the issue by ensuring those cases return a
`nullptr` value instead.

Fixes #74177.
---
 llvm/lib/MC/MCAsmStreamer.cpp| 5 -
 llvm/utils/TableGen/AsmWriterEmitter.cpp | 4 
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp
index 9e1d108ac14dc5..532ac89bf9ff76 100644
--- a/llvm/lib/MC/MCAsmStreamer.cpp
+++ b/llvm/lib/MC/MCAsmStreamer.cpp
@@ -154,7 +154,10 @@ class MCAsmStreamer final : public MCStreamer {
   void emitGNUAttribute(unsigned Tag, unsigned Value) override;
 
   StringRef getMnemonic(MCInst &MI) override {
-return InstPrinter->getMnemonic(&MI).first;
+std::pair M = InstPrinter->getMnemonic(&MI);
+assert((M.second != 0 || M.first == nullptr) &&
+   "Invalid char pointer for instruction with no mnemonic");
+return M.first;
   }
 
   void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
diff --git a/llvm/utils/TableGen/AsmWriterEmitter.cpp 
b/llvm/utils/TableGen/AsmWriterEmitter.cpp
index 0220927295cf78..e0cd5fad3254de 100644
--- a/llvm/utils/TableGen/AsmWriterEmitter.cpp
+++ b/llvm/utils/TableGen/AsmWriterEmitter.cpp
@@ -438,6 +438,10 @@ void AsmWriterEmitter::EmitGetMnemonic(
   O << "  // Emit the opcode for the instruction.\n";
   O << BitsString;
 
+  // Make sure we don't return an invalid pointer if bits is 0
+  O << "  if (Bits == 0)\n"
+   "return {nullptr, Bits};\n";
+
   // Return mnemonic string and bits.
   O << "  return {AsmStrs+(Bits & " << (1 << AsmStrBits) - 1
 << ")-1, Bits};\n\n";

>From 1326609f665f6f202301bc6f7945d49e3cd1b72c Mon Sep 17 00:00:00 2001
From: Lucas Prates 
Date: Mon, 18 Dec 2023 11:59:26 +
Subject: [PATCH 2/2] fixup! [AsmWriter] Ensure getMnemonic doesn't return
 invalid pointers

---
 llvm/lib/MC/MCAsmStreamer.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp
index 532ac89bf9ff76..49668de27d67e7 100644
--- a/llvm/lib/MC/MCAsmStreamer.cpp
+++ b/llvm/lib/MC/MCAsmStreamer.cpp
@@ -154,10 +154,10 @@ class MCAsmStreamer final : public MCStreamer {
   void emitGNUAttribute(unsigned Tag, unsigned Value) override;
 
   StringRef getMnemonic(MCInst &MI) override {
-std::pair M = InstPrinter->getMnemonic(&MI);
-assert((M.second != 0 || M.first == nullptr) &&
+auto [Ptr, Bits] = InstPrinter->getMnemonic(&MI);
+assert((Bits != 0 || Ptr == nullptr) &&
"Invalid char pointer for instruction with no mnemonic");
-return M.first;
+return Ptr;
   }
 
   void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;

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


[clang-tools-extra] [NFC][clang] add a clang tool for mlir refactor (PR #75279)

2023-12-18 Thread via cfe-commits

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


[clang] Revert "[RISCV] Implement multi-lib reuse rule for RISC-V bare-metal … (PR #75789)

2023-12-18 Thread antoine moynault via cfe-commits

https://github.com/antmox created 
https://github.com/llvm/llvm-project/pull/75789

…toolchain (#73765)"

This reverts commit 111a2290650743b27f70f9b24618411e54493b59,

as it broke several bots
  https://lab.llvm.org/buildbot/#/builders/245/builds/18162
  https://lab.llvm.org/buildbot/#/builders/188/builds/39436
  https://lab.llvm.org/buildbot/#/builders/187/builds/13723
  https://lab.llvm.org/buildbot/#/builders/182/builds/8449
  https://lab.llvm.org/buildbot/#/builders/198/builds/7438
  https://lab.llvm.org/buildbot/#/builders/176/builds/7419
  https://lab.llvm.org/buildbot/#/builders/186/builds/13781
  https://lab.llvm.org/buildbot/#/builders/183/builds/18116
  https://lab.llvm.org/buildbot/#/builders/197/builds/11410
  https://lab.llvm.org/buildbot/#/builders/184/builds/8651

When reapplying, please take care of another commit that have been merged after 
this one:
  c7cdf3cd5d74 [clang] Use 'starts_with' instead of 'startswith' in Gnu.cpp 
(NFC)

>From a8518cedb41a1aabd5dade1280cea27f961bf261 Mon Sep 17 00:00:00 2001
From: Antoine Moynault 
Date: Mon, 18 Dec 2023 12:27:42 +
Subject: [PATCH] Revert "[RISCV] Implement multi-lib reuse rule for RISC-V
 bare-metal toolchain (#73765)"

This reverts commit 111a2290650743b27f70f9b24618411e54493b59,

as it broke several bots
  https://lab.llvm.org/buildbot/#/builders/245/builds/18162
  https://lab.llvm.org/buildbot/#/builders/188/builds/39436
  https://lab.llvm.org/buildbot/#/builders/187/builds/13723
  https://lab.llvm.org/buildbot/#/builders/182/builds/8449
  https://lab.llvm.org/buildbot/#/builders/198/builds/7438
  https://lab.llvm.org/buildbot/#/builders/176/builds/7419
  https://lab.llvm.org/buildbot/#/builders/186/builds/13781
  https://lab.llvm.org/buildbot/#/builders/183/builds/18116
  https://lab.llvm.org/buildbot/#/builders/197/builds/11410
  https://lab.llvm.org/buildbot/#/builders/184/builds/8651

When reapplying, please take care of another commit that have
been merged after this one:
  c7cdf3cd5d74 [clang] Use 'starts_with' instead of 'startswith' in Gnu.cpp 
(NFC)
---
 clang/lib/Driver/ToolChains/Gnu.cpp   | 127 +-
 .../riscv-toolchain-gcc-multilib-reuse.c  |  81 ---
 2 files changed, 1 insertion(+), 207 deletions(-)
 delete mode 100644 clang/test/Driver/riscv-toolchain-gcc-multilib-reuse.c

diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 7f463ddd17d3d6..835215a83c4037 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -30,7 +30,6 @@
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/RISCVISAInfo.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/TargetParser/TargetParser.h"
 #include 
@@ -1716,129 +1715,6 @@ static void findCSKYMultilibs(const Driver &D, const 
llvm::Triple &TargetTriple,
 Result.Multilibs = CSKYMultilibs;
 }
 
-/// Extend the multi-lib re-use selection mechanism for RISC-V.
-/// This function will try to re-use multi-lib if they are compatible.
-/// Definition of compatible:
-///   - ABI must be the same.
-///   - multi-lib is a subset of current arch, e.g. multi-lib=march=rv32im
-/// is a subset of march=rv32imc.
-///   - march that contains atomic extension can't reuse multi-lib that
-/// doesn't have atomic, vice versa. e.g. multi-lib=march=rv32im and
-/// march=rv32ima are not compatible, because software and hardware
-/// atomic operation can't work together correctly.
-static bool
-selectRISCVMultilib(const MultilibSet &RISCVMultilibSet, StringRef Arch,
-const Multilib::flags_list &Flags,
-llvm::SmallVectorImpl &SelectedMultilibs) {
-  // Try to find the perfect matching multi-lib first.
-  if (RISCVMultilibSet.select(Flags, SelectedMultilibs))
-return true;
-
-  Multilib::flags_list NewFlags;
-  std::vector NewMultilibs;
-
-  llvm::Expected> ParseResult =
-  llvm::RISCVISAInfo::parseArchString(
-  Arch, /*EnableExperimentalExtension=*/true,
-  /*ExperimentalExtensionVersionCheck=*/false);
-  if (!ParseResult) {
-// Ignore any error here, we assume it will be handled in another place.
-consumeError(ParseResult.takeError());
-return false;
-  }
-
-  auto &ISAInfo = *ParseResult;
-
-  addMultilibFlag(ISAInfo->getXLen() == 32, "-m32", NewFlags);
-  addMultilibFlag(ISAInfo->getXLen() == 64, "-m64", NewFlags);
-
-  // Collect all flags except march=*
-  for (StringRef Flag : Flags) {
-if (Flag.starts_with("!march=") || Flag.starts_with("-march="))
-  continue;
-
-NewFlags.push_back(Flag.str());
-  }
-
-  llvm::StringSet<> AllArchExts;
-  // Reconstruct multi-lib list, and break march option into separated
-  // extension. e.g. march=rv32im -> +i +m
-  for (const auto &M : RISCVMultilibSet) {
-bool Skip = false;
-
-MultilibBuilder NewMultilib =
-MultilibBuilder(M.gccSuffix(), M.osSuffix(), M

[clang] Revert "[RISCV] Implement multi-lib reuse rule for RISC-V bare-metal … (PR #75789)

2023-12-18 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: antoine moynault (antmox)


Changes

…toolchain (#73765)"

This reverts commit 111a2290650743b27f70f9b24618411e54493b59,

as it broke several bots
  https://lab.llvm.org/buildbot/#/builders/245/builds/18162
  https://lab.llvm.org/buildbot/#/builders/188/builds/39436
  https://lab.llvm.org/buildbot/#/builders/187/builds/13723
  https://lab.llvm.org/buildbot/#/builders/182/builds/8449
  https://lab.llvm.org/buildbot/#/builders/198/builds/7438
  https://lab.llvm.org/buildbot/#/builders/176/builds/7419
  https://lab.llvm.org/buildbot/#/builders/186/builds/13781
  https://lab.llvm.org/buildbot/#/builders/183/builds/18116
  https://lab.llvm.org/buildbot/#/builders/197/builds/11410
  https://lab.llvm.org/buildbot/#/builders/184/builds/8651

When reapplying, please take care of another commit that have been merged after 
this one:
  c7cdf3cd5d74 [clang] Use 'starts_with' instead of 'startswith' in Gnu.cpp 
(NFC)

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


2 Files Affected:

- (modified) clang/lib/Driver/ToolChains/Gnu.cpp (+1-126) 
- (removed) clang/test/Driver/riscv-toolchain-gcc-multilib-reuse.c (-81) 


``diff
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 7f463ddd17d3d6..835215a83c4037 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -30,7 +30,6 @@
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/RISCVISAInfo.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/TargetParser/TargetParser.h"
 #include 
@@ -1716,129 +1715,6 @@ static void findCSKYMultilibs(const Driver &D, const 
llvm::Triple &TargetTriple,
 Result.Multilibs = CSKYMultilibs;
 }
 
-/// Extend the multi-lib re-use selection mechanism for RISC-V.
-/// This function will try to re-use multi-lib if they are compatible.
-/// Definition of compatible:
-///   - ABI must be the same.
-///   - multi-lib is a subset of current arch, e.g. multi-lib=march=rv32im
-/// is a subset of march=rv32imc.
-///   - march that contains atomic extension can't reuse multi-lib that
-/// doesn't have atomic, vice versa. e.g. multi-lib=march=rv32im and
-/// march=rv32ima are not compatible, because software and hardware
-/// atomic operation can't work together correctly.
-static bool
-selectRISCVMultilib(const MultilibSet &RISCVMultilibSet, StringRef Arch,
-const Multilib::flags_list &Flags,
-llvm::SmallVectorImpl &SelectedMultilibs) {
-  // Try to find the perfect matching multi-lib first.
-  if (RISCVMultilibSet.select(Flags, SelectedMultilibs))
-return true;
-
-  Multilib::flags_list NewFlags;
-  std::vector NewMultilibs;
-
-  llvm::Expected> ParseResult =
-  llvm::RISCVISAInfo::parseArchString(
-  Arch, /*EnableExperimentalExtension=*/true,
-  /*ExperimentalExtensionVersionCheck=*/false);
-  if (!ParseResult) {
-// Ignore any error here, we assume it will be handled in another place.
-consumeError(ParseResult.takeError());
-return false;
-  }
-
-  auto &ISAInfo = *ParseResult;
-
-  addMultilibFlag(ISAInfo->getXLen() == 32, "-m32", NewFlags);
-  addMultilibFlag(ISAInfo->getXLen() == 64, "-m64", NewFlags);
-
-  // Collect all flags except march=*
-  for (StringRef Flag : Flags) {
-if (Flag.starts_with("!march=") || Flag.starts_with("-march="))
-  continue;
-
-NewFlags.push_back(Flag.str());
-  }
-
-  llvm::StringSet<> AllArchExts;
-  // Reconstruct multi-lib list, and break march option into separated
-  // extension. e.g. march=rv32im -> +i +m
-  for (const auto &M : RISCVMultilibSet) {
-bool Skip = false;
-
-MultilibBuilder NewMultilib =
-MultilibBuilder(M.gccSuffix(), M.osSuffix(), M.includeSuffix());
-for (StringRef Flag : M.flags()) {
-  // Add back all flags except -march.
-  if (!Flag.consume_front("-march=")) {
-NewMultilib.flag(Flag);
-continue;
-  }
-
-  // Break down -march into individual extension.
-  llvm::Expected> MLConfigParseResult =
-  llvm::RISCVISAInfo::parseArchString(
-  Flag, /*EnableExperimentalExtension=*/true,
-  /*ExperimentalExtensionVersionCheck=*/false);
-  if (!MLConfigParseResult) {
-// Ignore any error here, we assume it will handled in another place.
-llvm::consumeError(MLConfigParseResult.takeError());
-
-// We might get a parsing error if rv32e in the list, we could just 
skip
-// that and process the rest of multi-lib configs.
-Skip = true;
-continue;
-  }
-  auto &MLConfigISAInfo = *MLConfigParseResult;
-
-  const llvm::RISCVISAInfo::OrderedExtensionMap &MLConfigArchExts =
-  MLConfigISAInfo->getExtensions();
-  for (auto MLConfigArchExt : MLConfigArchExts) {
-auto ExtName = MLConfigArch

[clang] Revert "[RISCV] Implement multi-lib reuse rule for RISC-V bare-metal … (PR #75789)

2023-12-18 Thread antoine moynault via cfe-commits

antmox wrote:

I would like to revert this as several arm/aarch64 bots are broken by this 
patch.
Do I have to first revert c7cdf3c or is it OK like this ?

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


[clang] Revert "[RISCV] Implement multi-lib reuse rule for RISC-V bare-metal … (PR #75789)

2023-12-18 Thread via cfe-commits

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

Thanks!

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


[clang] Revert "[RISCV] Implement multi-lib reuse rule for RISC-V bare-metal … (PR #75789)

2023-12-18 Thread antoine moynault via cfe-commits

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


[clang] 9727919 - Revert "[RISCV] Implement multi-lib reuse rule for RISC-V bare-metal … (#75789)

2023-12-18 Thread via cfe-commits

Author: antoine moynault
Date: 2023-12-18T13:52:21+01:00
New Revision: 9727919a2e35d2114d52f33a7751696ae1595581

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

LOG: Revert "[RISCV] Implement multi-lib reuse rule for RISC-V bare-metal … 
(#75789)

…toolchain (#73765)"

This reverts commit 111a2290650743b27f70f9b24618411e54493b59,

as it broke several bots
  https://lab.llvm.org/buildbot/#/builders/245/builds/18162
  https://lab.llvm.org/buildbot/#/builders/188/builds/39436
  https://lab.llvm.org/buildbot/#/builders/187/builds/13723
  https://lab.llvm.org/buildbot/#/builders/182/builds/8449
  https://lab.llvm.org/buildbot/#/builders/198/builds/7438
  https://lab.llvm.org/buildbot/#/builders/176/builds/7419
  https://lab.llvm.org/buildbot/#/builders/186/builds/13781
  https://lab.llvm.org/buildbot/#/builders/183/builds/18116
  https://lab.llvm.org/buildbot/#/builders/197/builds/11410
  https://lab.llvm.org/buildbot/#/builders/184/builds/8651

When reapplying, please take care of another commit that have been
merged after this one:
c7cdf3cd5d74 [clang] Use 'starts_with' instead of 'startswith' in
Gnu.cpp (NFC)

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp

Removed: 
clang/test/Driver/riscv-toolchain-gcc-multilib-reuse.c



diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 7f463ddd17d3d6..835215a83c4037 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -30,7 +30,6 @@
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/RISCVISAInfo.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/TargetParser/TargetParser.h"
 #include 
@@ -1716,129 +1715,6 @@ static void findCSKYMultilibs(const Driver &D, const 
llvm::Triple &TargetTriple,
 Result.Multilibs = CSKYMultilibs;
 }
 
-/// Extend the multi-lib re-use selection mechanism for RISC-V.
-/// This function will try to re-use multi-lib if they are compatible.
-/// Definition of compatible:
-///   - ABI must be the same.
-///   - multi-lib is a subset of current arch, e.g. multi-lib=march=rv32im
-/// is a subset of march=rv32imc.
-///   - march that contains atomic extension can't reuse multi-lib that
-/// doesn't have atomic, vice versa. e.g. multi-lib=march=rv32im and
-/// march=rv32ima are not compatible, because software and hardware
-/// atomic operation can't work together correctly.
-static bool
-selectRISCVMultilib(const MultilibSet &RISCVMultilibSet, StringRef Arch,
-const Multilib::flags_list &Flags,
-llvm::SmallVectorImpl &SelectedMultilibs) {
-  // Try to find the perfect matching multi-lib first.
-  if (RISCVMultilibSet.select(Flags, SelectedMultilibs))
-return true;
-
-  Multilib::flags_list NewFlags;
-  std::vector NewMultilibs;
-
-  llvm::Expected> ParseResult =
-  llvm::RISCVISAInfo::parseArchString(
-  Arch, /*EnableExperimentalExtension=*/true,
-  /*ExperimentalExtensionVersionCheck=*/false);
-  if (!ParseResult) {
-// Ignore any error here, we assume it will be handled in another place.
-consumeError(ParseResult.takeError());
-return false;
-  }
-
-  auto &ISAInfo = *ParseResult;
-
-  addMultilibFlag(ISAInfo->getXLen() == 32, "-m32", NewFlags);
-  addMultilibFlag(ISAInfo->getXLen() == 64, "-m64", NewFlags);
-
-  // Collect all flags except march=*
-  for (StringRef Flag : Flags) {
-if (Flag.starts_with("!march=") || Flag.starts_with("-march="))
-  continue;
-
-NewFlags.push_back(Flag.str());
-  }
-
-  llvm::StringSet<> AllArchExts;
-  // Reconstruct multi-lib list, and break march option into separated
-  // extension. e.g. march=rv32im -> +i +m
-  for (const auto &M : RISCVMultilibSet) {
-bool Skip = false;
-
-MultilibBuilder NewMultilib =
-MultilibBuilder(M.gccSuffix(), M.osSuffix(), M.includeSuffix());
-for (StringRef Flag : M.flags()) {
-  // Add back all flags except -march.
-  if (!Flag.consume_front("-march=")) {
-NewMultilib.flag(Flag);
-continue;
-  }
-
-  // Break down -march into individual extension.
-  llvm::Expected> MLConfigParseResult =
-  llvm::RISCVISAInfo::parseArchString(
-  Flag, /*EnableExperimentalExtension=*/true,
-  /*ExperimentalExtensionVersionCheck=*/false);
-  if (!MLConfigParseResult) {
-// Ignore any error here, we assume it will handled in another place.
-llvm::consumeError(MLConfigParseResult.takeError());
-
-// We might get a parsing error if rv32e in the list, we could just 
skip
-// that and process the rest of multi-lib configs.
-Skip = true;
-continue;
-  

[clang-tools-extra] [clangd] Expand response files before CDB interpolation (PR #75753)

2023-12-18 Thread Dmitry Polukhin via cfe-commits

https://github.com/dmpolukhin updated 
https://github.com/llvm/llvm-project/pull/75753

>From 957951483dab19b0982a5dbe7d5370bd9061d931 Mon Sep 17 00:00:00 2001
From: Dmitry Polukhin 
Date: Sun, 17 Dec 2023 14:11:11 -0800
Subject: [PATCH 1/2] [clangd] Expand response files before CDB interpolation

Summary:

After https://reviews.llvm.org/D143436 response files stopped working
with CDB interpolation. It has happened because interpolation removes
all unknwn flags and extra input files. Response file is treated as an
extra input because it is not a flag. Moreover inference needs full
command line for driver mode and file type detection so all response
files have to be expanded for correct inference.

This patch implements the simplest approach that add extra response file
expansion before inference. Response file expansion in CommandMangler
keep working for CDB pushed via LSP and will do nothing if all response
files are already expanded.

Test Plan: TBD

Reviewers:

Subscribers:

Tasks: https://github.com/llvm/llvm-project/issues/69690

Tags:
---
 .../clangd/GlobalCompilationDatabase.cpp  | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index d1833759917a30..03ac1aa132d0bf 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -244,7 +244,16 @@ static std::unique_ptr
 parseJSON(PathRef Path, llvm::StringRef Data, std::string &Error) {
   if (auto CDB = tooling::JSONCompilationDatabase::loadFromBuffer(
   Data, Error, tooling::JSONCommandLineSyntax::AutoDetect)) {
-return tooling::inferMissingCompileCommands(std::move(CDB));
+// FS used for expanding response files.
+// FIXME: ExpandResponseFilesDatabase appears not to provide the usual
+// thread-safety guarantees, as the access to FS is not locked!
+// For now, use the real FS, which is known to be threadsafe (if we don't
+// use/change working directory, which ExpandResponseFilesDatabase 
doesn't).
+// NOTE: response files have to be expanded before inference because 
inference
+// needs full command line to check/fix driver mode and file type.
+auto FS = llvm::vfs::getRealFileSystem();
+return tooling::inferMissingCompileCommands(
+expandResponseFiles(std::move(CDB), std::move(FS)));
   }
   return nullptr;
 }

>From f4b1a02354fa5085caf50a460363e75e10afc3bb Mon Sep 17 00:00:00 2001
From: Dmitry Polukhin 
Date: Sun, 17 Dec 2023 14:11:11 -0800
Subject: [PATCH 2/2] [clangd] Expand response files before CDB interpolation

Summary:

After https://reviews.llvm.org/D143436 response files stopped working
with CDB interpolation. It has happened because interpolation removes
all unknwn flags and extra input files. Response file is treated as an
extra input because it is not a flag. Moreover inference needs full
command line for driver mode and file type detection so all response
files have to be expanded for correct inference.

This patch partially reverts D143436 and add additional response file
expansion in OverlayCDB for CDBs pushed via LSP.

Test Plan: unittests

Reviewers:

Subscribers:

Tasks: https://github.com/llvm/llvm-project/issues/69690

Tags:
---
 clang-tools-extra/clangd/CompileCommands.cpp  | 15 --
 clang-tools-extra/clangd/CompileCommands.h|  3 --
 .../clangd/GlobalCompilationDatabase.cpp  | 24 +++--
 .../clangd/unittests/CompileCommandsTests.cpp | 15 --
 .../GlobalCompilationDatabaseTests.cpp| 53 +++
 5 files changed, 74 insertions(+), 36 deletions(-)

diff --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index f43ce928463b90..f4e8e7e74a3bee 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -28,7 +28,6 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
-#include "llvm/TargetParser/Host.h"
 #include 
 #include 
 #include 
@@ -187,12 +186,6 @@ static std::string resolveDriver(llvm::StringRef Driver, 
bool FollowSymlink,
 
 } // namespace
 
-CommandMangler::CommandMangler() {
-  Tokenizer = llvm::Triple(llvm::sys::getProcessTriple()).isOSWindows()
-  ? llvm::cl::TokenizeWindowsCommandLine
-  : llvm::cl::TokenizeGNUCommandLine;
-}
-
 CommandMangler CommandMangler::detect() {
   CommandMangler Result;
   Result.ClangPath = detectClangPath();
@@ -213,14 +206,6 @@ void CommandMangler::operator()(tooling::CompileCommand 
&Command,
   if (Cmd.empty())
 return;
 
-  // FS used for expanding response files.
-  // FIXME: ExpandResponseFiles appears not to provide the usual
-  // thread-safety guarantees, as the access to FS is not locked!
-  // For now, use the real FS, which is known to be threadsafe (if we don't
-  // use

[clang-tools-extra] [clangd] Expand response files before CDB interpolation (PR #75753)

2023-12-18 Thread Dmitry Polukhin via cfe-commits

dmpolukhin wrote:

@HighCommander4 PTAL

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


[clang-tools-extra] [clangd] Expand response files before CDB interpolation (PR #75753)

2023-12-18 Thread Dmitry Polukhin via cfe-commits

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


[clang] [Clang][AArch64] Add missing SME functions to header file. (PR #75791)

2023-12-18 Thread Sander de Smalen via cfe-commits

https://github.com/sdesmalen-arm created 
https://github.com/llvm/llvm-project/pull/75791

This includes:
* __arm_in_streaming_mode()
* __arm_has_sme()
* __arm_za_disable()
* __svundef_za()

>From 8b30f772982d7d608541526b1fa42de2b5eb7e1e Mon Sep 17 00:00:00 2001
From: Sander de Smalen 
Date: Mon, 18 Dec 2023 12:55:30 +
Subject: [PATCH] [Clang][AArch64] Add missing SME functions to header file.

This includes:
* __arm_in_streaming_mode()
* __arm_has_sme()
* __arm_za_disable()
* __svundef_za()
---
 clang/include/clang/Basic/BuiltinsAArch64.def |  3 +
 clang/lib/CodeGen/CGBuiltin.cpp   | 20 ++
 .../acle_sme_state_funs.c | 72 +++
 clang/utils/TableGen/SveEmitter.cpp   | 18 +
 4 files changed, 113 insertions(+)
 create mode 100644 
clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_state_funs.c

diff --git a/clang/include/clang/Basic/BuiltinsAArch64.def 
b/clang/include/clang/Basic/BuiltinsAArch64.def
index 82a1ba3c82ad35..31ec84143f65c1 100644
--- a/clang/include/clang/Basic/BuiltinsAArch64.def
+++ b/clang/include/clang/Basic/BuiltinsAArch64.def
@@ -68,6 +68,9 @@ TARGET_BUILTIN(__builtin_arm_ldg, "v*v*", "t", "mte")
 TARGET_BUILTIN(__builtin_arm_stg, "vv*", "t", "mte")
 TARGET_BUILTIN(__builtin_arm_subp, "Uiv*v*", "t", "mte")
 
+// SME state function
+BUILTIN(__builtin_arm_get_sme_state, "vULi*ULi*", "n")
+
 // Memory Operations
 TARGET_BUILTIN(__builtin_arm_mops_memset_tag, "v*v*iz", "", "mte,mops")
 
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 4eb1686f095062..ca9070aad95842 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -10570,6 +10570,26 @@ Value 
*CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID,
 return Builder.CreateCall(F, llvm::ConstantInt::get(Int32Ty, HintID));
   }
 
+  if (BuiltinID == clang::AArch64::BI__builtin_arm_get_sme_state) {
+// Create call to __arm_sme_state and store the results to the two 
pointers.
+CallInst *CI = EmitRuntimeCall(CGM.CreateRuntimeFunction(
+llvm::FunctionType::get(StructType::get(CGM.Int64Ty, CGM.Int64Ty), {},
+false),
+"__arm_sme_state"));
+auto Attrs =
+AttributeList()
+.addFnAttribute(getLLVMContext(), "aarch64_pstate_sm_compatible")
+.addFnAttribute(getLLVMContext(), "aarch64_pstate_za_preserved");
+CI->setAttributes(Attrs);
+CI->setCallingConv(
+llvm::CallingConv::
+AArch64_SME_ABI_Support_Routines_PreserveMost_From_X2);
+Builder.CreateStore(Builder.CreateExtractValue(CI, 0),
+EmitPointerWithAlignment(E->getArg(0)));
+return Builder.CreateStore(Builder.CreateExtractValue(CI, 1),
+   EmitPointerWithAlignment(E->getArg(1)));
+  }
+
   if (BuiltinID == clang::AArch64::BI__builtin_arm_rbit) {
 assert((getContext().getTypeSize(E->getType()) == 32) &&
"rbit of unusual size!");
diff --git a/clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_state_funs.c 
b/clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_state_funs.c
new file mode 100644
index 00..282819c8ca3501
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_state_funs.c
@@ -0,0 +1,72 @@
+// 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 +sme -S -O1 
-Werror -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme -S -O1 
-Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme -S 
-disable-O0-optnone -Werror -Wall -o /dev/null %s
+
+#include 
+
+// CHECK-LABEL: @test_in_streaming_mode(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call aarch64_sme_preservemost_from_x2 { 
i64, i64 } @__arm_sme_state() #[[ATTR3:[0-9]+]]
+// CHECK-NEXT:[[TMP1:%.*]] = extractvalue { i64, i64 } [[TMP0]], 0
+// CHECK-NEXT:[[AND_I:%.*]] = and i64 [[TMP1]], 1
+// CHECK-NEXT:[[TOBOOL_I:%.*]] = icmp ne i64 [[AND_I]], 0
+// CHECK-NEXT:ret i1 [[TOBOOL_I]]
+//
+// CPP-CHECK-LABEL: @_Z22test_in_streaming_modev(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call 
aarch64_sme_preservemost_from_x2 { i64, i64 } @__arm_sme_state() 
#[[ATTR3:[0-9]+]]
+// CPP-CHECK-NEXT:[[TMP1:%.*]] = extractvalue { i64, i64 } [[TMP0]], 0
+// CPP-CHECK-NEXT:[[AND_I:%.*]] = and i64 [[TMP1]], 1
+// CPP-CHECK-NEXT:[[TOBOOL_I:%.*]] = icmp ne i64 [[AND_I]], 0
+// CPP-CHECK-NEXT:ret i1 [[TOBOOL_I]]
+//
+bool test_in_streaming_mode(void) __arm_streaming_compatible {
+  return __arm_in_streaming_mode();
+}
+
+// CHECK-LABEL: @test_za_disable(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void @__arm_za_disable() #[[ATTR4:[0-9]+]]
+// CHECK-NEXT: 

[clang] [Clang][AArch64] Add missing SME functions to header file. (PR #75791)

2023-12-18 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Sander de Smalen (sdesmalen-arm)


Changes

This includes:
* __arm_in_streaming_mode()
* __arm_has_sme()
* __arm_za_disable()
* __svundef_za()

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


4 Files Affected:

- (modified) clang/include/clang/Basic/BuiltinsAArch64.def (+3) 
- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+20) 
- (added) clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_state_funs.c (+72) 
- (modified) clang/utils/TableGen/SveEmitter.cpp (+18) 


``diff
diff --git a/clang/include/clang/Basic/BuiltinsAArch64.def 
b/clang/include/clang/Basic/BuiltinsAArch64.def
index 82a1ba3c82ad35..31ec84143f65c1 100644
--- a/clang/include/clang/Basic/BuiltinsAArch64.def
+++ b/clang/include/clang/Basic/BuiltinsAArch64.def
@@ -68,6 +68,9 @@ TARGET_BUILTIN(__builtin_arm_ldg, "v*v*", "t", "mte")
 TARGET_BUILTIN(__builtin_arm_stg, "vv*", "t", "mte")
 TARGET_BUILTIN(__builtin_arm_subp, "Uiv*v*", "t", "mte")
 
+// SME state function
+BUILTIN(__builtin_arm_get_sme_state, "vULi*ULi*", "n")
+
 // Memory Operations
 TARGET_BUILTIN(__builtin_arm_mops_memset_tag, "v*v*iz", "", "mte,mops")
 
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 4eb1686f095062..ca9070aad95842 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -10570,6 +10570,26 @@ Value 
*CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID,
 return Builder.CreateCall(F, llvm::ConstantInt::get(Int32Ty, HintID));
   }
 
+  if (BuiltinID == clang::AArch64::BI__builtin_arm_get_sme_state) {
+// Create call to __arm_sme_state and store the results to the two 
pointers.
+CallInst *CI = EmitRuntimeCall(CGM.CreateRuntimeFunction(
+llvm::FunctionType::get(StructType::get(CGM.Int64Ty, CGM.Int64Ty), {},
+false),
+"__arm_sme_state"));
+auto Attrs =
+AttributeList()
+.addFnAttribute(getLLVMContext(), "aarch64_pstate_sm_compatible")
+.addFnAttribute(getLLVMContext(), "aarch64_pstate_za_preserved");
+CI->setAttributes(Attrs);
+CI->setCallingConv(
+llvm::CallingConv::
+AArch64_SME_ABI_Support_Routines_PreserveMost_From_X2);
+Builder.CreateStore(Builder.CreateExtractValue(CI, 0),
+EmitPointerWithAlignment(E->getArg(0)));
+return Builder.CreateStore(Builder.CreateExtractValue(CI, 1),
+   EmitPointerWithAlignment(E->getArg(1)));
+  }
+
   if (BuiltinID == clang::AArch64::BI__builtin_arm_rbit) {
 assert((getContext().getTypeSize(E->getType()) == 32) &&
"rbit of unusual size!");
diff --git a/clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_state_funs.c 
b/clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_state_funs.c
new file mode 100644
index 00..282819c8ca3501
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_state_funs.c
@@ -0,0 +1,72 @@
+// 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 +sme -S -O1 
-Werror -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme -S -O1 
-Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme -S 
-disable-O0-optnone -Werror -Wall -o /dev/null %s
+
+#include 
+
+// CHECK-LABEL: @test_in_streaming_mode(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call aarch64_sme_preservemost_from_x2 { 
i64, i64 } @__arm_sme_state() #[[ATTR3:[0-9]+]]
+// CHECK-NEXT:[[TMP1:%.*]] = extractvalue { i64, i64 } [[TMP0]], 0
+// CHECK-NEXT:[[AND_I:%.*]] = and i64 [[TMP1]], 1
+// CHECK-NEXT:[[TOBOOL_I:%.*]] = icmp ne i64 [[AND_I]], 0
+// CHECK-NEXT:ret i1 [[TOBOOL_I]]
+//
+// CPP-CHECK-LABEL: @_Z22test_in_streaming_modev(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call 
aarch64_sme_preservemost_from_x2 { i64, i64 } @__arm_sme_state() 
#[[ATTR3:[0-9]+]]
+// CPP-CHECK-NEXT:[[TMP1:%.*]] = extractvalue { i64, i64 } [[TMP0]], 0
+// CPP-CHECK-NEXT:[[AND_I:%.*]] = and i64 [[TMP1]], 1
+// CPP-CHECK-NEXT:[[TOBOOL_I:%.*]] = icmp ne i64 [[AND_I]], 0
+// CPP-CHECK-NEXT:ret i1 [[TOBOOL_I]]
+//
+bool test_in_streaming_mode(void) __arm_streaming_compatible {
+  return __arm_in_streaming_mode();
+}
+
+// CHECK-LABEL: @test_za_disable(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void @__arm_za_disable() #[[ATTR4:[0-9]+]]
+// CHECK-NEXT:ret void
+//
+// CPP-CHECK-LABEL: @_Z15test_za_disablev(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:tail call void @__arm_za_disable() #[[ATTR4:[0-9]+]]
+// CPP-CHECK-NEXT:ret void
+//
+void test_za_disable(void) __arm_streaming_compatible {
+  __arm_za_disable();
+}
+
+// CHECK-LABEL: @test_has

[clang-tools-extra] [clangd] Expand response files before CDB interpolation (PR #75753)

2023-12-18 Thread Dmitry Polukhin via cfe-commits

https://github.com/dmpolukhin updated 
https://github.com/llvm/llvm-project/pull/75753

>From 957951483dab19b0982a5dbe7d5370bd9061d931 Mon Sep 17 00:00:00 2001
From: Dmitry Polukhin 
Date: Sun, 17 Dec 2023 14:11:11 -0800
Subject: [PATCH 1/3] [clangd] Expand response files before CDB interpolation

Summary:

After https://reviews.llvm.org/D143436 response files stopped working
with CDB interpolation. It has happened because interpolation removes
all unknwn flags and extra input files. Response file is treated as an
extra input because it is not a flag. Moreover inference needs full
command line for driver mode and file type detection so all response
files have to be expanded for correct inference.

This patch implements the simplest approach that add extra response file
expansion before inference. Response file expansion in CommandMangler
keep working for CDB pushed via LSP and will do nothing if all response
files are already expanded.

Test Plan: TBD

Reviewers:

Subscribers:

Tasks: https://github.com/llvm/llvm-project/issues/69690

Tags:
---
 .../clangd/GlobalCompilationDatabase.cpp  | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index d1833759917a30..03ac1aa132d0bf 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -244,7 +244,16 @@ static std::unique_ptr
 parseJSON(PathRef Path, llvm::StringRef Data, std::string &Error) {
   if (auto CDB = tooling::JSONCompilationDatabase::loadFromBuffer(
   Data, Error, tooling::JSONCommandLineSyntax::AutoDetect)) {
-return tooling::inferMissingCompileCommands(std::move(CDB));
+// FS used for expanding response files.
+// FIXME: ExpandResponseFilesDatabase appears not to provide the usual
+// thread-safety guarantees, as the access to FS is not locked!
+// For now, use the real FS, which is known to be threadsafe (if we don't
+// use/change working directory, which ExpandResponseFilesDatabase 
doesn't).
+// NOTE: response files have to be expanded before inference because 
inference
+// needs full command line to check/fix driver mode and file type.
+auto FS = llvm::vfs::getRealFileSystem();
+return tooling::inferMissingCompileCommands(
+expandResponseFiles(std::move(CDB), std::move(FS)));
   }
   return nullptr;
 }

>From f4b1a02354fa5085caf50a460363e75e10afc3bb Mon Sep 17 00:00:00 2001
From: Dmitry Polukhin 
Date: Sun, 17 Dec 2023 14:11:11 -0800
Subject: [PATCH 2/3] [clangd] Expand response files before CDB interpolation

Summary:

After https://reviews.llvm.org/D143436 response files stopped working
with CDB interpolation. It has happened because interpolation removes
all unknwn flags and extra input files. Response file is treated as an
extra input because it is not a flag. Moreover inference needs full
command line for driver mode and file type detection so all response
files have to be expanded for correct inference.

This patch partially reverts D143436 and add additional response file
expansion in OverlayCDB for CDBs pushed via LSP.

Test Plan: unittests

Reviewers:

Subscribers:

Tasks: https://github.com/llvm/llvm-project/issues/69690

Tags:
---
 clang-tools-extra/clangd/CompileCommands.cpp  | 15 --
 clang-tools-extra/clangd/CompileCommands.h|  3 --
 .../clangd/GlobalCompilationDatabase.cpp  | 24 +++--
 .../clangd/unittests/CompileCommandsTests.cpp | 15 --
 .../GlobalCompilationDatabaseTests.cpp| 53 +++
 5 files changed, 74 insertions(+), 36 deletions(-)

diff --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index f43ce928463b90..f4e8e7e74a3bee 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -28,7 +28,6 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
-#include "llvm/TargetParser/Host.h"
 #include 
 #include 
 #include 
@@ -187,12 +186,6 @@ static std::string resolveDriver(llvm::StringRef Driver, 
bool FollowSymlink,
 
 } // namespace
 
-CommandMangler::CommandMangler() {
-  Tokenizer = llvm::Triple(llvm::sys::getProcessTriple()).isOSWindows()
-  ? llvm::cl::TokenizeWindowsCommandLine
-  : llvm::cl::TokenizeGNUCommandLine;
-}
-
 CommandMangler CommandMangler::detect() {
   CommandMangler Result;
   Result.ClangPath = detectClangPath();
@@ -213,14 +206,6 @@ void CommandMangler::operator()(tooling::CompileCommand 
&Command,
   if (Cmd.empty())
 return;
 
-  // FS used for expanding response files.
-  // FIXME: ExpandResponseFiles appears not to provide the usual
-  // thread-safety guarantees, as the access to FS is not locked!
-  // For now, use the real FS, which is known to be threadsafe (if we don't
-  // use

[clang] [OpenMP][Clang] Force use of `num_teams` and `thread_limit` for bare kernel (PR #68373)

2023-12-18 Thread Alexey Bataev via cfe-commits

https://github.com/alexey-bataev approved this pull request.


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


[clang] [OpenACC] Add 'clause' parsing infrastructure plus a few clauses (PR #75052)

2023-12-18 Thread Alexey Bataev via cfe-commits

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


[clang] [OpenACC] Add 'clause' parsing infrastructure plus a few clauses (PR #75052)

2023-12-18 Thread Alexey Bataev via cfe-commits


@@ -69,6 +69,19 @@ enum class OpenACCAtomicKind {
   Capture,
   Invalid,
 };
+
+// Represents the kind of an OpenACC clause.

alexey-bataev wrote:

Use '///' kind of comment here

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


[clang] [OpenACC] Add 'clause' parsing infrastructure plus a few clauses (PR #75052)

2023-12-18 Thread Alexey Bataev via cfe-commits

https://github.com/alexey-bataev approved this pull request.


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


[clang] [OpenACC] Add 'clause' parsing infrastructure plus a few clauses (PR #75052)

2023-12-18 Thread Alexey Bataev via cfe-commits


@@ -69,6 +69,19 @@ enum class OpenACCAtomicKind {
   Capture,
   Invalid,
 };
+
+// Represents the kind of an OpenACC clause.
+enum class OpenACCClauseKind {
+  Finalize,

alexey-bataev wrote:

Add the comments with the description of each clause kind?

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


[clang] [OpenACC] Add 'clause' parsing infrastructure plus a few clauses (PR #75052)

2023-12-18 Thread Alexey Bataev via cfe-commits

alexey-bataev wrote:

LG with nits

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


[openmp] [clang] [Clang][OpenMP] Fix mapping of structs to device (PR #75642)

2023-12-18 Thread Alexey Bataev via cfe-commits

https://github.com/alexey-bataev approved this pull request.


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


[clang] [clang][Interp] Implement integral->complex casts (PR #75590)

2023-12-18 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr updated 
https://github.com/llvm/llvm-project/pull/75590

>From 09d552b3e700ee8281a55fd63a5c4bc75a94251c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Fri, 15 Dec 2023 13:11:16 +0100
Subject: [PATCH] [clang][Interp] Implement integral->complex casts

---
 clang/lib/AST/Interp/ByteCodeExprGen.cpp | 26 
 clang/test/AST/Interp/complex.cpp|  9 
 2 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index e6b3097a80d8f7..bd9a58042f6cb5 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -283,6 +283,28 @@ bool ByteCodeExprGen::VisitCastExpr(const 
CastExpr *CE) {
   case CK_ToVoid:
 return discard(SubExpr);
 
+  case CK_IntegralRealToComplex:
+  case CK_FloatingRealToComplex: {
+// We're creating a complex value here, so we need to
+// allocate storage for it.
+if (!Initializing) {
+  std::optional LocalIndex =
+  allocateLocal(CE, /*IsExtended=*/true);
+  if (!LocalIndex)
+return false;
+  if (!this->emitGetPtrLocal(*LocalIndex, CE))
+return false;
+}
+
+if (!this->visitArrayElemInit(0, SubExpr))
+  return false;
+// Zero-init the second element.
+PrimType T = classifyPrim(SubExpr->getType());
+if (!this->visitZeroInitializer(T, SubExpr->getType(), SubExpr))
+  return false;
+return this->emitInitElem(T, 1, SubExpr);
+  }
+
   default:
 assert(false && "Cast not implemented");
   }
@@ -835,6 +857,10 @@ bool ByteCodeExprGen::VisitInitListExpr(const 
InitListExpr *E) {
 
   if (T->isAnyComplexType()) {
 unsigned NumInits = E->getNumInits();
+
+if (NumInits == 1)
+  return this->delegate(E->inits()[0]);
+
 QualType ElemQT = E->getType()->getAs()->getElementType();
 PrimType ElemT = classifyPrim(ElemQT);
 if (NumInits == 0) {
diff --git a/clang/test/AST/Interp/complex.cpp 
b/clang/test/AST/Interp/complex.cpp
index 66490e973988bb..bf340d6e3ff68a 100644
--- a/clang/test/AST/Interp/complex.cpp
+++ b/clang/test/AST/Interp/complex.cpp
@@ -37,21 +37,20 @@ constexpr _Complex int I2 = {};
 static_assert(__real(I2) == 0, "");
 static_assert(__imag(I2) == 0, "");
 
+static_assert(__real((_Complex unsigned)5) == 5);
+static_assert(__imag((_Complex unsigned)5) == 0);
 
 /// Standalone complex expressions.
 static_assert(__real((_Complex float){1.0, 3.0}) == 1.0, "");
 
 
-#if 0
-/// FIXME: This should work in the new interpreter.
 constexpr _Complex double D2 = {12};
 static_assert(__real(D2) == 12, "");
-static_assert(__imag(D2) == 12, "");
+static_assert(__imag(D2) == 0, "");
 
 constexpr _Complex int I3 = {15};
 static_assert(__real(I3) == 15, "");
-static_assert(__imag(I3) == 15, "");
-#endif
+static_assert(__imag(I3) == 0, "");
 
 /// FIXME: This should work in the new interpreter as well.
 // constexpr _Complex _BitInt(8) A = 0;// = {4};

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


[clang] [Cygwin] Reduced number of inline elements of CallArgList. (PR #74977)

2023-12-18 Thread 徐持恒 Xu Chiheng via cfe-commits

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


[clang] [MinGW] Fix the regression caused by commit 592e935e115ffb451eb9b782376711dab6558fe0, that, in MinGW, Clang can't be built by system Clang 15.0.4. (PR #74982)

2023-12-18 Thread 徐持恒 Xu Chiheng via cfe-commits

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


[clang-tools-extra] [clang] [llvm] [clang] Fix false positive -Wmissing-field-initializer for anonymous unions (PR #70829)

2023-12-18 Thread via cfe-commits

mikaelholmen wrote:

Hi again @Fznamznon 
the following also started causing warnings after this patch (also with the fix)
```
struct S3 {
  long int l;
  struct  { int a, b; } d1[2];
};

struct S3 s32 = { .d1[0].a = 1 };
```
We get
```
foo.c:6:30: warning: missing field 'b' initializer 
[-Wmissing-field-initializers]
6 | struct S3 s32 = { .d1[0].a = 1 };
  |  ^
1 warning generated.
```
with this patch.


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


[clang] [Clang][SME2] Add multi-vector zip & unzip builtins (PR #74841)

2023-12-18 Thread Sander de Smalen via cfe-commits

https://github.com/sdesmalen-arm approved this pull request.


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


[clang] [AST] RecursiveASTVisitor: traverse the require clause for partial template specializations. (PR #75795)

2023-12-18 Thread Haojian Wu via cfe-commits

https://github.com/hokein created 
https://github.com/llvm/llvm-project/pull/75795

This fixes tooling (clangd, include-cleaner) bugs where we miss functionalities 
on concept AST nodes.

>From 9012381987bd702a58683fc5c6c7452c32755a08 Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Mon, 18 Dec 2023 14:46:54 +0100
Subject: [PATCH] [AST] RecursiveASTVisitor: traverse the require clause for
 partial template specializations.

This fixes tooling (clangd, include-cleaner) bugs where we miss functionalities
on the concept AST nodes.
---
 clang/include/clang/AST/RecursiveASTVisitor.h |  7 +--
 .../RecursiveASTVisitorTests/Concept.cpp  | 19 +++
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index c501801b95bd95..8f2714e142bbe3 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2036,12 +2036,7 @@ bool 
RecursiveASTVisitor::TraverseTemplateArgumentLocsHelper(
 #define DEF_TRAVERSE_TMPL_PART_SPEC_DECL(TMPLDECLKIND, DECLKIND)   
\
   DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplatePartialSpecializationDecl, { 
\
 /* The partial specialization. */  
\
-if (TemplateParameterList *TPL = D->getTemplateParameters()) { 
\
-  for (TemplateParameterList::iterator I = TPL->begin(), E = TPL->end();   
\
-   I != E; ++I) {  
\
-TRY_TO(TraverseDecl(*I));  
\
-  }
\
-}  
\
+TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));   
\
 /* The args that remains unspecialized. */ 
\
 TRY_TO(TraverseTemplateArgumentLocsHelper( 
\
 D->getTemplateArgsAsWritten()->getTemplateArgs(),  
\
diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTests/Concept.cpp 
b/clang/unittests/Tooling/RecursiveASTVisitorTests/Concept.cpp
index 594b299b543694..6a8d91672f1d93 100644
--- a/clang/unittests/Tooling/RecursiveASTVisitorTests/Concept.cpp
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/Concept.cpp
@@ -86,6 +86,25 @@ TEST(RecursiveASTVisitor, Concepts) {
   EXPECT_EQ(3, Visitor.ConceptRequirementsTraversed);
   EXPECT_EQ(1, Visitor.ConceptReferencesTraversed);
   EXPECT_EQ(1, Visitor.ConceptReferencesVisited);
+
+  Visitor = {};
+  llvm::StringRef Code =
+  R"cpp(
+template concept True = false;
+template  struct Foo {};
+
+template 
+  requires requires { requires True; }
+struct Foo {};
+
+template  requires True
+struct Foo  {};
+  )cpp";
+  EXPECT_TRUE(Visitor.runOver(Code, ConceptVisitor::Lang_CXX2a));
+  // Check that the concept references from the partial specializations are
+  // visited.
+  EXPECT_EQ(2, Visitor.ConceptReferencesTraversed);
+  EXPECT_EQ(2, Visitor.ConceptReferencesVisited);
 }
 
 struct VisitDeclOnlyOnce : ExpectedLocationVisitor {

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


[clang] [AST] RecursiveASTVisitor: traverse the require clause for partial template specializations. (PR #75795)

2023-12-18 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Haojian Wu (hokein)


Changes

This fixes tooling (clangd, include-cleaner) bugs where we miss functionalities 
on concept AST nodes.

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


2 Files Affected:

- (modified) clang/include/clang/AST/RecursiveASTVisitor.h (+1-6) 
- (modified) clang/unittests/Tooling/RecursiveASTVisitorTests/Concept.cpp (+19) 


``diff
diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index c501801b95bd95..8f2714e142bbe3 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2036,12 +2036,7 @@ bool 
RecursiveASTVisitor::TraverseTemplateArgumentLocsHelper(
 #define DEF_TRAVERSE_TMPL_PART_SPEC_DECL(TMPLDECLKIND, DECLKIND)   
\
   DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplatePartialSpecializationDecl, { 
\
 /* The partial specialization. */  
\
-if (TemplateParameterList *TPL = D->getTemplateParameters()) { 
\
-  for (TemplateParameterList::iterator I = TPL->begin(), E = TPL->end();   
\
-   I != E; ++I) {  
\
-TRY_TO(TraverseDecl(*I));  
\
-  }
\
-}  
\
+TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));   
\
 /* The args that remains unspecialized. */ 
\
 TRY_TO(TraverseTemplateArgumentLocsHelper( 
\
 D->getTemplateArgsAsWritten()->getTemplateArgs(),  
\
diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTests/Concept.cpp 
b/clang/unittests/Tooling/RecursiveASTVisitorTests/Concept.cpp
index 594b299b543694..6a8d91672f1d93 100644
--- a/clang/unittests/Tooling/RecursiveASTVisitorTests/Concept.cpp
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/Concept.cpp
@@ -86,6 +86,25 @@ TEST(RecursiveASTVisitor, Concepts) {
   EXPECT_EQ(3, Visitor.ConceptRequirementsTraversed);
   EXPECT_EQ(1, Visitor.ConceptReferencesTraversed);
   EXPECT_EQ(1, Visitor.ConceptReferencesVisited);
+
+  Visitor = {};
+  llvm::StringRef Code =
+  R"cpp(
+template concept True = false;
+template  struct Foo {};
+
+template 
+  requires requires { requires True; }
+struct Foo {};
+
+template  requires True
+struct Foo  {};
+  )cpp";
+  EXPECT_TRUE(Visitor.runOver(Code, ConceptVisitor::Lang_CXX2a));
+  // Check that the concept references from the partial specializations are
+  // visited.
+  EXPECT_EQ(2, Visitor.ConceptReferencesTraversed);
+  EXPECT_EQ(2, Visitor.ConceptReferencesVisited);
 }
 
 struct VisitDeclOnlyOnce : ExpectedLocationVisitor {

``




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


[clang] [llvm] [AMDGPU] Improve selection of ballot.i64 intrinsic in wave32 mode. (PR #71556)

2023-12-18 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm commented:

Description should be adjusted, this isn't really changing the selection 
anymore 

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


[clang] [llvm] [AMDGPU] Improve selection of ballot.i64 intrinsic in wave32 mode. (PR #71556)

2023-12-18 Thread Matt Arsenault via cfe-commits


@@ -961,6 +961,19 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, 
IntrinsicInst &II) const {
 return IC.replaceInstUsesWith(II, 
Constant::getNullValue(II.getType()));
   }
 }
+if (ST->isWave32() && II.getType()->getIntegerBitWidth() == 64) {
+  // %b64 = call i64 ballot.i64(...)
+  // =>
+  // %b32 = call i32 ballot.i32(...)
+  // %b64 = zext i32 %b32 to i64
+  Value *Call = IC.Builder.CreateZExtOrBitCast(

arsenm wrote:

Should be CreateZExt, there's no way this can need a bitcast 

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


[clang] [ARM] arm_acle.h add Corprocessor Instrinsics (PR #75440)

2023-12-18 Thread Saleem Abdulrasool via cfe-commits

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


[clang] [ARM] arm_acle.h add Corprocessor Instrinsics (PR #75440)

2023-12-18 Thread Saleem Abdulrasool via cfe-commits

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


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


[clang] [ARM] arm_acle.h add Corprocessor Instrinsics (PR #75440)

2023-12-18 Thread Saleem Abdulrasool via cfe-commits


@@ -752,10 +752,57 @@ __arm_st64bv0(void *__addr, data512_t __value) {
 #define __arm_mte_ptrdiff(__ptra, __ptrb) __builtin_arm_subp(__ptra, __ptrb)
 
 /* Memory Operations Intrinsics */
-#define __arm_mops_memset_tag(__tagged_address, __value, __size)\
+#define __arm_mops_memset_tag(__tagged_address, __value, __size)   
\
   __builtin_arm_mops_memset_tag(__tagged_address, __value, __size)
 #endif
 
+/* Coprocessor Intrinsics */
+#if (!__thumb__ || __thumb2__) && __ARM_ARCH >= 4

compnerd wrote:

I think that if we are wrapping the version in to the same clause I would 
rather that we split this condition into:

```suggestion
#if (!__thumb__ || __thumb2__)
#if __ARM_ARCH >= 4
```

That makes all the versions uniform and makes it more obvious that the ARM or 
Thumb2 mode applies to all versions.

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


  1   2   3   4   5   >