[clang] [SVE ACLE] Allow default zero initialisation for svcount_t. (PR #69321)

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

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


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


[PATCH] D157331: [clang] Implement C23

2023-10-18 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

This change broke building a recent version of gettext. Gettext uses gnulib for 
polyfilling various utility functions. Since not long ago, these functions 
internally use ``, 
https://git.savannah.gnu.org/cgit/gnulib.git/commit/lib/malloca.c?id=ef5a4088d9236a55283d1eb576f560aa39c09e6f.
 If the toolchain doesn't provide the header, gnulib provides a fallback 
version of its own: 
https://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/stdckdint.in.h

Now since Clang provides it since this commit, gnulib doesn't provide their own 
fallback, but goes on to use `ckd_add`. This fails with Clang's `` 
implementation, since gnulib isn't built in C23 mode but still wants to use 
``:

  i686-w64-mingw32-clang -DHAVE_CONFIG_H -DEXEEXT=\".exe\" -I. 
-I../../../gettext-runtime/gnulib-lib -I..  -I../intl 
-I../../../gettext-runtime/intl -DDEPENDS_ON_LIBICONV=1 -DDEPENDS_ON_LIBINTL=1 
-I/home/martin/fate/vlc/src/contrib/i686-w64-mingw32/include  -Wno-cast-qual 
-Wno-conversion -Wno-float-equal -Wno-sign-compare -Wno-undef 
-Wno-unused-function -Wno-unused-parameter -Wno-float-conversion 
-Wimplicit-fallthrough -Wno-pedantic -Wno-sign-conversion -Wno-type-limits 
-I/home/martin/fate/vlc/src/contrib/i686-w64-mingw32/include -g -O2 -c -o 
libgrt_a-malloca.o `test -f 'malloca.c' || echo 
'../../../gettext-runtime/gnulib-lib/'`malloca.c
  ../../../gettext-runtime/gnulib-lib/malloca.c:53:8: error: call to undeclared 
function 'ckd_add'; ISO C99 and later do not support implicit function 
declarations [-Wimplicit-function-declaration]
 53 |   if (!ckd_add (&nplus, n, plus) && !xalloc_oversized (nplus, 1))
|^
  1 error generated.
  make: *** [Makefile:2246: libgrt_a-malloca.o] Error 1

It seems like GCC's version of this header exposes the functionality even if 
compiled in an older language mode: 
https://github.com/gcc-mirror/gcc/blob/f019251ac9be017aaf3c58f87f43d88b974d21cf/gcc/ginclude/stdckdint.h

Would you consider changing the Clang version to do the same? Otherwise we 
would need to convince gnulib to not try to use/polyfill this header unless 
gnulib itself is compiled in C23 mode.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157331

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


[clang] clang/OpenCL: set sqrt fp accuracy on call to Z4sqrt (PR #66651)

2023-10-18 Thread Romaric Jodin via cfe-commits

rjodinchr wrote:

@arsenm could you have another look at this PR?
Thank you

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


[libunwind] [libunwind] Fix running tests with MSan (PR #67860)

2023-10-18 Thread Fangrui Song via cfe-commits


@@ -43,6 +43,12 @@
   #define LIBUNWIND_AVAIL
 #endif
 
+#if defined(__SANITIZE_MEMORY__) ||
\

MaskRay wrote:

`__SANITIZE_MEMORY__` is a macro defined by the Linux kernel and copied to 
other projects.

We can drop it.

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


[clang-tools-extra] [LLVM] Add IRNormalizer Pass (PR #68176)

2023-10-18 Thread Michal Paszkowski via cfe-commits


@@ -543,6 +543,15 @@ variables with initializers are marked as internal.
 An interprocedural variant of :ref:`Sparse Conditional Constant Propagation
 `.
 
+``ir-normalizer``: Transforms IR into a canonical form that's easier to diff
+
+
+This pass aims to transform LLVM Modules into a canonical form by reordering 
and
+renaming instructions while preserving the same semantics. The canonicalizer 
makes
+it easier to spot semantic differences while diffing two modules which have 
undergone
+two different passes.
+
+---

michalpaszkowski wrote:

Shouldn't this line be removed? and the line underscoring the 
"``ir-normalizer``: Transforms IR into a canonical form that's easier to diff" 
be made a bit longer?

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


[PATCH] D93829: [clangd] Support outgoing calls in call hierarchy

2023-10-18 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 557745.
nridge added a comment.

Implement optimization to filter the refs stored in RevRefs to calls only


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93829

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/index/Index.cpp
  clang-tools-extra/clangd/index/Index.h
  clang-tools-extra/clangd/index/MemIndex.cpp
  clang-tools-extra/clangd/index/MemIndex.h
  clang-tools-extra/clangd/index/Merge.cpp
  clang-tools-extra/clangd/index/Merge.h
  clang-tools-extra/clangd/index/ProjectAware.cpp
  clang-tools-extra/clangd/index/Ref.h
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/index/dex/Dex.h
  clang-tools-extra/clangd/test/type-hierarchy-ext.test
  clang-tools-extra/clangd/test/type-hierarchy.test
  clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1417,6 +1417,12 @@
   return true; // has more references
 }
 
+bool refersTo(const RefsRequest &Req,
+  llvm::function_ref Callback)
+const override {
+  return false;
+}
+
 bool fuzzyFind(
 const FuzzyFindRequest &Req,
 llvm::function_ref Callback) const override {
@@ -1468,6 +1474,12 @@
   return false;
 }
 
+bool refersTo(const RefsRequest &Req,
+  llvm::function_ref Callback)
+const override {
+  return false;
+}
+
 bool fuzzyFind(const FuzzyFindRequest &,
llvm::function_ref) const override {
   return false;
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1644,6 +1644,12 @@
 return false;
   }
 
+  bool
+  refersTo(const RefsRequest &,
+   llvm::function_ref) const override {
+return false;
+  }
+
   void relations(const RelationsRequest &,
  llvm::function_ref)
   const override {}
Index: clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
===
--- clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
+++ clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
@@ -44,17 +44,27 @@
 
 // Helpers for matching call hierarchy data structures.
 MATCHER_P(withName, N, "") { return arg.name == N; }
+MATCHER_P(withDetail, N, "") { return arg.detail == N; }
 MATCHER_P(withSelectionRange, R, "") { return arg.selectionRange == R; }
 
 template 
 ::testing::Matcher from(ItemMatcher M) {
   return Field(&CallHierarchyIncomingCall::from, M);
 }
+template 
+::testing::Matcher to(ItemMatcher M) {
+  return Field(&CallHierarchyOutgoingCall::to, M);
+}
 template 
-::testing::Matcher fromRanges(RangeMatchers... M) {
+::testing::Matcher iFromRanges(RangeMatchers... M) {
   return Field(&CallHierarchyIncomingCall::fromRanges,
UnorderedElementsAre(M...));
 }
+template 
+::testing::Matcher oFromRanges(RangeMatchers... M) {
+  return Field(&CallHierarchyOutgoingCall::fromRanges,
+   UnorderedElementsAre(M...));
+}
 
 TEST(CallHierarchy, IncomingOneFileCpp) {
   Annotations Source(R"cpp(
@@ -79,21 +89,24 @@
   prepareCallHierarchy(AST, Source.point(), testPath(TU.Filename));
   ASSERT_THAT(Items, ElementsAre(withName("callee")));
   auto IncomingLevel1 = incomingCalls(Items[0], Index.get());
-  ASSERT_THAT(IncomingLevel1,
-  ElementsAre(AllOf(from(withName("caller1")),
-fromRanges(Source.range("Callee");
+  ASSERT_THAT(
+  IncomingLevel1,
+  ElementsAre(AllOf(from(AllOf(withName("caller1"), withDetail("caller1"))),
+iFromRanges(Source.range("Callee");
   auto IncomingLevel2 = incomingCalls(IncomingLevel1[0].from, Index.get());
-  ASSERT_THAT(IncomingLevel2,
-  ElementsAre(AllOf(from(withName("caller2")),
-fromRanges(Source.range("Caller1A"),
-   Source.range("Caller1B"))),
-  AllOf(from(withName("caller3")),
-fromRanges(Source.range("Caller1C");
+  ASS

[clang-tools-extra] [LLVM] Add IRNormalizer Pass (PR #68176)

2023-10-18 Thread Michal Paszkowski via cfe-commits


@@ -0,0 +1,637 @@
+//===--- IRNormalizer.cpp - IR Canonicalizer ---===//

michalpaszkowski wrote:

Canonicalizer -> Normalizer

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


[clang-tools-extra] [LLVM] Add IRNormalizer Pass (PR #68176)

2023-10-18 Thread Michal Paszkowski via cfe-commits


@@ -0,0 +1,637 @@
+//===--- IRNormalizer.cpp - IR Canonicalizer ---===//
+//
+// 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
+//
+//===--===//
+/// \file
+/// This file implements the IRNormalizer class which aims to transform LLVM
+/// Modules into a canonical form by reordering and renaming instructions while
+/// preserving the same semantics. The normalizer makes it easier to spot
+/// semantic differences while diffing two modules which have undergone
+/// different passes.
+///
+//===--===//
+
+#include "llvm/Transforms/Utils/IRNormalizer.h"
+#include "llvm/ADT/SetVector.h"
+#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/InstIterator.h"
+#include "llvm/IR/Module.h"
+#include "llvm/InitializePasses.h"
+#include "llvm/Pass.h"
+#include "llvm/PassRegistry.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Transforms/Utils.h"
+#include 
+#include 
+
+#define DEBUG_TYPE "normalize"
+
+using namespace llvm;
+
+namespace {
+/// IRNormalizer aims to transform LLVM IR into canonical form.
+class IRNormalizer {
+public:
+  /// \name Canonicalizer flags.

michalpaszkowski wrote:

Canonicalizer -> Normalizer

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


[clang-tools-extra] [LLVM] Add IRNormalizer Pass (PR #68176)

2023-10-18 Thread Michal Paszkowski via cfe-commits


@@ -543,6 +543,15 @@ variables with initializers are marked as internal.
 An interprocedural variant of :ref:`Sparse Conditional Constant Propagation
 `.
 
+``ir-normalizer``: Transforms IR into a canonical form that's easier to diff
+
+
+This pass aims to transform LLVM Modules into a canonical form by reordering 
and
+renaming instructions while preserving the same semantics. The canonicalizer 
makes

michalpaszkowski wrote:

canonicalizer -> normalizer

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


[PATCH] D93829: [clangd] Support outgoing calls in call hierarchy

2023-10-18 Thread Nathan Ridge via Phabricator via cfe-commits
nridge planned changes to this revision.
nridge added a comment.

The updated patch implements one of the optimizations discussed during review, 
namely filtering the Refs stored in the RevRefs data structure to just those 
that could be calls.

To this end, the patch introduces a new `RefKind`, `RefKind::Call`, as 
discussed.

With the updated patch, memory usage on the same workload is: background_index 
579MB (index 392MB, slabs 187MB).

This is an increase of (579 - 560) / 560 = 3.4% over baseline (down from 8.2% 
with the original patch!)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93829

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


[clang-tools-extra] [LLVM] Add IRNormalizer Pass (PR #68176)

2023-10-18 Thread Michal Paszkowski via cfe-commits


@@ -42,7 +42,10 @@ Non-comprehensive list of changes in this release
functionality, or simply have a lot to talk about), see the `NOTE` below
for adding a new subsection.
 
-* ...
+* Added a new IRNormalizer pass which aims to transform LLVM modules into
+  a canonical form by reordering and renaming instructions while preserving the
+  same semantics. The canonicalizer makes it easier to spot semantic 
differences

michalpaszkowski wrote:

canonicalizer -> normalizer

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


[clang-tools-extra] [LLVM] Add IRNormalizer Pass (PR #68176)

2023-10-18 Thread Michal Paszkowski via cfe-commits


@@ -0,0 +1,637 @@
+//===--- IRNormalizer.cpp - IR Canonicalizer ---===//
+//
+// 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
+//
+//===--===//
+/// \file
+/// This file implements the IRNormalizer class which aims to transform LLVM
+/// Modules into a canonical form by reordering and renaming instructions while
+/// preserving the same semantics. The normalizer makes it easier to spot
+/// semantic differences while diffing two modules which have undergone
+/// different passes.
+///
+//===--===//
+
+#include "llvm/Transforms/Utils/IRNormalizer.h"
+#include "llvm/ADT/SetVector.h"
+#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/InstIterator.h"
+#include "llvm/IR/Module.h"
+#include "llvm/InitializePasses.h"
+#include "llvm/Pass.h"
+#include "llvm/PassRegistry.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Transforms/Utils.h"
+#include 
+#include 
+
+#define DEBUG_TYPE "normalize"
+
+using namespace llvm;
+
+namespace {
+/// IRNormalizer aims to transform LLVM IR into canonical form.
+class IRNormalizer {
+public:
+  /// \name Canonicalizer flags.
+  /// @{
+  /// Preserves original order of instructions.
+  static cl::opt PreserveOrder;
+  /// Renames all instructions (including user-named).
+  static cl::opt RenameAll;
+  /// Folds all regular instructions (including pre-outputs).
+  static cl::opt FoldPreoutputs;
+  /// Sorts and reorders operands in commutative instructions.
+  static cl::opt ReorderOperands;
+  /// @}
+
+  bool runOnFunction(Function &F);
+
+private:
+  // Random constant for hashing, so the state isn't zero.
+  const uint64_t MagicHashConstant = 0x6acaa36bef8325c5ULL;
+  DenseSet NamedInstructions;
+
+  /// \name Naming.
+  /// @{
+  void nameFunctionArguments(Function &F);
+  void nameBasicBlocks(Function &F);
+  void nameInstruction(Instruction *I);
+  void nameAsInitialInstruction(Instruction *I);
+  void nameAsRegularInstruction(Instruction *I);
+  void foldInstructionName(Instruction *I);
+  /// @}
+
+  /// \name Reordering.
+  /// @{
+  void reorderInstructions(SmallVector &Outputs);
+  void reorderInstruction(Instruction *Used, Instruction *User,
+  SmallPtrSet &Visited);
+  void reorderInstructionOperandsByNames(Instruction *I);
+  void reorderPHIIncomingValues(PHINode *PN);
+  /// @}
+
+  /// \name Utility methods.
+  /// @{
+  SmallVector collectOutputInstructions(Function &F);
+  bool isOutput(const Instruction *I);
+  bool isInitialInstruction(const Instruction *I);
+  bool hasOnlyImmediateOperands(const Instruction *I);
+  SetVector
+  getOutputFootprint(Instruction *I,
+ SmallPtrSet &Visited);
+  /// @}
+};
+} // namespace
+
+cl::opt IRNormalizer::PreserveOrder(
+"preserve-order", cl::Hidden,
+cl::desc("Preserves original instruction order"));
+cl::opt IRNormalizer::RenameAll(
+"rename-all", cl::Hidden,
+cl::desc("Renames all instructions (including user-named)"));
+cl::opt IRNormalizer::FoldPreoutputs(
+"fold-all", cl::Hidden,
+cl::desc("Folds all regular instructions (including pre-outputs)"));
+cl::opt IRNormalizer::ReorderOperands(
+"reorder-operands", cl::Hidden,
+cl::desc("Sorts and reorders operands in commutative instructions"));
+
+/// Entry method to the IRNormalizer.
+///
+/// \param M Module to canonicalize.

michalpaszkowski wrote:

canonicalize -> normalize

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


[clang] [LLVM] Add IRNormalizer Pass (PR #68176)

2023-10-18 Thread Michal Paszkowski via cfe-commits

michalpaszkowski wrote:

I added a couple more comments regarding the name change and formatting of the 
docs, but apart from these the patch looks good to me. 

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


[clang] [X86][RFC] Support AVX10 options (PR #67278)

2023-10-18 Thread Phoebe Wang via cfe-commits


@@ -130,17 +131,35 @@ bool X86TargetInfo::initFeatureMap(
   continue;
 }
 
-if (!HasAVX512F && Feature.substr(0, 7) == "+avx512")
+if (Feature.substr(0, 7) == "+avx10.") {
+  HasAVX10 = true;
   HasAVX512F = true;
-if (HasAVX512F && Feature == "-avx512f")
+  if (Feature.substr(Feature.size() - 3, 3) == "512") {
+HasEVEX512 = true;
+  } else if (Feature.substr(7, 2) == "1-") {
+HasEVEX512 = false;
+  }
+} else if (!HasAVX512F && Feature.substr(0, 7) == "+avx512") {
+  HasAVX512F = true;
+} else if (HasAVX512F && Feature == "-avx512f") {
+  HasAVX512F = false;
+} else if (HasAVX10 && Feature == "-avx10.1-256") {
+  HasAVX10 = false;
   HasAVX512F = false;
-if (HasEVEX512 && Feature == "-evex512")
+} else if (!HasEVEX512 && Feature == "+evex512") {
+  HasEVEX512 = true;
+} else if (HasEVEX512 && Feature == "-avx10.1-512") {

phoebewang wrote:

Yes and no.
We have already filtered this case (and cases like this in prior features) in 
the driver. Only the last argument will be passed to Clang if there are both 
positive and negative set in command line. So it won't turn into `+avx10.1-256`.
Function attrribute is another story, we seldom use negative features in 
function attrribute, and if we use, yes, it will enable features it implies. I 
think it makes sense that the attrribute turns off itself rather than features 
command line enabled. See a precedent https://godbolt.org/z/xKWfvEWY7

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


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

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

https://github.com/kadircet created 
https://github.com/llvm/llvm-project/pull/69427

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


From e19bf2e40b79b5f65de91d566e675b560620517e Mon Sep 17 00:00:00 2001
From: Kadir Cetinkaya 
Date: Wed, 18 Oct 2023 09:34:21 +0200
Subject: [PATCH] [clangd] Disable crashy unchecked-optional-access tidy check

Fixes https://github.com/llvm/llvm-project/issues/69369.
---
 clang-tools-extra/clangd/TidyProvider.cpp | 3 +++
 1 file changed, 3 insertions(+)

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

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


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

2023-10-18 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clangd

Author: kadir çetinkaya (kadircet)


Changes

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


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


1 Files Affected:

- (modified) clang-tools-extra/clangd/TidyProvider.cpp (+3) 


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

``




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


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

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


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

HighCommander4 wrote:

A consequence of putting the check here, is that a user who wants the check in 
spite of its bugginess does not have a way to enable it.

It was suggested, in 
https://github.com/clangd/clangd/issues/1700#issuecomment-1659690492 and 
https://github.com/clangd/clangd/issues/1337#issuecomment-1610876189, that we 
should have a way to allow users to override the disablements in this "bad 
checks" list. Could you weigh in on that proposal?

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


[clang] [clang] Improve `_Alignas` on a `struct` declaration diagnostic (PR #65638)

2023-10-18 Thread Jerin Philip via cfe-commits

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


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

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


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

kadircet wrote:

FWIW, we had this check enabled internally before it was upstream'd and 
experience on incomplete code has always been problematic. Hence I don't see 
much point in letting people run this on an incomplete AST. I believe the 
recommended workflow should be through running clang-tidy binary directly. I'll 
add some comments on those threads too.

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


[clang] [X86][RFC] Support AVX10 options (PR #67278)

2023-10-18 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/67278

>From eaf36c8cac3fe6d9bb3dcb1387b0b4f1febf5ef7 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Mon, 25 Sep 2023 10:31:37 +0800
Subject: [PATCH 1/2] [X86][RFC] Support AVX10 options

AVX10 Architecture Specification: 
https://cdrdv2.intel.com/v1/dl/getContent/784267
AVX10 Technical Paper: https://cdrdv2.intel.com/v1/dl/getContent/784343
RFC: https://discourse.llvm.org/t/rfc-design-for-avx10-options-support/73672
---
 clang/docs/ReleaseNotes.rst   |  1 +
 clang/include/clang/Driver/Options.td |  9 +
 clang/lib/Basic/Targets/X86.cpp   | 37 +--
 clang/lib/Basic/Targets/X86.h |  2 +
 clang/lib/Driver/ToolChains/Arch/X86.cpp  | 30 +++
 clang/test/CodeGen/X86/avx512-error.c | 20 +++---
 clang/test/CodeGen/attr-target-x86.c  | 14 +--
 clang/test/CodeGen/target-avx-abi-diag.c  |  4 ++
 clang/test/Driver/x86-target-features.c   | 20 ++
 clang/test/Preprocessor/x86_target_features.c | 14 +++
 llvm/docs/ReleaseNotes.rst|  2 +
 .../llvm/TargetParser/X86TargetParser.def |  2 +
 llvm/lib/Target/X86/X86.td|  8 
 llvm/lib/Target/X86/X86InstrInfo.td   |  2 +
 llvm/lib/TargetParser/Host.cpp|  6 +++
 llvm/lib/TargetParser/X86TargetParser.cpp |  9 +
 16 files changed, 168 insertions(+), 12 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7abcb8d799e09dc..419bab7577cfad4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -387,6 +387,7 @@ X86 Support
 
 - Added option ``-m[no-]evex512`` to disable ZMM and 64-bit mask instructions
   for AVX512 features.
+- Support ISA of ``AVX10.1``.
 
 Arm and AArch64 Support
 ^^^
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0f93479170d73bc..dd44333e6cb30a7 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -197,6 +197,9 @@ def m_wasm_Features_Driver_Group : OptionGroup<"">,
 def m_x86_Features_Group : OptionGroup<"">,
Group, Visibility<[ClangOption, CLOption]>,
DocName<"X86">;
+def m_x86_AVX10_Features_Group : OptionGroup<"">,
+ Group, Visibility<[ClangOption, 
CLOption]>,
+ DocName<"X86 AVX10">;
 def m_riscv_Features_Group : OptionGroup<"">,
  Group, DocName<"RISC-V">;
 def m_ve_Features_Group : OptionGroup<"">,
@@ -5693,6 +5696,12 @@ def msse4a : Flag<["-"], "msse4a">, 
Group;
 def mno_sse4a : Flag<["-"], "mno-sse4a">, Group;
 def mavx : Flag<["-"], "mavx">, Group;
 def mno_avx : Flag<["-"], "mno-avx">, Group;
+def mavx10_1_256 : Flag<["-"], "mavx10.1-256">, 
Group;
+def mno_avx10_1_256 : Flag<["-"], "mno-avx10.1-256">, 
Group;
+def mavx10_1_512 : Flag<["-"], "mavx10.1-512">, 
Group;
+def mno_avx10_1_512 : Flag<["-"], "mno-avx10.1-512">, 
Group;
+def mavx10_1 : Flag<["-"], "mavx10.1">, Alias;
+def mno_avx10_1 : Flag<["-"], "mno-avx10.1">, Alias;
 def mavx2 : Flag<["-"], "mavx2">, Group;
 def mno_avx2 : Flag<["-"], "mno-avx2">, Group;
 def mavx512f : Flag<["-"], "mavx512f">, Group;
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 022d5753135e160..746414181926f7d 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -121,6 +121,7 @@ bool X86TargetInfo::initFeatureMap(
   std::vector UpdatedFeaturesVec;
   bool HasEVEX512 = true;
   bool HasAVX512F = false;
+  bool HasAVX10 = false;
   for (const auto &Feature : FeaturesVec) {
 // Expand general-regs-only to -x86, -mmx and -sse
 if (Feature == "+general-regs-only") {
@@ -130,17 +131,35 @@ bool X86TargetInfo::initFeatureMap(
   continue;
 }
 
-if (!HasAVX512F && Feature.substr(0, 7) == "+avx512")
+if (Feature.substr(0, 7) == "+avx10.") {
+  HasAVX10 = true;
   HasAVX512F = true;
-if (HasAVX512F && Feature == "-avx512f")
+  if (Feature.substr(Feature.size() - 3, 3) == "512") {
+HasEVEX512 = true;
+  } else if (Feature.substr(7, 2) == "1-") {
+HasEVEX512 = false;
+  }
+} else if (!HasAVX512F && Feature.substr(0, 7) == "+avx512") {
+  HasAVX512F = true;
+} else if (HasAVX512F && Feature == "-avx512f") {
+  HasAVX512F = false;
+} else if (HasAVX10 && Feature == "-avx10.1-256") {
+  HasAVX10 = false;
   HasAVX512F = false;
-if (HasEVEX512 && Feature == "-evex512")
+} else if (!HasEVEX512 && Feature == "+evex512") {
+  HasEVEX512 = true;
+} else if (HasEVEX512 && Feature == "-avx10.1-512") {
   HasEVEX512 = false;
+} else if (HasEVEX512 && Feature == "-evex512") {
+  HasEVEX512 = false;
+}
 
 UpdatedFeaturesVec.push_back(Feature);

[libunwind] [X86][RFC] Support AVX10 options (PR #67278)

2023-10-18 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/67278

>From eaf36c8cac3fe6d9bb3dcb1387b0b4f1febf5ef7 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Mon, 25 Sep 2023 10:31:37 +0800
Subject: [PATCH 1/2] [X86][RFC] Support AVX10 options

AVX10 Architecture Specification: 
https://cdrdv2.intel.com/v1/dl/getContent/784267
AVX10 Technical Paper: https://cdrdv2.intel.com/v1/dl/getContent/784343
RFC: https://discourse.llvm.org/t/rfc-design-for-avx10-options-support/73672
---
 clang/docs/ReleaseNotes.rst   |  1 +
 clang/include/clang/Driver/Options.td |  9 +
 clang/lib/Basic/Targets/X86.cpp   | 37 +--
 clang/lib/Basic/Targets/X86.h |  2 +
 clang/lib/Driver/ToolChains/Arch/X86.cpp  | 30 +++
 clang/test/CodeGen/X86/avx512-error.c | 20 +++---
 clang/test/CodeGen/attr-target-x86.c  | 14 +--
 clang/test/CodeGen/target-avx-abi-diag.c  |  4 ++
 clang/test/Driver/x86-target-features.c   | 20 ++
 clang/test/Preprocessor/x86_target_features.c | 14 +++
 llvm/docs/ReleaseNotes.rst|  2 +
 .../llvm/TargetParser/X86TargetParser.def |  2 +
 llvm/lib/Target/X86/X86.td|  8 
 llvm/lib/Target/X86/X86InstrInfo.td   |  2 +
 llvm/lib/TargetParser/Host.cpp|  6 +++
 llvm/lib/TargetParser/X86TargetParser.cpp |  9 +
 16 files changed, 168 insertions(+), 12 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7abcb8d799e09dc..419bab7577cfad4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -387,6 +387,7 @@ X86 Support
 
 - Added option ``-m[no-]evex512`` to disable ZMM and 64-bit mask instructions
   for AVX512 features.
+- Support ISA of ``AVX10.1``.
 
 Arm and AArch64 Support
 ^^^
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0f93479170d73bc..dd44333e6cb30a7 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -197,6 +197,9 @@ def m_wasm_Features_Driver_Group : OptionGroup<"">,
 def m_x86_Features_Group : OptionGroup<"">,
Group, Visibility<[ClangOption, CLOption]>,
DocName<"X86">;
+def m_x86_AVX10_Features_Group : OptionGroup<"">,
+ Group, Visibility<[ClangOption, 
CLOption]>,
+ DocName<"X86 AVX10">;
 def m_riscv_Features_Group : OptionGroup<"">,
  Group, DocName<"RISC-V">;
 def m_ve_Features_Group : OptionGroup<"">,
@@ -5693,6 +5696,12 @@ def msse4a : Flag<["-"], "msse4a">, 
Group;
 def mno_sse4a : Flag<["-"], "mno-sse4a">, Group;
 def mavx : Flag<["-"], "mavx">, Group;
 def mno_avx : Flag<["-"], "mno-avx">, Group;
+def mavx10_1_256 : Flag<["-"], "mavx10.1-256">, 
Group;
+def mno_avx10_1_256 : Flag<["-"], "mno-avx10.1-256">, 
Group;
+def mavx10_1_512 : Flag<["-"], "mavx10.1-512">, 
Group;
+def mno_avx10_1_512 : Flag<["-"], "mno-avx10.1-512">, 
Group;
+def mavx10_1 : Flag<["-"], "mavx10.1">, Alias;
+def mno_avx10_1 : Flag<["-"], "mno-avx10.1">, Alias;
 def mavx2 : Flag<["-"], "mavx2">, Group;
 def mno_avx2 : Flag<["-"], "mno-avx2">, Group;
 def mavx512f : Flag<["-"], "mavx512f">, Group;
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 022d5753135e160..746414181926f7d 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -121,6 +121,7 @@ bool X86TargetInfo::initFeatureMap(
   std::vector UpdatedFeaturesVec;
   bool HasEVEX512 = true;
   bool HasAVX512F = false;
+  bool HasAVX10 = false;
   for (const auto &Feature : FeaturesVec) {
 // Expand general-regs-only to -x86, -mmx and -sse
 if (Feature == "+general-regs-only") {
@@ -130,17 +131,35 @@ bool X86TargetInfo::initFeatureMap(
   continue;
 }
 
-if (!HasAVX512F && Feature.substr(0, 7) == "+avx512")
+if (Feature.substr(0, 7) == "+avx10.") {
+  HasAVX10 = true;
   HasAVX512F = true;
-if (HasAVX512F && Feature == "-avx512f")
+  if (Feature.substr(Feature.size() - 3, 3) == "512") {
+HasEVEX512 = true;
+  } else if (Feature.substr(7, 2) == "1-") {
+HasEVEX512 = false;
+  }
+} else if (!HasAVX512F && Feature.substr(0, 7) == "+avx512") {
+  HasAVX512F = true;
+} else if (HasAVX512F && Feature == "-avx512f") {
+  HasAVX512F = false;
+} else if (HasAVX10 && Feature == "-avx10.1-256") {
+  HasAVX10 = false;
   HasAVX512F = false;
-if (HasEVEX512 && Feature == "-evex512")
+} else if (!HasEVEX512 && Feature == "+evex512") {
+  HasEVEX512 = true;
+} else if (HasEVEX512 && Feature == "-avx10.1-512") {
   HasEVEX512 = false;
+} else if (HasEVEX512 && Feature == "-evex512") {
+  HasEVEX512 = false;
+}
 
 UpdatedFeaturesVec.push_back(Feature);

[clang-tools-extra] [X86][RFC] Support AVX10 options (PR #67278)

2023-10-18 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/67278

>From eaf36c8cac3fe6d9bb3dcb1387b0b4f1febf5ef7 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Mon, 25 Sep 2023 10:31:37 +0800
Subject: [PATCH 1/2] [X86][RFC] Support AVX10 options

AVX10 Architecture Specification: 
https://cdrdv2.intel.com/v1/dl/getContent/784267
AVX10 Technical Paper: https://cdrdv2.intel.com/v1/dl/getContent/784343
RFC: https://discourse.llvm.org/t/rfc-design-for-avx10-options-support/73672
---
 clang/docs/ReleaseNotes.rst   |  1 +
 clang/include/clang/Driver/Options.td |  9 +
 clang/lib/Basic/Targets/X86.cpp   | 37 +--
 clang/lib/Basic/Targets/X86.h |  2 +
 clang/lib/Driver/ToolChains/Arch/X86.cpp  | 30 +++
 clang/test/CodeGen/X86/avx512-error.c | 20 +++---
 clang/test/CodeGen/attr-target-x86.c  | 14 +--
 clang/test/CodeGen/target-avx-abi-diag.c  |  4 ++
 clang/test/Driver/x86-target-features.c   | 20 ++
 clang/test/Preprocessor/x86_target_features.c | 14 +++
 llvm/docs/ReleaseNotes.rst|  2 +
 .../llvm/TargetParser/X86TargetParser.def |  2 +
 llvm/lib/Target/X86/X86.td|  8 
 llvm/lib/Target/X86/X86InstrInfo.td   |  2 +
 llvm/lib/TargetParser/Host.cpp|  6 +++
 llvm/lib/TargetParser/X86TargetParser.cpp |  9 +
 16 files changed, 168 insertions(+), 12 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7abcb8d799e09dc..419bab7577cfad4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -387,6 +387,7 @@ X86 Support
 
 - Added option ``-m[no-]evex512`` to disable ZMM and 64-bit mask instructions
   for AVX512 features.
+- Support ISA of ``AVX10.1``.
 
 Arm and AArch64 Support
 ^^^
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0f93479170d73bc..dd44333e6cb30a7 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -197,6 +197,9 @@ def m_wasm_Features_Driver_Group : OptionGroup<"">,
 def m_x86_Features_Group : OptionGroup<"">,
Group, Visibility<[ClangOption, CLOption]>,
DocName<"X86">;
+def m_x86_AVX10_Features_Group : OptionGroup<"">,
+ Group, Visibility<[ClangOption, 
CLOption]>,
+ DocName<"X86 AVX10">;
 def m_riscv_Features_Group : OptionGroup<"">,
  Group, DocName<"RISC-V">;
 def m_ve_Features_Group : OptionGroup<"">,
@@ -5693,6 +5696,12 @@ def msse4a : Flag<["-"], "msse4a">, 
Group;
 def mno_sse4a : Flag<["-"], "mno-sse4a">, Group;
 def mavx : Flag<["-"], "mavx">, Group;
 def mno_avx : Flag<["-"], "mno-avx">, Group;
+def mavx10_1_256 : Flag<["-"], "mavx10.1-256">, 
Group;
+def mno_avx10_1_256 : Flag<["-"], "mno-avx10.1-256">, 
Group;
+def mavx10_1_512 : Flag<["-"], "mavx10.1-512">, 
Group;
+def mno_avx10_1_512 : Flag<["-"], "mno-avx10.1-512">, 
Group;
+def mavx10_1 : Flag<["-"], "mavx10.1">, Alias;
+def mno_avx10_1 : Flag<["-"], "mno-avx10.1">, Alias;
 def mavx2 : Flag<["-"], "mavx2">, Group;
 def mno_avx2 : Flag<["-"], "mno-avx2">, Group;
 def mavx512f : Flag<["-"], "mavx512f">, Group;
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 022d5753135e160..746414181926f7d 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -121,6 +121,7 @@ bool X86TargetInfo::initFeatureMap(
   std::vector UpdatedFeaturesVec;
   bool HasEVEX512 = true;
   bool HasAVX512F = false;
+  bool HasAVX10 = false;
   for (const auto &Feature : FeaturesVec) {
 // Expand general-regs-only to -x86, -mmx and -sse
 if (Feature == "+general-regs-only") {
@@ -130,17 +131,35 @@ bool X86TargetInfo::initFeatureMap(
   continue;
 }
 
-if (!HasAVX512F && Feature.substr(0, 7) == "+avx512")
+if (Feature.substr(0, 7) == "+avx10.") {
+  HasAVX10 = true;
   HasAVX512F = true;
-if (HasAVX512F && Feature == "-avx512f")
+  if (Feature.substr(Feature.size() - 3, 3) == "512") {
+HasEVEX512 = true;
+  } else if (Feature.substr(7, 2) == "1-") {
+HasEVEX512 = false;
+  }
+} else if (!HasAVX512F && Feature.substr(0, 7) == "+avx512") {
+  HasAVX512F = true;
+} else if (HasAVX512F && Feature == "-avx512f") {
+  HasAVX512F = false;
+} else if (HasAVX10 && Feature == "-avx10.1-256") {
+  HasAVX10 = false;
   HasAVX512F = false;
-if (HasEVEX512 && Feature == "-evex512")
+} else if (!HasEVEX512 && Feature == "+evex512") {
+  HasEVEX512 = true;
+} else if (HasEVEX512 && Feature == "-avx10.1-512") {
   HasEVEX512 = false;
+} else if (HasEVEX512 && Feature == "-evex512") {
+  HasEVEX512 = false;
+}
 
 UpdatedFeaturesVec.push_back(Feature);

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

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

https://github.com/ChuanqiXu9 created 
https://github.com/llvm/llvm-project/pull/69431

There are already 3 issues about the broken state of -fdelayed-template-parsing 
and C++20 modules:
- https://github.com/llvm/llvm-project/issues/61068
- https://github.com/llvm/llvm-project/issues/64810
- https://github.com/llvm/llvm-project/issues/65027

The problem is more complex than I thought. I am not sure how to fix it 
properly now. Given the complexities and -fdelayed-template-parsing is actually 
an extension to support old MS codes, I think it may make sense to not enable 
the -fdelayed-template-parsing option by default with C++20 modules to give 
more user friendly experience. Users who still want -fdelayed-template-parsing 
can specify it explicitly.

>From 197a64c2520a224ec81dcec363d96a6b42c4d567 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Wed, 18 Oct 2023 15:58:03 +0800
Subject: [PATCH] [C++20] [Modules] [Driver] Don't enable
 -fdelayed-template-parsing by default on windows with C++20 modules

There are already 3 issues about the broken state of
-fdelayed-template-parsing and C++20 modules:
- https://github.com/llvm/llvm-project/issues/61068
- https://github.com/llvm/llvm-project/issues/64810
- https://github.com/llvm/llvm-project/issues/65027

The problem is more complex than I thought. I am not sure how to fix it
properly now. Given the complexities and -fdelayed-template-parsing is
actually an extension to support old MS codes, I think it may make sense
to not enable the -fdelayed-template-parsing option by default with
C++20 modules to give more user friendly experience. Users who still want
-fdelayed-template-parsing can specify it explicitly.
---
 .../clang/Basic/DiagnosticDriverKinds.td  |  4 +++
 clang/include/clang/Driver/Types.h|  3 +++
 clang/lib/Driver/ToolChains/Clang.cpp | 25 +--
 clang/lib/Driver/Types.cpp|  4 +++
 .../cl-delayed-template-parsing-modules.cppm  |  7 ++
 5 files changed, 35 insertions(+), 8 deletions(-)
 create mode 100644 clang/test/Driver/cl-delayed-template-parsing-modules.cppm

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 9c00fa50bb95580..0a64f8573931f37 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -527,6 +527,10 @@ def err_test_module_file_extension_format : Error<
 def err_drv_module_output_with_multiple_arch : Error<
   "option '-fmodule-output' can't be used with multiple arch options">;
 
+def warn_drv_delayed_template_parsing_with_module : Warning<
+  "-fdelayed-template-parsing is broken with C++20 modules">,
+  InGroup>;
+
 def err_drv_extract_api_wrong_kind : Error<
   "header file '%0' input '%1' does not match the type of prior input "
   "in api extraction; use '-x %2' to override">;
diff --git a/clang/include/clang/Driver/Types.h 
b/clang/include/clang/Driver/Types.h
index 121b58a6b477d9b..b6a05e1ec9d624a 100644
--- a/clang/include/clang/Driver/Types.h
+++ b/clang/include/clang/Driver/Types.h
@@ -80,6 +80,9 @@ namespace types {
   /// isCXX - Is this a "C++" input (C++ and Obj-C++ sources and headers).
   bool isCXX(ID Id);
 
+  /// isCXXModules - Is this a standard C++ modules input.
+  bool isCXXModules(ID Id);
+
   /// Is this LLVM IR.
   bool isLLVMIR(ID Id);
 
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 94c184435ae14de..21aee28a2b6ba9b 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6842,14 +6842,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 (!IsWindowsMSVC || IsMSVC2015Compatible)))
 CmdArgs.push_back("-fno-threadsafe-statics");
 
-  // -fno-delayed-template-parsing is default, except when targeting MSVC.
-  // Many old Windows SDK versions require this to parse.
-  // FIXME: MSVC introduced /Zc:twoPhase- to disable this behavior in their
-  // compiler. We should be able to disable this by default at some point.
-  if (Args.hasFlag(options::OPT_fdelayed_template_parsing,
-   options::OPT_fno_delayed_template_parsing, IsWindowsMSVC))
-CmdArgs.push_back("-fdelayed-template-parsing");
-
   // -fgnu-keywords default varies depending on language; only pass if
   // specified.
   Args.AddLastArg(CmdArgs, options::OPT_fgnu_keywords,
@@ -6872,6 +6864,23 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 
   bool HaveModules =
   RenderModulesOptions(C, D, Args, Input, Output, Std, CmdArgs);
+  bool IsModulesInput = HaveModules && isCXXModules(Input.getType());
+  // It is possible to compile .pcm files with C++20 modules.
+  IsModulesInput |= Input.getType() == types::TY_ModuleFile;
+
+  // -fno-delayed-template-parsing is default, except when targeting MSVC.
+  // Many old Windows SDK versions require this to parse.
+  // FIXME: MSVC introd

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

2023-10-18 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-modules

Author: Chuanqi Xu (ChuanqiXu9)


Changes

There are already 3 issues about the broken state of -fdelayed-template-parsing 
and C++20 modules:
- https://github.com/llvm/llvm-project/issues/61068
- https://github.com/llvm/llvm-project/issues/64810
- https://github.com/llvm/llvm-project/issues/65027

The problem is more complex than I thought. I am not sure how to fix it 
properly now. Given the complexities and -fdelayed-template-parsing is actually 
an extension to support old MS codes, I think it may make sense to not enable 
the -fdelayed-template-parsing option by default with C++20 modules to give 
more user friendly experience. Users who still want -fdelayed-template-parsing 
can specify it explicitly.

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


5 Files Affected:

- (modified) clang/include/clang/Basic/DiagnosticDriverKinds.td (+4) 
- (modified) clang/include/clang/Driver/Types.h (+3) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+17-8) 
- (modified) clang/lib/Driver/Types.cpp (+4) 
- (added) clang/test/Driver/cl-delayed-template-parsing-modules.cppm (+7) 


``diff
diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 9c00fa50bb95580..0a64f8573931f37 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -527,6 +527,10 @@ def err_test_module_file_extension_format : Error<
 def err_drv_module_output_with_multiple_arch : Error<
   "option '-fmodule-output' can't be used with multiple arch options">;
 
+def warn_drv_delayed_template_parsing_with_module : Warning<
+  "-fdelayed-template-parsing is broken with C++20 modules">,
+  InGroup>;
+
 def err_drv_extract_api_wrong_kind : Error<
   "header file '%0' input '%1' does not match the type of prior input "
   "in api extraction; use '-x %2' to override">;
diff --git a/clang/include/clang/Driver/Types.h 
b/clang/include/clang/Driver/Types.h
index 121b58a6b477d9b..b6a05e1ec9d624a 100644
--- a/clang/include/clang/Driver/Types.h
+++ b/clang/include/clang/Driver/Types.h
@@ -80,6 +80,9 @@ namespace types {
   /// isCXX - Is this a "C++" input (C++ and Obj-C++ sources and headers).
   bool isCXX(ID Id);
 
+  /// isCXXModules - Is this a standard C++ modules input.
+  bool isCXXModules(ID Id);
+
   /// Is this LLVM IR.
   bool isLLVMIR(ID Id);
 
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 94c184435ae14de..21aee28a2b6ba9b 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6842,14 +6842,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 (!IsWindowsMSVC || IsMSVC2015Compatible)))
 CmdArgs.push_back("-fno-threadsafe-statics");
 
-  // -fno-delayed-template-parsing is default, except when targeting MSVC.
-  // Many old Windows SDK versions require this to parse.
-  // FIXME: MSVC introduced /Zc:twoPhase- to disable this behavior in their
-  // compiler. We should be able to disable this by default at some point.
-  if (Args.hasFlag(options::OPT_fdelayed_template_parsing,
-   options::OPT_fno_delayed_template_parsing, IsWindowsMSVC))
-CmdArgs.push_back("-fdelayed-template-parsing");
-
   // -fgnu-keywords default varies depending on language; only pass if
   // specified.
   Args.AddLastArg(CmdArgs, options::OPT_fgnu_keywords,
@@ -6872,6 +6864,23 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 
   bool HaveModules =
   RenderModulesOptions(C, D, Args, Input, Output, Std, CmdArgs);
+  bool IsModulesInput = HaveModules && isCXXModules(Input.getType());
+  // It is possible to compile .pcm files with C++20 modules.
+  IsModulesInput |= Input.getType() == types::TY_ModuleFile;
+
+  // -fno-delayed-template-parsing is default, except when targeting MSVC.
+  // Many old Windows SDK versions require this to parse.
+  // FIXME: MSVC introduced /Zc:twoPhase- to disable this behavior in their
+  // compiler. We should be able to disable this by default at some point.
+  // FIXME: The -fdelayed-template-parsing mode is broken with C++20 modules.
+  if (Args.hasFlag(options::OPT_fdelayed_template_parsing,
+   options::OPT_fno_delayed_template_parsing,
+   IsWindowsMSVC && !IsModulesInput)) {
+if (IsModulesInput)
+  D.Diag(clang::diag::warn_drv_delayed_template_parsing_with_module);
+
+CmdArgs.push_back("-fdelayed-template-parsing");
+  }
 
   if (Args.hasFlag(options::OPT_fpch_validate_input_files_content,
options::OPT_fno_pch_validate_input_files_content, false))
diff --git a/clang/lib/Driver/Types.cpp b/clang/lib/Driver/Types.cpp
index 08df34ade7b6530..6977b5509c26a9b 100644
--- a/clang/lib/Driver/Types.cpp
+++ b/clang/lib/Driver/Types.cpp
@@ -249,6 +249,10 @@ bool types::isCXX(ID Id) {
   }
 }
 

[clang] [Clang][Sema] Skip RecordDecl when checking scope of declarations (PR #69432)

2023-10-18 Thread Qiu Chaofan via cfe-commits

https://github.com/ecnelises created 
https://github.com/llvm/llvm-project/pull/69432

In non C++ mode, struct definitions does not create a scope for declaration.

Fixes #41302 

Fixes #44080

>From 6828025e788347f21a41d4a9aa138af032017b80 Mon Sep 17 00:00:00 2001
From: Qiu Chaofan 
Date: Wed, 18 Oct 2023 16:02:02 +0800
Subject: [PATCH] [Clang][Sema] Skip RecordDecl when checking scope of
 declarations

---
 clang/lib/AST/DeclBase.cpp| 1 -
 clang/lib/Sema/IdentifierResolver.cpp | 4 +++-
 clang/test/Sema/nested-redef.c| 6 +-
 clang/test/SemaObjC/ivar-lookup.m | 4 ++--
 4 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index a3847a73faf8183..845f9b1d1f302af 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -1315,7 +1315,6 @@ bool DeclContext::isDependentContext() const {
 bool DeclContext::isTransparentContext() const {
   if (getDeclKind() == Decl::Enum)
 return !cast(this)->isScoped();
-
   return isa(this);
 }
 
diff --git a/clang/lib/Sema/IdentifierResolver.cpp 
b/clang/lib/Sema/IdentifierResolver.cpp
index 98a6f3b45089b3a..2213c3c837243ad 100644
--- a/clang/lib/Sema/IdentifierResolver.cpp
+++ b/clang/lib/Sema/IdentifierResolver.cpp
@@ -109,7 +109,9 @@ bool IdentifierResolver::isDeclInScope(Decl *D, DeclContext 
*Ctx, Scope *S,
 return false;
   if (Ctx->isFunctionOrMethod() || (S && S->isFunctionPrototypeScope())) {
 // Ignore the scopes associated within transparent declaration contexts.
-while (S->getEntity() && S->getEntity()->isTransparentContext())
+while (S->getEntity() &&
+   (S->getEntity()->isTransparentContext() ||
+(!LangOpt.CPlusPlus && isa(S->getEntity()
   S = S->getParent();
 
 if (S->isDeclScope(D))
diff --git a/clang/test/Sema/nested-redef.c b/clang/test/Sema/nested-redef.c
index bbc485936770478..c5a726c30422f98 100644
--- a/clang/test/Sema/nested-redef.c
+++ b/clang/test/Sema/nested-redef.c
@@ -19,4 +19,8 @@ void f2(void) {
   struct U u;
 }
 
-
+void f3(void) {
+  struct G { // expected-note{{previous definition is here}}
+struct G {}; // expected-error{{nested redefinition of 'G'}}
+  };
+}
diff --git a/clang/test/SemaObjC/ivar-lookup.m 
b/clang/test/SemaObjC/ivar-lookup.m
index 898ffac99692ced..d88299e58e0f594 100644
--- a/clang/test/SemaObjC/ivar-lookup.m
+++ b/clang/test/SemaObjC/ivar-lookup.m
@@ -95,11 +95,11 @@ - (int) test
   union U {
 __typeof(myStatus) __in;  // fails.
   };
-  struct S {
+  struct S { // expected-note{{previous definition is here}}
 __typeof(myStatus) __in;  // fails.
 struct S1 { // expected-warning {{declaration does not declare anything}}
   __typeof(myStatus) __in;  // fails.
-  struct S { // expected-warning {{declaration does not declare anything}}
+  struct S { // expected-error {{nested redefinition of 'S'}}
 __typeof(myStatus) __in;  // fails.
   };
 };

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


[clang] [Clang][Sema] Skip RecordDecl when checking scope of declarations (PR #69432)

2023-10-18 Thread Qiu Chaofan via cfe-commits

https://github.com/ecnelises updated 
https://github.com/llvm/llvm-project/pull/69432

>From f97807afc177ab04c97d0c346081fc92d3e79e6c Mon Sep 17 00:00:00 2001
From: Qiu Chaofan 
Date: Wed, 18 Oct 2023 16:02:02 +0800
Subject: [PATCH] [Clang][Sema] Skip RecordDecl when checking scope of
 declarations

---
 clang/lib/Sema/IdentifierResolver.cpp | 4 +++-
 clang/test/Sema/nested-redef.c| 6 +-
 clang/test/SemaObjC/ivar-lookup.m | 4 ++--
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Sema/IdentifierResolver.cpp 
b/clang/lib/Sema/IdentifierResolver.cpp
index 98a6f3b45089b3a..2213c3c837243ad 100644
--- a/clang/lib/Sema/IdentifierResolver.cpp
+++ b/clang/lib/Sema/IdentifierResolver.cpp
@@ -109,7 +109,9 @@ bool IdentifierResolver::isDeclInScope(Decl *D, DeclContext 
*Ctx, Scope *S,
 return false;
   if (Ctx->isFunctionOrMethod() || (S && S->isFunctionPrototypeScope())) {
 // Ignore the scopes associated within transparent declaration contexts.
-while (S->getEntity() && S->getEntity()->isTransparentContext())
+while (S->getEntity() &&
+   (S->getEntity()->isTransparentContext() ||
+(!LangOpt.CPlusPlus && isa(S->getEntity()
   S = S->getParent();
 
 if (S->isDeclScope(D))
diff --git a/clang/test/Sema/nested-redef.c b/clang/test/Sema/nested-redef.c
index bbc485936770478..c5a726c30422f98 100644
--- a/clang/test/Sema/nested-redef.c
+++ b/clang/test/Sema/nested-redef.c
@@ -19,4 +19,8 @@ void f2(void) {
   struct U u;
 }
 
-
+void f3(void) {
+  struct G { // expected-note{{previous definition is here}}
+struct G {}; // expected-error{{nested redefinition of 'G'}}
+  };
+}
diff --git a/clang/test/SemaObjC/ivar-lookup.m 
b/clang/test/SemaObjC/ivar-lookup.m
index 898ffac99692ced..d88299e58e0f594 100644
--- a/clang/test/SemaObjC/ivar-lookup.m
+++ b/clang/test/SemaObjC/ivar-lookup.m
@@ -95,11 +95,11 @@ - (int) test
   union U {
 __typeof(myStatus) __in;  // fails.
   };
-  struct S {
+  struct S { // expected-note{{previous definition is here}}
 __typeof(myStatus) __in;  // fails.
 struct S1 { // expected-warning {{declaration does not declare anything}}
   __typeof(myStatus) __in;  // fails.
-  struct S { // expected-warning {{declaration does not declare anything}}
+  struct S { // expected-error {{nested redefinition of 'S'}}
 __typeof(myStatus) __in;  // fails.
   };
 };

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


[clang] [Clang][Sema] Skip RecordDecl when checking scope of declarations (PR #69432)

2023-10-18 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Qiu Chaofan (ecnelises)


Changes

In non C++ mode, struct definitions does not create a scope for declaration.

Fixes #41302 

Fixes #44080

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


3 Files Affected:

- (modified) clang/lib/Sema/IdentifierResolver.cpp (+3-1) 
- (modified) clang/test/Sema/nested-redef.c (+5-1) 
- (modified) clang/test/SemaObjC/ivar-lookup.m (+2-2) 


``diff
diff --git a/clang/lib/Sema/IdentifierResolver.cpp 
b/clang/lib/Sema/IdentifierResolver.cpp
index 98a6f3b45089b3a..2213c3c837243ad 100644
--- a/clang/lib/Sema/IdentifierResolver.cpp
+++ b/clang/lib/Sema/IdentifierResolver.cpp
@@ -109,7 +109,9 @@ bool IdentifierResolver::isDeclInScope(Decl *D, DeclContext 
*Ctx, Scope *S,
 return false;
   if (Ctx->isFunctionOrMethod() || (S && S->isFunctionPrototypeScope())) {
 // Ignore the scopes associated within transparent declaration contexts.
-while (S->getEntity() && S->getEntity()->isTransparentContext())
+while (S->getEntity() &&
+   (S->getEntity()->isTransparentContext() ||
+(!LangOpt.CPlusPlus && isa(S->getEntity()
   S = S->getParent();
 
 if (S->isDeclScope(D))
diff --git a/clang/test/Sema/nested-redef.c b/clang/test/Sema/nested-redef.c
index bbc485936770478..c5a726c30422f98 100644
--- a/clang/test/Sema/nested-redef.c
+++ b/clang/test/Sema/nested-redef.c
@@ -19,4 +19,8 @@ void f2(void) {
   struct U u;
 }
 
-
+void f3(void) {
+  struct G { // expected-note{{previous definition is here}}
+struct G {}; // expected-error{{nested redefinition of 'G'}}
+  };
+}
diff --git a/clang/test/SemaObjC/ivar-lookup.m 
b/clang/test/SemaObjC/ivar-lookup.m
index 898ffac99692ced..d88299e58e0f594 100644
--- a/clang/test/SemaObjC/ivar-lookup.m
+++ b/clang/test/SemaObjC/ivar-lookup.m
@@ -95,11 +95,11 @@ - (int) test
   union U {
 __typeof(myStatus) __in;  // fails.
   };
-  struct S {
+  struct S { // expected-note{{previous definition is here}}
 __typeof(myStatus) __in;  // fails.
 struct S1 { // expected-warning {{declaration does not declare anything}}
   __typeof(myStatus) __in;  // fails.
-  struct S { // expected-warning {{declaration does not declare anything}}
+  struct S { // expected-error {{nested redefinition of 'S'}}
 __typeof(myStatus) __in;  // fails.
   };
 };

``




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


[clang] [clang] [unittest] Add a test for Generic_GCC::GCCVersion::Parse (PR #69078)

2023-10-18 Thread Martin Storsjö via cfe-commits

https://github.com/mstorsjo updated 
https://github.com/llvm/llvm-project/pull/69078

From 1aac071988f66ccab67c7a6179841bb272b5684a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 
Date: Sat, 14 Oct 2023 00:06:05 +0300
Subject: [PATCH] [clang] [unittest] Add a test for
 Generic_GCC::GCCVersion::Parse

This adds actual test cases for all the cases that are listed in
a code comment in the implementation of this function; having such
test coverage eases doing further modifications to the function.
---
 clang/unittests/Driver/CMakeLists.txt |  1 +
 clang/unittests/Driver/GCCVersionTest.cpp | 52 +++
 2 files changed, 53 insertions(+)
 create mode 100644 clang/unittests/Driver/GCCVersionTest.cpp

diff --git a/clang/unittests/Driver/CMakeLists.txt 
b/clang/unittests/Driver/CMakeLists.txt
index e37c158d7137a88..752037f78fb147d 100644
--- a/clang/unittests/Driver/CMakeLists.txt
+++ b/clang/unittests/Driver/CMakeLists.txt
@@ -9,6 +9,7 @@ set(LLVM_LINK_COMPONENTS
 add_clang_unittest(ClangDriverTests
   DistroTest.cpp
   DXCModeTest.cpp
+  GCCVersionTest.cpp
   ToolChainTest.cpp
   ModuleCacheTest.cpp
   MultilibBuilderTest.cpp
diff --git a/clang/unittests/Driver/GCCVersionTest.cpp 
b/clang/unittests/Driver/GCCVersionTest.cpp
new file mode 100644
index 000..9ae335bca77dc12
--- /dev/null
+++ b/clang/unittests/Driver/GCCVersionTest.cpp
@@ -0,0 +1,52 @@
+//===- unittests/Driver/GCCVersionTest.cpp --- GCCVersion parser tests 
===//
+//
+// 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
+//
+//===--===//
+//
+// Unit tests for Generic_GCC::GCCVersion
+//
+//===--===//
+
+#include "../../lib/Driver/ToolChains/Gnu.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace clang::driver;
+
+namespace {
+
+struct VersionParseTest {
+  std::string Text;
+
+  int Major, Minor, Patch;
+  std::string MajorStr, MinorStr, PatchSuffix;
+};
+
+const VersionParseTest TestCases[] = {
+{"5", 5, -1, -1, "5", "", ""},
+{"4.4", 4, 4, -1, "4", "4", ""},
+{"4.4-patched", 4, 4, -1, "4", "4", "-patched"},
+{"4.4.0", 4, 4, 0, "4", "4", ""},
+{"4.4.x", 4, 4, -1, "4", "4", ""},
+{"4.4.2-rc4", 4, 4, 2, "4", "4", "-rc4"},
+{"4.4.x-patched", 4, 4, -1, "4", "4", ""},
+{"not-a-version", -1, -1, -1, "", "", ""},
+};
+
+TEST(GCCVersionTest, Parse) {
+  for (const auto &TC : TestCases) {
+auto V = toolchains::Generic_GCC::GCCVersion::Parse(TC.Text);
+EXPECT_EQ(V.Text, TC.Text);
+EXPECT_EQ(V.Major, TC.Major);
+EXPECT_EQ(V.Minor, TC.Minor);
+EXPECT_EQ(V.Patch, TC.Patch);
+EXPECT_EQ(V.MajorStr, TC.MajorStr);
+EXPECT_EQ(V.MinorStr, TC.MinorStr);
+EXPECT_EQ(V.PatchSuffix, TC.PatchSuffix);
+  }
+}
+
+} // end anonymous namespace

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


[clang] [clang][Diagnostics] Highlight code snippets (PR #66514)

2023-10-18 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= 
Message-ID:
In-Reply-To: 


tbaederr wrote:

> > > I really like this direction, thanks!
> > > I left a few comments, i will do another pass later
> > 
> > 
> > So you'd accept the lexing slowdown instead of using a maximum file size 
> > for highlighting?
> 
> Do I understand correctly that with the latest change there is no noticeable 
> perf impact? Otherwise, yes I'm happy limiting to 2MB - it seems the biggest 
> files in clang are about 500K. So it should only disable highlighting on 
> generated files, which seems reasonable

Kind of  - [this 
run](http://llvm-compile-time-tracker.com/compare.php?from=6ade5183232dc1398205d7c9dbe21243b2560837&to=5ad516d39b6706af6fd55eded264aba4ba432ad2&stat=instructions:u)
 only shows noticeable slowdown in one test. But we also only highlight the 
main file right now - that means we don't get syntax highlighting in included 
files and implementing that would probably make it a bit slower as well since 
we'd have to map the save points to their FileID.

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


[clang] [clang] [unittest] Add a test for Generic_GCC::GCCVersion::Parse (PR #69078)

2023-10-18 Thread Martin Storsjö via cfe-commits

mstorsjo wrote:

Thanks, I applied the suggested changes - will push in a little while.

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


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

2023-10-18 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto updated this revision to Diff 557746.
CarolineConcatto added a comment.

-Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151199

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


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

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

2023-10-18 Thread Tobias Burnus via cfe-commits

tob2 wrote:

> V3 has been deprecated for a while as well, so it can safely be removed

We are using v3 for (better) backward compatibility with the older gfx803 / 
fiji cards (GCN GFX8 (Volcanic Islands (VI))) — thus, this commit on Monday 
broke our tester for gfx803 / fiji cards :-(

However, for newer cards (like GCN GFX9 (Vega) – or newer), we use v4, which 
works perfectly well.

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


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

2023-10-18 Thread Dominik Wójt via cfe-commits

https://github.com/domin144 updated 
https://github.com/llvm/llvm-project/pull/67412

From e20234c6a73a2dded9e5a34e2900e7757ac9460f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dominik=20W=C3=B3jt?= 
Date: Wed, 20 Sep 2023 16:39:27 +0200
Subject: [PATCH 1/2] [ARM] fix "+fp.dp" in multilib selection

When the FPU was selected with "+(no)fp(.dp)" extensions in "-march" or
"-mcpu" options, the FPU used for multilib selection was still the
default one for given architecture or CPU.
---
 clang/lib/Driver/ToolChains/Arch/ARM.cpp  |  5 ++
 .../test/Driver/print-multi-selection-flags.c | 10 +++
 .../llvm/TargetParser/ARMTargetParser.h   |  8 +++
 llvm/lib/TargetParser/ARMTargetParser.cpp | 69 +++
 4 files changed, 77 insertions(+), 15 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 8e1cff0b443eeeb..f1d7aeb555f8bd0 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -627,6 +627,11 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver 
&D,
 if (!llvm::ARM::getFPUFeatures(FPUKind, Features))
   D.Diag(clang::diag::err_drv_clang_unsupported)
   << std::string("-mfpu=") + AndroidFPU;
+  } else if (ArchArgFPUKind != llvm::ARM::FK_INVALID ||
+ CPUArgFPUKind != llvm::ARM::FK_INVALID) {
+FPUKind =
+CPUArgFPUKind != llvm::ARM::FK_INVALID ? CPUArgFPUKind : 
ArchArgFPUKind;
+(void)llvm::ARM::getFPUFeatures(FPUKind, Features);
   } else {
 if (!ForAS) {
   std::string CPU = arm::getARMTargetCPU(CPUName, ArchName, Triple);
diff --git a/clang/test/Driver/print-multi-selection-flags.c 
b/clang/test/Driver/print-multi-selection-flags.c
index 819ff242ced0026..f020a22ea128aac 100644
--- a/clang/test/Driver/print-multi-selection-flags.c
+++ b/clang/test/Driver/print-multi-selection-flags.c
@@ -35,6 +35,16 @@
 // CHECK-MVENOFP-NOT: -march=thumbv8.1m.main{{.*}}+mve.fp{{.*}}
 // CHECK-MVENOFP: -mfpu=none
 
+// RUN: %clang -print-multi-flags-experimental --target=arm-none-eabihf 
-march=armv8.1m.main+fp.dp | FileCheck --check-prefix=CHECK-V8_1_FP_DP %s
+// CHECK-V8_1_FP_DP: -march=thumbv8.1m.main{{.*}}
+// CHECK-V8_1_FP_DP: -mfloat-abi=hard
+// CHECK-V8_1_FP_DP: -mfpu=fp-armv8-fullfp16-d16
+
+// RUN: %clang -print-multi-flags-experimental --target=arm-none-eabihf 
-mcpu=cortex-m85+nofp.dp | FileCheck --check-prefix=CHECK-M85_NO_FP_DP %s
+// CHECK-M85_NO_FP_DP: -march=thumbv8.1m.main{{.*}}
+// CHECK-M85_NO_FP_DP: -mfloat-abi=hard
+// CHECK-M85_NO_FP_DP: -mfpu=fp-armv8-fullfp16-sp-d16
+
 // RUN: %clang -print-multi-flags-experimental --target=aarch64-none-elf 
-march=armv8-a+lse | FileCheck --check-prefix=CHECK-LSE %s
 // CHECK-LSE: -march=aarch64{{.*}}+lse{{.*}}
 
diff --git a/llvm/include/llvm/TargetParser/ARMTargetParser.h 
b/llvm/include/llvm/TargetParser/ARMTargetParser.h
index b893eab1902f81b..c42d66f048fccc0 100644
--- a/llvm/include/llvm/TargetParser/ARMTargetParser.h
+++ b/llvm/include/llvm/TargetParser/ARMTargetParser.h
@@ -143,6 +143,14 @@ enum class FPURestriction {
   SP_D16///< Only single-precision instructions, with 16 D registers
 };
 
+inline bool isDoublePrecision(const FPURestriction restriction) {
+  return restriction != FPURestriction::SP_D16;
+}
+
+inline bool has32Regs(const FPURestriction restriction) {
+  return restriction == FPURestriction::None;
+}
+
 // An FPU name implies one of three levels of Neon support:
 enum class NeonSupportLevel {
   None = 0, ///< No Neon
diff --git a/llvm/lib/TargetParser/ARMTargetParser.cpp 
b/llvm/lib/TargetParser/ARMTargetParser.cpp
index 20225232b3cccb7..671063d831e2bd6 100644
--- a/llvm/lib/TargetParser/ARMTargetParser.cpp
+++ b/llvm/lib/TargetParser/ARMTargetParser.cpp
@@ -366,26 +366,50 @@ StringRef ARM::getArchExtFeature(StringRef ArchExt) {
 }
 
 static ARM::FPUKind findDoublePrecisionFPU(ARM::FPUKind InputFPUKind) {
+  if (InputFPUKind == ARM::FK_INVALID || InputFPUKind == ARM::FK_NONE)
+return ARM::FK_INVALID;
+
+  const ARM::FPUName &InputFPU = ARM::FPUNames[InputFPUKind];
+
+  if (ARM::isDoublePrecision(InputFPU.Restriction))
+return InputFPUKind;
+
+  // Otherwise, look for an FPU entry with all the same fields, except
+  // that it supports double precision.
+  for (const ARM::FPUName &CandidateFPU : ARM::FPUNames) {
+if (CandidateFPU.FPUVer == InputFPU.FPUVer &&
+CandidateFPU.NeonSupport == InputFPU.NeonSupport &&
+ARM::has32Regs(CandidateFPU.Restriction) ==
+ARM::has32Regs(InputFPU.Restriction) &&
+ARM::isDoublePrecision(CandidateFPU.Restriction)) {
+  return CandidateFPU.ID;
+}
+  }
+
+  // nothing found
+  return ARM::FK_INVALID;
+}
+
+static ARM::FPUKind findSinglePrecisionFPU(ARM::FPUKind InputFPUKind) {
+  if (InputFPUKind == ARM::FK_INVALID || InputFPUKind == ARM::FK_NONE)
+return ARM::FK_INVALID;
+
   const ARM::FPUName &InputFPU = ARM::FPUNames[InputFPUKind];
 
   // If the input FPU already 

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

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

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


[clang] 48a5350 - [clang][USR] Encode full decl-context also for anon namespaces (#68325)

2023-10-18 Thread via cfe-commits

Author: kadir çetinkaya
Date: 2023-10-18T10:51:31+02:00
New Revision: 48a53509e851c93f352c967da1feb1c8fb2abd9a

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

LOG: [clang][USR] Encode full decl-context also for anon namespaces (#68325)

Otherwise we create collisions, e.g. a struct named Foo inside an
anonymous
namespace will get the same USR no matter what the surrounding
decl-context is.

Added: 
clang/test/Index/USR/decl-context.cpp

Modified: 
clang/lib/Index/USRGeneration.cpp

Removed: 




diff  --git a/clang/lib/Index/USRGeneration.cpp 
b/clang/lib/Index/USRGeneration.cpp
index f778a6208d5122d..614f5d8d2cad520 100644
--- a/clang/lib/Index/USRGeneration.cpp
+++ b/clang/lib/Index/USRGeneration.cpp
@@ -9,6 +9,7 @@
 #include "clang/Index/USRGeneration.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/DeclVisitor.h"
 #include "clang/Basic/FileManager.h"
@@ -368,14 +369,14 @@ void USRGenerator::VisitTemplateTemplateParmDecl(
 }
 
 void USRGenerator::VisitNamespaceDecl(const NamespaceDecl *D) {
+  if (IgnoreResults)
+return;
+  VisitDeclContext(D->getDeclContext());
   if (D->isAnonymousNamespace()) {
 Out << "@aN";
 return;
   }
-
-  VisitDeclContext(D->getDeclContext());
-  if (!IgnoreResults)
-Out << "@N@" << D->getName();
+  Out << "@N@" << D->getName();
 }
 
 void USRGenerator::VisitFunctionTemplateDecl(const FunctionTemplateDecl *D) {

diff  --git a/clang/test/Index/USR/decl-context.cpp 
b/clang/test/Index/USR/decl-context.cpp
new file mode 100644
index 000..a57137a5c89b5fd
--- /dev/null
+++ b/clang/test/Index/USR/decl-context.cpp
@@ -0,0 +1,14 @@
+// RUN: c-index-test core -print-source-symbols -- -std=c++20 %s | FileCheck %s
+
+namespace ns {
+namespace {
+struct Foo {};
+// CHECK: [[@LINE-1]]:8 | struct/C | Foo | c:decl-context.cpp@N@ns@aN@S@Foo
+}
+}
+namespace ns2 {
+namespace {
+struct Foo {};
+// CHECK: [[@LINE-1]]:8 | struct/C | Foo | c:decl-context.cpp@N@ns2@aN@S@Foo
+}
+}



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


[clang] [clang][USR] Encode full decl-context also for anon namespaces (PR #68325)

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

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


[clang] fix usr rhs (PR #68329)

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

https://github.com/kadircet updated 
https://github.com/llvm/llvm-project/pull/68329

From 80fa52f6efa36e04bf87c525013513d4429788ae Mon Sep 17 00:00:00 2001
From: Kadir Cetinkaya 
Date: Thu, 5 Oct 2023 18:05:11 +0200
Subject: [PATCH] [clang][Index] Improve USR generation for using-decls

Make sure we include filename and namespace for the target declarations.
---
 .../clangd/unittests/SymbolInfoTests.cpp  |  2 +-
 clang/lib/Index/USRGeneration.cpp | 27 +--
 clang/test/Index/USR/using-decl.cpp   | 16 +++
 clang/test/Index/using_if_exists.cpp  |  2 +-
 clang/test/Index/usrs.cpp |  2 +-
 5 files changed, 38 insertions(+), 11 deletions(-)
 create mode 100644 clang/test/Index/USR/using-decl.cpp

diff --git a/clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp 
b/clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp
index 6c91f3783a6220a..64c8834ab2e95bc 100644
--- a/clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp
@@ -202,7 +202,7 @@ TEST(SymbolInfoTests, All) {
  "def_bool"},
ExpectedSymbolDetails{"foo", "", "c:@F@foo#I#", "def_int",
  "def_int"},
-   ExpectedSymbolDetails{"foo", "bar::", "c:@N@bar@UD@foo",
+   ExpectedSymbolDetails{"foo", "bar::", 
"c:TestTU.cpp@N@bar@UD@foo",
  "decl"}}},
   {
   R"cpp( // Multiple symbols returned - implicit conversion
diff --git a/clang/lib/Index/USRGeneration.cpp 
b/clang/lib/Index/USRGeneration.cpp
index 614f5d8d2cad520..5a409f34242ecd1 100644
--- a/clang/lib/Index/USRGeneration.cpp
+++ b/clang/lib/Index/USRGeneration.cpp
@@ -114,14 +114,7 @@ class USRGenerator : public ConstDeclVisitor 
{
 IgnoreResults = true;
   }
 
-  void VisitUsingDecl(const UsingDecl *D) {
-VisitDeclContext(D->getDeclContext());
-Out << "@UD@";
-
-bool EmittedDeclName = !EmitDeclName(D);
-assert(EmittedDeclName && "EmitDeclName can not fail for UsingDecls");
-(void)EmittedDeclName;
-  }
+  void VisitBaseUsingDecl(const BaseUsingDecl *D);
 
   bool ShouldGenerateLocation(const NamedDecl *D);
 
@@ -1070,6 +1063,24 @@ void USRGenerator::VisitMSGuidDecl(const MSGuidDecl *D) {
   D->NamedDecl::printName(Out);
 }
 
+void USRGenerator::VisitBaseUsingDecl(const BaseUsingDecl *D) {
+  // Add the filename when needed to disambiguate using decls from different
+  // files.
+  if (ShouldGenerateLocation(D) && GenLoc(D, /*IncludeOffset=*/false))
+return;
+  VisitDeclContext(D->getDeclContext());
+  Out << "@UD";
+
+  // When the using-decl is resolved also print the context of the first target
+  // decl. All shadows must be from the same decl-context.
+  if (auto FirstShadow = D->shadow_begin(); FirstShadow != D->shadow_end())
+VisitDeclContext(FirstShadow->getTargetDecl()->getDeclContext());
+  Out << "@";
+  bool EmittedDeclName = !EmitDeclName(D);
+  assert(EmittedDeclName && "EmitDeclName can not fail for UsingDecls");
+  (void)EmittedDeclName;
+}
+
 
//===--===//
 // USR generation functions.
 
//===--===//
diff --git a/clang/test/Index/USR/using-decl.cpp 
b/clang/test/Index/USR/using-decl.cpp
new file mode 100644
index 000..91a4a8f7946cd61
--- /dev/null
+++ b/clang/test/Index/USR/using-decl.cpp
@@ -0,0 +1,16 @@
+// RUN: c-index-test core -print-source-symbols -- -std=c++20 %s | FileCheck %s
+
+namespace ns { void foo(); }
+namespace ns2 { void foo(int); }
+
+namespace exporting {
+namespace {
+using ns::foo;
+// CHECK: [[@LINE-1]]:11 | using/C++ | foo | 
c:using-decl.cpp@N@exporting@aN@UD@N@ns@foo
+using ::ns::foo;
+// CHECK: [[@LINE-1]]:13 | using/C++ | foo | 
c:using-decl.cpp@N@exporting@aN@UD@N@ns@foo
+// FIXME: Also put the qualified name for the target decl
+using ns2::foo;
+// CHECK: [[@LINE-1]]:12 | using/C++ | foo | 
c:using-decl.cpp@N@exporting@aN@UD@N@ns2@foo
+}
+}
diff --git a/clang/test/Index/using_if_exists.cpp 
b/clang/test/Index/using_if_exists.cpp
index 73d1be739e42816..339d7fa233d68bd 100644
--- a/clang/test/Index/using_if_exists.cpp
+++ b/clang/test/Index/using_if_exists.cpp
@@ -6,5 +6,5 @@ namespace ns {
 }
 
 using ns::foo __attribute__((using_if_exists));
-// CHECK: [[@LINE-1]]:11 | using/C++ | foo | c:@UD@foo |  | Decl | 
rel: 0
+// CHECK: [[@LINE-1]]:11 | using/C++ | foo | c:using_if_exists.cpp@UD@foo | 
 | Decl | rel: 0
 // CHECK-NOT: 
diff --git a/clang/test/Index/usrs.cpp b/clang/test/Index/usrs.cpp
index dbfa44f4b676489..08b9c6f60bd8cc8 100644
--- a/clang/test/Index/usrs.cpp
+++ b/clang/test/Index/usrs.cpp
@@ -158,7 +158,7 @@ __m128 vectorOverload(__m128 f);
 // CHECK: usrs.cpp c:@NA@foo_alias
 // CHECK-NOT: foo
 // CHECK: usrs.cpp c:@NA@foo_alias2
-// CHECK: usrs.cpp c:@UD@ClsB Extent=[64:

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

2023-10-18 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto updated this revision to Diff 557747.
CarolineConcatto added a comment.

-Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151307

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

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

[clang] b4b35a5 - [clang] [unittest] Add a test for Generic_GCC::GCCVersion::Parse (#69078)

2023-10-18 Thread via cfe-commits

Author: Martin Storsjö
Date: 2023-10-18T12:36:27+03:00
New Revision: b4b35a5d2b4ee26bf79b8a92715dd200f3f9cc49

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

LOG: [clang] [unittest] Add a test for Generic_GCC::GCCVersion::Parse (#69078)

This adds actual test cases for all the cases that are listed in a code
comment in the implementation of this function; having such test
coverage eases doing further modifications to the function.

Added: 
clang/unittests/Driver/GCCVersionTest.cpp

Modified: 
clang/unittests/Driver/CMakeLists.txt

Removed: 




diff  --git a/clang/unittests/Driver/CMakeLists.txt 
b/clang/unittests/Driver/CMakeLists.txt
index e37c158d7137a88..752037f78fb147d 100644
--- a/clang/unittests/Driver/CMakeLists.txt
+++ b/clang/unittests/Driver/CMakeLists.txt
@@ -9,6 +9,7 @@ set(LLVM_LINK_COMPONENTS
 add_clang_unittest(ClangDriverTests
   DistroTest.cpp
   DXCModeTest.cpp
+  GCCVersionTest.cpp
   ToolChainTest.cpp
   ModuleCacheTest.cpp
   MultilibBuilderTest.cpp

diff  --git a/clang/unittests/Driver/GCCVersionTest.cpp 
b/clang/unittests/Driver/GCCVersionTest.cpp
new file mode 100644
index 000..9ae335bca77dc12
--- /dev/null
+++ b/clang/unittests/Driver/GCCVersionTest.cpp
@@ -0,0 +1,52 @@
+//===- unittests/Driver/GCCVersionTest.cpp --- GCCVersion parser tests 
===//
+//
+// 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
+//
+//===--===//
+//
+// Unit tests for Generic_GCC::GCCVersion
+//
+//===--===//
+
+#include "../../lib/Driver/ToolChains/Gnu.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace clang::driver;
+
+namespace {
+
+struct VersionParseTest {
+  std::string Text;
+
+  int Major, Minor, Patch;
+  std::string MajorStr, MinorStr, PatchSuffix;
+};
+
+const VersionParseTest TestCases[] = {
+{"5", 5, -1, -1, "5", "", ""},
+{"4.4", 4, 4, -1, "4", "4", ""},
+{"4.4-patched", 4, 4, -1, "4", "4", "-patched"},
+{"4.4.0", 4, 4, 0, "4", "4", ""},
+{"4.4.x", 4, 4, -1, "4", "4", ""},
+{"4.4.2-rc4", 4, 4, 2, "4", "4", "-rc4"},
+{"4.4.x-patched", 4, 4, -1, "4", "4", ""},
+{"not-a-version", -1, -1, -1, "", "", ""},
+};
+
+TEST(GCCVersionTest, Parse) {
+  for (const auto &TC : TestCases) {
+auto V = toolchains::Generic_GCC::GCCVersion::Parse(TC.Text);
+EXPECT_EQ(V.Text, TC.Text);
+EXPECT_EQ(V.Major, TC.Major);
+EXPECT_EQ(V.Minor, TC.Minor);
+EXPECT_EQ(V.Patch, TC.Patch);
+EXPECT_EQ(V.MajorStr, TC.MajorStr);
+EXPECT_EQ(V.MinorStr, TC.MinorStr);
+EXPECT_EQ(V.PatchSuffix, TC.PatchSuffix);
+  }
+}
+
+} // end anonymous namespace



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


[clang] [clang] [unittest] Add a test for Generic_GCC::GCCVersion::Parse (PR #69078)

2023-10-18 Thread Martin Storsjö via cfe-commits

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


[clang] [clang] [Gnu] Improve GCCVersion parsing to match versions such as "10-win32" (PR #69079)

2023-10-18 Thread Martin Storsjö via cfe-commits

https://github.com/mstorsjo updated 
https://github.com/llvm/llvm-project/pull/69079

From 468befbb3eeaa0a23b001141976108157608e11d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 
Date: Sat, 14 Oct 2023 00:55:18 +0300
Subject: [PATCH] [clang] [Gnu] Improve GCCVersion parsing to match versions
 such as "10-win32"

In earlier GCC versions, the Debian/Ubuntu provided mingw toolchains
were packaged in /usr/lib/gcc/ with version strings such
as "5.3-win32", which were matched and found since
6afcd64eb65fca233a7b173f88cffb2c2c9c114c. However in recent versions,
they have stopped including the minor version number and only
have version strings such as "10-win32" and "10-posix".

Generalize the parsing code to tolerate the patch suffix to be
present on a version number with only a major number.

Refactor the string parsing code to highlight the overall structure
of the parsing. This implementation should yield the same result
as before, except for when there's only one segment and it has
trailing, non-number contents.

This allows Clang to find the GCC libraries and headers in
Debian/Ubuntu provided MinGW cross compilers.
---
 clang/lib/Driver/ToolChains/Gnu.cpp   | 82 +++
 clang/unittests/Driver/GCCVersionTest.cpp |  1 +
 2 files changed, 55 insertions(+), 28 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index cdd911af9a73361..e6f94836c4110a1 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2007,45 +2007,71 @@ Generic_GCC::GCCVersion 
Generic_GCC::GCCVersion::Parse(StringRef VersionText) {
   std::pair First = VersionText.split('.');
   std::pair Second = First.second.split('.');
 
-  GCCVersion GoodVersion = {VersionText.str(), -1, -1, -1, "", "", ""};
-  if (First.first.getAsInteger(10, GoodVersion.Major) || GoodVersion.Major < 0)
-return BadVersion;
-  GoodVersion.MajorStr = First.first.str();
-  if (First.second.empty())
-return GoodVersion;
+  StringRef MajorStr = First.first;
   StringRef MinorStr = Second.first;
-  if (Second.second.empty()) {
-if (size_t EndNumber = MinorStr.find_first_not_of("0123456789")) {
-  GoodVersion.PatchSuffix = std::string(MinorStr.substr(EndNumber));
-  MinorStr = MinorStr.slice(0, EndNumber);
-}
-  }
-  if (MinorStr.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 0)
-return BadVersion;
-  GoodVersion.MinorStr = MinorStr.str();
+  StringRef PatchStr = Second.second;
 
-  // First look for a number prefix and parse that if present. Otherwise just
-  // stash the entire patch string in the suffix, and leave the number
-  // unspecified. This covers versions strings such as:
-  //   5(handled above)
+  GCCVersion GoodVersion = {VersionText.str(), -1, -1, -1, "", "", ""};
+
+  // Parse version number strings such as:
+  //   5
   //   4.4
   //   4.4-patched
   //   4.4.0
   //   4.4.x
   //   4.4.2-rc4
   //   4.4.x-patched
-  // And retains any patch number it finds.
-  StringRef PatchText = Second.second;
-  if (!PatchText.empty()) {
-if (size_t EndNumber = PatchText.find_first_not_of("0123456789")) {
-  // Try to parse the number and any suffix.
-  if (PatchText.slice(0, EndNumber).getAsInteger(10, GoodVersion.Patch) ||
-  GoodVersion.Patch < 0)
-return BadVersion;
-  GoodVersion.PatchSuffix = std::string(PatchText.substr(EndNumber));
+  //   10-win32
+  // Split on '.', handle 1, 2 or 3 such segments. Each segment must contain
+  // purely a number, except for the last one, where a non-number suffix
+  // is stored in PatchSuffix. The third segment is allowed to not contain
+  // a number at all.
+
+  auto HandleLastNumber = [&](StringRef Segment, int &Number,
+  std::string &OutStr) -> bool {
+// Look for a number prefix and parse that, and split out any trailing
+// string into GoodVersion.PatchSuffix.
+
+if (size_t EndNumber = Segment.find_first_not_of("0123456789")) {
+  StringRef NumberStr = Segment.slice(0, EndNumber);
+  if (NumberStr.getAsInteger(10, Number) || Number < 0)
+return false;
+  OutStr = NumberStr;
+  GoodVersion.PatchSuffix = Segment.substr(EndNumber);
+  return true;
 }
+return false;
+  };
+  auto HandleNumber = [](StringRef Segment, int &Number) -> bool {
+if (Segment.getAsInteger(10, Number) || Number < 0)
+  return false;
+return true;
+  };
+
+  if (MinorStr.empty()) {
+// If no minor string, major is the last segment
+if (!HandleLastNumber(MajorStr, GoodVersion.Major, GoodVersion.MajorStr))
+  return BadVersion;
+return GoodVersion;
+  } else {
+if (!HandleNumber(MajorStr, GoodVersion.Major))
+  return BadVersion;
+GoodVersion.MajorStr = MajorStr;
+  }
+  if (PatchStr.empty()) {
+// If no patch string, minor is the last segment
+if (!HandleLastNumber(MinorStr, GoodVersion.Minor, GoodVersion.MinorStr))
+ 

[clang] [clang] [Gnu] Improve GCCVersion parsing to match versions such as "10-win32" (PR #69079)

2023-10-18 Thread Martin Storsjö via cfe-commits

mstorsjo wrote:

The prerequisite to this PR has been merged now.

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


[clang] 675231e - [SVE ACLE] Allow default zero initialisation for svcount_t. (#69321)

2023-10-18 Thread via cfe-commits

Author: Paul Walker
Date: 2023-10-18T10:40:07+01:00
New Revision: 675231eb09ca37a8b76f748c0b73a1e26604ff20

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

LOG: [SVE ACLE] Allow default zero initialisation for svcount_t. (#69321)

This matches the behaviour of the other SVE ACLE types.

Added: 


Modified: 
clang/test/CodeGenCXX/aarch64-sve-vector-init.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/IR/Type.cpp
llvm/test/CodeGen/AArch64/sve-zeroinit.ll

Removed: 




diff  --git a/clang/test/CodeGenCXX/aarch64-sve-vector-init.cpp 
b/clang/test/CodeGenCXX/aarch64-sve-vector-init.cpp
index 2088e80acfc80f4..464275f164c2a54 100644
--- a/clang/test/CodeGenCXX/aarch64-sve-vector-init.cpp
+++ b/clang/test/CodeGenCXX/aarch64-sve-vector-init.cpp
@@ -55,6 +55,7 @@
 // CHECK-NEXT:[[B8:%.*]] = alloca , align 2
 // CHECK-NEXT:[[B8X2:%.*]] = alloca , align 2
 // CHECK-NEXT:[[B8X4:%.*]] = alloca , align 2
+// CHECK-NEXT:[[CNT:%.*]] = alloca target("aarch64.svcount"), align 2
 // CHECK-NEXT:store  zeroinitializer, ptr [[S8]], align 
16
 // CHECK-NEXT:store  zeroinitializer, ptr [[S16]], align 
16
 // CHECK-NEXT:store  zeroinitializer, ptr [[S32]], align 
16
@@ -106,6 +107,7 @@
 // CHECK-NEXT:store  zeroinitializer, ptr [[B8]], align 2
 // CHECK-NEXT:store  zeroinitializer, ptr [[B8X2]], 
align 2
 // CHECK-NEXT:store  zeroinitializer, ptr [[B8X4]], 
align 2
+// CHECK-NEXT:store target("aarch64.svcount") zeroinitializer, ptr 
[[CNT]], align 2
 // CHECK-NEXT:ret void
 //
 void test_locals(void) {
@@ -164,6 +166,8 @@ void test_locals(void) {
   __SVBool_t b8{};
   __clang_svboolx2_t b8x2{};
   __clang_svboolx4_t b8x4{};
+
+  __SVCount_t cnt{};
 }
 
 // CHECK-LABEL: define dso_local void @_Z12test_copy_s8u10__SVInt8_t
@@ -879,3 +883,17 @@ void test_copy_b8x2(__clang_svboolx2_t a) {
 void test_copy_b8x4(__clang_svboolx4_t a) {
   __clang_svboolx4_t b{a};
 }
+
+// CHECK-LABEL: define dso_local void @_Z13test_copy_cntu11__SVCount_t
+// CHECK-SAME: (target("aarch64.svcount") [[A:%.*]]) #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca target("aarch64.svcount"), align 2
+// CHECK-NEXT:[[B:%.*]] = alloca target("aarch64.svcount"), align 2
+// CHECK-NEXT:store target("aarch64.svcount") [[A]], ptr [[A_ADDR]], align 
2
+// CHECK-NEXT:[[TMP0:%.*]] = load target("aarch64.svcount"), ptr 
[[A_ADDR]], align 2
+// CHECK-NEXT:store target("aarch64.svcount") [[TMP0]], ptr [[B]], align 2
+// CHECK-NEXT:ret void
+//
+void test_copy_cnt(__SVCount_t a) {
+  __SVCount_t b{a};
+}

diff  --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp 
b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 4bb0ba6f083109b..eabc76334fae1f2 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -1738,6 +1738,12 @@ SDValue SelectionDAGBuilder::getValueImpl(const Value 
*V) {
 if (const auto *NC = dyn_cast(C))
   return getValue(NC->getGlobalValue());
 
+if (VT == MVT::aarch64svcount) {
+  assert(C->isNullValue() && "Can only zero this target type!");
+  return DAG.getNode(ISD::BITCAST, getCurSDLoc(), VT,
+ DAG.getConstant(0, getCurSDLoc(), MVT::nxv16i1));
+}
+
 VectorType *VecTy = cast(V->getType());
 
 // Now that we know the number and type of the elements, get that number of

diff  --git a/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp
index 97febcd99b4114f..006278d16484c1c 100644
--- a/llvm/lib/IR/Type.cpp
+++ b/llvm/lib/IR/Type.cpp
@@ -841,7 +841,8 @@ static TargetTypeInfo getTargetTypeInfo(const TargetExtType 
*Ty) {
 
   // Opaque types in the AArch64 name space.
   if (Name == "aarch64.svcount")
-return TargetTypeInfo(ScalableVectorType::get(Type::getInt1Ty(C), 16));
+return TargetTypeInfo(ScalableVectorType::get(Type::getInt1Ty(C), 16),
+  TargetExtType::HasZeroInit);
 
   return TargetTypeInfo(Type::getVoidTy(C));
 }

diff  --git a/llvm/test/CodeGen/AArch64/sve-zeroinit.ll 
b/llvm/test/CodeGen/AArch64/sve-zeroinit.ll
index c436bb7f822b7a3..eab39d0ef402526 100644
--- a/llvm/test/CodeGen/AArch64/sve-zeroinit.ll
+++ b/llvm/test/CodeGen/AArch64/sve-zeroinit.ll
@@ -86,3 +86,10 @@ define  @test_zeroinit_16xi1() {
 ; CHECK-NEXT:  ret
   ret  zeroinitializer
 }
+
+define target("aarch64.svcount") @test_zeroinit_svcount() 
"target-features"="+sme2" {
+; CHECK-LABEL: test_zeroinit_svcount
+; CHECK:   pfalse p0.b
+; CHECK-NEXT:  ret
+  ret target("aarch64.svcount") zeroinitializer
+}



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

[clang] [SVE ACLE] Allow default zero initialisation for svcount_t. (PR #69321)

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

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


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-18 Thread Rainer Orth via cfe-commits


@@ -2,8 +2,9 @@
 ! invocation. These libraries are added on top of other standard runtime
 ! libraries that the Clang driver will include.
 
-! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
+! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX

rorth wrote:

Done: since I'd already touched almost half the instances, I changed them all 
for consistency.

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


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-18 Thread Rainer Orth via cfe-commits


@@ -21,12 +22,12 @@
 !   run on any other platform, such as Windows that use a .exe
 !   suffix. Clang's driver will try to resolve the path to the ld
 !   executable and may find the GNU linker from MinGW or Cygwin.
-! GNU-LABEL:  "{{.*}}ld{{(\.exe)?}}"
-! GNU-SAME: "[[object_file]]"
-! GNU-SAME: -lFortran_main
-! GNU-SAME: -lFortranRuntime
-! GNU-SAME: -lFortranDecimal
-! GNU-SAME: -lm
+! UNIX-LABEL:  "{{.*}}ld{{(\.exe)?}}"
+! UNIX-SAME: "[[object_file]]"
+! UNIX-SAME: -lFortran_main

rorth wrote:

Right: they fit nicely even with the double quotes.  To avoid swamping the 
patch with unrelated changes, I've only adjusted the `UNIX` case.

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


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-18 Thread Rainer Orth via cfe-commits

https://github.com/rorth updated https://github.com/llvm/llvm-project/pull/65644

>From 31bdd3477d9f54996b71584598bdd75f2cef31db Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Thu, 7 Sep 2023 19:19:32 +0200
Subject: [PATCH 1/3] [Driver] Link Flang runtime on Solaris

I noticed that `flang-new` cannot link Fortran executables on Solaris since
the runtime libs are missing.

This patch fixes this, following `Gnu.cpp`.  The `linker-flags.f90` testcase
is augmented to test for this.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.
---
 clang/lib/Driver/ToolChains/Solaris.cpp | 8 
 flang/test/Driver/linker-flags.f90  | 1 +
 2 files changed, 9 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 36fe12608eefc6c..252c71d3379eab4 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -223,6 +223,14 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
   CmdArgs.push_back("-lm");
 }
+// Additional linker set-up and flags for Fortran. This is required in 
order
+// to generate executables. As Fortran runtime depends on the C runtime,
+// these dependencies need to be listed before the C runtime below.
+if (D.IsFlangMode()) {
+  addFortranRuntimeLibraryPath(getToolChain(), Args, CmdArgs);
+  addFortranRuntimeLibs(getToolChain(), CmdArgs);
+  CmdArgs.push_back("-lm");
+}
 if (Args.hasArg(options::OPT_fstack_protector) ||
 Args.hasArg(options::OPT_fstack_protector_strong) ||
 Args.hasArg(options::OPT_fstack_protector_all)) {
diff --git a/flang/test/Driver/linker-flags.f90 
b/flang/test/Driver/linker-flags.f90
index 09b8a224df13828..717dcc7775e2126 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,MINGW
 
 ! NOTE: Clang's driver library, clangDriver, usually adds 'libcmt' and

>From bf1b865045ed4f484f24746aa18405d93e760979 Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Tue, 17 Oct 2023 20:43:23 +0200
Subject: [PATCH 2/3] Rename `GNU` label to `UNIX` to better match use.

---
 flang/test/Driver/linker-flags.f90 | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/flang/test/Driver/linker-flags.f90 
b/flang/test/Driver/linker-flags.f90
index 717dcc7775e2126..fd61825eb4023a5 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -2,9 +2,9 @@
 ! invocation. These libraries are added on top of other standard runtime
 ! libraries that the Clang driver will include.
 
-! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
+! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
-! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX
 ! RUN: %flang -### -target x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,MINGW
 
 ! NOTE: Clang's driver library, clangDriver, usually adds 'libcmt' and
@@ -22,12 +22,12 @@
 !   run on any other platform, such as Windows that use a .exe
 !   suffix. Clang's driver will try to resolve the path to the ld
 !   executable and may find the GNU linker from MinGW or Cygwin.
-! GNU-LABEL:  "{{.*}}ld{{(\.exe)?}}"
-! GNU-SAME: "[[object_file]]"
-! GNU-SAME: -lFortran_main
-! GNU-SAME: -lFortranRuntime
-! GNU-SAME: -lFortranDecimal
-! GNU-SAME: -lm
+! UNIX-LABEL:  "{{.*}}ld{{(\.exe)?}}"
+! UNIX-SAME: "[[object_file]]"
+! UNIX-SAME: -lFortran_main
+! UNIX-SAME: -lFortranRuntime
+! UNIX-SAME: -lFortranDecimal
+! UNIX-SAME: -lm
 
 ! DARWIN-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! DARWIN-SAME: "[[object_file]]"

>From 5e7ca991bd8b87b754e982d9836460dc0f31e59f Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Wed, 18 Oct 2023 12:01:15 +0200
Subject: [PATCH 3/3] Use `--target=`.  Join `-l` lines for `UNIX` case.

---
 flang/test/Driver/linker-flags.f90 | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/flang/test/Driver/linker-flags.f90 
b/flang/te

[clang] [AMDGPU] Fix image intrinsic optimizer on loads from different resources (PR #69355)

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

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


[clang-tools-extra] [AMDGPU] Fix image intrinsic optimizer on loads from different resources (PR #69355)

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

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


[PATCH] D123235: [OpenMP] atomic compare fail : Parser & AST support

2023-10-18 Thread Sunil K via Phabricator via cfe-commits
koops updated this revision to Diff 557749.
koops added a comment.

Removed the tail-allocation.
Other changes suggested in the previous review.


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

https://reviews.llvm.org/D123235

Files:
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/atomic_ast_print.cpp
  clang/test/OpenMP/atomic_messages.cpp
  clang/tools/libclang/CIndex.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -209,6 +209,7 @@
 def OMPC_Update : Clause<"update"> { let clangClass = "OMPUpdateClause"; }
 def OMPC_Capture : Clause<"capture"> { let clangClass = "OMPCaptureClause"; }
 def OMPC_Compare : Clause<"compare"> { let clangClass = "OMPCompareClause"; }
+def OMPC_Fail : Clause<"fail"> { let clangClass = "OMPFailClause"; }
 def OMPC_SeqCst : Clause<"seq_cst"> { let clangClass = "OMPSeqCstClause"; }
 def OMPC_AcqRel : Clause<"acq_rel"> { let clangClass = "OMPAcqRelClause"; }
 def OMPC_Acquire : Clause<"acquire"> { let clangClass = "OMPAcquireClause"; }
@@ -637,7 +638,8 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause
   ];
 }
 def OMP_Target : Directive<"target"> {
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -2167,6 +2167,7 @@
 CHECK_SIMPLE_CLAUSE(Doacross, OMPC_doacross)
 CHECK_SIMPLE_CLAUSE(OmpxAttribute, OMPC_ompx_attribute)
 CHECK_SIMPLE_CLAUSE(OmpxBare, OMPC_ompx_bare)
+CHECK_SIMPLE_CLAUSE(Fail, OMPC_fail)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
 CHECK_REQ_SCALAR_INT_CLAUSE(NumTasks, OMPC_num_tasks)
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2402,6 +2402,8 @@
 
 void OMPClauseEnqueue::VisitOMPCompareClause(const OMPCompareClause *) {}
 
+void OMPClauseEnqueue::VisitOMPFailClause(const OMPFailClause *) {}
+
 void OMPClauseEnqueue::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
 
 void OMPClauseEnqueue::VisitOMPAcqRelClause(const OMPAcqRelClause *) {}
Index: clang/test/OpenMP/atomic_messages.cpp
===
--- clang/test/OpenMP/atomic_messages.cpp
+++ clang/test/OpenMP/atomic_messages.cpp
@@ -958,6 +958,25 @@
 // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'capture' clause}}
 #pragma omp atomic compare compare capture capture
   { v = a; if (a > b) a = b; }
+// expected-error@+1 {{expected 'compare' clause with the 'fail' modifier}}
+#pragma omp atomic fail(seq_cst)
+  if(v == a) { v = a; }
+// expected-error@+2 {{expected '(' after 'fail'}}
+// expected-error@+1 {{expected a memory order clause}}
+#pragma omp atomic compare fail
+  if(v < a) { v = a; }
+// expected-error@+1 {{expected a memory order clause}}
+#pragma omp atomic compare fail(capture)
+  if(v < a) { v = a; }
+ // expected-error@+2 {{expected ')' after 'atomic compare fail'}}
+ // expected-warning@+1 {{extra tokens at the end of '#pragma omp atomic' are ignored}}
+#pragma omp atomic compare fail(seq_cst | acquire)
+  if(v < a) { v = a; }
+// expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'fail' clause}}
+#pragma omp atomic compare fail(relaxed) fail(seq_cst)
+  if(v < a) { v = a; }
+
+
 #endif
   // expected-note@+1 {{in instantiation of function template specialization 'mixed' requested here}}
   return mixed();
Index: clang/test/OpenMP/atomic_ast_print.cpp
===
--- clang/test/OpenMP/atomic_ast_print.cpp
+++ clang/test/OpenMP/atomic_ast_print.cpp
@@ -226,6 +226,16 @@
   { v = a; if (a < b) { a = b; } }
 #pragma omp atomic compare capture hint(6)
   { v = a == b; if (v) a = c; }
+#pragma omp atomic compare fail(acq_rel)
+  { if (a < c) { a = c; } }
+#pragma omp atomic compare fail(acquire)
+  { if (a < c) { a = c; } }
+#pragma omp atomic compare fail(release)
+  { if (a < c) { a = c; } }
+

[clang-tools-extra] [analyzer] Add std::variant checker (PR #66481)

2023-10-18 Thread Gábor Spaits via cfe-commits

spaits wrote:

@steakhal we have also run the checker on multiple open source projects (a few 
weeks ago) and it did not crash. (It did not have any findings. There were only 
two C++ 17 projects and they had retrieved value from std::variant at most 20 
times).

Could you please take another look at the commit and give feedback, when you'll 
have time for it?

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


[clang] [clang][Interp] Implement __builtin_bit_cast (PR #68288)

2023-10-18 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= 
Message-ID:
In-Reply-To: 


tbaederr wrote:

@AaronBallman This is still in a rough WIP state, but I've added support for 
bitcasts with bitfields involved, take a look at the tests if you have some 
time.

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


[clang-tools-extra] [include-cleaner] Handle symbols from system headers. (PR #66089)

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

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


[clang-tools-extra] [include-cleaner] Handle symbols from system headers. (PR #66089)

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


@@ -176,6 +180,104 @@ headersForSpecialSymbol(const Symbol &S, const 
SourceManager &SM,
   return std::nullopt;
 }
 
+// A hand-mainained list of include mappings for system headers.
+// The first element is the suffix of the physical file path for the system
+// header, the second element is the final verbatim header spelling.
+const std::pair IncludeMappings[] = {
+{"bits/types/struct_timeval.h", ""},
+{"bits/pthreadtypes.h", ""},
+{"bits/types/struct_iovec.h", ""},
+{"linux/limits.h", ""},
+{"bits/getopt_core.h", ""},
+{"asm-generic/socket.h", ""},
+{"bits/posix1_lim.h", ""},
+{"bits/time.h", "time.h"},
+{"bits/getopt_ext.h", ""},
+{"bits/types/sigset_t.h", ""},
+{"bits/types/siginfo_t.h", ""},
+{"bits/types/FILE.h", ""},
+{"asm/unistd_64.h", ""},
+{"bits/stat.h", ""},
+{"asm-generic/ioctls.h", ""},
+{"asm-generic/errno.h", ""},
+{"asm-generic/int-ll64.h", ""},
+{"bits/sigaction.h", ""},
+{"bits/types/struct_rusage.h", ""},
+{"sys/syscall.h", ""},
+{"linux/prctl.h", ""},
+{"sys/ucontext.h", ""},
+{"bits/types/clockid_t.h", ""},
+{"bits/types/mbstate_t.h", ""},
+{"bits/types/mbstate_t.h", ""},
+{"bits/types/struct_itimerspec.h", ""},
+{"bits/types/time_t.h", ""},
+{"bits/sockaddr.h", ""},
+};
+// The maximum number of path components in a key from SuffixHeaderMapping.
+// Used to minimize the number of lookups in suffix path mappings.
+constexpr int MaxSuffixComponents = 3;
+
+// A mapping for system headers based on a set of filename rules.
+class SystemIncludeMap {
+public:
+  static const SystemIncludeMap &get() {

kadircet wrote:

i think it's important that we also make these mappings different per language. 
most of them will likely be language independent, but at least libc extensions 
are likely to have different spellings for c vs c++.

moreover these fell more like private -> public mappings we perform via 
PragmaIncludes, so what about just moving them there? that way we can also 
initialize the mapping based on language options and also benefit all the other 
users of pragma includes with similar mappings?

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


[clang-tools-extra] [include-cleaner] Handle symbols from system headers. (PR #66089)

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

https://github.com/kadircet commented:

thanks a lot, and so sorry for taking so long on getting to this

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


[clang-tools-extra] [include-cleaner] Handle symbols from system headers. (PR #66089)

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


@@ -176,6 +180,104 @@ headersForSpecialSymbol(const Symbol &S, const 
SourceManager &SM,
   return std::nullopt;
 }
 
+// A hand-mainained list of include mappings for system headers.
+// The first element is the suffix of the physical file path for the system
+// header, the second element is the final verbatim header spelling.
+const std::pair IncludeMappings[] = {
+{"bits/types/struct_timeval.h", ""},
+{"bits/pthreadtypes.h", ""},
+{"bits/types/struct_iovec.h", ""},
+{"linux/limits.h", ""},
+{"bits/getopt_core.h", ""},
+{"asm-generic/socket.h", ""},
+{"bits/posix1_lim.h", ""},
+{"bits/time.h", "time.h"},
+{"bits/getopt_ext.h", ""},
+{"bits/types/sigset_t.h", ""},
+{"bits/types/siginfo_t.h", ""},
+{"bits/types/FILE.h", ""},
+{"asm/unistd_64.h", ""},
+{"bits/stat.h", ""},
+{"asm-generic/ioctls.h", ""},
+{"asm-generic/errno.h", ""},
+{"asm-generic/int-ll64.h", ""},
+{"bits/sigaction.h", ""},
+{"bits/types/struct_rusage.h", ""},
+{"sys/syscall.h", ""},
+{"linux/prctl.h", ""},
+{"sys/ucontext.h", ""},
+{"bits/types/clockid_t.h", ""},
+{"bits/types/mbstate_t.h", ""},
+{"bits/types/mbstate_t.h", ""},
+{"bits/types/struct_itimerspec.h", ""},
+{"bits/types/time_t.h", ""},
+{"bits/sockaddr.h", ""},
+};
+// The maximum number of path components in a key from SuffixHeaderMapping.
+// Used to minimize the number of lookups in suffix path mappings.
+constexpr int MaxSuffixComponents = 3;
+
+// A mapping for system headers based on a set of filename rules.
+class SystemIncludeMap {
+public:
+  static const SystemIncludeMap &get() {
+static SystemIncludeMap Instance;
+static const auto *SystemHeaderMap = [] {
+  const size_t Size = sizeof(IncludeMappings) / sizeof(IncludeMappings[0]);
+  auto *HeaderMap = new std::multimap();
+  for (size_t I = 0; I < Size; I++) {
+HeaderMap->insert(IncludeMappings[I]);
+  }
+  return HeaderMap;
+}();
+
+// // Check MaxSuffixComponents constant is correct.
+assert(llvm::all_of(*SystemHeaderMap, [](const auto &KeyAndValue) {
+  return std::distance(
+ llvm::sys::path::begin(KeyAndValue.first,
+llvm::sys::path::Style::posix),
+ llvm::sys::path::end(KeyAndValue.first)) <=
+ MaxSuffixComponents;
+}));
+// ... and precise.
+assert(llvm::any_of(*SystemHeaderMap, [](const auto &KeyAndValue) {
+  return std::distance(
+ llvm::sys::path::begin(KeyAndValue.first,
+llvm::sys::path::Style::posix),
+ llvm::sys::path::end(KeyAndValue.first)) ==
+ MaxSuffixComponents;
+}));
+
+Instance.SuffixHeaderMapping = SystemHeaderMap;

kadircet wrote:

you're modifying a global with every call here, in a non-thread safe way.

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


[clang-tools-extra] [include-cleaner] Handle symbols from system headers. (PR #66089)

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


@@ -176,6 +180,104 @@ headersForSpecialSymbol(const Symbol &S, const 
SourceManager &SM,
   return std::nullopt;
 }
 
+// A hand-mainained list of include mappings for system headers.
+// The first element is the suffix of the physical file path for the system
+// header, the second element is the final verbatim header spelling.
+const std::pair IncludeMappings[] = {
+{"bits/types/struct_timeval.h", ""},
+{"bits/pthreadtypes.h", ""},
+{"bits/types/struct_iovec.h", ""},
+{"linux/limits.h", ""},
+{"bits/getopt_core.h", ""},
+{"asm-generic/socket.h", ""},
+{"bits/posix1_lim.h", ""},
+{"bits/time.h", "time.h"},
+{"bits/getopt_ext.h", ""},
+{"bits/types/sigset_t.h", ""},
+{"bits/types/siginfo_t.h", ""},
+{"bits/types/FILE.h", ""},
+{"asm/unistd_64.h", ""},
+{"bits/stat.h", ""},
+{"asm-generic/ioctls.h", ""},
+{"asm-generic/errno.h", ""},
+{"asm-generic/int-ll64.h", ""},
+{"bits/sigaction.h", ""},
+{"bits/types/struct_rusage.h", ""},
+{"sys/syscall.h", ""},
+{"linux/prctl.h", ""},
+{"sys/ucontext.h", ""},
+{"bits/types/clockid_t.h", ""},
+{"bits/types/mbstate_t.h", ""},
+{"bits/types/mbstate_t.h", ""},
+{"bits/types/struct_itimerspec.h", ""},
+{"bits/types/time_t.h", ""},
+{"bits/sockaddr.h", ""},
+};
+// The maximum number of path components in a key from SuffixHeaderMapping.
+// Used to minimize the number of lookups in suffix path mappings.
+constexpr int MaxSuffixComponents = 3;
+
+// A mapping for system headers based on a set of filename rules.
+class SystemIncludeMap {
+public:
+  static const SystemIncludeMap &get() {
+static SystemIncludeMap Instance;
+static const auto *SystemHeaderMap = [] {
+  const size_t Size = sizeof(IncludeMappings) / sizeof(IncludeMappings[0]);
+  auto *HeaderMap = new std::multimap();
+  for (size_t I = 0; I < Size; I++) {
+HeaderMap->insert(IncludeMappings[I]);
+  }
+  return HeaderMap;
+}();
+
+// // Check MaxSuffixComponents constant is correct.
+assert(llvm::all_of(*SystemHeaderMap, [](const auto &KeyAndValue) {
+  return std::distance(
+ llvm::sys::path::begin(KeyAndValue.first,
+llvm::sys::path::Style::posix),
+ llvm::sys::path::end(KeyAndValue.first)) <=
+ MaxSuffixComponents;
+}));
+// ... and precise.
+assert(llvm::any_of(*SystemHeaderMap, [](const auto &KeyAndValue) {
+  return std::distance(
+ llvm::sys::path::begin(KeyAndValue.first,
+llvm::sys::path::Style::posix),
+ llvm::sys::path::end(KeyAndValue.first)) ==
+ MaxSuffixComponents;
+}));
+
+Instance.SuffixHeaderMapping = SystemHeaderMap;
+return Instance;
+  }
+
+  // Returns the overridden verbatim spellings for HeaderPath that can be
+  // directly included.
+  llvm::SmallVector
+  mapHeader(llvm::StringRef HeaderPath) const {

kadircet wrote:

what about making this one static instead and getting rid of the extra 
singleton interface?

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


[clang-tools-extra] [include-cleaner] Handle symbols from system headers. (PR #66089)

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


@@ -176,6 +180,104 @@ headersForSpecialSymbol(const Symbol &S, const 
SourceManager &SM,
   return std::nullopt;
 }
 
+// A hand-mainained list of include mappings for system headers.
+// The first element is the suffix of the physical file path for the system
+// header, the second element is the final verbatim header spelling.
+const std::pair IncludeMappings[] = {
+{"bits/types/struct_timeval.h", ""},

kadircet wrote:

what about extracting these into a `SystemHeaderSuffixes.inc` with entries like 
`SYSTEM_HEADER_DETAIL(bits/types/struct_timeval.h, )`. that way we 
can have an easy way to inject more mappings going forward for other libraries 
in the future.

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


[clang-tools-extra] [include-cleaner] Handle symbols from system headers. (PR #66089)

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


@@ -176,6 +180,104 @@ headersForSpecialSymbol(const Symbol &S, const 
SourceManager &SM,
   return std::nullopt;
 }
 
+// A hand-mainained list of include mappings for system headers.
+// The first element is the suffix of the physical file path for the system
+// header, the second element is the final verbatim header spelling.
+const std::pair IncludeMappings[] = {

kadircet wrote:

we discussed offline that this list is mostly for demonstration purposes, but 
wanted to remind it once again. we probably want to start with at least what we 
have in clangd, right?

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


[clang-tools-extra] [include-cleaner] Handle symbols from system headers. (PR #66089)

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


@@ -176,6 +180,104 @@ headersForSpecialSymbol(const Symbol &S, const 
SourceManager &SM,
   return std::nullopt;
 }
 
+// A hand-mainained list of include mappings for system headers.
+// The first element is the suffix of the physical file path for the system
+// header, the second element is the final verbatim header spelling.
+const std::pair IncludeMappings[] = {
+{"bits/types/struct_timeval.h", ""},
+{"bits/pthreadtypes.h", ""},
+{"bits/types/struct_iovec.h", ""},
+{"linux/limits.h", ""},
+{"bits/getopt_core.h", ""},
+{"asm-generic/socket.h", ""},
+{"bits/posix1_lim.h", ""},
+{"bits/time.h", "time.h"},
+{"bits/getopt_ext.h", ""},
+{"bits/types/sigset_t.h", ""},
+{"bits/types/siginfo_t.h", ""},
+{"bits/types/FILE.h", ""},
+{"asm/unistd_64.h", ""},
+{"bits/stat.h", ""},
+{"asm-generic/ioctls.h", ""},
+{"asm-generic/errno.h", ""},
+{"asm-generic/int-ll64.h", ""},
+{"bits/sigaction.h", ""},
+{"bits/types/struct_rusage.h", ""},
+{"sys/syscall.h", ""},
+{"linux/prctl.h", ""},
+{"sys/ucontext.h", ""},
+{"bits/types/clockid_t.h", ""},
+{"bits/types/mbstate_t.h", ""},
+{"bits/types/mbstate_t.h", ""},
+{"bits/types/struct_itimerspec.h", ""},
+{"bits/types/time_t.h", ""},
+{"bits/sockaddr.h", ""},
+};
+// The maximum number of path components in a key from SuffixHeaderMapping.
+// Used to minimize the number of lookups in suffix path mappings.
+constexpr int MaxSuffixComponents = 3;
+
+// A mapping for system headers based on a set of filename rules.
+class SystemIncludeMap {
+public:
+  static const SystemIncludeMap &get() {
+static SystemIncludeMap Instance;
+static const auto *SystemHeaderMap = [] {
+  const size_t Size = sizeof(IncludeMappings) / sizeof(IncludeMappings[0]);
+  auto *HeaderMap = new std::multimap();
+  for (size_t I = 0; I < Size; I++) {
+HeaderMap->insert(IncludeMappings[I]);
+  }
+  return HeaderMap;
+}();
+
+// // Check MaxSuffixComponents constant is correct.
+assert(llvm::all_of(*SystemHeaderMap, [](const auto &KeyAndValue) {
+  return std::distance(
+ llvm::sys::path::begin(KeyAndValue.first,
+llvm::sys::path::Style::posix),
+ llvm::sys::path::end(KeyAndValue.first)) <=
+ MaxSuffixComponents;
+}));
+// ... and precise.
+assert(llvm::any_of(*SystemHeaderMap, [](const auto &KeyAndValue) {
+  return std::distance(
+ llvm::sys::path::begin(KeyAndValue.first,
+llvm::sys::path::Style::posix),
+ llvm::sys::path::end(KeyAndValue.first)) ==
+ MaxSuffixComponents;
+}));

kadircet wrote:

i think we can move these assertions into the lambda, no need to perform them 
every time we access the singleton

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


[clang-tools-extra] [include-cleaner] Handle symbols from system headers. (PR #66089)

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


@@ -188,6 +290,20 @@ llvm::SmallVector> findHeaders(const 
SymbolLocation &Loc,
 OptionalFileEntryRef FE = SM.getFileEntryRefForID(FID);
 if (!FE)
   return {};
+
+if (SrcMgr::isSystem(
+SM.getSLocEntry(FID).getFile().getFileCharacteristic())) {
+  if (auto MappingHeader = 
SystemIncludeMap::get().mapHeader(FE->getName());
+  !MappingHeader.empty()) {
+for (auto &Header : MappingHeader)
+  Results.emplace_back(Header, Hints::PublicHeader);
+assert(!Results.empty());
+Results.front().Hint |= Hints::PreferredHeader;
+// FIXME: should we include the original header as well?

kadircet wrote:

yes, i think we should treat these similar to IWYU private -> public mappings.

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


[clang-tools-extra] [include-cleaner] Handle symbols from system headers. (PR #66089)

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


@@ -188,6 +290,20 @@ llvm::SmallVector> findHeaders(const 
SymbolLocation &Loc,
 OptionalFileEntryRef FE = SM.getFileEntryRefForID(FID);
 if (!FE)
   return {};
+
+if (SrcMgr::isSystem(

kadircet wrote:

i am afraid this check might be overly strict, maybe drop this initially and 
see if we have too many false-positives?

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


[clang-tools-extra] [include-cleaner] Handle symbols from system headers. (PR #66089)

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


@@ -176,6 +180,104 @@ headersForSpecialSymbol(const Symbol &S, const 
SourceManager &SM,
   return std::nullopt;
 }
 
+// A hand-mainained list of include mappings for system headers.
+// The first element is the suffix of the physical file path for the system
+// header, the second element is the final verbatim header spelling.
+const std::pair IncludeMappings[] = {
+{"bits/types/struct_timeval.h", ""},
+{"bits/pthreadtypes.h", ""},
+{"bits/types/struct_iovec.h", ""},
+{"linux/limits.h", ""},
+{"bits/getopt_core.h", ""},
+{"asm-generic/socket.h", ""},
+{"bits/posix1_lim.h", ""},
+{"bits/time.h", "time.h"},
+{"bits/getopt_ext.h", ""},
+{"bits/types/sigset_t.h", ""},
+{"bits/types/siginfo_t.h", ""},
+{"bits/types/FILE.h", ""},
+{"asm/unistd_64.h", ""},
+{"bits/stat.h", ""},
+{"asm-generic/ioctls.h", ""},
+{"asm-generic/errno.h", ""},
+{"asm-generic/int-ll64.h", ""},
+{"bits/sigaction.h", ""},
+{"bits/types/struct_rusage.h", ""},
+{"sys/syscall.h", ""},
+{"linux/prctl.h", ""},
+{"sys/ucontext.h", ""},
+{"bits/types/clockid_t.h", ""},
+{"bits/types/mbstate_t.h", ""},
+{"bits/types/mbstate_t.h", ""},
+{"bits/types/struct_itimerspec.h", ""},
+{"bits/types/time_t.h", ""},
+{"bits/sockaddr.h", ""},
+};
+// The maximum number of path components in a key from SuffixHeaderMapping.
+// Used to minimize the number of lookups in suffix path mappings.
+constexpr int MaxSuffixComponents = 3;
+
+// A mapping for system headers based on a set of filename rules.
+class SystemIncludeMap {
+public:
+  static const SystemIncludeMap &get() {
+static SystemIncludeMap Instance;
+static const auto *SystemHeaderMap = [] {
+  const size_t Size = sizeof(IncludeMappings) / sizeof(IncludeMappings[0]);
+  auto *HeaderMap = new std::multimap();

kadircet wrote:

why do we have a multipmap here instead of a just StringMap? do we expect to 
have suffixes that map to multiple umbrella headers?

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


[clang-tools-extra] [include-cleaner] Handle symbols from system headers. (PR #66089)

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


@@ -176,6 +180,104 @@ headersForSpecialSymbol(const Symbol &S, const 
SourceManager &SM,
   return std::nullopt;
 }
 
+// A hand-mainained list of include mappings for system headers.
+// The first element is the suffix of the physical file path for the system
+// header, the second element is the final verbatim header spelling.
+const std::pair IncludeMappings[] = {
+{"bits/types/struct_timeval.h", ""},
+{"bits/pthreadtypes.h", ""},
+{"bits/types/struct_iovec.h", ""},
+{"linux/limits.h", ""},
+{"bits/getopt_core.h", ""},
+{"asm-generic/socket.h", ""},
+{"bits/posix1_lim.h", ""},
+{"bits/time.h", "time.h"},
+{"bits/getopt_ext.h", ""},
+{"bits/types/sigset_t.h", ""},
+{"bits/types/siginfo_t.h", ""},
+{"bits/types/FILE.h", ""},
+{"asm/unistd_64.h", ""},
+{"bits/stat.h", ""},
+{"asm-generic/ioctls.h", ""},
+{"asm-generic/errno.h", ""},
+{"asm-generic/int-ll64.h", ""},
+{"bits/sigaction.h", ""},
+{"bits/types/struct_rusage.h", ""},
+{"sys/syscall.h", ""},
+{"linux/prctl.h", ""},
+{"sys/ucontext.h", ""},
+{"bits/types/clockid_t.h", ""},
+{"bits/types/mbstate_t.h", ""},
+{"bits/types/mbstate_t.h", ""},
+{"bits/types/struct_itimerspec.h", ""},
+{"bits/types/time_t.h", ""},
+{"bits/sockaddr.h", ""},
+};
+// The maximum number of path components in a key from SuffixHeaderMapping.
+// Used to minimize the number of lookups in suffix path mappings.
+constexpr int MaxSuffixComponents = 3;
+
+// A mapping for system headers based on a set of filename rules.
+class SystemIncludeMap {
+public:
+  static const SystemIncludeMap &get() {
+static SystemIncludeMap Instance;
+static const auto *SystemHeaderMap = [] {
+  const size_t Size = sizeof(IncludeMappings) / sizeof(IncludeMappings[0]);
+  auto *HeaderMap = new std::multimap();
+  for (size_t I = 0; I < Size; I++) {
+HeaderMap->insert(IncludeMappings[I]);
+  }
+  return HeaderMap;
+}();
+
+// // Check MaxSuffixComponents constant is correct.
+assert(llvm::all_of(*SystemHeaderMap, [](const auto &KeyAndValue) {
+  return std::distance(
+ llvm::sys::path::begin(KeyAndValue.first,
+llvm::sys::path::Style::posix),
+ llvm::sys::path::end(KeyAndValue.first)) <=
+ MaxSuffixComponents;
+}));
+// ... and precise.
+assert(llvm::any_of(*SystemHeaderMap, [](const auto &KeyAndValue) {
+  return std::distance(
+ llvm::sys::path::begin(KeyAndValue.first,
+llvm::sys::path::Style::posix),
+ llvm::sys::path::end(KeyAndValue.first)) ==
+ MaxSuffixComponents;
+}));
+
+Instance.SuffixHeaderMapping = SystemHeaderMap;
+return Instance;
+  }
+
+  // Returns the overridden verbatim spellings for HeaderPath that can be
+  // directly included.
+  llvm::SmallVector
+  mapHeader(llvm::StringRef HeaderPath) const {
+if (!SuffixHeaderMapping)
+  return {};
+
+int Components = 1;
+llvm::SmallVector Headers;
+for (auto It = llvm::sys::path::rbegin(HeaderPath),
+  End = llvm::sys::path::rend(HeaderPath);
+ It != End && Components <= MaxSuffixComponents; ++It, ++Components) {
+  auto SubPath = HeaderPath.substr(It->data() - HeaderPath.begin());
+  auto FoundRange = SuffixHeaderMapping->equal_range(SubPath);
+  for (auto It = FoundRange.first; It != FoundRange.second; ++It)
+Headers.push_back(It->second);
+}
+return Headers;;

kadircet wrote:

extra `;`

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


[clang] [NVPTX] Fixed some wmma store builtins that had non-const src param. (PR #69354)

2023-10-18 Thread via cfe-commits

JackAKirk wrote:

cc @Artem-B 

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


[PATCH] D123235: [OpenMP] atomic compare fail : Parser & AST support

2023-10-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/AST/ASTNodeTraverser.h:217-220
+if (const auto *OMPC = dyn_cast(C)) {
+  Visit(OMPC);
+  return;
+}

Why do you need special logic here?



Comment at: clang/include/clang/AST/OpenMPClause.h:2320
+
+  OMPClause *MemoryOrderClause = nullptr;
+  OpenMPClauseKind FailParameter = llvm::omp::OMPC_unknown;

That's not the best decision, better to make this kind of clause a base class 
for these new class.



Comment at: clang/include/clang/AST/OpenMPClause.h:2373
+SourceLocation StartLoc, SourceLocation LParenLoc,
+   SourceLocation EndLoc)
+  : OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc), 
ArgumentLoc(ArgumentLoc), LParenLoc(LParenLoc)  {

Formatting



Comment at: clang/include/clang/AST/OpenMPClause.h:2429
+
+  const OMPClause *const_getMemoryOrderClause() const {
+return static_cast(MemoryOrderClause);

No need for const_ prefix in the name


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

https://reviews.llvm.org/D123235

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


[PATCH] D151439: [Clang][SVE2.1] Add builtins for 2-way svdot (vectors, indexed)

2023-10-18 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto updated this revision to Diff 557751.
CarolineConcatto added a comment.
Herald added a subscriber: sunshaoce.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151439

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

Index: clang/test/Sema/aarch64-sve2p1-intrinsics/acle_sve2p1_imm.cpp
===
--- clang/test/Sema/aarch64-sve2p1-intrinsics/acle_sve2p1_imm.cpp
+++ clang/test/Sema/aarch64-sve2p1-intrinsics/acle_sve2p1_imm.cpp
@@ -107,3 +107,12 @@
   svcntp_c14(c, 3); // expected-error {{argument should be a multiple of 2}}
 }
 
+void test_svdot_lane_2way(svint32_t s32, svuint32_t u32, svint16_t s16, svuint16_t u16,
+  svfloat32_t f32, svfloat16_t f16) {
+  svdot_lane_s32_s16_s16(s32, s16, s16, 1); // expected-error {{argument value 4 is outside the valid range [0, 3]}}
+  svdot_lane_u32_u16_u16(u32, u16, u16, 1); // expected-error {{argument value 4 is outside the valid range [0, 3]}}
+  svdot_lane_f32_f16_f16(f32, f16, f16, 1); // expected-error {{argument value 4 is outside the valid range [0, 3]}}
+  svdot_lane_s32_s16_s16(s32, s16, s16, 4); // expected-error {{argument value 4 is outside the valid range [0, 3]}}
+  svdot_lane_u32_u16_u16(u32, u16, u16, 4); // expected-error {{argument value 4 is outside the valid range [0, 3]}}
+  svdot_lane_f32_f16_f16(f32, f16, f16, 4); // expected-error {{argument value 4 is outside the valid range [0, 3]}}
+}
Index: clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_dot.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_dot.c
@@ -0,0 +1,107 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,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 -p mem2reg,instcombine,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 -p mem2reg,instcombine,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 -p mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3) A1##A2##A3
+#endif
+
+// CHECK-LABEL: @test_svdot_s32_x2(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.sdot.x2.nxv4i32( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
+// CHECK-NEXT:ret  [[TMP0]]
+//
+// CPP-CHECK-LABEL: @_Z17test_svdot_s32_x2u11__SVInt32_tu11__SVInt16_tu11__SVInt16_t(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.sdot.x2.nxv4i32( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
+// CPP-CHECK-NEXT:ret  [[TMP0]]
+//
+svint32_t test_svdot_s32_x2(svint32_t op1, svint16_t op2, svint16_t op3)
+{
+  return SVE_ACLE_FUNC(svdot,_s32_s16_s16,)(op1, op2, op3);
+}
+
+// CHECK-LABEL: @test_svdot_u32_x2(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.udot.x2.nxv4i32( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
+// CHECK-NEXT:ret  [[TMP0]]
+//
+// CPP-CHECK-LABEL: @_Z17test_svdot_u32_x2u12__SVUint32_tu12__SVUint16_tu12__SVUint16_t(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.udot.x2.nxv4i32( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
+// CPP-CHECK-NEXT:ret  [[TMP0]]
+//
+svuint32_t test_svdot_u32_x2(svuint32_t op1, svuint16_t op2, svuint16_t op3)
+{
+  return SVE_ACLE_FUNC(svdot,_u32_u16_u16,)(op1, op2, op3);
+}
+
+// CHECK-LABEL: @test_svdot_f32_x2(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.fdot.x2.nxv4f32( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
+// CHECK-NEXT:ret  [[TMP0]]
+//
+// CPP-CHECK-LABEL: @_Z17test_svdot_f32_x2u13__SVFloat32_tu13__SVFloat16_tu13__SVFloat16_t(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.fdot.x2.nxv4f32( [[OP1:%.*]

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

2023-10-18 Thread Dinar Temirbulatov via Phabricator via cfe-commits
dtemirbulatov accepted this revision.
dtemirbulatov added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151199

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


[PATCH] D151197: [Clang][SVE2p1] Add svpsel builtins

2023-10-18 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin accepted this revision.
kmclaughlin added a comment.
This revision is now accepted and ready to land.

Thank you for updating this @CarolineConcatto, LGTM




Comment at: clang/include/clang/Basic/arm_sve.td:1886
 
+
+

nit: extra whitespace


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151197

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


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

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

ams-cs wrote:

@Pierre-vh Can we undo this please? Just for now.

This broke the GCC build (which uses llvm-mc) because we still use v3 like 
@tob2 said. I don't know that anyone is using Fiji in production, but it's 
still a good proportion of what we have in our compiler test farm.

As far as I know, the last good ROCm for that device was 3.8 which doesn't 
support v4.

I appreciate that this isn't ideal; I'd like to remove that device too.

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


[PATCH] D151461: [Clang][SVE2.1] Add builtins and intrinsics for SVBFMLSLB/T

2023-10-18 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto updated this revision to Diff 557754.
CarolineConcatto added a comment.

-rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151461

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/include/clang/Basic/arm_sve_sme_incl.td
  clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_bfmlsl.c
  clang/utils/TableGen/SveEmitter.cpp
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/test/CodeGen/AArch64/sve2p1-intrinsics-bfmls.ll

Index: llvm/test/CodeGen/AArch64/sve2p1-intrinsics-bfmls.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2p1-intrinsics-bfmls.ll
@@ -0,0 +1,43 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sme2p1 -mattr=+b16b16 -verify-machineinstrs < %s | FileCheck %s
+
+define  @bfmlslb_f32( %zda,  %zn,  %zm) {
+; CHECK-LABEL: bfmlslb_f32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:bfmlslb z0.s, z1.h, z2.h
+; CHECK-NEXT:ret
+  %out = call  @llvm.aarch64.sve.bfmlslb( %zda,  %zn,  %zm)
+  ret  %out
+}
+
+define  @bfmlslt_f32( %zda,  %zn,  %zm) {
+; CHECK-LABEL: bfmlslt_f32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:bfmlslt z0.s, z1.h, z2.h
+; CHECK-NEXT:ret
+  %out = call  @llvm.aarch64.sve.bfmlslt( %zda,  %zn,  %zm)
+  ret  %out
+}
+
+define  @bfmlslb_lane_f32( %zda,  %zn,  %zm) {
+; CHECK-LABEL: bfmlslb_lane_f32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:bfmlslb z0.s, z1.h, z2.h[7]
+; CHECK-NEXT:ret
+  %out = call  @llvm.aarch64.sve.bfmlslb.lane( %zda,  %zn,  %zm, i32 7)
+  ret  %out
+}
+
+define  @bfmlslt_lane_f32( %zda,  %zn,  %zm) {
+; CHECK-LABEL: bfmlslt_lane_f32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:bfmlslt z0.s, z1.h, z2.h[7]
+; CHECK-NEXT:ret
+  %out = call  @llvm.aarch64.sve.bfmlslt.lane( %zda,  %zn,  %zm, i32 7)
+  ret  %out
+}
+
+declare  @llvm.aarch64.sve.bfmlslb(, , )
+declare  @llvm.aarch64.sve.bfmlslt(, , )
+declare  @llvm.aarch64.sve.bfmlslb.lane(, , , i32)
+declare  @llvm.aarch64.sve.bfmlslt.lane(, , , i32)
Index: llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
===
--- llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
@@ -3753,12 +3753,14 @@
 
 let Predicates = [HasSVE2p1_or_HasSME2] in {
 defm FCLAMP_ZZZ : sve2p1_fclamp<"fclamp", int_aarch64_sve_fclamp>;
+
 defm FDOT_ZZZ_S  : sve_float_dot<0b0, 0b0, ZPR32, ZPR16, "fdot", nxv8f16, int_aarch64_sve_fdot_x2>;
 defm FDOT_ZZZI_S : sve_float_dot_indexed<0b0, 0b00, ZPR16, ZPR3b16, "fdot", nxv8f16, int_aarch64_sve_fdot_lane_x2>;
-def BFMLSLB_ZZZ_S : sve2_fp_mla_long<0b110, "bfmlslb">;
-def BFMLSLT_ZZZ_S : sve2_fp_mla_long<0b111, "bfmlslt">;
-def BFMLSLB_ZZZI_S : sve2_fp_mla_long_by_indexed_elem<0b110, "bfmlslb">;
-def BFMLSLT_ZZZI_S : sve2_fp_mla_long_by_indexed_elem<0b111, "bfmlslt">;
+
+defm BFMLSLB_ZZZ_S : sve2_fp_mla_long<0b110, "bfmlslb", nxv4f32, nxv8bf16, int_aarch64_sve_bfmlslb>;
+defm BFMLSLT_ZZZ_S : sve2_fp_mla_long<0b111, "bfmlslt", nxv4f32, nxv8bf16, int_aarch64_sve_bfmlslt>;
+defm BFMLSLB_ZZZI_S : sve2_fp_mla_long_by_indexed_elem<0b110, "bfmlslb", nxv4f32, nxv8bf16, int_aarch64_sve_bfmlslb_lane>;
+defm BFMLSLT_ZZZI_S : sve2_fp_mla_long_by_indexed_elem<0b111, "bfmlslt", nxv4f32, nxv8bf16, int_aarch64_sve_bfmlslt_lane>;
 
 defm SDOT_ZZZ_HtoS  : sve2p1_two_way_dot_vv<"sdot", 0b0, int_aarch64_sve_sdot_x2>;
 defm UDOT_ZZZ_HtoS  : sve2p1_two_way_dot_vv<"udot", 0b1, int_aarch64_sve_udot_x2>;
Index: llvm/include/llvm/IR/IntrinsicsAArch64.td
===
--- llvm/include/llvm/IR/IntrinsicsAArch64.td
+++ llvm/include/llvm/IR/IntrinsicsAArch64.td
@@ -3011,6 +3011,16 @@
 [llvm_anyvector_ty, LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>],
 [IntrNoMem]>;
 
+  class SME2_BFMLS_Intrinsic
+: DefaultAttrsIntrinsic<[llvm_nxv4f32_ty],
+[llvm_nxv4f32_ty, llvm_nxv8bf16_ty, llvm_nxv8bf16_ty],
+[IntrNoMem]>;
+
+  class SME2_BFMLS_Lane_Intrinsic
+: DefaultAttrsIntrinsic<[llvm_nxv4f32_ty],
+[llvm_nxv4f32_ty, llvm_nxv8bf16_ty, llvm_nxv8bf16_ty, llvm_i32_ty],
+[IntrNoMem, ImmArg>]>;
+
   class SME2_ZA_ArrayVector_Read_VG2_Intrinsic
 : DefaultAttrsIntrinsic<[llvm_anyvector_ty, LLVMMatchType<0>],
 [llvm_i32_ty],
@@ -3214,6 +3224,12 @@
   def int_aarch64_sme_usmla_za32_lane_vg4x2 : SME2_Matrix_ArrayVector_VG2_Multi_Index_Intrinsic;
   def int_aarch64_sme_usmla_za32_lane_vg4x4 : SME2_Matrix_ArrayVector_VG4_Multi_Index_Intrinsic;
 
+  def int_aarch64_sve_bfmlslb : SME2_BFMLS_Intrinsic;
+  def int_aarch64_sve_bfmlslb_lane : SME2_BFMLS_Lane_Intrinsic;
+
+  def int_aa

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

2023-10-18 Thread Pierre van Houtryve via cfe-commits

Pierre-vh wrote:

I don't mind reverting, but do you have a timeline for removal of that device? 
v3 has been deprecated for a while, AFAIK.

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


[clang-tools-extra] [libc++] Add assertions for potential OOB reads in std::nth_element (PR #67023)

2023-10-18 Thread Daniel Kutenin via cfe-commits

https://github.com/danlark1 updated 
https://github.com/llvm/llvm-project/pull/67023

>From 059bbfab50592026ce2785c5f7d98eaf5c9f8bd6 Mon Sep 17 00:00:00 2001
From: Daniel Kutenin 
Date: Thu, 21 Sep 2023 14:55:11 +0100
Subject: [PATCH 1/7] Add bound checking in nth_element

---
 libcxx/include/__algorithm/nth_element.h | 28 +++-
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/libcxx/include/__algorithm/nth_element.h 
b/libcxx/include/__algorithm/nth_element.h
index dbacf58f9ecdbc4..37e43ab0db8ca4f 100644
--- a/libcxx/include/__algorithm/nth_element.h
+++ b/libcxx/include/__algorithm/nth_element.h
@@ -116,10 +116,18 @@ __nth_element(_RandomAccessIterator __first, 
_RandomAccessIterator __nth, _Rando
 return;
 }
 while (true) {
-while (!__comp(*__first, *__i))
+while (!__comp(*__first, *__i)) {
 ++__i;
-while (__comp(*__first, *--__j))
-;
+_LIBCPP_ASSERT_UNCATEGORIZED(
+__i != __last,
+"Would read out of bounds, does your comparator 
satisfy the strict-weak ordering requirement?");
+}
+do {
+_LIBCPP_ASSERT_UNCATEGORIZED(
+__j != __first,
+"Would read out of bounds, does your comparator 
satisfy the strict-weak ordering requirement?");
+--__j;
+} while (__comp(*__first, *__j));
 if (__i >= __j)
 break;
 _Ops::iter_swap(__i, __j);
@@ -146,11 +154,19 @@ __nth_element(_RandomAccessIterator __first, 
_RandomAccessIterator __nth, _Rando
 while (true)
 {
 // __m still guards upward moving __i
-while (__comp(*__i, *__m))
+while (__comp(*__i, *__m)) {
 ++__i;
+_LIBCPP_ASSERT_UNCATEGORIZED(
+__i != __last,
+"Would read out of bounds, does your comparator 
satisfy the strict-weak ordering requirement?");
+}
 // It is now known that a guard exists for downward moving __j
-while (!__comp(*--__j, *__m))
-;
+do {
+_LIBCPP_ASSERT_UNCATEGORIZED(
+__j != __first,
+"Would read out of bounds, does your comparator 
satisfy the strict-weak ordering requirement?");
+--__j;
+} while (!__comp(*__j, *__m));
 if (__i >= __j)
 break;
 _Ops::iter_swap(__i, __j);

>From 8e128c3ce6d8dc8afb94ba2465a2585fe3b8525a Mon Sep 17 00:00:00 2001
From: Daniel Kutenin 
Date: Thu, 21 Sep 2023 15:22:18 +0100
Subject: [PATCH 2/7] Update nth_element out of bound test

---
 .../assert.sort.invalid_comparator.pass.cpp   | 77 +++
 1 file changed, 61 insertions(+), 16 deletions(-)

diff --git 
a/libcxx/test/libcxx/algorithms/alg.sorting/assert.sort.invalid_comparator.pass.cpp
 
b/libcxx/test/libcxx/algorithms/alg.sorting/assert.sort.invalid_comparator.pass.cpp
index e5e417fe7bda2d4..b02ae2118ec5f47 100644
--- 
a/libcxx/test/libcxx/algorithms/alg.sorting/assert.sort.invalid_comparator.pass.cpp
+++ 
b/libcxx/test/libcxx/algorithms/alg.sorting/assert.sort.invalid_comparator.pass.cpp
@@ -50,27 +50,37 @@
 #include "bad_comparator_values.h"
 #include "check_assertion.h"
 
-void check_oob_sort_read() {
-std::map> comparison_results; // 
terrible for performance, but really convenient
-for (auto line : std::views::split(DATA, '\n') | 
std::views::filter([](auto const& line) { return !line.empty(); })) {
-auto values = std::views::split(line, ' ');
-auto it = values.begin();
-std::size_t left = std::stol(std::string((*it).data(), (*it).size()));
-it = std::next(it);
-std::size_t right = std::stol(std::string((*it).data(), (*it).size()));
-it = std::next(it);
-bool result = static_cast(std::stol(std::string((*it).data(), 
(*it).size(;
-comparison_results[left][right] = result;
-}
-auto predicate = [&](std::size_t* left, std::size_t* right) {
+class ComparisonResults {
+public:
+ComparisonResults(std::string_view data) {
+for (auto line : std::views::split(data, '\n') | 
std::views::filter([](auto const& line) { return !line.empty(); })) {
+auto values = std::views::split(line, ' ');
+auto it = values.begin();
+std::size_t left = std::stol(std::string((*it).data(), 
(*it).size()));
+it = std::next(it);
+std::size_t right = std::stol(std::string((*it).data(), 
(*it).size()));
+it = std::next(it);
+ 

[clang] [libc++] Add assertions for potential OOB reads in std::nth_element (PR #67023)

2023-10-18 Thread Daniel Kutenin via cfe-commits

https://github.com/danlark1 updated 
https://github.com/llvm/llvm-project/pull/67023

>From 059bbfab50592026ce2785c5f7d98eaf5c9f8bd6 Mon Sep 17 00:00:00 2001
From: Daniel Kutenin 
Date: Thu, 21 Sep 2023 14:55:11 +0100
Subject: [PATCH 1/7] Add bound checking in nth_element

---
 libcxx/include/__algorithm/nth_element.h | 28 +++-
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/libcxx/include/__algorithm/nth_element.h 
b/libcxx/include/__algorithm/nth_element.h
index dbacf58f9ecdbc4..37e43ab0db8ca4f 100644
--- a/libcxx/include/__algorithm/nth_element.h
+++ b/libcxx/include/__algorithm/nth_element.h
@@ -116,10 +116,18 @@ __nth_element(_RandomAccessIterator __first, 
_RandomAccessIterator __nth, _Rando
 return;
 }
 while (true) {
-while (!__comp(*__first, *__i))
+while (!__comp(*__first, *__i)) {
 ++__i;
-while (__comp(*__first, *--__j))
-;
+_LIBCPP_ASSERT_UNCATEGORIZED(
+__i != __last,
+"Would read out of bounds, does your comparator 
satisfy the strict-weak ordering requirement?");
+}
+do {
+_LIBCPP_ASSERT_UNCATEGORIZED(
+__j != __first,
+"Would read out of bounds, does your comparator 
satisfy the strict-weak ordering requirement?");
+--__j;
+} while (__comp(*__first, *__j));
 if (__i >= __j)
 break;
 _Ops::iter_swap(__i, __j);
@@ -146,11 +154,19 @@ __nth_element(_RandomAccessIterator __first, 
_RandomAccessIterator __nth, _Rando
 while (true)
 {
 // __m still guards upward moving __i
-while (__comp(*__i, *__m))
+while (__comp(*__i, *__m)) {
 ++__i;
+_LIBCPP_ASSERT_UNCATEGORIZED(
+__i != __last,
+"Would read out of bounds, does your comparator 
satisfy the strict-weak ordering requirement?");
+}
 // It is now known that a guard exists for downward moving __j
-while (!__comp(*--__j, *__m))
-;
+do {
+_LIBCPP_ASSERT_UNCATEGORIZED(
+__j != __first,
+"Would read out of bounds, does your comparator 
satisfy the strict-weak ordering requirement?");
+--__j;
+} while (!__comp(*__j, *__m));
 if (__i >= __j)
 break;
 _Ops::iter_swap(__i, __j);

>From 8e128c3ce6d8dc8afb94ba2465a2585fe3b8525a Mon Sep 17 00:00:00 2001
From: Daniel Kutenin 
Date: Thu, 21 Sep 2023 15:22:18 +0100
Subject: [PATCH 2/7] Update nth_element out of bound test

---
 .../assert.sort.invalid_comparator.pass.cpp   | 77 +++
 1 file changed, 61 insertions(+), 16 deletions(-)

diff --git 
a/libcxx/test/libcxx/algorithms/alg.sorting/assert.sort.invalid_comparator.pass.cpp
 
b/libcxx/test/libcxx/algorithms/alg.sorting/assert.sort.invalid_comparator.pass.cpp
index e5e417fe7bda2d4..b02ae2118ec5f47 100644
--- 
a/libcxx/test/libcxx/algorithms/alg.sorting/assert.sort.invalid_comparator.pass.cpp
+++ 
b/libcxx/test/libcxx/algorithms/alg.sorting/assert.sort.invalid_comparator.pass.cpp
@@ -50,27 +50,37 @@
 #include "bad_comparator_values.h"
 #include "check_assertion.h"
 
-void check_oob_sort_read() {
-std::map> comparison_results; // 
terrible for performance, but really convenient
-for (auto line : std::views::split(DATA, '\n') | 
std::views::filter([](auto const& line) { return !line.empty(); })) {
-auto values = std::views::split(line, ' ');
-auto it = values.begin();
-std::size_t left = std::stol(std::string((*it).data(), (*it).size()));
-it = std::next(it);
-std::size_t right = std::stol(std::string((*it).data(), (*it).size()));
-it = std::next(it);
-bool result = static_cast(std::stol(std::string((*it).data(), 
(*it).size(;
-comparison_results[left][right] = result;
-}
-auto predicate = [&](std::size_t* left, std::size_t* right) {
+class ComparisonResults {
+public:
+ComparisonResults(std::string_view data) {
+for (auto line : std::views::split(data, '\n') | 
std::views::filter([](auto const& line) { return !line.empty(); })) {
+auto values = std::views::split(line, ' ');
+auto it = values.begin();
+std::size_t left = std::stol(std::string((*it).data(), 
(*it).size()));
+it = std::next(it);
+std::size_t right = std::stol(std::string((*it).data(), 
(*it).size()));
+it = std::next(it);
+ 

[clang] [Driver] Add ExclusiveGroup feature to multilib.yaml. (PR #69447)

2023-10-18 Thread Simon Tatham via cfe-commits

https://github.com/statham-arm created 
https://github.com/llvm/llvm-project/pull/69447

This allows a YAML-based multilib configuration to specify explicitly that a 
subset of its library directories are alternatives to each other, i.e. at most 
one of that subset should be selected.

So if you have multiple sysroots each including a full set of headers and 
libraries, you can mark them as members of the same ExclusiveGroup, and then 
you'll be sure that only one of them is selected, even if two or more are 
compatible with the compile options.

This is particularly important in multilib setups including the libc++ headers, 
where selecting the include directories from two different sysroots can cause 
an actual build failure. This occurs when including , for example: 
libc++'s stdio.h is included first, and will try to use `#include_next` to 
fetch the underlying libc's version. But if there are two include directories 
from separate multilibs, then both of their C++ include directories will end up 
on the include path first, followed by both the C directories. So the 
`#include_next` from the first libc++ stdio.h will include the second libc++ 
stdio.h, which will do nothing because it has the same include guard macro, and 
the libc header won't ever be included at all.

If more than one of the options in an ExclusiveGroup matches the given flags, 
the last one wins.

>From 5b3289a7ad40850cbe1c438345a181b01c500639 Mon Sep 17 00:00:00 2001
From: Simon Tatham 
Date: Thu, 14 Sep 2023 14:51:17 +0100
Subject: [PATCH] [Driver] Add ExclusiveGroup feature to multilib.yaml.

This allows a YAML-based multilib configuration to specify explicitly
that a subset of its library directories are alternatives to each
other, i.e. at most one of that subset should be selected.

So if you have multiple sysroots each including a full set of headers
and libraries, you can mark them as members of the same
ExclusiveGroup, and then you'll be sure that only one of them is
selected, even if two or more are compatible with the compile options.

This is particularly important in multilib setups including the libc++
headers, where selecting the include directories from two different
sysroots can cause an actual build failure. This occurs when including
, for example: libc++'s stdio.h is included first, and will
try to use `#include_next` to fetch the underlying libc's version. But
if there are two include directories from separate multilibs, then
both of their C++ include directories will end up on the include path
first, followed by both the C directories. So the `#include_next` from
the first libc++ stdio.h will include the second libc++ stdio.h, which
will do nothing because it has the same include guard macro, and the
libc header won't ever be included at all.

If more than one of the options in an ExclusiveGroup matches the given
flags, the last one wins.
---
 clang/include/clang/Driver/Multilib.h | 15 +++-
 clang/lib/Driver/Multilib.cpp | 49 ++---
 .../baremetal-multilib-exclusive-group.yaml   | 69 +++
 3 files changed, 122 insertions(+), 11 deletions(-)
 create mode 100644 clang/test/Driver/baremetal-multilib-exclusive-group.yaml

diff --git a/clang/include/clang/Driver/Multilib.h 
b/clang/include/clang/Driver/Multilib.h
index 1416559414f894b..46f23a2ff5fabac 100644
--- a/clang/include/clang/Driver/Multilib.h
+++ b/clang/include/clang/Driver/Multilib.h
@@ -39,13 +39,23 @@ class Multilib {
   std::string IncludeSuffix;
   flags_list Flags;
 
+  // Optionally, a multilib can be assigned a string tag indicating that it's
+  // part of a group of mutually exclusive possibilities. If two or more
+  // multilibs have the same non-empty value of ExclusiveGroup, then only the
+  // last matching one of them will be selected.
+  //
+  // Setting this to the empty string is a special case, indicating that the
+  // directory is not mutually exclusive with anything else.
+  std::string ExclusiveGroup;
+
 public:
   /// GCCSuffix, OSSuffix & IncludeSuffix will be appended directly to the
   /// sysroot string so they must either be empty or begin with a '/' 
character.
   /// This is enforced with an assert in the constructor.
   Multilib(StringRef GCCSuffix = {}, StringRef OSSuffix = {},
StringRef IncludeSuffix = {},
-   const flags_list &Flags = flags_list());
+   const flags_list &Flags = flags_list(),
+   StringRef ExclusiveGroup = {});
 
   /// Get the detected GCC installation path suffix for the multi-arch
   /// target variant. Always starts with a '/', unless empty
@@ -63,6 +73,9 @@ class Multilib {
   /// All elements begin with either '-' or '!'
   const flags_list &flags() const { return Flags; }
 
+  /// Get the exclusive group label.
+  const std::string &exclusiveGroup() const { return ExclusiveGroup; }
+
   LLVM_DUMP_METHOD void dump() const;
   /// print summary of the Multilib
   void print(raw_ostream &OS) const;
diff --git a/clang/lib/

[clang] [Driver] Add ExclusiveGroup feature to multilib.yaml. (PR #69447)

2023-10-18 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Simon Tatham (statham-arm)


Changes

This allows a YAML-based multilib configuration to specify explicitly that a 
subset of its library directories are alternatives to each other, i.e. at most 
one of that subset should be selected.

So if you have multiple sysroots each including a full set of headers and 
libraries, you can mark them as members of the same ExclusiveGroup, and then 
you'll be sure that only one of them is selected, even if two or more are 
compatible with the compile options.

This is particularly important in multilib setups including the libc++ headers, 
where selecting the include directories from two different sysroots can cause 
an actual build failure. This occurs when including , for 
example: libc++'s stdio.h is included first, and will try to use 
`#include_next` to fetch the underlying libc's version. But if there are two 
include directories from separate multilibs, then both of their C++ include 
directories will end up on the include path first, followed by both the C 
directories. So the `#include_next` from the first libc++ stdio.h will include 
the second libc++ stdio.h, which will do nothing because it has the same 
include guard macro, and the libc header won't ever be included at all.

If more than one of the options in an ExclusiveGroup matches the given flags, 
the last one wins.

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


3 Files Affected:

- (modified) clang/include/clang/Driver/Multilib.h (+14-1) 
- (modified) clang/lib/Driver/Multilib.cpp (+39-10) 
- (added) clang/test/Driver/baremetal-multilib-exclusive-group.yaml (+69) 


``diff
diff --git a/clang/include/clang/Driver/Multilib.h 
b/clang/include/clang/Driver/Multilib.h
index 1416559414f894b..46f23a2ff5fabac 100644
--- a/clang/include/clang/Driver/Multilib.h
+++ b/clang/include/clang/Driver/Multilib.h
@@ -39,13 +39,23 @@ class Multilib {
   std::string IncludeSuffix;
   flags_list Flags;
 
+  // Optionally, a multilib can be assigned a string tag indicating that it's
+  // part of a group of mutually exclusive possibilities. If two or more
+  // multilibs have the same non-empty value of ExclusiveGroup, then only the
+  // last matching one of them will be selected.
+  //
+  // Setting this to the empty string is a special case, indicating that the
+  // directory is not mutually exclusive with anything else.
+  std::string ExclusiveGroup;
+
 public:
   /// GCCSuffix, OSSuffix & IncludeSuffix will be appended directly to the
   /// sysroot string so they must either be empty or begin with a '/' 
character.
   /// This is enforced with an assert in the constructor.
   Multilib(StringRef GCCSuffix = {}, StringRef OSSuffix = {},
StringRef IncludeSuffix = {},
-   const flags_list &Flags = flags_list());
+   const flags_list &Flags = flags_list(),
+   StringRef ExclusiveGroup = {});
 
   /// Get the detected GCC installation path suffix for the multi-arch
   /// target variant. Always starts with a '/', unless empty
@@ -63,6 +73,9 @@ class Multilib {
   /// All elements begin with either '-' or '!'
   const flags_list &flags() const { return Flags; }
 
+  /// Get the exclusive group label.
+  const std::string &exclusiveGroup() const { return ExclusiveGroup; }
+
   LLVM_DUMP_METHOD void dump() const;
   /// print summary of the Multilib
   void print(raw_ostream &OS) const;
diff --git a/clang/lib/Driver/Multilib.cpp b/clang/lib/Driver/Multilib.cpp
index ba466af39e2dcaf..a8eff30f1416852 100644
--- a/clang/lib/Driver/Multilib.cpp
+++ b/clang/lib/Driver/Multilib.cpp
@@ -29,9 +29,10 @@ using namespace driver;
 using namespace llvm::sys;
 
 Multilib::Multilib(StringRef GCCSuffix, StringRef OSSuffix,
-   StringRef IncludeSuffix, const flags_list &Flags)
+   StringRef IncludeSuffix, const flags_list &Flags,
+   StringRef ExclusiveGroup)
 : GCCSuffix(GCCSuffix), OSSuffix(OSSuffix), IncludeSuffix(IncludeSuffix),
-  Flags(Flags) {
+  Flags(Flags), ExclusiveGroup(ExclusiveGroup) {
   assert(GCCSuffix.empty() ||
  (StringRef(GCCSuffix).front() == '/' && GCCSuffix.size() > 1));
   assert(OSSuffix.empty() ||
@@ -96,13 +97,39 @@ bool MultilibSet::select(const Multilib::flags_list &Flags,
  llvm::SmallVector &Selected) const {
   llvm::StringSet<> FlagSet(expandFlags(Flags));
   Selected.clear();
-  llvm::copy_if(Multilibs, std::back_inserter(Selected),
-[&FlagSet](const Multilib &M) {
-  for (const std::string &F : M.flags())
-if (!FlagSet.contains(F))
-  return false;
-  return true;
-});
+
+  // Decide which multilibs we're going to select at all
+  std::vector IsSelected(Multilibs.size(), false);
+  std::map ExclusiveGroupMembers;
+  for (size_t i = 0, e = Multilibs.size(); i < e; ++i) {
+co

[clang] [Driver] Add ExclusiveGroup feature to multilib.yaml. (PR #69447)

2023-10-18 Thread via cfe-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff ebdb0cbef5e9be57237403c46bfdbe985313bb1c 
5b3289a7ad40850cbe1c438345a181b01c500639 -- 
clang/include/clang/Driver/Multilib.h clang/lib/Driver/Multilib.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/include/clang/Driver/Multilib.h 
b/clang/include/clang/Driver/Multilib.h
index 46f23a2ff..6a9533e6d 100644
--- a/clang/include/clang/Driver/Multilib.h
+++ b/clang/include/clang/Driver/Multilib.h
@@ -53,8 +53,7 @@ public:
   /// sysroot string so they must either be empty or begin with a '/' 
character.
   /// This is enforced with an assert in the constructor.
   Multilib(StringRef GCCSuffix = {}, StringRef OSSuffix = {},
-   StringRef IncludeSuffix = {},
-   const flags_list &Flags = flags_list(),
+   StringRef IncludeSuffix = {}, const flags_list &Flags = 
flags_list(),
StringRef ExclusiveGroup = {});
 
   /// Get the detected GCC installation path suffix for the multi-arch

``




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


[clang] [Driver] Add ExclusiveGroup feature to multilib.yaml. (PR #69447)

2023-10-18 Thread Simon Tatham via cfe-commits

https://github.com/statham-arm updated 
https://github.com/llvm/llvm-project/pull/69447

>From 3a0481134343339ce8132419fde875ac9977b734 Mon Sep 17 00:00:00 2001
From: Simon Tatham 
Date: Thu, 14 Sep 2023 14:51:17 +0100
Subject: [PATCH] [Driver] Add ExclusiveGroup feature to multilib.yaml.

This allows a YAML-based multilib configuration to specify explicitly
that a subset of its library directories are alternatives to each
other, i.e. at most one of that subset should be selected.

So if you have multiple sysroots each including a full set of headers
and libraries, you can mark them as members of the same
ExclusiveGroup, and then you'll be sure that only one of them is
selected, even if two or more are compatible with the compile options.

This is particularly important in multilib setups including the libc++
headers, where selecting the include directories from two different
sysroots can cause an actual build failure. This occurs when including
, for example: libc++'s stdio.h is included first, and will
try to use `#include_next` to fetch the underlying libc's version. But
if there are two include directories from separate multilibs, then
both of their C++ include directories will end up on the include path
first, followed by both the C directories. So the `#include_next` from
the first libc++ stdio.h will include the second libc++ stdio.h, which
will do nothing because it has the same include guard macro, and the
libc header won't ever be included at all.

If more than one of the options in an ExclusiveGroup matches the given
flags, the last one wins.
---
 clang/include/clang/Driver/Multilib.h | 16 -
 clang/lib/Driver/Multilib.cpp | 49 ++---
 .../baremetal-multilib-exclusive-group.yaml   | 69 +++
 3 files changed, 122 insertions(+), 12 deletions(-)
 create mode 100644 clang/test/Driver/baremetal-multilib-exclusive-group.yaml

diff --git a/clang/include/clang/Driver/Multilib.h 
b/clang/include/clang/Driver/Multilib.h
index 1416559414f894b..6a9533e6dd831f1 100644
--- a/clang/include/clang/Driver/Multilib.h
+++ b/clang/include/clang/Driver/Multilib.h
@@ -39,13 +39,22 @@ class Multilib {
   std::string IncludeSuffix;
   flags_list Flags;
 
+  // Optionally, a multilib can be assigned a string tag indicating that it's
+  // part of a group of mutually exclusive possibilities. If two or more
+  // multilibs have the same non-empty value of ExclusiveGroup, then only the
+  // last matching one of them will be selected.
+  //
+  // Setting this to the empty string is a special case, indicating that the
+  // directory is not mutually exclusive with anything else.
+  std::string ExclusiveGroup;
+
 public:
   /// GCCSuffix, OSSuffix & IncludeSuffix will be appended directly to the
   /// sysroot string so they must either be empty or begin with a '/' 
character.
   /// This is enforced with an assert in the constructor.
   Multilib(StringRef GCCSuffix = {}, StringRef OSSuffix = {},
-   StringRef IncludeSuffix = {},
-   const flags_list &Flags = flags_list());
+   StringRef IncludeSuffix = {}, const flags_list &Flags = 
flags_list(),
+   StringRef ExclusiveGroup = {});
 
   /// Get the detected GCC installation path suffix for the multi-arch
   /// target variant. Always starts with a '/', unless empty
@@ -63,6 +72,9 @@ class Multilib {
   /// All elements begin with either '-' or '!'
   const flags_list &flags() const { return Flags; }
 
+  /// Get the exclusive group label.
+  const std::string &exclusiveGroup() const { return ExclusiveGroup; }
+
   LLVM_DUMP_METHOD void dump() const;
   /// print summary of the Multilib
   void print(raw_ostream &OS) const;
diff --git a/clang/lib/Driver/Multilib.cpp b/clang/lib/Driver/Multilib.cpp
index ba466af39e2dcaf..a8eff30f1416852 100644
--- a/clang/lib/Driver/Multilib.cpp
+++ b/clang/lib/Driver/Multilib.cpp
@@ -29,9 +29,10 @@ using namespace driver;
 using namespace llvm::sys;
 
 Multilib::Multilib(StringRef GCCSuffix, StringRef OSSuffix,
-   StringRef IncludeSuffix, const flags_list &Flags)
+   StringRef IncludeSuffix, const flags_list &Flags,
+   StringRef ExclusiveGroup)
 : GCCSuffix(GCCSuffix), OSSuffix(OSSuffix), IncludeSuffix(IncludeSuffix),
-  Flags(Flags) {
+  Flags(Flags), ExclusiveGroup(ExclusiveGroup) {
   assert(GCCSuffix.empty() ||
  (StringRef(GCCSuffix).front() == '/' && GCCSuffix.size() > 1));
   assert(OSSuffix.empty() ||
@@ -96,13 +97,39 @@ bool MultilibSet::select(const Multilib::flags_list &Flags,
  llvm::SmallVector &Selected) const {
   llvm::StringSet<> FlagSet(expandFlags(Flags));
   Selected.clear();
-  llvm::copy_if(Multilibs, std::back_inserter(Selected),
-[&FlagSet](const Multilib &M) {
-  for (const std::string &F : M.flags())
-if (!FlagSet.contains(F))
-  return false;
-  return true

[clang] [clang] Bail out if the result of function template instantiation is not a function. (PR #69449)

2023-10-18 Thread via cfe-commits

https://github.com/VitaNuo created 
https://github.com/llvm/llvm-project/pull/69449

None

>From 27dc15e7467afa7bc4ee17a907a088e59719ca5d Mon Sep 17 00:00:00 2001
From: Viktoriia Bakalova 
Date: Wed, 18 Oct 2023 10:18:43 +
Subject: [PATCH] [clang] Bail out if the result of function template
 instantiation is not a function.

---
 clang/lib/Sema/SemaTemplateInstantiate.cpp|  4 +++-
 .../function-decl-nested-type-alias.cpp   | 15 +++
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/SemaTemplate/function-decl-nested-type-alias.cpp

diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 3b1731edec95237..fd4dbcd2cd80587 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2649,7 +2649,9 @@ TypeSourceInfo 
*Sema::SubstFunctionDeclType(TypeSourceInfo *T,
   } else {
 Result = Instantiator.TransformType(TLB, TL);
   }
-  if (Result.isNull())
+  // When clang goes into recovery mode, it substitutes the incorrect function
+  // type with a primitive (e.g., int).
+  if (Result.isNull() || !Result->isFunctionType())
 return nullptr;
 
   return TLB.getTypeSourceInfo(Context, Result);
diff --git a/clang/test/SemaTemplate/function-decl-nested-type-alias.cpp 
b/clang/test/SemaTemplate/function-decl-nested-type-alias.cpp
new file mode 100644
index 000..45e03b3c6ba850c
--- /dev/null
+++ b/clang/test/SemaTemplate/function-decl-nested-type-alias.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -x c++ -std=c++14 -fsyntax-only -verify %s
+
+template 
+using Type = typename A::NestedType; // expected-error {{type 'float' cannot 
be used prior to '::' because it has no members}}
+
+template 
+void Func() {
+  using MyType = Type(); // expected-note{{in instantiation of template 
type alias 'Type' requested here}}
+  MyType var;
+}
+
+void Test() {
+  Func(); // expected-note{{in instantiation of function template 
specialization 'Func' requested here}}
+}
+

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


[clang] [clang] Bail out if the result of function template instantiation is not a function. (PR #69449)

2023-10-18 Thread via cfe-commits

https://github.com/VitaNuo updated 
https://github.com/llvm/llvm-project/pull/69449

>From 27dc15e7467afa7bc4ee17a907a088e59719ca5d Mon Sep 17 00:00:00 2001
From: Viktoriia Bakalova 
Date: Wed, 18 Oct 2023 10:18:43 +
Subject: [PATCH 1/2] [clang] Bail out if the result of function template
 instantiation is not a function.

---
 clang/lib/Sema/SemaTemplateInstantiate.cpp|  4 +++-
 .../function-decl-nested-type-alias.cpp   | 15 +++
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/SemaTemplate/function-decl-nested-type-alias.cpp

diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 3b1731edec95237..fd4dbcd2cd80587 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2649,7 +2649,9 @@ TypeSourceInfo 
*Sema::SubstFunctionDeclType(TypeSourceInfo *T,
   } else {
 Result = Instantiator.TransformType(TLB, TL);
   }
-  if (Result.isNull())
+  // When clang goes into recovery mode, it substitutes the incorrect function
+  // type with a primitive (e.g., int).
+  if (Result.isNull() || !Result->isFunctionType())
 return nullptr;
 
   return TLB.getTypeSourceInfo(Context, Result);
diff --git a/clang/test/SemaTemplate/function-decl-nested-type-alias.cpp 
b/clang/test/SemaTemplate/function-decl-nested-type-alias.cpp
new file mode 100644
index 000..45e03b3c6ba850c
--- /dev/null
+++ b/clang/test/SemaTemplate/function-decl-nested-type-alias.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -x c++ -std=c++14 -fsyntax-only -verify %s
+
+template 
+using Type = typename A::NestedType; // expected-error {{type 'float' cannot 
be used prior to '::' because it has no members}}
+
+template 
+void Func() {
+  using MyType = Type(); // expected-note{{in instantiation of template 
type alias 'Type' requested here}}
+  MyType var;
+}
+
+void Test() {
+  Func(); // expected-note{{in instantiation of function template 
specialization 'Func' requested here}}
+}
+

>From a766065301f0e35d5e769c96b46bc1eba8550423 Mon Sep 17 00:00:00 2001
From: Viktoriia Bakalova 
Date: Wed, 18 Oct 2023 10:18:43 +
Subject: [PATCH 2/2] [clang] Bail out if the result of function template
 instantiation is not a function.

---
 clang/lib/Sema/SemaTemplateInstantiate.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index fd4dbcd2cd80587..273ab66ead6741e 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2649,8 +2649,8 @@ TypeSourceInfo 
*Sema::SubstFunctionDeclType(TypeSourceInfo *T,
   } else {
 Result = Instantiator.TransformType(TLB, TL);
   }
-  // When clang goes into recovery mode, it substitutes the incorrect function
-  // type with a primitive (e.g., int).
+  // When clang goes into recovery mode, it might substitute
+  // the incorrect function type with a primitive (e.g., int).
   if (Result.isNull() || !Result->isFunctionType())
 return nullptr;
 

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


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

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

ams-cs wrote:

We're discussing replacing the devices with something newer, but there are 
practical and business issues with that, so no hard plans. Sorry.

I'm leaning toward officially deprecating Fiji for GCC 14, and remove it from 
GCC 15 (so, sometime next year). If we can get these devices replaced then it 
can happen sooner. For release branches we can document a fixed LLVM version to 
use, so it's only really the mainline development branch that is the problem.

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


[clang-tools-extra] [run-clang-tidy] Add option -export-directory (PR #69453)

2023-10-18 Thread Amadeus Gebauer via cfe-commits

https://github.com/amgebauer created 
https://github.com/llvm/llvm-project/pull/69453

Adding an additional parameter to run_clang_tidy.py to accept a directory where 
the clang-tidy fixes are saved to. This directory can then be used to run 
`clang-apply-replacements`.

>From fd908df80b14933c849e498769cff6152276c2c3 Mon Sep 17 00:00:00 2001
From: Amadeus Gebauer 
Date: Wed, 18 Oct 2023 14:02:44 +0200
Subject: [PATCH] [run-clang-tidy] Add option -export-directory

---
 .../clang-tidy/tool/run-clang-tidy.py | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py 
b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
index 312d9241cfa57c5..b8d482809e293a5 100755
--- a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -372,6 +372,11 @@ def main():
 default=None,
 help="Upgrades warnings to errors. Same format as " "'-checks'",
 )
+parser.add_argument(
+"-export-directory",
+default=None,
+help="Path to the export directory. Within this directory, a file with 
the fixes will be created for every compilation unit.",
+)
 args = parser.parse_args()
 
 db_path = "compile_commands.json"
@@ -384,15 +389,17 @@ def main():
 
 clang_tidy_binary = find_binary(args.clang_tidy_binary, "clang-tidy", 
build_path)
 
-tmpdir = None
 if args.fix:
 clang_apply_replacements_binary = find_binary(
 args.clang_apply_replacements_binary, "clang-apply-replacements", 
build_path
 )
 
-if args.fix or (yaml and args.export_fixes):
+tmpdir = args.export_directory
+if tmpdir is None and (args.fix or (yaml and args.export_fixes)):
 tmpdir = tempfile.mkdtemp()
 
+delete_temporary_directory = args.export_directory is None and tmpdir is 
not None
+
 try:
 invocation = get_tidy_invocation(
 "",
@@ -474,7 +481,7 @@ def main():
 # This is a sad hack. Unfortunately subprocess goes
 # bonkers with ctrl-c and we start forking merrily.
 print("\nCtrl-C detected, goodbye.")
-if tmpdir:
+if tmpdir and delete_temporary_directory:
 shutil.rmtree(tmpdir)
 os.kill(0, 9)
 
@@ -496,7 +503,7 @@ def main():
 traceback.print_exc()
 return_code = 1
 
-if tmpdir:
+if tmpdir and delete_temporary_directory:
 shutil.rmtree(tmpdir)
 sys.exit(return_code)
 

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


[clang-tools-extra] [run-clang-tidy] Add option -export-directory (PR #69453)

2023-10-18 Thread Amadeus Gebauer via cfe-commits

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


[clang] [clang] [unittest] Add a test for Generic_GCC::GCCVersion::Parse (PR #69078)

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

tbaederr wrote:

This doesn't build for me locally:
```
mold: error: undefined symbol: 
tools/clang/unittests/Driver/CMakeFiles/ClangDriverTests.dir/GCCVersionTest.cpp.o:
 clang::driver::toolchains::Generic_GCC::GCCVersion::Parse(llvm::StringRef)
```

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


[clang] 66c9915 - [clang][Interp][NFC] Remove from(Boolean) overload

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

Author: Timm Bäder
Date: 2023-10-18T14:23:29+02:00
New Revision: 66c99154a130553a50e499d898ef1fba5b755dcf

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

LOG: [clang][Interp][NFC] Remove from(Boolean) overload

This code is unused now that we have special casts from/to IntAP(S).

Added: 


Modified: 
clang/lib/AST/Interp/IntegralAP.h
clang/test/AST/Interp/intap.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/IntegralAP.h 
b/clang/lib/AST/Interp/IntegralAP.h
index f17fb8e484415d2..fd120944a25043e 100644
--- a/clang/lib/AST/Interp/IntegralAP.h
+++ b/clang/lib/AST/Interp/IntegralAP.h
@@ -29,7 +29,6 @@ namespace interp {
 using APInt = llvm::APInt;
 using APSInt = llvm::APSInt;
 template  class Integral;
-class Boolean;
 
 template  class IntegralAP final {
 private:
@@ -104,10 +103,6 @@ template  class IntegralAP final {
 assert(Copy.isSigned() == Signed);
 return IntegralAP(Copy);
   }
-  static IntegralAP from(const Boolean &B) {
-assert(false);
-return IntegralAP::zero();
-  }
 
   static IntegralAP zero() {
 assert(false);

diff  --git a/clang/test/AST/Interp/intap.cpp b/clang/test/AST/Interp/intap.cpp
index f9cbc698a3290d8..ef7a0d4f0dfdab0 100644
--- a/clang/test/AST/Interp/intap.cpp
+++ b/clang/test/AST/Interp/intap.cpp
@@ -42,6 +42,9 @@ namespace i128 {
  // ref-note {{outside the range}}
   constexpr int128_t Two = (int128_t)1 << 1ul;
   static_assert(Two == 2, "");
+  static_assert(Two, "");
+  constexpr bool CastedToBool = Two;
+  static_assert(CastedToBool, "");
 
   constexpr uint128_t AllOnes = ~static_cast(0);
   static_assert(AllOnes == UINT128_MAX, "");



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


[clang] [clang][Interp] IntegralAP zero-init (PR #68081)

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


@@ -100,12 +100,13 @@ template  class IntegralAP final {
   }
   static IntegralAP from(const Boolean &B) {
 assert(false);
-return IntegralAP::zero();
+return IntegralAP::zero(1);

tbaederr wrote:

Removed that code in 
https://github.com/llvm/llvm-project/commit/66c99154a130553a50e499d898ef1fba5b755dcf.

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


[clang] [clang] [unittest] Add a test for Generic_GCC::GCCVersion::Parse (PR #69078)

2023-10-18 Thread Alex Bradbury via cfe-commits

asb wrote:

@tbaederr Just came to report the same thing!

@mstorsjo This broke builds that use `-DBUILD_SHARED_LIBS=True`. The problem 
seems to be that the `Generic_GCC` class has the `LLVM_LIBRARY_VISIBILITY` 
attribute meaning the 
`clang::driver::toolchains::Generic_GCC::GCCVersion::Parse(llvm::StringRef)` 
symbol is hidden. Removing that attribute fixes the build. It would be good for 
someone more familiar with this part of the codebase to confirm if that's an 
acceptable fix however.

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


[clang] [clang][Interp] IntegralAP zero-init (PR #68081)

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

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

>From d6b0b306353fb2d8eaef6835f6313277eaf94bbd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Tue, 3 Oct 2023 11:05:27 +0200
Subject: [PATCH] [clang][Interp] IntegralAP zero-init

---
 clang/lib/AST/Interp/ByteCodeExprGen.cpp |  4 ++--
 clang/lib/AST/Interp/IntegralAP.h| 11 ++-
 clang/lib/AST/Interp/Interp.h| 10 ++
 clang/lib/AST/Interp/Opcodes.td  | 15 ++-
 clang/test/AST/Interp/intap.cpp  | 15 +++
 5 files changed, 47 insertions(+), 8 deletions(-)

diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index e9e20b222d5d34f..d9389e7b0033191 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1665,9 +1665,9 @@ bool 
ByteCodeExprGen::visitZeroInitializer(PrimType T, QualType QT,
   case PT_Uint64:
 return this->emitZeroUint64(E);
   case PT_IntAP:
+return this->emitZeroIntAP(Ctx.getBitWidth(QT), E);
   case PT_IntAPS:
-assert(false);
-return false;
+return this->emitZeroIntAPS(Ctx.getBitWidth(QT), E);
   case PT_Ptr:
 return this->emitNullPtr(E);
   case PT_FnPtr:
diff --git a/clang/lib/AST/Interp/IntegralAP.h 
b/clang/lib/AST/Interp/IntegralAP.h
index fd120944a25043e..ebf362238ba09d5 100644
--- a/clang/lib/AST/Interp/IntegralAP.h
+++ b/clang/lib/AST/Interp/IntegralAP.h
@@ -78,7 +78,8 @@ template  class IntegralAP final {
 
   template  static IntegralAP from(T Value, unsigned NumBits = 0) {
 assert(NumBits > 0);
-APSInt Copy = APSInt(APInt(NumBits, static_cast(Value), Signed), 
!Signed);
+APSInt Copy =
+APSInt(APInt(NumBits, static_cast(Value), Signed), !Signed);
 
 return IntegralAP(Copy);
   }
@@ -97,16 +98,16 @@ template  class IntegralAP final {
   template 
   static IntegralAP from(Integral I, unsigned BitWidth) {
 APSInt Copy =
-APSInt(APInt(BitWidth, static_cast(I), InputSigned), !Signed);
+APSInt(APInt(BitWidth, static_cast(I), InputSigned), 
!Signed);
 Copy.setIsSigned(Signed);
 
 assert(Copy.isSigned() == Signed);
 return IntegralAP(Copy);
   }
 
-  static IntegralAP zero() {
-assert(false);
-return IntegralAP(0);
+  static IntegralAP zero(int32_t BitWidth) {
+APSInt V = APSInt(APInt(BitWidth, 0LL, Signed), !Signed);
+return IntegralAP(V);
   }
 
   constexpr unsigned bitWidth() const { return V.getBitWidth(); }
diff --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h
index 3d226a40f9cf608..4b081301655cfb2 100644
--- a/clang/lib/AST/Interp/Interp.h
+++ b/clang/lib/AST/Interp/Interp.h
@@ -1688,6 +1688,16 @@ bool Zero(InterpState &S, CodePtr OpPC) {
   return true;
 }
 
+static inline bool ZeroIntAP(InterpState &S, CodePtr OpPC, uint32_t BitWidth) {
+  S.Stk.push>(IntegralAP::zero(BitWidth));
+  return true;
+}
+
+static inline bool ZeroIntAPS(InterpState &S, CodePtr OpPC, uint32_t BitWidth) 
{
+  S.Stk.push>(IntegralAP::zero(BitWidth));
+  return true;
+}
+
 template ::T>
 inline bool Null(InterpState &S, CodePtr OpPC) {
   S.Stk.push();
diff --git a/clang/lib/AST/Interp/Opcodes.td b/clang/lib/AST/Interp/Opcodes.td
index 9d390fed152417f..e1e7e5e2efbb059 100644
--- a/clang/lib/AST/Interp/Opcodes.td
+++ b/clang/lib/AST/Interp/Opcodes.td
@@ -72,6 +72,11 @@ def IntegerTypeClass : TypeClass {
Uint32, Sint64, Uint64, IntAP, IntAPS];
 }
 
+def FixedSizeIntegralTypeClass : TypeClass {
+  let Types = [Sint8, Uint8, Sint16, Uint16, Sint32,
+   Uint32, Sint64, Uint64, Bool];
+}
+
 def NumberTypeClass : TypeClass {
   let Types = !listconcat(IntegerTypeClass.Types, [Float]);
 }
@@ -243,10 +248,18 @@ def ConstBool : ConstOpcode;
 
 // [] -> [Integer]
 def Zero : Opcode {
-  let Types = [AluTypeClass];
+  let Types = [FixedSizeIntegralTypeClass];
   let HasGroup = 1;
 }
 
+def ZeroIntAP : Opcode {
+  let Args = [ArgUint32];
+}
+
+def ZeroIntAPS : Opcode {
+  let Args = [ArgUint32];
+}
+
 // [] -> [Pointer]
 def Null : Opcode {
   let Types = [PtrTypeClass];
diff --git a/clang/test/AST/Interp/intap.cpp b/clang/test/AST/Interp/intap.cpp
index ef7a0d4f0dfdab0..27fae1b904351ce 100644
--- a/clang/test/AST/Interp/intap.cpp
+++ b/clang/test/AST/Interp/intap.cpp
@@ -17,6 +17,16 @@ constexpr MaxBitInt A_ = 0;
 constexpr MaxBitInt B_ = A_ + 1;
 static_assert(B_ == 1, "");
 
+constexpr MaxBitInt BitIntZero{};
+static_assert(BitIntZero == 0, "");
+constexpr unsigned _BitInt(128) UBitIntZero{};
+static_assert(UBitIntZero == 0, "");
+
+constexpr _BitInt(2) BitIntZero2{};
+static_assert(BitIntZero2 == 0, "");
+constexpr unsigned _BitInt(1) UBitIntZero1{};
+static_assert(UBitIntZero1 == 0, "");
+
 
 #ifdef __SIZEOF_INT128__
 namespace i128 {
@@ -49,6 +59,11 @@ namespace i128 {
   constexpr uint128_t AllOnes = ~static_cast(0);
   static_assert(AllOnes == UINT128_MAX, "");
 
+  constexpr uint128_t i128Zero{};
+  

[PATCH] D151197: [Clang][SVE2p1] Add svpsel builtins

2023-10-18 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto updated this revision to Diff 557756.
CarolineConcatto added a comment.

-Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151197

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

Index: clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_psel.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_psel.c
@@ -0,0 +1,165 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu \
+// RUN:   -target-feature +sve2p1 -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu \
+// RUN:   -target-feature +sve2p1 -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 +sve2p1 -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
+
+#include 
+
+// CHECK-LABEL: @test_svpsel_lane_b8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[ADD:%.*]] = add i32 [[IDX:%.*]], 15
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.psel.nxv16i1( [[P1:%.*]],  [[P2:%.*]], i32 [[ADD]])
+// CHECK-NEXT:ret  [[TMP0]]
+//
+// CPP-CHECK-LABEL: @_Z19test_svpsel_lane_b8u10__SVBool_tu10__SVBool_tj(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[ADD:%.*]] = add i32 [[IDX:%.*]], 15
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.psel.nxv16i1( [[P1:%.*]],  [[P2:%.*]], i32 [[ADD]])
+// CPP-CHECK-NEXT:ret  [[TMP0]]
+//
+svbool_t test_svpsel_lane_b8(svbool_t p1, svbool_t p2, uint32_t idx) {
+  return svpsel_lane_b8(p1, p2, idx + 15);
+}
+
+// CHECK-LABEL: @test_svpsel_lane_b16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[ADD:%.*]] = add i32 [[IDX:%.*]], 7
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv8i1( [[P2:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.psel.nxv8i1( [[P1:%.*]],  [[TMP0]], i32 [[ADD]])
+// CHECK-NEXT:ret  [[TMP1]]
+//
+// CPP-CHECK-LABEL: @_Z20test_svpsel_lane_b16u10__SVBool_tu10__SVBool_tj(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[ADD:%.*]] = add i32 [[IDX:%.*]], 7
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv8i1( [[P2:%.*]])
+// CPP-CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.psel.nxv8i1( [[P1:%.*]],  [[TMP0]], i32 [[ADD]])
+// CPP-CHECK-NEXT:ret  [[TMP1]]
+//
+svbool_t test_svpsel_lane_b16(svbool_t p1, svbool_t p2, uint32_t idx) {
+  return svpsel_lane_b16(p1, p2, idx + 7);
+}
+
+// CHECK-LABEL: @test_svpsel_lane_b32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[ADD:%.*]] = add i32 [[IDX:%.*]], 3
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv4i1( [[P2:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.psel.nxv4i1( [[P1:%.*]],  [[TMP0]], i32 [[ADD]])
+// CHECK-NEXT:ret  [[TMP1]]
+//
+// CPP-CHECK-LABEL: @_Z20test_svpsel_lane_b32u10__SVBool_tu10__SVBool_tj(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[ADD:%.*]] = add i32 [[IDX:%.*]], 3
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv4i1( [[P2:%.*]])
+// CPP-CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.psel.nxv4i1( [[P1:%.*]],  [[TMP0]], i32 [[ADD]])
+// CPP-CHECK-NEXT:ret  [[TMP1]]
+//
+svbool_t test_svpsel_lane_b32(svbool_t p1, svbool_t p2, uint32_t idx) {
+  return svpsel_lane_b32(p1, p2, idx + 3);
+}
+
+// CHECK-LABEL: @test_svpsel_lane_b64(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[ADD:%.*]] = add i32 [[IDX:%.*]], 1
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[P2:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.psel.nxv2i1( [[P1:%.*]],  [[TMP0]], i32 [[ADD]])
+// CHECK-NEXT:ret  [[TMP1]]
+//
+// CPP-CHECK-LABEL: @_Z20test_svpsel_lane_b64u10__SVBool_tu10__SVBool_tj(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[ADD:%.*]] = add i32 [[IDX:%.*]], 1
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[P2:%.*]])
+// CPP-CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.psel.nxv2i1( [[P1:%.*]],  [[TMP0]], i32 [[ADD]])
+// CPP-CHECK-NEXT:ret  [[TMP1]]
+//
+svbool_t test_svpsel_lane_b64(svbool_t p1, svbool_t p2, uint32_t idx) {
+  return svpsel_lane_b64(p1, p2, idx + 1);
+}
+
+// CHECK-LABEL: @test_svpsel_lane_c8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[ADD:%.*]] = add i32 [[IDX:%.*]], 15
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.to.svbool.taarch64.svcountt(target("aarch64.svcount") [[P1:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.psel.nx

[clang] [clang] [unittest] Add a test for Generic_GCC::GCCVersion::Parse (PR #69078)

2023-10-18 Thread Martin Storsjö via cfe-commits

mstorsjo wrote:

> @tbaederr Just came to report the same thing!
> 
> @mstorsjo This broke builds that use `-DBUILD_SHARED_LIBS=True`.

Thanks! That was my guess as well, I was running a build with that enabled to 
try to reproduce @tbaederr 's issue.

> The problem seems to be that the `Generic_GCC` class has the 
> `LLVM_LIBRARY_VISIBILITY` attribute meaning the 
> `clang::driver::toolchains::Generic_GCC::GCCVersion::Parse(llvm::StringRef)` 
> symbol is hidden. Removing that attribute fixes the build. It would be good 
> for someone more familiar with this part of the codebase to confirm if that's 
> an acceptable fix however.

Thanks for the analysis! I guess that sounds reasonable, although I wonder how 
these unit test, that test internals within libclang are meant to work in this 
configuration. The number of extra exported symbols by removing 
`LLVM_LIBRARY_VISIBILITY` probably isn't that bad, I wonder if it has other 
implications wrt ABI of the shared libs?

I guess it's safest to revert this for now, so we can figure out the best path 
forward here without a rush?

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


[clang] 1072b94 - Revert "[clang] [unittest] Add a test for Generic_GCC::GCCVersion::Parse (#69078)"

2023-10-18 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2023-10-18T15:42:18+03:00
New Revision: 1072b94ed8e5a051100557185cb384364850635a

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

LOG: Revert "[clang] [unittest] Add a test for Generic_GCC::GCCVersion::Parse 
(#69078)"

This reverts commit b4b35a5d2b4ee26bf79b8a92715dd200f3f9cc49.

That commit broke builds with -DBUILD_SHARED_LIBS=ON. The reason
is that clang::driver::toolchains::Generic_GCC::GCCVersion::Parse
isn't visible outside of the shared library, because
the Generic_GCC class is marked with LLVM_LIBRARY_VISIBILITY.

Added: 


Modified: 
clang/unittests/Driver/CMakeLists.txt

Removed: 
clang/unittests/Driver/GCCVersionTest.cpp



diff  --git a/clang/unittests/Driver/CMakeLists.txt 
b/clang/unittests/Driver/CMakeLists.txt
index 752037f78fb147d..e37c158d7137a88 100644
--- a/clang/unittests/Driver/CMakeLists.txt
+++ b/clang/unittests/Driver/CMakeLists.txt
@@ -9,7 +9,6 @@ set(LLVM_LINK_COMPONENTS
 add_clang_unittest(ClangDriverTests
   DistroTest.cpp
   DXCModeTest.cpp
-  GCCVersionTest.cpp
   ToolChainTest.cpp
   ModuleCacheTest.cpp
   MultilibBuilderTest.cpp

diff  --git a/clang/unittests/Driver/GCCVersionTest.cpp 
b/clang/unittests/Driver/GCCVersionTest.cpp
deleted file mode 100644
index 9ae335bca77dc12..000
--- a/clang/unittests/Driver/GCCVersionTest.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-//===- unittests/Driver/GCCVersionTest.cpp --- GCCVersion parser tests 
===//
-//
-// 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
-//
-//===--===//
-//
-// Unit tests for Generic_GCC::GCCVersion
-//
-//===--===//
-
-#include "../../lib/Driver/ToolChains/Gnu.h"
-#include "gtest/gtest.h"
-
-using namespace clang;
-using namespace clang::driver;
-
-namespace {
-
-struct VersionParseTest {
-  std::string Text;
-
-  int Major, Minor, Patch;
-  std::string MajorStr, MinorStr, PatchSuffix;
-};
-
-const VersionParseTest TestCases[] = {
-{"5", 5, -1, -1, "5", "", ""},
-{"4.4", 4, 4, -1, "4", "4", ""},
-{"4.4-patched", 4, 4, -1, "4", "4", "-patched"},
-{"4.4.0", 4, 4, 0, "4", "4", ""},
-{"4.4.x", 4, 4, -1, "4", "4", ""},
-{"4.4.2-rc4", 4, 4, 2, "4", "4", "-rc4"},
-{"4.4.x-patched", 4, 4, -1, "4", "4", ""},
-{"not-a-version", -1, -1, -1, "", "", ""},
-};
-
-TEST(GCCVersionTest, Parse) {
-  for (const auto &TC : TestCases) {
-auto V = toolchains::Generic_GCC::GCCVersion::Parse(TC.Text);
-EXPECT_EQ(V.Text, TC.Text);
-EXPECT_EQ(V.Major, TC.Major);
-EXPECT_EQ(V.Minor, TC.Minor);
-EXPECT_EQ(V.Patch, TC.Patch);
-EXPECT_EQ(V.MajorStr, TC.MajorStr);
-EXPECT_EQ(V.MinorStr, TC.MinorStr);
-EXPECT_EQ(V.PatchSuffix, TC.PatchSuffix);
-  }
-}
-
-} // end anonymous namespace



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


[clang-tools-extra] [run-clang-tidy] Add option -export-directory (PR #69453)

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

PiotrZSL wrote:

There is already --export_fixes that can be used in +- same way.
Maybe better would be to change --export_fixes to take filename or directory 
(ends with / or exist as directory), and in that case it could save to 
directory or merge to single file.

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


[clang] [HIP] Document func ptr and virtual func (PR #68126)

2023-10-18 Thread Siu Chi Chan via cfe-commits

scchan wrote:

LGTM thanks

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


[clang] [clang] Bail out if the result of function template instantiation is not a function type. (PR #69459)

2023-10-18 Thread via cfe-commits

https://github.com/VitaNuo created 
https://github.com/llvm/llvm-project/pull/69459

…not a function.

>From d8305b64a464e5cd992c836ef13d452f62235442 Mon Sep 17 00:00:00 2001
From: Viktoriia Bakalova 
Date: Wed, 18 Oct 2023 12:55:04 +
Subject: [PATCH] [clang] Bail out if the result of function template
 instantiation is not a function.

---
 clang/lib/Sema/SemaTemplateInstantiate.cpp |  4 +++-
 .../function-decl-nested-type-alias.cpp| 14 ++
 2 files changed, 17 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/SemaTemplate/function-decl-nested-type-alias.cpp

diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 23de64080a070ca..dfd7cc284eb6b73 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2662,7 +2662,9 @@ TypeSourceInfo 
*Sema::SubstFunctionDeclType(TypeSourceInfo *T,
   } else {
 Result = Instantiator.TransformType(TLB, TL);
   }
-  if (Result.isNull())
+  // When clang goes into recovery mode, it might substitute
+  // the incorrect function type with a primitive (e.g., int).
+  if (Result.isNull() || !Result->isFunctionType())
 return nullptr;
 
   return TLB.getTypeSourceInfo(Context, Result);
diff --git a/clang/test/SemaTemplate/function-decl-nested-type-alias.cpp 
b/clang/test/SemaTemplate/function-decl-nested-type-alias.cpp
new file mode 100644
index 000..139706f73d24dba
--- /dev/null
+++ b/clang/test/SemaTemplate/function-decl-nested-type-alias.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -x c++ -std=c++14 -fsyntax-only -verify %s
+
+template 
+using Type = typename A::NestedType; // expected-error {{type 'float' cannot 
be used prior to '::' because it has no members}}
+
+template 
+void Func() {
+  using MyType = Type(); // expected-note {{in instantiation of template 
type alias 'Type' requested here}}
+  MyType var;
+}
+
+void Test() {
+  Func(); // expected-note {{in instantiation of function template 
specialization 'Func' requested here}}
+}
\ No newline at end of file

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


[clang] [clang] Bail out if the result of function template instantiation is not a function type. (PR #69459)

2023-10-18 Thread via cfe-commits

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


[clang] [clang] Bail out if the result of function template instantiation is not a function. (PR #69449)

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

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


[clang] [clang] Bail out if the result of function template instantiation is not a function. (PR #69449)

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

https://github.com/sam-mccall approved this pull request.

Thanks! Looks great, just comment nits

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


[clang] [clang] Bail out if the result of function template instantiation is not a function. (PR #69449)

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


@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -x c++ -std=c++14 -fsyntax-only -verify %s
+
+template 
+using Type = typename A::NestedType; // expected-error {{type 'float' cannot 
be used prior to '::' because it has no members}}
+
+template 
+void Func() {
+  using MyType = Type(); // expected-note{{in instantiation of template 
type alias 'Type' requested here}}
+  MyType var;

sam-mccall wrote:

// This is a function declaration, not a variable declaration!
// After substitution, we do not have a valid function type, and used to crash.

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


[clang] [clang] Bail out if the result of function template instantiation is not a function. (PR #69449)

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


@@ -2649,7 +2649,9 @@ TypeSourceInfo 
*Sema::SubstFunctionDeclType(TypeSourceInfo *T,
   } else {
 Result = Instantiator.TransformType(TLB, TL);
   }
-  if (Result.isNull())
+  // When clang goes into recovery mode, it might substitute

sam-mccall wrote:

Not sure "recovery mode" is well-defined enough to refer to in this way

maybe:
When there are errors resolving types, clang may use IntTy as a fallback, 
breaking our assumption that function declarations have function types.

(I thought there was a name for this usage of IntTy but I can't find one. It 
happens e.g. at GetFullTypeForDeclarator, SemaType.cpp:5734)

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


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

2023-10-18 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin accepted this revision.
kmclaughlin added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151307

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


  1   2   3   4   >