[clang] [clang] Diagnose default arguments defined in different scopes (PR #124844)

2025-01-29 Thread via cfe-commits


@@ -488,6 +490,20 @@ bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, 
FunctionDecl *Old,
   continue;
 }
 
+if (PrevForDefaultArgs->getLexicalDeclContext()->getPrimaryContext() !=
+ScopeDC->getPrimaryContext() &&
+!New->isCXXClassMember())
+  // If previous declaration is lexically in a different scope,
+  // we don't inherit its default arguments, except for out-of-line
+  // declarations of member functions.
+  //
+  // extern "C" and local functions can have default arguments across
+  // different scopes, but diagnosing that early would reject well-formed
+  // code (_N5001_.[over.match.best]/4.) Instead, they are checked
+  // in ConvertArgumentsForCall, after the best viable function has been
+  // selected.
+  continue;
+

cor3ntin wrote:

do we have tests for that?

```cpp

struct S {
void f(int a = 0);
};

void S::f(int a = 2) {}
```

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


[clang] [clang] Diagnose default arguments defined in different scopes (PR #124844)

2025-01-29 Thread via cfe-commits


@@ -10960,6 +10960,10 @@ OverloadCandidateSet::BestViableFunction(Sema &S, 
SourceLocation Loc,
 S.diagnoseEquivalentInternalLinkageDeclarations(Loc, Best->Function,
 EquivalentCands);
 
+  // [over.match.best]/4 is checked for in Sema::ConvertArgumentsForCall,
+  // because not every function call goes through our overload resolution
+  // machinery, even if the Standard says it supposed to.
+

cor3ntin wrote:

ideally we would return `OR_Ambiguous` here, and then special case the 
diagnostic for that when all candidates are redeclarations

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


[clang] [clang] Diagnose default arguments defined in different scopes (PR #124844)

2025-01-29 Thread via cfe-commits


@@ -27,3 +27,23 @@ extern double(*func2)(
   P_1(int u)
   P_1(int v) // expected-error {{too many function parameters; subsequent 
parameters will be ignored}}
   int w);
+
+#define PD_10(x) x, x, x, x, x, x, x, x, x, x,
+#define PD_100(x) PD_10(x) PD_10(x) PD_10(x) PD_10(x) PD_10(x) \
+  PD_10(x) PD_10(x) PD_10(x) PD_10(x) PD_10(x)
+#define PD_1000(x) PD_100(x) PD_100(x) PD_100(x) PD_100(x) PD_100(x) \
+   PD_100(x) PD_100(x) PD_100(x) PD_100(x) PD_100(x)
+#define PD_1(x) PD_1000(x) PD_1000(x) PD_1000(x) PD_1000(x) PD_1000(x) \
+PD_1000(x) PD_1000(x) PD_1000(x) PD_1000(x) PD_1000(x)
+
+extern "C" int func3( 
+  PD_1(int = 0)
+  PD_1(int = 0)
+  PD_1(int = 0)
+  PD_1(int = 0)
+  PD_1(int = 0)
+  PD_1(int = 0)
+  PD_1(int = 0) // expected-error {{too many function parameters; 
subsequent parameters will be ignored}} 
+  int = 0);
+
+int h = func3();

cor3ntin wrote:

Is that really related to the change?

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


[clang] [clang] Diagnose default arguments defined in different scopes (PR #124844)

2025-01-29 Thread via cfe-commits


@@ -5810,6 +5810,62 @@ static bool 
isParenthetizedAndQualifiedAddressOfExpr(Expr *Fn) {
   return false;
 }
 
+/// @brief Checks that each default argument needed to make the call
+/// is defined only once, implementing [over.match.best]/4 rule.
+///
+/// @param FDecl Function declaration selected for the call
+/// @param NumArgs Number of argument explicitly specified in the call
+/// expression
+/// @param CallLoc Source location of the call expression
+static void checkDefaultArgumentsAcrossScopes(Sema &S, FunctionDecl *FDecl,
+  int NumArgs,
+  SourceLocation CallLoc) {
+  // [over.match.best]/4:
+  // If the best viable function resolves to a function
+  // for which multiple declarations were found,
+  // and if any two of these declarations inhabit different scopes
+  // and specify a default argument that made the function viable,
+  // the program is ill-formed.
+
+  // Calculate the range of parameters,
+  // default arguments of which made the candidate viable.
+  int FirstDefaultArgIndex = NumArgs;
+  int LastDefaultArgIndex = FDecl->getNumParams() - 1;
+
+  // For each such parameter, collect all redeclarations
+  // that have non-inherited default argument.
+  llvm::SmallDenseMap> ParamRedecls(
+  LastDefaultArgIndex - FirstDefaultArgIndex + 1);
+  for (FunctionDecl *Redecl : FDecl->redecls()) {
+for (int i = FirstDefaultArgIndex; i <= LastDefaultArgIndex; ++i) {
+  ParmVarDecl *Param = Redecl->getParamDecl(i);
+  if (Param->hasDefaultArg() && !Param->hasInheritedDefaultArg())
+ParamRedecls[i].push_back(Param);
+}
+  }

cor3ntin wrote:

If you iterate over `i` in the outer loop, you can forgo the map entirely and 
do it on one pass 

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


[clang] [clang] Diagnose default arguments defined in different scopes (PR #124844)

2025-01-29 Thread via cfe-commits


@@ -73,6 +73,11 @@ C++17 Feature Support
 Resolutions to C++ Defect Reports
 ^
 
+- Clang now diagnoses ambiguous default arguments declared in different scopes
+  when calling functions, implementing [over.match.best] p4.
+  (`CWG1: What if two using-declarations refer to the same function but the 
declarations introduce different default-arguments? 
`_,
+  `CWG418: Imperfect wording on error on multiple default arguments on a 
called function `_)
+

cor3ntin wrote:

As an aside should we augment our #GH logic to support #CWG123 and #LWG123? 
:D

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


[clang] [clang] Diagnose default arguments defined in different scopes (PR #124844)

2025-01-29 Thread via cfe-commits


@@ -5810,6 +5810,62 @@ static bool 
isParenthetizedAndQualifiedAddressOfExpr(Expr *Fn) {
   return false;
 }
 
+/// @brief Checks that each default argument needed to make the call
+/// is defined only once, implementing [over.match.best]/4 rule.
+///
+/// @param FDecl Function declaration selected for the call
+/// @param NumArgs Number of argument explicitly specified in the call
+/// expression
+/// @param CallLoc Source location of the call expression
+static void checkDefaultArgumentsAcrossScopes(Sema &S, FunctionDecl *FDecl,
+  int NumArgs,
+  SourceLocation CallLoc) {
+  // [over.match.best]/4:
+  // If the best viable function resolves to a function
+  // for which multiple declarations were found,
+  // and if any two of these declarations inhabit different scopes
+  // and specify a default argument that made the function viable,
+  // the program is ill-formed.
+
+  // Calculate the range of parameters,
+  // default arguments of which made the candidate viable.
+  int FirstDefaultArgIndex = NumArgs;
+  int LastDefaultArgIndex = FDecl->getNumParams() - 1;
+
+  // For each such parameter, collect all redeclarations
+  // that have non-inherited default argument.
+  llvm::SmallDenseMap> ParamRedecls(
+  LastDefaultArgIndex - FirstDefaultArgIndex + 1);
+  for (FunctionDecl *Redecl : FDecl->redecls()) {
+for (int i = FirstDefaultArgIndex; i <= LastDefaultArgIndex; ++i) {

cor3ntin wrote:

```suggestion
for (int I = FirstDefaultArgIndex; I <= LastDefaultArgIndex; ++I) {
```

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


[clang] [clang] Diagnose default arguments defined in different scopes (PR #124844)

2025-01-29 Thread via cfe-commits


@@ -488,6 +490,20 @@ bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, 
FunctionDecl *Old,
   continue;
 }
 
+if (PrevForDefaultArgs->getLexicalDeclContext()->getPrimaryContext() !=
+ScopeDC->getPrimaryContext() &&
+!New->isCXXClassMember())
+  // If previous declaration is lexically in a different scope,
+  // we don't inherit its default arguments, except for out-of-line
+  // declarations of member functions.
+  //
+  // extern "C" and local functions can have default arguments across
+  // different scopes, but diagnosing that early would reject well-formed
+  // code (_N5001_.[over.match.best]/4.) Instead, they are checked
+  // in ConvertArgumentsForCall, after the best viable function has been
+  // selected.
+  continue;
+

cor3ntin wrote:

we usually quote C++2c rather than a specific draft

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


[clang] [clang-format] Fix erroneous BraceWrapping.BeforeLambdaBody column calcs (PR #76673)

2025-01-29 Thread James Grant via cfe-commits

https://github.com/jamesg-nz updated 
https://github.com/llvm/llvm-project/pull/76673

>From 04885844162b5390d8041a44a1895ad6ac160228 Mon Sep 17 00:00:00 2001
From: James Grant <42079499+jamesg...@users.noreply.github.com>
Date: Mon, 1 Jan 2024 20:27:41 +1300
Subject: [PATCH 1/2] [clang-format] Fix erroneous
 BraceWrapping.BeforeLambdaBody column calcs

Firstly, must check ColumnLimit > 0 before comparing calculated columns
to the limit. Otherwise it always breaks before the brace if ColumnLimit
= 0 (no limit). Fixes #50275

Secondly, the lambda body length alone is currently compared with the
column limit. Should instead be comparing a column position, which
includes everything before the lambda body, the body length itself, and
any unbreakable tail. Fixes #59724

Thirdly, if must break before the lambda right brace, e.g. line comment
in body, then must also break before the left brace. Can't use column
calculation in this instance.
---
 clang/lib/Format/ContinuationIndenter.cpp | 10 ++-
 clang/unittests/Format/FormatTest.cpp | 78 +++
 2 files changed, 86 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 102504182c4505b..f4f8b694f7ff51e 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -366,8 +366,14 @@ bool ContinuationIndenter::mustBreak(const LineState 
&State) {
   const auto &CurrentState = State.Stack.back();
   if (Style.BraceWrapping.BeforeLambdaBody && Current.CanBreakBefore &&
   Current.is(TT_LambdaLBrace) && Previous.isNot(TT_LineComment)) {
-auto LambdaBodyLength = getLengthToMatchingParen(Current, State.Stack);
-return LambdaBodyLength > getColumnLimit(State);
+if (Current.MatchingParen->MustBreakBefore)
+  return true;
+
+auto LambdaEnd = getLengthToMatchingParen(Current, State.Stack) +
+ Current.MatchingParen->UnbreakableTailLength +
+ State.Column - 1;
+
+return Style.ColumnLimit > 0 && LambdaEnd > getColumnLimit(State);
   }
   if (Current.MustBreakBefore ||
   (Current.is(TT_InlineASMColon) &&
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 881993ede17c3dc..f5aadec3500ccb7 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -22965,6 +22965,84 @@ TEST_F(FormatTest, EmptyLinesInLambdas) {
"};");
 }
 
+TEST_F(FormatTest, BreakBeforeLambdaBodyWrapping) {
+  verifyFormat("connect([]() {\n"
+   "  foo();\n"
+   "  bar();\n"
+   "});");
+
+  auto Style = getLLVMStyle();
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.BeforeLambdaBody = true;
+
+  verifyFormat("connect(\n"
+   "[]()\n"
+   "{\n"
+   "  foo();\n"
+   "  bar();\n"
+   "});",
+   Style);
+
+  for (unsigned l : {0, 41}) {
+Style.ColumnLimit = l;
+verifyFormat("auto lambda = []() { return foo + bar; };", Style);
+  }
+  for (unsigned l : {40, 22}) {
+Style.ColumnLimit = l;
+verifyFormat("auto lambda = []()\n"
+ "{ return foo + bar; };",
+ Style);
+  }
+  Style.ColumnLimit = 21;
+  verifyFormat("auto lambda = []()\n"
+   "{\n"
+   "  return foo + bar;\n"
+   "};",
+   Style);
+
+  for (unsigned l : {0, 67}) {
+Style.ColumnLimit = l;
+verifyFormat(
+"auto result = [](int foo, int bar) { return foo + bar; }(foo, bar);",
+Style);
+  }
+  Style.ColumnLimit = 66;
+  verifyFormat("auto result = [](int foo, int bar)\n"
+   "{ return foo + bar; }(foo, bar);",
+   Style);
+
+  Style.ColumnLimit = 36;
+  verifyFormat("myFunc([&]() { return foo + bar; });", Style);
+  Style.ColumnLimit = 35;
+  verifyFormat("myFunc([&]()\n"
+   "   { return foo + bar; });",
+   Style);
+
+  Style = getGoogleStyleWithColumns(100);
+  Style.BreakBeforeBraces = FormatStyle::BS_Allman;
+  Style.IndentWidth = 4;
+  verifyFormat(
+  "void Func()\n"
+  "{\n"
+  "[]()\n"
+  "{\n"
+  "return TestVeryLongThingName::TestVeryLongFunctionName()\n"
+  ".TestAnotherVeryVeryLongFunctionName();\n"
+  "}\n"
+  "}\n",
+  Style);
+  verifyFormat(
+  "void Func()\n"
+  "{\n"
+  "[]()\n"
+  "{\n"
+  "return TestVeryLongThingName::TestVeryLongFunctionName()\n"
+  ".TestAnotherVeryVeryVeryLongFunctionName();\n"
+  "}\n"
+  "}\n",
+  Style);
+}
+
 TEST_F(FormatTest, FormatsBlocks) {
   FormatStyle ShortBlocks = getLLVMStyle();
   ShortBlocks.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Always;

>From 346e7da1f6eb184f7fc5212af94f5e7c83d5a494 Mon Sep 17 00:00:00 2001
From: James Gran

[clang] Optimize -Wunsafe-buffer-usage. (PR #124554)

2025-01-29 Thread via cfe-commits


@@ -186,106 +205,202 @@ class MatchDescendantVisitor : public 
DynamicRecursiveASTVisitor {
 return DynamicRecursiveASTVisitor::TraverseStmt(Node);
   }
 
+  void set_ast_context(ASTContext &Context) { ActiveASTContext = &Context; }
+
+  void set_handler(const UnsafeBufferUsageHandler &NewHandler) {
+Handler = &NewHandler;
+  }
+
 private:
   // Sets 'Matched' to true if 'Matcher' matches 'Node'
   //
   // Returns 'true' if traversal should continue after this function
   // returns, i.e. if no match is found or 'Bind' is 'BK_All'.
   template  bool match(const T &Node) {
-internal::BoundNodesTreeBuilder RecursiveBuilder(*Builder);
-
-if (Matcher->matches(DynTypedNode::create(Node), Finder,
- &RecursiveBuilder)) {
-  ResultBindings.addMatch(RecursiveBuilder);
+if (Matcher->matches(DynTypedNode::create(Node), *ActiveASTContext,
+ *Handler)) {
   Matches = true;
-  if (Bind != internal::ASTMatchFinder::BK_All)
+  if (!BindAll)
 return false; // Abort as soon as a match is found.
 }
 return true;
   }
 
-  const internal::DynTypedMatcher *const Matcher;
-  internal::ASTMatchFinder *const Finder;
-  internal::BoundNodesTreeBuilder *const Builder;
-  internal::BoundNodesTreeBuilder ResultBindings;
-  const internal::ASTMatchFinder::BindKind Bind;
+  CustomMatcher *const Matcher;
+  /// Defines how bindings are processed on recursive matches.
+  /// true: Create results for all combinations of bindings that match.
+  /// false: Stop at the first match and only bind the first match.
+  const bool BindAll;
   bool Matches;
   bool ignoreUnevaluatedContext;
+  ASTContext *ActiveASTContext;
+  const UnsafeBufferUsageHandler *Handler;
 };
 
 // Because we're dealing with raw pointers, let's define what we mean by that.
-static auto hasPointerType() {
-  return hasType(hasCanonicalType(pointerType()));
+static auto hasPointerType(const Expr &E) {
+  return isa(E.getType().getCanonicalType());
 }
 
-static auto hasArrayType() { return hasType(hasCanonicalType(arrayType())); }
-
-AST_MATCHER_P(Stmt, forEachDescendantEvaluatedStmt, internal::Matcher,

ivanaivanovska wrote:

Done.

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


[clang] Optimize -Wunsafe-buffer-usage. (PR #124554)

2025-01-29 Thread Ilya Biryukov via cfe-commits

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


[clang] Optimize -Wunsafe-buffer-usage. (PR #124554)

2025-01-29 Thread Ilya Biryukov via cfe-commits

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


[clang] [StaticAnalyzer] Fix state update in VisitObjCForCollectionStmt (PR #124477)

2025-01-29 Thread Balazs Benics via cfe-commits

steakhal wrote:

I wanted to push to your branch but for some reason I could not.
Here is what I would have proposed to unblock this change:
```diff
commit ab9670b613be2bdd802342f031bd5e3d20680925
Author: Balazs Benics 
Date:   2025.01.29 13:02:16

Add a unittest demonstrating that we no longer crash

diff --git a/clang/unittests/StaticAnalyzer/CMakeLists.txt 
b/clang/unittests/StaticAnalyzer/CMakeLists.txt
index f5da86e54560..7b574bdf7cbc 100644
--- a/clang/unittests/StaticAnalyzer/CMakeLists.txt
+++ b/clang/unittests/StaticAnalyzer/CMakeLists.txt
@@ -15,6 +15,7 @@ add_clang_unittest(StaticAnalysisTests
   IsCLibraryFunctionTest.cpp
   MemRegionDescriptiveNameTest.cpp
   NoStateChangeFuncVisitorTest.cpp
+  ObjCTest.cpp
   ParamRegionTest.cpp
   RangeSetTest.cpp
   RegisterCustomCheckersTest.cpp
diff --git a/clang/unittests/StaticAnalyzer/ObjCTest.cpp 
b/clang/unittests/StaticAnalyzer/ObjCTest.cpp
new file mode 100644
index ..16cab5336813
--- /dev/null
+++ b/clang/unittests/StaticAnalyzer/ObjCTest.cpp
@@ -0,0 +1,62 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "CheckerRegistration.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
+#include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
+#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace ento;
+
+// Some dummy trait that we can mutate back and forth to force a new State.
+REGISTER_TRAIT_WITH_PROGRAMSTATE(Flag, bool)
+
+namespace {
+class FlipFlagOnCheckLocation : public Checker {
+public:
+  // We make sure we alter the State every time we model a checkLocation event.
+  void checkLocation(SVal l, bool isLoad, const Stmt *S,
+ CheckerContext &C) const {
+ProgramStateRef State = C.getState();
+State = State->set(!State->get());
+C.addTransition(State);
+  }
+};
+
+void addFlagFlipperChecker(AnalysisASTConsumer &AnalysisConsumer,
+   AnalyzerOptions &AnOpts) {
+  AnOpts.CheckersAndPackages = {{"test.FlipFlagOnCheckLocation", true}};
+  AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
+
Registry.addChecker("test.FlipFlagOnCheckLocation",
+ "Description", "");
+  });
+}
+
+TEST(ObjCTest, CheckLocationEventsShouldMaterializeInObjCForCollectionStmts) {
+  // Previously, the `ExprEngine::hasMoreIteration` may fired an assertion
+  // because we forgot to handle correctly the resulting nodes of the
+  // check::Location callback for the ObjCForCollectionStmts.
+  // This caused inconsistencies in the graph and triggering the assertion.
+  std::string Diags;
+  EXPECT_TRUE(runCheckerOnCodeWithArgs(
+  R"(
+@class NSArray, NSDictionary, NSString;
+extern void NSLog(NSString *format, ...) 
__attribute__((format(__NSString__, 1, 2)));
+void entrypoint(NSArray *bowl) {
+  for (NSString *fruit in bowl) { // no-crash
+NSLog(@"Fruit: %@", fruit);
+  }
+})",
+  {"-x", "objective-c"}, Diags));
+}
+
+} // namespace
```

Feel free to tweak it, especially the comment as you know the most of this 
context.
I checked and without your fix the test would crash, and after your fix it 
would work.

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


[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2025-01-29 Thread Fraser Cormack via cfe-commits

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


[clang] [X86][AVX10] Disable m[no-]avx10.1 and switch m[no-]avx10.2 to alias of 512 bit options (PR #124511)

2025-01-29 Thread Phoebe Wang via cfe-commits

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

>From 806ed62f5c856ad15e5290da3b3b84ddcf9083d3 Mon Sep 17 00:00:00 2001
From: "Wang, Phoebe" 
Date: Mon, 27 Jan 2025 14:13:22 +0800
Subject: [PATCH 1/2] [X86][AVX10] Disable m[no-]avx10.1 and switch
 m[no-]avx10.2 to alias of 512
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Per the feedback we got, we’d like to switch m[no-]avx10.2 to alias of
512 bit options and disable m[no-]avx10.1 due to they were alias of 256
bit options.

We also change -mno-avx10.[1,2]-512 to alias of 256 bit options to disable
both 256 and 512 instructions.
---
 clang/docs/ReleaseNotes.rst   |  4 
 clang/include/clang/Driver/Options.td | 10 +-
 clang/test/Driver/x86-target-features.c   | 14 --
 clang/test/Preprocessor/x86_target_features.c |  3 +--
 4 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b63bd366cfe884..c9d84a34b9d44f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1117,6 +1117,10 @@ X86 Support
 - Support ISA of ``MOVRS``.
 
 - Supported ``-march/tune=diamondrapids``
+- Disable ``-m[no-]avx10.1`` and switch ``-m[no-]avx10.2`` to alias of 512 bit
+  options.
+- Change ``-mno-avx10.1-512`` to alias of ``-mno-avx10.1-256`` to disable both
+  256 and 512 bit instructions.
 
 Arm and AArch64 Support
 ^^^
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c5b7fcb7c7f09b..c55e242d47dbfd 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6424,14 +6424,14 @@ 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 mno_avx10_1_512 : Flag<["-"], "mno-avx10.1-512">, Alias;
+def mavx10_1 : Flag<["-"], "mavx10.1">, Flags<[Unsupported]>;
+def mno_avx10_1 : Flag<["-"], "mno-avx10.1">, Flags<[Unsupported]>;
 def mavx10_2_256 : Flag<["-"], "mavx10.2-256">, 
Group;
 def mno_avx10_2_256 : Flag<["-"], "mno-avx10.2-256">, 
Group;
 def mavx10_2_512 : Flag<["-"], "mavx10.2-512">, 
Group;
-def mno_avx10_2_512 : Flag<["-"], "mno-avx10.2-512">, 
Group;
-def mavx10_2 : Flag<["-"], "mavx10.2">, Alias;
+def mno_avx10_2_512 : Flag<["-"], "mno-avx10.2-512">, Alias;
+def mavx10_2 : Flag<["-"], "mavx10.2">, Alias;
 def mno_avx10_2 : Flag<["-"], "mno-avx10.2">, Alias;
 def mavx2 : Flag<["-"], "mavx2">, Group;
 def mno_avx2 : Flag<["-"], "mno-avx2">, Group;
diff --git a/clang/test/Driver/x86-target-features.c 
b/clang/test/Driver/x86-target-features.c
index 339f593dc760a8..8498416fe7ead7 100644
--- a/clang/test/Driver/x86-target-features.c
+++ b/clang/test/Driver/x86-target-features.c
@@ -395,7 +395,8 @@
 // EVEX512: "-target-feature" "+evex512"
 // NO-EVEX512: "-target-feature" "-evex512"
 
-// RUN: %clang --target=i386 -mavx10.1 %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=AVX10_1_256 %s
+// RUN: not %clang --target=i386 -march=i386 -mavx10.1 %s -### -o %t.o 2>&1 | 
FileCheck -check-prefix=UNSUPPORT-AVX10 %s
+// RUN: not %clang --target=i386 -march=i386 -mno-avx10.1 %s -### -o %t.o 2>&1 
| FileCheck -check-prefix=UNSUPPORT-AVX10 %s
 // RUN: %clang --target=i386 -mavx10.1-256 %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=AVX10_1_256 %s
 // RUN: %clang --target=i386 -mavx10.1-512 %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=AVX10_1_512 %s
 // RUN: %clang --target=i386 -mavx10.1-256 -mavx10.1-512 %s -### -o %t.o 2>&1 
| FileCheck -check-prefix=AVX10_1_512 %s
@@ -403,15 +404,16 @@
 // RUN: not %clang --target=i386 -march=i386 -mavx10.1-128 %s -### -o %t.o 
2>&1 | FileCheck -check-prefix=BAD-AVX10 %s
 // RUN: not %clang --target=i386 -march=i386 -mavx10.a-256 %s -### -o %t.o 
2>&1 | FileCheck -check-prefix=BAD-AVX10 %s
 // RUN: not %clang --target=i386 -march=i386 -mavx10.1024-512 %s -### -o %t.o 
2>&1 | FileCheck -check-prefix=BAD-AVX10 %s
-// RUN: %clang --target=i386 -march=i386 -mavx10.1 -mavx512f %s -### -o %t.o 
2>&1 | FileCheck -check-prefix=AVX10-AVX512 %s
-// RUN: %clang --target=i386 -march=i386 -mavx10.1 -mno-avx512f %s -### -o 
%t.o 2>&1 | FileCheck -check-prefix=AVX10-AVX512 %s
-// RUN: %clang --target=i386 -march=i386 -mavx10.1 -mevex512 %s -### -o %t.o 
2>&1 | FileCheck -check-prefix=AVX10-EVEX512 %s
-// RUN: %clang --target=i386 -march=i386 -mavx10.1 -mno-evex512 %s -### -o 
%t.o 2>&1 | FileCheck -check-prefix=AVX10-EVEX512 %s
-// RUN: %clang --target=i386 -mavx10.2 %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=AVX10_2_256 %s
+// RUN: %clang --target=i386 -march=i386 -mavx10.1-256 -mavx512f %s -###

[clang] [clang][bytecode] Handle non-primitive vector element types (PR #124926)

2025-01-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

By rejecting them. We would crash before.

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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Program.cpp (+10-4) 
- (added) clang/test/AST/ByteCode/neon.c (+19) 


``diff
diff --git a/clang/lib/AST/ByteCode/Program.cpp 
b/clang/lib/AST/ByteCode/Program.cpp
index 7d8862d606ba3c..1ffe7cd721f11f 100644
--- a/clang/lib/AST/ByteCode/Program.cpp
+++ b/clang/lib/AST/ByteCode/Program.cpp
@@ -453,15 +453,21 @@ Descriptor *Program::createDescriptor(const DeclTy &D, 
const Type *Ty,
 
   // Complex types - represented as arrays of elements.
   if (const auto *CT = Ty->getAs()) {
-PrimType ElemTy = *Ctx.classify(CT->getElementType());
-return allocateDescriptor(D, ElemTy, MDSize, 2, IsConst, IsTemporary,
+std::optional ElemTy = Ctx.classify(CT->getElementType());
+if (!ElemTy)
+  return nullptr;
+
+return allocateDescriptor(D, *ElemTy, MDSize, 2, IsConst, IsTemporary,
   IsMutable);
   }
 
   // Same with vector types.
   if (const auto *VT = Ty->getAs()) {
-PrimType ElemTy = *Ctx.classify(VT->getElementType());
-return allocateDescriptor(D, ElemTy, MDSize, VT->getNumElements(), IsConst,
+std::optional ElemTy = Ctx.classify(VT->getElementType());
+if (!ElemTy)
+  return nullptr;
+
+return allocateDescriptor(D, *ElemTy, MDSize, VT->getNumElements(), 
IsConst,
   IsTemporary, IsMutable);
   }
 
diff --git a/clang/test/AST/ByteCode/neon.c b/clang/test/AST/ByteCode/neon.c
new file mode 100644
index 00..5905d780860399
--- /dev/null
+++ b/clang/test/AST/ByteCode/neon.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon 
-disable-O0-optnone -emit-llvm -o - %s -fexperimental-new-constant-interpreter
+
+// REQUIRES: aarch64-registered-target
+
+/// This just tests that we're not crashing with a non-primitive vector 
element type.
+
+typedef __mfp8 mfloat8_t;
+typedef __bf16 bfloat16_t;
+
+typedef __attribute__((neon_vector_type(8))) mfloat8_t mfloat8x8_t;
+typedef __attribute__((neon_vector_type(8))) bfloat16_t bfloat16x8_t;
+
+typedef __UINT64_TYPE__ fpm_t;
+#define __ai static __inline__ __attribute__((__always_inline__, __nodebug__))
+__ai __attribute__((target("fp8,neon"))) bfloat16x8_t 
vcvt1_bf16_mf8_fpm(mfloat8x8_t __p0, fpm_t __p1) {
+  bfloat16x8_t __ret;
+  __ret = (bfloat16x8_t) __builtin_neon_vcvt1_bf16_mf8_fpm(__p0, __p1);
+  return __ret;
+}

``




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


[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2025-01-29 Thread Fraser Cormack via cfe-commits


@@ -0,0 +1,21 @@
+// TYPE sign(TYPE x) {
+//   if (isnan(x)) {
+// return 0.0F;
+//   }
+//   if (x > 0.0F) {
+// return 1.0F;
+//   }
+//   if (x < 0.0F) {
+// return -1.0F;
+//   }
+//   return x; /* -0.0 or +0.0 */
+// }
+_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_sign(__CLC_GENTYPE x) {
+  __CLC_BIT_INTN x_isnan = __clc_isnan(x);
+  __CLC_BIT_INTN x_isgreater_zero = x > __CLC_FP_LIT(0.0);
+  __CLC_BIT_INTN x_isless_zero = x < __CLC_FP_LIT(0.0);
+  __CLC_GENTYPE sel0 = __clc_select(x, __CLC_FP_LIT(1.0), x_isgreater_zero);
+  __CLC_GENTYPE sel1 = __clc_select(sel0, __CLC_FP_LIT(-1.0), x_isless_zero);
+  __CLC_GENTYPE sel2 = __clc_select(sel1, __CLC_FP_LIT(0.0), x_isnan);
+  return sel2;
+}

frasercrmck wrote:

Nice idea, thanks. I think we have to account for `%x` being NaN in the 
`copysign` though. Alive2 picks up on the fact that we'd copy the sign bit from 
a negative NaN and return `-0.0`: https://alive2.llvm.org/ce/z/8E6wp8. The 
`@src` there is what's generated by this patch.

Note that the OpenCL-CTS seems happy enough with either version, which is 
unexpected.

If we had `return copysign((__builtin_isnan(x) || (x == 0.0f)) ? 0.0f : 1.0f, 
__builtin_isnan(x) ? 0.0 : x);` then Alive2 is happy enough. The double check 
for NaN starts to look a bit off, but the IR produced is:

``` llvm
define float @tgt(float %a) {
  %v0 = fcmp ord float %a, 0.00e+00
  %v1 = fcmp ueq float %a, 0.00e+00
  %cond.i = select i1 %v1, float 0.00e+00, float 1.00e+00
  %cond3.i = select i1 %v0, float %a, float 0.00e+00
  %v2 = tail call noundef float @llvm.copysign.f32(float %cond.i, float 
%cond3.i)
  ret float %v2
}
```

What do you think? Still better than the triple fcmp + triple select?

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


[clang] [AArch64] Refactor implementation of FP8 types (NFC) (PR #123604)

2025-01-29 Thread Momchil Velikov via cfe-commits

momchil-velikov wrote:

> Is `__mfp8` a floating type? `isFloatingType()` on it returns `false`, was 
> that the case before as well?

It was the case before and it's intentional. That type is more like a union of 
two floating-point types.

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


[clang] [clang][bytecode] Handle non-primitive vector element types (PR #124926)

2025-01-29 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/124926

By rejecting them. We would crash before.

>From bd1f50f8ef4ea1139f3058b1c24a71e9cbee0823 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Wed, 29 Jan 2025 15:24:51 +0100
Subject: [PATCH] [clang][bytecode] Handle non-primitive vector element types

By rejecting them. We would crash before.
---
 clang/lib/AST/ByteCode/Program.cpp | 14 ++
 clang/test/AST/ByteCode/neon.c | 19 +++
 2 files changed, 29 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/AST/ByteCode/neon.c

diff --git a/clang/lib/AST/ByteCode/Program.cpp 
b/clang/lib/AST/ByteCode/Program.cpp
index 7d8862d606ba3c..1ffe7cd721f11f 100644
--- a/clang/lib/AST/ByteCode/Program.cpp
+++ b/clang/lib/AST/ByteCode/Program.cpp
@@ -453,15 +453,21 @@ Descriptor *Program::createDescriptor(const DeclTy &D, 
const Type *Ty,
 
   // Complex types - represented as arrays of elements.
   if (const auto *CT = Ty->getAs()) {
-PrimType ElemTy = *Ctx.classify(CT->getElementType());
-return allocateDescriptor(D, ElemTy, MDSize, 2, IsConst, IsTemporary,
+std::optional ElemTy = Ctx.classify(CT->getElementType());
+if (!ElemTy)
+  return nullptr;
+
+return allocateDescriptor(D, *ElemTy, MDSize, 2, IsConst, IsTemporary,
   IsMutable);
   }
 
   // Same with vector types.
   if (const auto *VT = Ty->getAs()) {
-PrimType ElemTy = *Ctx.classify(VT->getElementType());
-return allocateDescriptor(D, ElemTy, MDSize, VT->getNumElements(), IsConst,
+std::optional ElemTy = Ctx.classify(VT->getElementType());
+if (!ElemTy)
+  return nullptr;
+
+return allocateDescriptor(D, *ElemTy, MDSize, VT->getNumElements(), 
IsConst,
   IsTemporary, IsMutable);
   }
 
diff --git a/clang/test/AST/ByteCode/neon.c b/clang/test/AST/ByteCode/neon.c
new file mode 100644
index 00..5905d780860399
--- /dev/null
+++ b/clang/test/AST/ByteCode/neon.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon 
-disable-O0-optnone -emit-llvm -o - %s -fexperimental-new-constant-interpreter
+
+// REQUIRES: aarch64-registered-target
+
+/// This just tests that we're not crashing with a non-primitive vector 
element type.
+
+typedef __mfp8 mfloat8_t;
+typedef __bf16 bfloat16_t;
+
+typedef __attribute__((neon_vector_type(8))) mfloat8_t mfloat8x8_t;
+typedef __attribute__((neon_vector_type(8))) bfloat16_t bfloat16x8_t;
+
+typedef __UINT64_TYPE__ fpm_t;
+#define __ai static __inline__ __attribute__((__always_inline__, __nodebug__))
+__ai __attribute__((target("fp8,neon"))) bfloat16x8_t 
vcvt1_bf16_mf8_fpm(mfloat8x8_t __p0, fpm_t __p1) {
+  bfloat16x8_t __ret;
+  __ret = (bfloat16x8_t) __builtin_neon_vcvt1_bf16_mf8_fpm(__p0, __p1);
+  return __ret;
+}

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


[clang] Add clang atomic control options and attribute (PR #114841)

2025-01-29 Thread Yaxun Liu via cfe-commits


@@ -0,0 +1,19 @@
+//===--- AtomicOptions.def - Atomic Options database -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+// This file defines the Atomic language options. Users of this file
+// must define the OPTION macro to make use of this information.
+#ifndef OPTION
+#  error Define the OPTION macro to handle atomic language options
+#endif
+
+// OPTION(name, type, width, previousName)
+OPTION(NoRemoteMemory, bool, 1, First)
+OPTION(NoFineGrainedMemory, bool, 1, NoRemoteMemory)
+OPTION(IgnoreDenormalMode, bool, 1, NoFineGrainedMemory)

yxsamliu wrote:

I understand the desire to avoid negative naming in APIs. However, in this 
case, the negative naming (NoRemoteMemory, NoFineGrainedMemory) actually better 
reflects the IR structure. By default, atomic instructions in IR have no 
metadata, which corresponds to the conservative worst case (memory may be 
remote/fine-grained). The metadata we add serves as explicit performance hints 
promising the memory is not remote/fine-grained.
If we used positive names like RemoteMemory, it would imply there's a default 
remote_memory metadata in IR, which isn't true and could cause confusion. The 
current negative naming makes it clearer that we're adding explicit metadata to 
opt out of the conservative default behavior.

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


[clang] [Fuchsia] Support PGO (PR #120323)

2025-01-29 Thread via cfe-commits

Andarwinux wrote:

Any progress on this PR? I'm using Fuchsia Clang as CI compiler and PGO will be 
able to save a lot of time.

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


[clang] [X86][AVX10] Disable m[no-]avx10.1 and switch m[no-]avx10.2 to alias of 512 bit options (PR #124511)

2025-01-29 Thread Phoebe Wang via cfe-commits

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

>From 806ed62f5c856ad15e5290da3b3b84ddcf9083d3 Mon Sep 17 00:00:00 2001
From: "Wang, Phoebe" 
Date: Mon, 27 Jan 2025 14:13:22 +0800
Subject: [PATCH 1/2] [X86][AVX10] Disable m[no-]avx10.1 and switch
 m[no-]avx10.2 to alias of 512
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Per the feedback we got, we’d like to switch m[no-]avx10.2 to alias of
512 bit options and disable m[no-]avx10.1 due to they were alias of 256
bit options.

We also change -mno-avx10.[1,2]-512 to alias of 256 bit options to disable
both 256 and 512 instructions.
---
 clang/docs/ReleaseNotes.rst   |  4 
 clang/include/clang/Driver/Options.td | 10 +-
 clang/test/Driver/x86-target-features.c   | 14 --
 clang/test/Preprocessor/x86_target_features.c |  3 +--
 4 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b63bd366cfe884..c9d84a34b9d44f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1117,6 +1117,10 @@ X86 Support
 - Support ISA of ``MOVRS``.
 
 - Supported ``-march/tune=diamondrapids``
+- Disable ``-m[no-]avx10.1`` and switch ``-m[no-]avx10.2`` to alias of 512 bit
+  options.
+- Change ``-mno-avx10.1-512`` to alias of ``-mno-avx10.1-256`` to disable both
+  256 and 512 bit instructions.
 
 Arm and AArch64 Support
 ^^^
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c5b7fcb7c7f09b..c55e242d47dbfd 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6424,14 +6424,14 @@ 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 mno_avx10_1_512 : Flag<["-"], "mno-avx10.1-512">, Alias;
+def mavx10_1 : Flag<["-"], "mavx10.1">, Flags<[Unsupported]>;
+def mno_avx10_1 : Flag<["-"], "mno-avx10.1">, Flags<[Unsupported]>;
 def mavx10_2_256 : Flag<["-"], "mavx10.2-256">, 
Group;
 def mno_avx10_2_256 : Flag<["-"], "mno-avx10.2-256">, 
Group;
 def mavx10_2_512 : Flag<["-"], "mavx10.2-512">, 
Group;
-def mno_avx10_2_512 : Flag<["-"], "mno-avx10.2-512">, 
Group;
-def mavx10_2 : Flag<["-"], "mavx10.2">, Alias;
+def mno_avx10_2_512 : Flag<["-"], "mno-avx10.2-512">, Alias;
+def mavx10_2 : Flag<["-"], "mavx10.2">, Alias;
 def mno_avx10_2 : Flag<["-"], "mno-avx10.2">, Alias;
 def mavx2 : Flag<["-"], "mavx2">, Group;
 def mno_avx2 : Flag<["-"], "mno-avx2">, Group;
diff --git a/clang/test/Driver/x86-target-features.c 
b/clang/test/Driver/x86-target-features.c
index 339f593dc760a8..8498416fe7ead7 100644
--- a/clang/test/Driver/x86-target-features.c
+++ b/clang/test/Driver/x86-target-features.c
@@ -395,7 +395,8 @@
 // EVEX512: "-target-feature" "+evex512"
 // NO-EVEX512: "-target-feature" "-evex512"
 
-// RUN: %clang --target=i386 -mavx10.1 %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=AVX10_1_256 %s
+// RUN: not %clang --target=i386 -march=i386 -mavx10.1 %s -### -o %t.o 2>&1 | 
FileCheck -check-prefix=UNSUPPORT-AVX10 %s
+// RUN: not %clang --target=i386 -march=i386 -mno-avx10.1 %s -### -o %t.o 2>&1 
| FileCheck -check-prefix=UNSUPPORT-AVX10 %s
 // RUN: %clang --target=i386 -mavx10.1-256 %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=AVX10_1_256 %s
 // RUN: %clang --target=i386 -mavx10.1-512 %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=AVX10_1_512 %s
 // RUN: %clang --target=i386 -mavx10.1-256 -mavx10.1-512 %s -### -o %t.o 2>&1 
| FileCheck -check-prefix=AVX10_1_512 %s
@@ -403,15 +404,16 @@
 // RUN: not %clang --target=i386 -march=i386 -mavx10.1-128 %s -### -o %t.o 
2>&1 | FileCheck -check-prefix=BAD-AVX10 %s
 // RUN: not %clang --target=i386 -march=i386 -mavx10.a-256 %s -### -o %t.o 
2>&1 | FileCheck -check-prefix=BAD-AVX10 %s
 // RUN: not %clang --target=i386 -march=i386 -mavx10.1024-512 %s -### -o %t.o 
2>&1 | FileCheck -check-prefix=BAD-AVX10 %s
-// RUN: %clang --target=i386 -march=i386 -mavx10.1 -mavx512f %s -### -o %t.o 
2>&1 | FileCheck -check-prefix=AVX10-AVX512 %s
-// RUN: %clang --target=i386 -march=i386 -mavx10.1 -mno-avx512f %s -### -o 
%t.o 2>&1 | FileCheck -check-prefix=AVX10-AVX512 %s
-// RUN: %clang --target=i386 -march=i386 -mavx10.1 -mevex512 %s -### -o %t.o 
2>&1 | FileCheck -check-prefix=AVX10-EVEX512 %s
-// RUN: %clang --target=i386 -march=i386 -mavx10.1 -mno-evex512 %s -### -o 
%t.o 2>&1 | FileCheck -check-prefix=AVX10-EVEX512 %s
-// RUN: %clang --target=i386 -mavx10.2 %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=AVX10_2_256 %s
+// RUN: %clang --target=i386 -march=i386 -mavx10.1-256 -mavx512f %s -###

[clang] [ARM] Forbid use of TLS with execute-only (PR #124806)

2025-01-29 Thread Oliver Stannard via cfe-commits

https://github.com/ostannard updated 
https://github.com/llvm/llvm-project/pull/124806

>From 2a1fb2ed2a91cf0a3da2c24b7e4c68fd5fc81751 Mon Sep 17 00:00:00 2001
From: Oliver Stannard 
Date: Tue, 28 Jan 2025 17:49:42 +
Subject: [PATCH] [ARM] Forbid use of TLS with execute-only

Thread-local code generation requires constant pools because most of the
relocations needed for it operate on data, so it cannot be used with
-mexecute-only (or -mpure-code, which is aliased in the driver).

Without this we hit an assertion in the backend when trying to generate
a constant pool.
---
 clang/lib/Basic/Targets/ARM.cpp|  2 ++
 clang/test/Sema/arm-execute-only-tls.c | 10 ++
 2 files changed, 12 insertions(+)
 create mode 100644 clang/test/Sema/arm-execute-only-tls.c

diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index 0fd5433a76402ef..5aa2baeb81b731c 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -608,6 +608,8 @@ bool 
ARMTargetInfo::handleTargetFeatures(std::vector &Features,
   HasBTI = 1;
 } else if (Feature == "+fullbf16") {
   HasFullBFloat16 = true;
+} else if (Feature == "+execute-only") {
+  TLSSupported = false;
 }
   }
 
diff --git a/clang/test/Sema/arm-execute-only-tls.c 
b/clang/test/Sema/arm-execute-only-tls.c
new file mode 100644
index 000..b17ff450cb74d16
--- /dev/null
+++ b/clang/test/Sema/arm-execute-only-tls.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple arm-none-eabi   
-fsyntax-only -verify=default  %s
+// RUN: %clang_cc1 -triple arm-none-eabi -target-feature +execute-only 
-fsyntax-only -verify=execute-only %s
+
+// default-no-diagnostics
+
+/// Thread-local code generation requires constant pools because most of the
+/// relocations needed for it operate on data, so it cannot be used with
+/// -mexecute-only (or -mpure-code, which is aliased in the driver).
+
+_Thread_local int t; // execute-only-error {{thread-local storage is not 
supported for the current target}}

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


[clang] [clang-format] Add AlignAfterOpenBracketOptions (PR #108332)

2025-01-29 Thread Björn Schäpers via cfe-commits

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


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


[clang] [clang-format] Add ClassHeadName to help annotating StartOfName (PR #124891)

2025-01-29 Thread Björn Schäpers via cfe-commits

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


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


[clang] Optimize -Wunsafe-buffer-usage. (PR #124554)

2025-01-29 Thread Ilya Biryukov via cfe-commits


@@ -186,106 +213,221 @@ class MatchDescendantVisitor : public 
DynamicRecursiveASTVisitor {
 return DynamicRecursiveASTVisitor::TraverseStmt(Node);
   }
 
+  void setASTContext(ASTContext &Context) { ActiveASTContext = &Context; }
+
+  void setHandler(const UnsafeBufferUsageHandler &NewHandler) {
+Handler = &NewHandler;
+  }
+
 private:
   // Sets 'Matched' to true if 'Matcher' matches 'Node'
   //
   // Returns 'true' if traversal should continue after this function
   // returns, i.e. if no match is found or 'Bind' is 'BK_All'.
   template  bool match(const T &Node) {
-internal::BoundNodesTreeBuilder RecursiveBuilder(*Builder);
-
-if (Matcher->matches(DynTypedNode::create(Node), Finder,
- &RecursiveBuilder)) {
-  ResultBindings.addMatch(RecursiveBuilder);
+if (Matcher->matches(DynTypedNode::create(Node), *ActiveASTContext,
+ *Handler)) {
   Matches = true;
-  if (Bind != internal::ASTMatchFinder::BK_All)
+  if (!FindAll)
 return false; // Abort as soon as a match is found.
 }
 return true;
   }
 
-  const internal::DynTypedMatcher *const Matcher;
-  internal::ASTMatchFinder *const Finder;
-  internal::BoundNodesTreeBuilder *const Builder;
-  internal::BoundNodesTreeBuilder ResultBindings;
-  const internal::ASTMatchFinder::BindKind Bind;
+  FastMatcher *const Matcher;
+  // When true, finds all matches. When false, finds the first match and stops.
+  const bool FindAll;
   bool Matches;
   bool ignoreUnevaluatedContext;
+  ASTContext *ActiveASTContext;
+  const UnsafeBufferUsageHandler *Handler;
 };
 
 // Because we're dealing with raw pointers, let's define what we mean by that.
-static auto hasPointerType() {
-  return hasType(hasCanonicalType(pointerType()));
+static bool hasPointerType(const Expr &E) {
+  return isa(E.getType().getCanonicalType());
 }
 
-static auto hasArrayType() { return hasType(hasCanonicalType(arrayType())); }
-
-AST_MATCHER_P(Stmt, forEachDescendantEvaluatedStmt, internal::Matcher,
-  innerMatcher) {
-  const DynTypedMatcher &DTM = static_cast(innerMatcher);
-
-  MatchDescendantVisitor Visitor(&DTM, Finder, Builder, ASTMatchFinder::BK_All,
- true);
-  return Visitor.findMatch(DynTypedNode::create(Node));
+static bool hasArrayType(const Expr &E) {
+  return isa(E.getType().getCanonicalType());
 }
 
-AST_MATCHER_P(Stmt, forEachDescendantStmt, internal::Matcher,
-  innerMatcher) {
-  const DynTypedMatcher &DTM = static_cast(innerMatcher);
+static void
+forEachDescendantEvaluatedStmt(const Stmt *S, ASTContext &Ctx,
+   const UnsafeBufferUsageHandler &Handler,
+   FastMatcher &Matcher) {
+  MatchDescendantVisitor Visitor(Matcher, /* FindAll */ true,
+ /*ignoreUnevaluatedContext*/ true);
+  Visitor.setASTContext(Ctx);
+  Visitor.setHandler(Handler);
+  Visitor.findMatch(DynTypedNode::create(*S));
+}
 
-  MatchDescendantVisitor Visitor(&DTM, Finder, Builder, ASTMatchFinder::BK_All,
- false);
-  return Visitor.findMatch(DynTypedNode::create(Node));
+static void forEachDescendantStmt(const Stmt *S, ASTContext &Ctx,
+  const UnsafeBufferUsageHandler &Handler,
+  FastMatcher &Matcher) {
+  MatchDescendantVisitor Visitor(Matcher, /* FindAll */ true,
+ /*ignoreUnevaluatedContext*/ false);
+  Visitor.setASTContext(Ctx);
+  Visitor.setHandler(Handler);
+  Visitor.findMatch(DynTypedNode::create(*S));
 }
 
 // Matches a `Stmt` node iff the node is in a safe-buffer opt-out region
-AST_MATCHER_P(Stmt, notInSafeBufferOptOut, const UnsafeBufferUsageHandler *,
-  Handler) {
+static bool notInSafeBufferOptOut(const Stmt &Node,
+  const UnsafeBufferUsageHandler *Handler) {
   return !Handler->isSafeBufferOptOut(Node.getBeginLoc());
 }
 
-AST_MATCHER_P(Stmt, ignoreUnsafeBufferInContainer,
-  const UnsafeBufferUsageHandler *, Handler) {
+static bool
+ignoreUnsafeBufferInContainer(const Stmt &Node,
+  const UnsafeBufferUsageHandler *Handler) {
   return Handler->ignoreUnsafeBufferInContainer(Node.getBeginLoc());
 }
 
-AST_MATCHER_P(Stmt, ignoreUnsafeLibcCall, const UnsafeBufferUsageHandler *,
-  Handler) {
-  if (Finder->getASTContext().getLangOpts().CPlusPlus)
+static bool ignoreUnsafeLibcCall(const ASTContext &Ctx, const Stmt &Node,
+ const UnsafeBufferUsageHandler *Handler) {
+  if (Ctx.getLangOpts().CPlusPlus)
 return Handler->ignoreUnsafeBufferInLibcCall(Node.getBeginLoc());
   return true; /* Only warn about libc calls for C++ */
 }
 
-AST_MATCHER_P(CastExpr, castSubExpr, internal::Matcher, innerMatcher) {
-  return innerMatcher.matches(*Node.getSubExpr(), Finder, Builder);
+// Finds any

[clang] [llvm] [LLVM][AMDGPU] Add Intrinsic and Builtin for ds_bpermute_fi_b32 (PR #124616)

2025-01-29 Thread Jay Foad via cfe-commits

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

LGTM

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


[clang] [TBAA] Don't emit pointer-tbaa for void pointers. (PR #122116)

2025-01-29 Thread Florian Hahn via cfe-commits

https://github.com/fhahn updated 
https://github.com/llvm/llvm-project/pull/122116

>From bac0f4a9dfbf375d876bc84c4474a533cbecec0e Mon Sep 17 00:00:00 2001
From: Florian Hahn 
Date: Wed, 8 Jan 2025 13:07:01 +
Subject: [PATCH 1/7] [TBAA] Don't emit pointer-tbaa for void pointers.

While there are no special rules in the standards regarding
void pointers and strict aliasing, emitting distinct tags for void
pointers break some common idioms and there is no good alternative to
re-write the code without strict-aliasing violations. An example is
to count the entries in an array of pointers:

int count_elements(void * values) {
  void **seq = values;
  int count;
  for (count = 0; seq && seq[count]; count++);
  return count;
}

https://clang.godbolt.org/z/8dTv51v8W

An example in the wild is from
https://github.com/llvm/llvm-project/issues/119099

This patch avoids emitting distinct tags for void pointers, to avoid
those idioms causing mis-compiles for now.
---
 clang/lib/CodeGen/CodeGenTBAA.cpp  |  8 
 clang/test/CodeGen/tbaa-pointers.c | 13 +++--
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenTBAA.cpp 
b/clang/lib/CodeGen/CodeGenTBAA.cpp
index 75e66bae79afdc..3f1a24791ddd81 100644
--- a/clang/lib/CodeGen/CodeGenTBAA.cpp
+++ b/clang/lib/CodeGen/CodeGenTBAA.cpp
@@ -226,6 +226,14 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type 
*Ty) {
   PtrDepth++;
   Ty = Ty->getPointeeType()->getBaseElementTypeUnsafe();
 } while (Ty->isPointerType());
+
+// While there are no special rules in the standards regarding void 
pointers
+// and strict aliasing, emitting distinct tags for void pointers break some
+// common idioms and there is no good alternative to re-write the code
+// without strict-aliasing violations.
+if (Ty->isVoidType())
+  return AnyPtr;
+
 assert(!isa(Ty));
 // When the underlying type is a builtin type, we compute the pointee type
 // string recursively, which is implicitly more forgiving than the 
standards
diff --git a/clang/test/CodeGen/tbaa-pointers.c 
b/clang/test/CodeGen/tbaa-pointers.c
index 4aae2552f107a3..48adac503357f0 100644
--- a/clang/test/CodeGen/tbaa-pointers.c
+++ b/clang/test/CodeGen/tbaa-pointers.c
@@ -208,12 +208,9 @@ int void_ptrs(void **ptr) {
 // COMMON-LABEL: define i32 @void_ptrs(
 // COMMON-SAME: ptr noundef [[PTRA:%.+]])
 // COMMON:[[PTR_ADDR:%.+]]  = alloca ptr, align 8
-// DISABLE-NEXT:  store ptr [[PTRA]], ptr [[PTR_ADDR]], align 8, !tbaa 
[[ANYPTR]]
-// DISABLE-NEXT:  [[L0:%.+]] = load ptr, ptr  [[PTR_ADDR]], align 8, !tbaa  
[[ANYPTR]]
-// DISABLE-NEXT:  [[L1:%.+]] = load ptr, ptr [[L0]], align 8, !tbaa  [[ANYPTR]]
-// DEFAULT-NEXT:  store ptr [[PTRA]], ptr [[PTR_ADDR]], align 8, !tbaa 
[[P2VOID:!.+]]
-// DEFAULT-NEXT:  [[L0:%.+]] = load ptr, ptr  [[PTR_ADDR]], align 8, !tbaa  
[[P2VOID]]
-// DEFAULT-NEXT:  [[L1:%.+]] = load ptr, ptr [[L0]], align 8, !tbaa  
[[P1VOID:!.+]]
+// COMMON-NEXT:   store ptr [[PTRA]], ptr [[PTR_ADDR]], align 8, !tbaa 
[[ANYPTR]]
+// COMMON-NEXT:   [[L0:%.+]] = load ptr, ptr  [[PTR_ADDR]], align 8, !tbaa  
[[ANYPTR]]
+// COMMON-NEXT:   [[L1:%.+]] = load ptr, ptr [[L0]], align 8, !tbaa  [[ANYPTR]]
 // COMMON-NEXT:   [[BOOL:%.+]] = icmp ne ptr [[L1]], null
 // COMMON-NEXT:   [[BOOL_EXT:%.+]] = zext i1 [[BOOL]] to i64
 // COMMON-NEXT:   [[COND:%.+]] = select i1 [[BOOL]], i32 0, i32 1
@@ -254,7 +251,3 @@ int void_ptrs(void **ptr) {
 // COMMON:  [[INT_TAG]] = !{[[INT_TY:!.+]], [[INT_TY]], i64 0}
 // COMMON:  [[INT_TY]] = !{!"int", [[CHAR]], i64 0}
 // DEFAULT: [[ANYPTR]] = !{[[ANY_POINTER]],  [[ANY_POINTER]], i64 0}
-// DEFAULT: [[P2VOID]] = !{[[P2VOID_TY:!.+]], [[P2VOID_TY]], i64 0}
-// DEFAULT: [[P2VOID_TY]] = !{!"p2 void", [[ANY_POINTER]], i64 0}
-// DEFAULT: [[P1VOID]] = !{[[P1VOID_TY:!.+]], [[P1VOID_TY]], i64 0}
-// DEFAULT: [[P1VOID_TY]] = !{!"p1 void", [[ANY_POINTER]], i64 0}

>From eaa5206563a00dfe54e18594175228cca09230a0 Mon Sep 17 00:00:00 2001
From: Florian Hahn 
Date: Thu, 9 Jan 2025 11:49:55 +
Subject: [PATCH 2/7] !fixup update remaining tests accessing void *

---
 .../CodeGenOpenCL/amdgpu-enqueue-kernel.cl| 25 +--
 clang/unittests/CodeGen/TBAAMetadataTest.cpp  |  5 +---
 2 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/clang/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl 
b/clang/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl
index 5599f4dd50f042..ace34dd0ca6dce 100644
--- a/clang/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl
+++ b/clang/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl
@@ -651,7 +651,7 @@ kernel void test_target_features_kernel(global int *i) {
 //
 // GFX900: Function Attrs: convergent nounwind
 // GFX900-LABEL: define {{[^@]+}}@__test_block_invoke_3_kernel
-// GFX900-SAME: (<{ i32, i32, ptr, ptr addrspace(1), ptr addrspace(1), i64, i8 
}> [[TMP0:%.*]], ptr addrspace(3) [[TMP1:%.*]]) #[[ATTR6]] 
!kernel_arg_addr_space [[META28:![0-9]+]] !kernel

[clang] [TBAA] Don't emit pointer-tbaa for void pointers. (PR #122116)

2025-01-29 Thread Florian Hahn via cfe-commits


@@ -2489,6 +2489,30 @@ are listed below.
 
 $ clang -fuse-ld=lld -Oz -Wl,--icf=safe -fcodegen-data-use code.cc
 
+Strict Aliasing
+---
+
+Clang by default applies C/C++'s strict aliasing rules during optimizations. In
+cases C and C++ rules diverge, the more conservative rules are used. Clang does
+not make use of strict aliasing rules in all cases yet, including unions and
+variable-sized arrays. That may change in the future.
+
+Internally Clang encodes the strict aliasing rules in LLVM IR using type-based
+alias analysis (TBAA) metadata.
+
+Note that clang-cl disables strict aliasing by default, see
+:ref:`Strict aliasing in clang-cl. `
+
+As of Clang 20, strict aliasing rules are also applied to nested pointers. The
+new behavior can be disabled using ``-fno-pointer-tbaa``. Note that Clang does
+not apply strict aliasing rules to `void*` pointers to avoid breaking existing
+code, even though this is not required by the standard.
+
+Strict aliasing violations in the source may change program behavior and
+``-fno-strict-aliasing`` disables use of the strict aliasing rules. There also
+is an experimental :ref:`TypeSanitizer ` to detect strict
+aliasing violations.

fhahn wrote:

That's much better, updated thanks!

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


[clang] Optimize -Wunsafe-buffer-usage. (PR #124554)

2025-01-29 Thread via cfe-commits


@@ -186,106 +213,221 @@ class MatchDescendantVisitor : public 
DynamicRecursiveASTVisitor {
 return DynamicRecursiveASTVisitor::TraverseStmt(Node);
   }
 
+  void setASTContext(ASTContext &Context) { ActiveASTContext = &Context; }
+
+  void setHandler(const UnsafeBufferUsageHandler &NewHandler) {
+Handler = &NewHandler;
+  }
+
 private:
   // Sets 'Matched' to true if 'Matcher' matches 'Node'
   //
   // Returns 'true' if traversal should continue after this function
   // returns, i.e. if no match is found or 'Bind' is 'BK_All'.
   template  bool match(const T &Node) {
-internal::BoundNodesTreeBuilder RecursiveBuilder(*Builder);
-
-if (Matcher->matches(DynTypedNode::create(Node), Finder,
- &RecursiveBuilder)) {
-  ResultBindings.addMatch(RecursiveBuilder);
+if (Matcher->matches(DynTypedNode::create(Node), *ActiveASTContext,
+ *Handler)) {
   Matches = true;
-  if (Bind != internal::ASTMatchFinder::BK_All)
+  if (!FindAll)
 return false; // Abort as soon as a match is found.
 }
 return true;
   }
 
-  const internal::DynTypedMatcher *const Matcher;
-  internal::ASTMatchFinder *const Finder;
-  internal::BoundNodesTreeBuilder *const Builder;
-  internal::BoundNodesTreeBuilder ResultBindings;
-  const internal::ASTMatchFinder::BindKind Bind;
+  FastMatcher *const Matcher;
+  // When true, finds all matches. When false, finds the first match and stops.
+  const bool FindAll;
   bool Matches;
   bool ignoreUnevaluatedContext;
+  ASTContext *ActiveASTContext;
+  const UnsafeBufferUsageHandler *Handler;
 };
 
 // Because we're dealing with raw pointers, let's define what we mean by that.
-static auto hasPointerType() {
-  return hasType(hasCanonicalType(pointerType()));
+static bool hasPointerType(const Expr &E) {
+  return isa(E.getType().getCanonicalType());
 }
 
-static auto hasArrayType() { return hasType(hasCanonicalType(arrayType())); }
-
-AST_MATCHER_P(Stmt, forEachDescendantEvaluatedStmt, internal::Matcher,
-  innerMatcher) {
-  const DynTypedMatcher &DTM = static_cast(innerMatcher);
-
-  MatchDescendantVisitor Visitor(&DTM, Finder, Builder, ASTMatchFinder::BK_All,
- true);
-  return Visitor.findMatch(DynTypedNode::create(Node));
+static bool hasArrayType(const Expr &E) {
+  return isa(E.getType().getCanonicalType());
 }
 
-AST_MATCHER_P(Stmt, forEachDescendantStmt, internal::Matcher,
-  innerMatcher) {
-  const DynTypedMatcher &DTM = static_cast(innerMatcher);
+static void
+forEachDescendantEvaluatedStmt(const Stmt *S, ASTContext &Ctx,
+   const UnsafeBufferUsageHandler &Handler,
+   FastMatcher &Matcher) {
+  MatchDescendantVisitor Visitor(Matcher, /* FindAll */ true,
+ /*ignoreUnevaluatedContext*/ true);
+  Visitor.setASTContext(Ctx);
+  Visitor.setHandler(Handler);
+  Visitor.findMatch(DynTypedNode::create(*S));
+}
 
-  MatchDescendantVisitor Visitor(&DTM, Finder, Builder, ASTMatchFinder::BK_All,
- false);
-  return Visitor.findMatch(DynTypedNode::create(Node));
+static void forEachDescendantStmt(const Stmt *S, ASTContext &Ctx,
+  const UnsafeBufferUsageHandler &Handler,
+  FastMatcher &Matcher) {
+  MatchDescendantVisitor Visitor(Matcher, /* FindAll */ true,
+ /*ignoreUnevaluatedContext*/ false);
+  Visitor.setASTContext(Ctx);
+  Visitor.setHandler(Handler);
+  Visitor.findMatch(DynTypedNode::create(*S));
 }
 
 // Matches a `Stmt` node iff the node is in a safe-buffer opt-out region
-AST_MATCHER_P(Stmt, notInSafeBufferOptOut, const UnsafeBufferUsageHandler *,
-  Handler) {
+static bool notInSafeBufferOptOut(const Stmt &Node,
+  const UnsafeBufferUsageHandler *Handler) {
   return !Handler->isSafeBufferOptOut(Node.getBeginLoc());
 }
 
-AST_MATCHER_P(Stmt, ignoreUnsafeBufferInContainer,
-  const UnsafeBufferUsageHandler *, Handler) {
+static bool
+ignoreUnsafeBufferInContainer(const Stmt &Node,
+  const UnsafeBufferUsageHandler *Handler) {
   return Handler->ignoreUnsafeBufferInContainer(Node.getBeginLoc());
 }
 
-AST_MATCHER_P(Stmt, ignoreUnsafeLibcCall, const UnsafeBufferUsageHandler *,
-  Handler) {
-  if (Finder->getASTContext().getLangOpts().CPlusPlus)
+static bool ignoreUnsafeLibcCall(const ASTContext &Ctx, const Stmt &Node,
+ const UnsafeBufferUsageHandler *Handler) {
+  if (Ctx.getLangOpts().CPlusPlus)
 return Handler->ignoreUnsafeBufferInLibcCall(Node.getBeginLoc());
   return true; /* Only warn about libc calls for C++ */
 }
 
-AST_MATCHER_P(CastExpr, castSubExpr, internal::Matcher, innerMatcher) {
-  return innerMatcher.matches(*Node.getSubExpr(), Finder, Builder);
+// Finds any

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #124554)

2025-01-29 Thread via cfe-commits

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


[clang] 978e083 - [OpenMP] Allow OMP6.0 features. (#122108)

2025-01-29 Thread via cfe-commits

Author: Zahira Ammarguellat
Date: 2025-01-29T07:51:02-05:00
New Revision: 978e0839ae2feb5ddda3e4e0b5a7ddba1727d2d8

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

LOG: [OpenMP] Allow OMP6.0 features. (#122108)

Add support for the `-fopenmp-version=60` command line argument. It is
needed for https://github.com/llvm/llvm-project/pull/119891 (`#pragma
omp stripe`) which will be the first OpenMP 6.0 directive implemented.
Add regression tests for Clang in `-fopenmp-version=60` mode.

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/test/OpenMP/declare_mapper_messages.c
clang/test/OpenMP/declare_target_ast_print.cpp
clang/test/OpenMP/declare_target_messages.cpp
clang/test/OpenMP/depobj_messages.cpp
clang/test/OpenMP/distribute_parallel_for_ast_print.cpp
clang/test/OpenMP/distribute_parallel_for_simd_ast_print.cpp
clang/test/OpenMP/distribute_simd_ast_print.cpp
clang/test/OpenMP/distribute_simd_misc_messages.c
clang/test/OpenMP/driver.c
clang/test/OpenMP/error_ast_print.cpp
clang/test/OpenMP/error_codegen.cpp
clang/test/OpenMP/error_message.cpp
clang/test/OpenMP/flush_ast_print.cpp
clang/test/OpenMP/flush_codegen.cpp
clang/test/OpenMP/for_linear_messages.cpp
clang/test/OpenMP/for_simd_ast_print.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 2097a83e870053..8411217be8c8a6 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4215,7 +4215,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, 
ArgList &Args,
 }
   }
 
-  // Check if -fopenmp is specified and set default version to 5.0.
+  // Check if -fopenmp is specified and set default version to 5.1.
   Opts.OpenMP = Args.hasArg(OPT_fopenmp) ? 51 : 0;
   // Check if -fopenmp-simd is specified.
   bool IsSimdSpecified =

diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 17f624e9645395..542e26b6a129b4 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -1466,9 +1466,15 @@ static void InitializePredefinedMacros(const TargetInfo 
&TI,
 case 50:
   Builder.defineMacro("_OPENMP", "201811");
   break;
+case 51:
+  Builder.defineMacro("_OPENMP", "202011");
+  break;
 case 52:
   Builder.defineMacro("_OPENMP", "202111");
   break;
+case 60:
+  Builder.defineMacro("_OPENMP", "202411");
+  break;
 default: // case 51:
   // Default version is OpenMP 5.1
   Builder.defineMacro("_OPENMP", "202011");

diff  --git a/clang/test/OpenMP/declare_mapper_messages.c 
b/clang/test/OpenMP/declare_mapper_messages.c
index 288caca097648c..22386892273110 100644
--- a/clang/test/OpenMP/declare_mapper_messages.c
+++ b/clang/test/OpenMP/declare_mapper_messages.c
@@ -1,10 +1,12 @@
 // RUN: %clang_cc1 -verify=omp50,expected -fopenmp -fopenmp-version=50 
-ferror-limit 100 -DOMP50 %s
 // RUN: %clang_cc1 -verify=omp51,expected -fopenmp -ferror-limit 100 %s
 // RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 
-ferror-limit 100 -DOMP52 %s
+// RUN: %clang_cc1 -verify=expected,omp60 -fopenmp -fopenmp-version=60 
-ferror-limit 100 -DOMP60 %s
 
 // RUN: %clang_cc1 -verify=omp50,expected -fopenmp-simd -fopenmp-version=50 
-ferror-limit 100 -DOMP50 %s
 // RUN: %clang_cc1 -verify=omp51-simd,expected -fopenmp-simd -ferror-limit 100 
%s
 // RUN: %clang_cc1 -verify=expected,omp52 -fopenmp-simd -fopenmp-version=52 
-ferror-limit 100 -DOMP52 %s
+// RUN: %clang_cc1 -verify=expected,omp60-simd -fopenmp-simd 
-fopenmp-version=60 -ferror-limit 100 -DOMP60 %s
 
 int temp; // expected-note {{'temp' declared here}}
 
@@ -32,11 +34,11 @@ struct vec {
// expec
 #pragma omp declare mapper(struct vec v) map(v.len) // 
expected-error {{redefinition of user-defined mapper for type 'struct vec' with 
name 'default'}}
 #pragma omp declare mapper(int v) map(v)// 
expected-error {{mapper type must be of struct, union or class type}}
 
-#ifndef OMP52
-// omp51-simd-error@+6 {{incorrect map type modifier, expected one of: 
'always', 'close', 'mapper', 'present', 'ompx_hold'}} 
-// omp50-error@+5 {{incorrect map type modifier, expected one of: 'always', 
'close', 'mapper', 'ompx_hold'}} 
-// omp51-error@+4 {{incorrect map type modifier, expected one of: 'always', 
'close', 'mapper', 'present', 'ompx_hold'}} 
-// expected-error@+3 {{only variable 'vvec' is allowed in map clauses of this 
'omp declare mapper' directive}} 
+#if !defined(OMP52) &

[clang] [OpenMP] Allow OMP6.0 features. (PR #122108)

2025-01-29 Thread Zahira Ammarguellat via cfe-commits

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


[clang] 3a29dfe - [LLVM][AMDGPU] Add Intrinsic and Builtin for ds_bpermute_fi_b32 (#124616)

2025-01-29 Thread via cfe-commits

Author: Acim Maravic
Date: 2025-01-29T14:04:10+01:00
New Revision: 3a29dfe37c585355dc70c7c614f5bbf071cd7efb

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

LOG: [LLVM][AMDGPU] Add Intrinsic and Builtin for ds_bpermute_fi_b32 (#124616)

Added: 
llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ds.bpermute.fi.b32.ll

Modified: 
clang/include/clang/Basic/BuiltinsAMDGPU.def
clang/test/CodeGenOpenCL/builtins-amdgcn-gfx11-err.cl
clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12.cl
llvm/include/llvm/IR/IntrinsicsAMDGPU.td
llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
llvm/lib/Target/AMDGPU/DSInstructions.td
llvm/test/MC/AMDGPU/gfx11_unsupported.s

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def 
b/clang/include/clang/Basic/BuiltinsAMDGPU.def
index 1b29a8e359c205..39e295aced96b2 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -504,6 +504,8 @@ TARGET_BUILTIN(__builtin_amdgcn_global_load_tr_b128_v4i16, 
"V4sV4s*1", "nc", "gf
 TARGET_BUILTIN(__builtin_amdgcn_global_load_tr_b128_v4f16, "V4hV4h*1", "nc", 
"gfx12-insts,wavefrontsize64")
 TARGET_BUILTIN(__builtin_amdgcn_global_load_tr_b128_v4bf16, "V4yV4y*1", "nc", 
"gfx12-insts,wavefrontsize64")
 
+TARGET_BUILTIN(__builtin_amdgcn_ds_bpermute_fi_b32, "iii", "nc", "gfx12-insts")
+
 
//===--===//
 // WMMA builtins.
 // Postfix w32 indicates the builtin requires wavefront size of 32.

diff  --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx11-err.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx11-err.cl
index 08f70a25276f17..d518fe3a11a81c 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx11-err.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx11-err.cl
@@ -2,7 +2,7 @@
 
 // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1100 -verify 
-emit-llvm -o - %s
 
-void test_s_sleep_var(int d)
-{
-  __builtin_amdgcn_s_sleep_var(d); // expected-error 
{{'__builtin_amdgcn_s_sleep_var' needs target feature gfx12-insts}}
+void builtin_test_unsupported(int a, int b) {
+  __builtin_amdgcn_s_sleep_var(a); // expected-error 
{{'__builtin_amdgcn_s_sleep_var' needs target feature gfx12-insts}}
+  b = __builtin_amdgcn_ds_bpermute_fi_b32(a, b); // expected-error 
{{'__builtin_amdgcn_ds_bpermute_fi_b32' needs target feature gfx12-insts}}
 }

diff  --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12.cl
index 5b5ae419f0a4a9..234ad4fd8cde61 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12.cl
@@ -296,3 +296,26 @@ void test_s_buffer_prefetch_data(__amdgpu_buffer_rsrc_t 
rsrc, unsigned int len)
   __builtin_amdgcn_s_buffer_prefetch_data(rsrc, 128, len);
   __builtin_amdgcn_s_buffer_prefetch_data(rsrc, 0, 31);
 }
+
+// CHECK-LABEL: @test_ds_bpermute_fi_b32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[OUT_ADDR:%.*]] = alloca ptr addrspace(1), align 8, 
addrspace(5)
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
+// CHECK-NEXT:[[OUT_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) 
[[OUT_ADDR]] to ptr
+// CHECK-NEXT:[[A_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) 
[[A_ADDR]] to ptr
+// CHECK-NEXT:[[B_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) 
[[B_ADDR]] to ptr
+// CHECK-NEXT:store ptr addrspace(1) [[OUT:%.*]], ptr [[OUT_ADDR_ASCAST]], 
align 8
+// CHECK-NEXT:store i32 [[A:%.*]], ptr [[A_ADDR_ASCAST]], align 4
+// CHECK-NEXT:store i32 [[B:%.*]], ptr [[B_ADDR_ASCAST]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr [[A_ADDR_ASCAST]], align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[B_ADDR_ASCAST]], align 4
+// CHECK-NEXT:[[TMP2:%.*]] = call i32 @llvm.amdgcn.ds.bpermute.fi.b32(i32 
[[TMP0]], i32 [[TMP1]])
+// CHECK-NEXT:[[TMP3:%.*]] = load ptr addrspace(1), ptr 
[[OUT_ADDR_ASCAST]], align 8
+// CHECK-NEXT:store i32 [[TMP2]], ptr addrspace(1) [[TMP3]], align 4
+// CHECK-NEXT:ret void
+//
+void test_ds_bpermute_fi_b32(global int* out, int a, int b)
+{
+  *out = __builtin_amdgcn_ds_bpermute_fi_b32(a, b);
+}

diff  --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td 
b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
index cc3584833202bf..f721d5267cd2a0 100644
--- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -2923,6 +2923,12 @@ def int_amdgcn_s_prefetch_data :
 "", [SDNPMemOperand]
   >;
 
+// llvm.amdgcn.ds.bpermute.fi.b32  
+def int_amdgcn_ds_bpermute_fi_b32 :
+  ClangBuiltin<"__builtin_amdgcn_ds_bpermute_fi_b32">,
+  Intrinsic<[llvm_i32_ty], [llvm_i32_ty,

[clang] [llvm] [LLVM][AMDGPU] Add Intrinsic and Builtin for ds_bpermute_fi_b32 (PR #124616)

2025-01-29 Thread Acim Maravic via cfe-commits

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


[clang] [llvm] [Clang] Cleanup docs and comments relating to -fextend-variable-liveness (PR #124767)

2025-01-29 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `premerge-monolithic-linux` 
running on `premerge-linux-1` while building `clang,llvm` at step 6 
"build-unified-tree".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/153/builds/21224


Here is the relevant piece of the build log for the reference

```
Step 6 (build-unified-tree) failure: build (failure)
0.008 [3601/6/1] Performing build step for 'bolt_rt'
ninja: no work to do.
0.012 [3600/6/2] No install step for 'bolt_rt'
0.014 [3599/6/3] Building CXX object 
tools/llvm-config/CMakeFiles/llvm-config.dir/llvm-config.cpp.o
0.017 [3598/6/4] Generating VCSRevision.h
0.026 [3595/8/5] Generating VCSVersion.inc
0.027 [3594/8/6] Completed 'bolt_rt'
0.027 [3594/7/7] Generating VCSVersion.inc
0.031 [3593/7/8] Building Options.inc...
FAILED: tools/clang/include/clang/Driver/Options.inc 
/build/buildbot/premerge-monolithic-linux/build/tools/clang/include/clang/Driver/Options.inc
 
cd /build/buildbot/premerge-monolithic-linux/build && 
/build/buildbot/premerge-monolithic-linux/build/bin/llvm-tblgen 
-gen-opt-parser-defs -I 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/include/clang/Driver
 -I/build/buildbot/premerge-monolithic-linux/llvm-project/clang/include 
-I/build/buildbot/premerge-monolithic-linux/build/tools/clang/include 
-I/build/buildbot/premerge-monolithic-linux/build/include 
-I/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/include 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/include/clang/Driver/Options.td
 --write-if-changed -o tools/clang/include/clang/Driver/Options.inc -d 
tools/clang/include/clang/Driver/Options.inc.d
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/include/clang/Driver/Options.td:4356:3:
 error: Expected comma before next argument
  Values<"all,this,none">,
  ^
0.088 [3593/6/9] Linking CXX executable bin/llvm-config
0.644 [3593/5/10] Building CXX object 
tools/flang/lib/Common/CMakeFiles/FortranCommon.dir/Version.cpp.o
1.313 [3593/4/11] Building CXX object 
tools/bolt/lib/Utils/CMakeFiles/LLVMBOLTUtils.dir/CommandLineOpts.cpp.o
2.710 [3593/3/12] Building CXX object 
lib/Object/CMakeFiles/LLVMObject.dir/IRSymtab.cpp.o
11.201 [3593/2/13] Building CXX object 
lib/CodeGen/AsmPrinter/CMakeFiles/LLVMAsmPrinter.dir/AsmPrinter.cpp.o
12.631 [3593/1/14] Building CXX object lib/LTO/CMakeFiles/LLVMLTO.dir/LTO.cpp.o
ninja: build stopped: subcommand failed.

```



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


[clang] [llvm] [mlir] Fix typo "tranpose" (PR #124929)

2025-01-29 Thread Jakub Kuderski via cfe-commits

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


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


[clang] [llvm] [ARM] Ensure FPU Selection can select mode correctly (PR #124935)

2025-01-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-arm

Author: Jack Styles (Stylie777)


Changes

Previously, when selecting a Single Precision FPU, LLVM would ensure all 
elements of the Candidate FPU matched the InputFPU that was given. However, for 
cases such as Cortex-R52, there are FPU options where not all fields match 
exactly, for example NEON Support or Restrictions on the Registers available.

This change ensures that LLVM can select the FPU correctly, removing the 
requirement for Neon Support and Restrictions for the Candidate FPU to be the 
same as the InputFPU.

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


4 Files Affected:

- (modified) clang/test/Preprocessor/arm-target-features.c (+16) 
- (modified) llvm/lib/TargetParser/ARMTargetParser.cpp (+4-5) 
- (added) llvm/test/MC/ARM/cortex-r52-nofp.s (+9) 
- (modified) llvm/unittests/TargetParser/TargetParserTest.cpp (+26) 


``diff
diff --git a/clang/test/Preprocessor/arm-target-features.c 
b/clang/test/Preprocessor/arm-target-features.c
index ecf9d7eb5c19c9..7395ed8b57f845 100644
--- a/clang/test/Preprocessor/arm-target-features.c
+++ b/clang/test/Preprocessor/arm-target-features.c
@@ -1013,3 +1013,19 @@
 // CHECK-MVE1_2: #define __ARM_FEATURE_MVE 1
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve.fp -x c -E 
-dM %s -o - | FileCheck -check-prefix=CHECK-MVE3 %s
 // CHECK-MVE3: #define __ARM_FEATURE_MVE 3
+
+// Cortex-R52 and Cortex-R52Plus correctly enable the `fpv5-sp-d16` FPU when 
compiling for the SP only version of the CPU.
+// RUN: %clang -target arm-none-eabi -mcpu=cortex-r52+nosimd+nofp.dp 
-mfloat-abi=hard -x c -E -dM -o - %s | FileCheck -check-prefix=CHECK-R52 %s
+// CHECK-R52: #define __ARM_FEATURE_FMA 1
+// CHECK-R52: #define __ARM_FP 0x6
+// CHECK-R52: #define __ARM_FPV5__ 1
+// CHECK-R52: #define __ARM_VFPV2__ 1
+// CHECK-R52-NEXT: #define __ARM_VFPV3__ 1
+// CHECK-R52-NEXT: #define __ARM_VFPV4__ 1
+// RUN: %clang -target arm-none-eabi -mcpu=cortex-r52plus+nosimd+nofp.dp 
-mfloat-abi=hard -x c -E -dM -o - %s | FileCheck -check-prefix=CHECK-R52PLUS %s
+// CHECK-R52PLUS: #define __ARM_FEATURE_FMA 1
+// CHECK-R52PLUS: #define __ARM_FP 0x6
+// CHECK-R52PLUS: #define __ARM_FPV5__ 1
+// CHECK-R52PLUS: #define __ARM_VFPV2__ 1
+// CHECK-R52PLUS-NEXT: #define __ARM_VFPV3__ 1
+// CHECK-R52PLUS-NEXT: #define __ARM_VFPV4__ 1
diff --git a/llvm/lib/TargetParser/ARMTargetParser.cpp 
b/llvm/lib/TargetParser/ARMTargetParser.cpp
index 9bcfa6ca62c97f..8f9753775c204a 100644
--- a/llvm/lib/TargetParser/ARMTargetParser.cpp
+++ b/llvm/lib/TargetParser/ARMTargetParser.cpp
@@ -403,13 +403,12 @@ static ARM::FPUKind findSinglePrecisionFPU(ARM::FPUKind 
InputFPUKind) {
   if (!ARM::isDoublePrecision(InputFPU.Restriction))
 return InputFPUKind;
 
-  // Otherwise, look for an FPU entry with all the same fields, except
-  // that it does not support double precision.
+  // Otherwise, look for an FPU entry that has the same FPUVer
+  // and is not Double Precision. We want to allow for changing of
+  // NEON Support and Restrictions so CPU's such as Cortex-R52 can
+  // select between SP Only and Full DP modes.
   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;
 }
diff --git a/llvm/test/MC/ARM/cortex-r52-nofp.s 
b/llvm/test/MC/ARM/cortex-r52-nofp.s
new file mode 100644
index 00..cc72cecd131152
--- /dev/null
+++ b/llvm/test/MC/ARM/cortex-r52-nofp.s
@@ -0,0 +1,9 @@
+@ RUN: llvm-mc -triple armv8-none-eabi -mcpu=cortex-r52 -mattr=+nosimd+nofp.dp 
%s -o - | FileCheck %s -check-prefix=CHECK-NO-FP
+@ RUN: llvm-mc -triple armv8-none-eabi -mcpu=cortex-r52 %s -o - | FileCheck %s 
-check-prefix=CHECK-FP
+
+.text
+vadd.f32 s0, s1, s2
+@ CHECK-NO-FP: vadd.f32 s0, s1, s2
+@ CHECK-FP: vadd.f32 s0, s1, s2
+@ CHECK-NOT-NO-FP: error: instruction requires: VPF2
+@ CHECK-NOT-FP: error: instruction requires: VPF2
diff --git a/llvm/unittests/TargetParser/TargetParserTest.cpp 
b/llvm/unittests/TargetParser/TargetParserTest.cpp
index c594d38b50b22e..48730578692539 100644
--- a/llvm/unittests/TargetParser/TargetParserTest.cpp
+++ b/llvm/unittests/TargetParser/TargetParserTest.cpp
@@ -10,6 +10,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ARMBuildAttributes.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/FormatVariadic.h"
@@ -2085,4 +2086,29 @@ INSTANTIATE_TEST_SUITE_P(
 AArch64ExtensionDependenciesBaseCPUTestFixture,
 ::testing::ValuesIn(AArch64ExtensionDependenciesCPUData));
 
+struct CheckFindSinglePrecisionFpuTest {
+  StringRef Cpu;
+  ARM::ArchKind Arch;
+  Strin

[clang] [llvm] [ARM] Ensure FPU Selection can select mode correctly (PR #124935)

2025-01-29 Thread Jack Styles via cfe-commits

https://github.com/Stylie777 created 
https://github.com/llvm/llvm-project/pull/124935

Previously, when selecting a Single Precision FPU, LLVM would ensure all 
elements of the Candidate FPU matched the InputFPU that was given. However, for 
cases such as Cortex-R52, there are FPU options where not all fields match 
exactly, for example NEON Support or Restrictions on the Registers available.

This change ensures that LLVM can select the FPU correctly, removing the 
requirement for Neon Support and Restrictions for the Candidate FPU to be the 
same as the InputFPU.

>From 1b12ad277c63e707c1b4268fc46f942349bbb1d9 Mon Sep 17 00:00:00 2001
From: Jack Styles 
Date: Wed, 29 Jan 2025 15:19:46 +
Subject: [PATCH] [ARM] Ensure FPU Selection can select mode correctly

Previously, when selecting a Single Precision FPU, LLVM would
ensure all elements of the Candidate FPU matched the InputFPU
that was given. However, for cases such as Cortex-R52, there
are FPU options where not all fields match exactly, for example
NEON Support or Restrictions on the Registers available.

This change ensures that LLVM can select the FPU correctly,
removing the requirement for Neon Support and Restrictions
for the Candidate FPU to be the same as the InputFPU.
---
 clang/test/Preprocessor/arm-target-features.c | 16 
 llvm/lib/TargetParser/ARMTargetParser.cpp |  9 +++
 llvm/test/MC/ARM/cortex-r52-nofp.s|  9 +++
 .../TargetParser/TargetParserTest.cpp | 26 +++
 4 files changed, 55 insertions(+), 5 deletions(-)
 create mode 100644 llvm/test/MC/ARM/cortex-r52-nofp.s

diff --git a/clang/test/Preprocessor/arm-target-features.c 
b/clang/test/Preprocessor/arm-target-features.c
index ecf9d7eb5c19c9..7395ed8b57f845 100644
--- a/clang/test/Preprocessor/arm-target-features.c
+++ b/clang/test/Preprocessor/arm-target-features.c
@@ -1013,3 +1013,19 @@
 // CHECK-MVE1_2: #define __ARM_FEATURE_MVE 1
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve.fp -x c -E 
-dM %s -o - | FileCheck -check-prefix=CHECK-MVE3 %s
 // CHECK-MVE3: #define __ARM_FEATURE_MVE 3
+
+// Cortex-R52 and Cortex-R52Plus correctly enable the `fpv5-sp-d16` FPU when 
compiling for the SP only version of the CPU.
+// RUN: %clang -target arm-none-eabi -mcpu=cortex-r52+nosimd+nofp.dp 
-mfloat-abi=hard -x c -E -dM -o - %s | FileCheck -check-prefix=CHECK-R52 %s
+// CHECK-R52: #define __ARM_FEATURE_FMA 1
+// CHECK-R52: #define __ARM_FP 0x6
+// CHECK-R52: #define __ARM_FPV5__ 1
+// CHECK-R52: #define __ARM_VFPV2__ 1
+// CHECK-R52-NEXT: #define __ARM_VFPV3__ 1
+// CHECK-R52-NEXT: #define __ARM_VFPV4__ 1
+// RUN: %clang -target arm-none-eabi -mcpu=cortex-r52plus+nosimd+nofp.dp 
-mfloat-abi=hard -x c -E -dM -o - %s | FileCheck -check-prefix=CHECK-R52PLUS %s
+// CHECK-R52PLUS: #define __ARM_FEATURE_FMA 1
+// CHECK-R52PLUS: #define __ARM_FP 0x6
+// CHECK-R52PLUS: #define __ARM_FPV5__ 1
+// CHECK-R52PLUS: #define __ARM_VFPV2__ 1
+// CHECK-R52PLUS-NEXT: #define __ARM_VFPV3__ 1
+// CHECK-R52PLUS-NEXT: #define __ARM_VFPV4__ 1
diff --git a/llvm/lib/TargetParser/ARMTargetParser.cpp 
b/llvm/lib/TargetParser/ARMTargetParser.cpp
index 9bcfa6ca62c97f..8f9753775c204a 100644
--- a/llvm/lib/TargetParser/ARMTargetParser.cpp
+++ b/llvm/lib/TargetParser/ARMTargetParser.cpp
@@ -403,13 +403,12 @@ static ARM::FPUKind findSinglePrecisionFPU(ARM::FPUKind 
InputFPUKind) {
   if (!ARM::isDoublePrecision(InputFPU.Restriction))
 return InputFPUKind;
 
-  // Otherwise, look for an FPU entry with all the same fields, except
-  // that it does not support double precision.
+  // Otherwise, look for an FPU entry that has the same FPUVer
+  // and is not Double Precision. We want to allow for changing of
+  // NEON Support and Restrictions so CPU's such as Cortex-R52 can
+  // select between SP Only and Full DP modes.
   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;
 }
diff --git a/llvm/test/MC/ARM/cortex-r52-nofp.s 
b/llvm/test/MC/ARM/cortex-r52-nofp.s
new file mode 100644
index 00..cc72cecd131152
--- /dev/null
+++ b/llvm/test/MC/ARM/cortex-r52-nofp.s
@@ -0,0 +1,9 @@
+@ RUN: llvm-mc -triple armv8-none-eabi -mcpu=cortex-r52 -mattr=+nosimd+nofp.dp 
%s -o - | FileCheck %s -check-prefix=CHECK-NO-FP
+@ RUN: llvm-mc -triple armv8-none-eabi -mcpu=cortex-r52 %s -o - | FileCheck %s 
-check-prefix=CHECK-FP
+
+.text
+vadd.f32 s0, s1, s2
+@ CHECK-NO-FP: vadd.f32 s0, s1, s2
+@ CHECK-FP: vadd.f32 s0, s1, s2
+@ CHECK-NOT-NO-FP: error: instruction requires: VPF2
+@ CHECK-NOT-FP: error: instruction requires: VPF2
diff --git a/llvm/unittests/TargetParser/TargetParserTest.cpp 
b/llvm/unittests/TargetParser/TargetParserTest.cpp
ind

[clang] [clang][Sema] Improve template argument deduction diagnostic (PR #122754)

2025-01-29 Thread Aidan Goldfarb via cfe-commits

https://github.com/AidanGoldfarb updated 
https://github.com/llvm/llvm-project/pull/122754

>From b6c576fb90362640b2fd4e41bd7f13dfee95d04d Mon Sep 17 00:00:00 2001
From: Aidan 
Date: Mon, 13 Jan 2025 11:53:39 -0500
Subject: [PATCH 01/22] initial template arg fix push

---
 .../clang/Basic/DiagnosticSemaKinds.td|  4 +-
 clang/include/clang/Sema/TemplateDeduction.h  |  5 ++
 clang/lib/Sema/SemaOverload.cpp   | 56 +++
 clang/lib/Sema/SemaTemplateDeduction.cpp  |  8 +++
 4 files changed, 61 insertions(+), 12 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 8be4f946dce1cc..1456f34538bcc0 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4871,8 +4871,8 @@ def note_ovl_candidate_inconsistent_deduction_types : 
Note<
 "of conflicting types for parameter %0 (%1 of type $ vs. %3 of type $)|"
 "%1 and %3 of conflicting types for parameter %0}2,4">;
 def note_ovl_candidate_explicit_arg_mismatch_named : Note<
-"candidate template ignored: invalid explicitly-specified argument "
-"for template parameter %0">;
+"template argument deduction/substitution failed:" 
+"error: could not convert '%0' from %1 to %2">;
 def note_ovl_candidate_unsatisfied_constraints : Note<
 "candidate template ignored: constraints not satisfied%0">;
 def note_ovl_candidate_explicit_arg_mismatch_unnamed : Note<
diff --git a/clang/include/clang/Sema/TemplateDeduction.h 
b/clang/include/clang/Sema/TemplateDeduction.h
index 28b014fd84e4b3..9edd3724cf53cd 100644
--- a/clang/include/clang/Sema/TemplateDeduction.h
+++ b/clang/include/clang/Sema/TemplateDeduction.h
@@ -250,6 +250,9 @@ class TemplateDeductionInfo {
   /// \brief The constraint satisfaction details resulting from the associated
   /// constraints satisfaction tests.
   ConstraintSatisfaction AssociatedConstraintsSatisfaction;
+
+  /// \brief Type supplied by user for deduction
+  TemplateArgument SuppliedType;
 };
 
 } // namespace sema
@@ -300,6 +303,8 @@ struct DeductionFailureInfo {
   TemplateDeductionResult getResult() const {
 return static_cast(Result);
   }
+
+  const TemplateArgument *getSuppliedType();
 };
 
 /// TemplateSpecCandidate - This is a generalization of OverloadCandidate
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 34c287926b1d7d..6c437a52be21db 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -715,12 +715,18 @@ namespace {
   struct DFIParamWithArguments : DFIArguments {
 TemplateParameter Param;
   };
+
   // Structure used by DeductionFailureInfo to store template argument
   // information and the index of the problematic call argument.
   struct DFIDeducedMismatchArgs : DFIArguments {
 TemplateArgumentList *TemplateArgs;
 unsigned CallArgIndex;
   };
+
+  struct DFIParamWithArgumentsAndSuppliedType : DFIArguments {
+TemplateParameter Param;
+TemplateArgument SuppliedType;
+  };
   // Structure used by DeductionFailureInfo to store information about
   // unsatisfied constraints.
   struct CNSInfo {
@@ -736,8 +742,10 @@ clang::MakeDeductionFailureInfo(ASTContext &Context,
 TemplateDeductionResult TDK,
 TemplateDeductionInfo &Info) {
   DeductionFailureInfo Result;
+
   Result.Result = static_cast(TDK);
   Result.HasDiagnostic = false;
+
   switch (TDK) {
   case TemplateDeductionResult::Invalid:
   case TemplateDeductionResult::InstantiationDepth:
@@ -749,10 +757,9 @@ clang::MakeDeductionFailureInfo(ASTContext &Context,
 break;
 
   case TemplateDeductionResult::Incomplete:
-  case TemplateDeductionResult::InvalidExplicitArguments:
+// case TemplateDeductionResult::InvalidExplicitArguments:
 Result.Data = Info.Param.getOpaqueValue();
 break;
-
   case TemplateDeductionResult::DeducedMismatch:
   case TemplateDeductionResult::DeducedMismatchNested: {
 // FIXME: Should allocate from normal heap so that we can free this later.
@@ -777,6 +784,7 @@ clang::MakeDeductionFailureInfo(ASTContext &Context,
   case TemplateDeductionResult::IncompletePack:
 // FIXME: It's slightly wasteful to allocate two TemplateArguments for 
this.
   case TemplateDeductionResult::Inconsistent:
+
   case TemplateDeductionResult::Underqualified: {
 // FIXME: Should allocate from normal heap so that we can free this later.
 DFIParamWithArguments *Saved = new (Context) DFIParamWithArguments;
@@ -786,6 +794,16 @@ clang::MakeDeductionFailureInfo(ASTContext &Context,
 Result.Data = Saved;
 break;
   }
+  case TemplateDeductionResult::InvalidExplicitArguments: {
+DFIParamWithArgumentsAndSuppliedType *Saved =
+new (Context) DFIParamWithArgumentsAndSuppliedType;
+Saved->Param = Info.Param;
+Saved->FirstArg = Info.FirstArg;
+Saved->SecondArg = Info.SecondA

[clang] [clang][Sema] Improve template argument deduction diagnostic (PR #122754)

2025-01-29 Thread Aidan Goldfarb via cfe-commits


@@ -4870,9 +4870,21 @@ def note_ovl_candidate_inconsistent_deduction_types : 
Note<
 "candidate template ignored: deduced values %diff{"
 "of conflicting types for parameter %0 (%1 of type $ vs. %3 of type $)|"
 "%1 and %3 of conflicting types for parameter %0}2,4">;
-def note_ovl_candidate_explicit_arg_mismatch_named : Note<
+def note_ovl_candidate_explicit_arg_mismatch_named_temptemppd : Note<
 "candidate template ignored: invalid explicitly-specified argument "
 "for template parameter %0">;
+def note_ovl_candidate_explicit_arg_mismatch_named_ttpd : Note<
+"candidate template ignored: invalid explicitly-specified argument "
+"for template parameter %0: "
+"expected a type, but got value '%1' (of type %2)">;
+def note_ovl_candidate_explicit_arg_mismatch_named_nttpd_b : Note<
+"candidate template ignored: invalid explicitly-specified argument "
+"for template parameter %0: "
+"could not convert '%1' from %2 to %3">;
+def note_ovl_candidate_explicit_arg_mismatch_named_nttpd_a : Note<
+"candidate template ignored: invalid explicitly-specified argument "
+"for template parameter %0: "
+"expected constant of type %1 got type %2">;

AidanGoldfarb wrote:

I believe I resolved this with the merging of diag messages, but I am not 
exactly sure what you mean. Please let me know if I misunderstood.

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


[clang] [llvm] [ARM] Ensure FPU Selection can select mode correctly (PR #124935)

2025-01-29 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 12cdf4330d32ce073f88dfaa1ab9a32327b9ef38 
1b12ad277c63e707c1b4268fc46f942349bbb1d9 --extensions c,cpp -- 
clang/test/Preprocessor/arm-target-features.c 
llvm/lib/TargetParser/ARMTargetParser.cpp 
llvm/unittests/TargetParser/TargetParserTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/unittests/TargetParser/TargetParserTest.cpp 
b/llvm/unittests/TargetParser/TargetParserTest.cpp
index 4873057869..1f346c9a84 100644
--- a/llvm/unittests/TargetParser/TargetParserTest.cpp
+++ b/llvm/unittests/TargetParser/TargetParserTest.cpp
@@ -2097,16 +2097,41 @@ struct CheckFindSinglePrecisionFpuTest {
 
 TEST(TargetParserTest, checkFindSinglePrecisionFPU) {
   CheckFindSinglePrecisionFpuTest tests[] = {
-{"cortex-r4f", ARM::ArchKind::ARMV7R, "nofp.dp", {}, ARM::FK_INVALID, 
ARM::FK_VFPV3XD},
-{"cortex-r7", ARM::ArchKind::ARMV7R, "nofp.dp", {}, ARM::FK_INVALID, 
ARM::FK_VFPV3XD_FP16},
-{"cortex-a7", ARM::ArchKind::ARMV7A, "nofp.dp", {}, ARM::FK_INVALID, 
ARM::FK_FPV4_SP_D16},
-{"cortex-r52", ARM::ArchKind::ARMV8R, "nofp.dp", {}, ARM::FK_INVALID, 
ARM::FK_FPV5_SP_D16},
-{"cortex-m55", ARM::ArchKind::ARMV8_1MMainline, "nofp.dp", {}, 
ARM::FK_INVALID, ARM::FK_FP_ARMV8_FULLFP16_SP_D16}
-  };
+  {"cortex-r4f",
+   ARM::ArchKind::ARMV7R,
+   "nofp.dp",
+   {},
+   ARM::FK_INVALID,
+   ARM::FK_VFPV3XD},
+  {"cortex-r7",
+   ARM::ArchKind::ARMV7R,
+   "nofp.dp",
+   {},
+   ARM::FK_INVALID,
+   ARM::FK_VFPV3XD_FP16},
+  {"cortex-a7",
+   ARM::ArchKind::ARMV7A,
+   "nofp.dp",
+   {},
+   ARM::FK_INVALID,
+   ARM::FK_FPV4_SP_D16},
+  {"cortex-r52",
+   ARM::ArchKind::ARMV8R,
+   "nofp.dp",
+   {},
+   ARM::FK_INVALID,
+   ARM::FK_FPV5_SP_D16},
+  {"cortex-m55",
+   ARM::ArchKind::ARMV8_1MMainline,
+   "nofp.dp",
+   {},
+   ARM::FK_INVALID,
+   ARM::FK_FP_ARMV8_FULLFP16_SP_D16}};
 
   for (auto X : tests) {
 ARM::FPUKind FPU = X.Fpu;
-EXPECT_TRUE(ARM::appendArchExtFeatures(X.Cpu, X.Arch, X.Archext, 
X.Features, FPU));
+EXPECT_TRUE(
+ARM::appendArchExtFeatures(X.Cpu, X.Arch, X.Archext, X.Features, FPU));
 EXPECT_EQ(FPU, X.Output);
   }
 }

``




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


[clang] [llvm] [WIP][clang][DebugInfo] Add new DW_AT_APPLE_enum_kind to encode enum_extensibility (PR #124752)

2025-01-29 Thread Michael Buch via cfe-commits

Michael137 wrote:

> (hmm, can't use the foundation library on godbolt/compiler explorer) Can you 
> show a small example of the code you're interested in and the DWARF it 
> produces? The documentation I can find seems to suggest that the extensible 
> enums have ctors that take the underlying integer type, but the 
> non-extensible ones don't, so I'd have thought that might be adequate to 
> differentiate without an extra attribute?

`NS_ENUM` is just a `#define` that adds the `enum_extensibility(open)` 
attribute to a plain C enum. Given following example:
```
#import 

enum Enum {
e1
} e;

enum class EnumClass : unsigned {
ec1
} ec;

enum __attribute__((enum_extensibility(open))) OpenEnum {
  oe1
} oe;

enum __attribute__((enum_extensibility(open))) OpenEnumClass : unsigned {
  oec1
} oec;

typedef NS_ENUM(unsigned, ns_enum) {
  ns1
} ns;
```

Here are all the `DW_TAG_enumeration_type`s:
```
0x002c:   DW_TAG_enumeration_type
DW_AT_type  (0x0039 "unsigned int")
DW_AT_name  ("Enum")
DW_AT_byte_size (0x04)
DW_AT_decl_file ("/Users/michaelbuch/ns_enum.m")
DW_AT_decl_line (3)

0x0035: DW_TAG_enumerator
  DW_AT_name("e1")
  DW_AT_const_value (0)

0x0048:   DW_TAG_enumeration_type
DW_AT_type  (0x0039 "unsigned int")
DW_AT_enum_class(true)
DW_AT_name  ("EnumClass")
DW_AT_byte_size (0x04)
DW_AT_decl_file ("/Users/michaelbuch/ns_enum.m")
DW_AT_decl_line (7)

0x0051: DW_TAG_enumerator
  DW_AT_name("ec1")
  DW_AT_const_value (0)

0x0060:   DW_TAG_enumeration_type
DW_AT_type  (0x0039 "unsigned int")
DW_AT_name  ("OpenEnum")
DW_AT_byte_size (0x04)
DW_AT_decl_file ("/Users/michaelbuch/ns_enum.m")
DW_AT_decl_line (11)

0x0069: DW_TAG_enumerator
  DW_AT_name("oe1")
  DW_AT_const_value (0)

0x0078:   DW_TAG_enumeration_type
DW_AT_type  (0x0039 "unsigned int")
DW_AT_enum_class(true)
DW_AT_name  ("OpenEnumClass")
DW_AT_byte_size (0x04)
DW_AT_decl_file ("/Users/michaelbuch/ns_enum.m")
DW_AT_decl_line (15)

0x0081: DW_TAG_enumerator
  DW_AT_name("oec1")
  DW_AT_const_value (0)

0x0090:   DW_TAG_enumeration_type
DW_AT_type  (0x0039 "unsigned int")
DW_AT_name  ("ns_enum")
DW_AT_byte_size (0x04)
DW_AT_decl_file ("/Users/michaelbuch/ns_enum.m")
DW_AT_decl_line (19)

0x0099: DW_TAG_enumerator
  DW_AT_name("ns1")
  DW_AT_const_value (0)
```

So nothing about the extensibility is reflected here

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


[libclc] [libclc] Move (add|sub)_sat to CLC; optimize (PR #124903)

2025-01-29 Thread Fraser Cormack via cfe-commits

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


[clang] [clang] Restrict the use of scalar types in vector builtins (PR #119423)

2025-01-29 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `llvm-clang-aarch64-darwin` 
running on `doug-worker-4` while building `clang` at step 6 
"test-build-unified-tree-check-all".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/190/builds/13711


Here is the relevant piece of the build log for the reference

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: Analysis/live-stmts.cpp' FAILED 

Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang 
-cc1 -internal-isystem 
/Users/buildbot/buildbot-root/aarch64-darwin/build/lib/clang/21/include 
-nostdsysteminc -analyze -analyzer-constraints=range -setup-static-analyzer -w 
-analyzer-checker=debug.DumpLiveExprs 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp
 2>&1   | /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -cc1 
-internal-isystem 
/Users/buildbot/buildbot-root/aarch64-darwin/build/lib/clang/21/include 
-nostdsysteminc -analyze -analyzer-constraints=range -setup-static-analyzer -w 
-analyzer-checker=debug.DumpLiveExprs 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp:239:16:
 error: CHECK-EMPTY: is not on the line after the previous 
match
// CHECK-EMPTY:
   ^
:180:1: note: 'next' match was here

^
:177:1: note: previous match ended here

^
:178:1: note: non-matching line after 
previous match is here
ImplicitCastExpr 0x13f811978 '_Bool' 
^

Input file: 
Check file: 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp

-dump-input=help explains the following input dump.

Input was:
<<
   1:  
   2: [ B0 (live expressions at block 
exit) ] 
check:21  ^~~
   3:  
empty:22  ^
   4:  
empty:23  ^
   5: [ B1 (live expressions at block 
exit) ] 
check:24  ^~~
   6:  
empty:25  ^
   7:  
empty:26  ^
   8: [ B2 (live expressions at block 
exit) ] 
check:27  ^~~
   9:  
empty:28  ^
  10: DeclRefExpr 0x12e80b2e0 'int' 
lvalue ParmVar 0x12f10f270 'y' 'int' 
next:29   
^~
  11:  
empty:30  ^
  12: DeclRefExpr 0x12e80b300 'int' 
lvalue ParmVar 0x12f10f2f0 'z' 'int' 
...

```



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


[clang] [Clang][OpenCL][AMDGPU] Allow a kernel to call another kernel (PR #115821)

2025-01-29 Thread Aniket Lal via cfe-commits


@@ -1582,6 +1582,26 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, 
llvm::Function *Fn,
 // Implicit copy-assignment gets the same special treatment as implicit
 // copy-constructors.
 emitImplicitAssignmentOperatorBody(Args);
+  } else if (FD->hasAttr() &&
+ GD.getKernelReferenceKind() == KernelReferenceKind::Kernel) {
+CallArgList CallArgs;
+for (unsigned i = 0; i < Args.size(); ++i) {
+  Address ArgAddr = GetAddrOfLocalVar(Args[i]);
+  QualType ArgQualType = Args[i]->getType();
+  RValue ArgRValue = convertTempToRValue(ArgAddr, ArgQualType, Loc);

lalaniket8 wrote:

To emit call to device function, I need to pass the arguments of kernel 
function, which reside in `FunctionArgList Args` to `EmitCall()`. To do this I 
have used an object of `CallArgList` and passed the same to `EmitCall()` 
method. 

I iterate over each argument and construct `CallArgList` using 
`convertTempToRValue()`

Is this approach to construct `CallArgList` correct?

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


[clang] [clang-format] Fix erroneous BraceWrapping.BeforeLambdaBody column calcs (PR #76673)

2025-01-29 Thread James Grant via cfe-commits

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


[libclc] [libclc] Move (add|sub)_sat to CLC; optimize (PR #124903)

2025-01-29 Thread Fraser Cormack via cfe-commits

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


[libclc] [libclc] Move (add|sub)_sat to CLC; optimize (PR #124903)

2025-01-29 Thread Fraser Cormack via cfe-commits

https://github.com/frasercrmck created 
https://github.com/llvm/llvm-project/pull/124903

Using the __builtin_elementwise_(add|sub)_sat functions allows us to directly 
optimize to the desired intrinsic, and avoid scalarization for vector types.

>From f4570c42ea9adf6b10a911fd57d3152ad6f5c1e4 Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Wed, 29 Jan 2025 10:49:56 +
Subject: [PATCH] [libclc] Move (add|sub)_sat to CLC; optimize

Using the __builtin_elementwise_(add|sub)_sat functions allows us to
directly optimize to the desired intrinsic, and avoid scalarization for
vector types.
---
 libclc/clc/include/clc/integer/clc_add_sat.h  | 12 +++
 libclc/clc/include/clc/integer/clc_sub_sat.h  | 12 +++
 libclc/clc/lib/clspv/SOURCES  |  2 +
 libclc/clc/lib/generic/SOURCES|  2 +
 libclc/clc/lib/generic/integer/clc_add_sat.cl |  7 ++
 libclc/clc/lib/generic/integer/clc_sub_sat.cl |  7 ++
 libclc/clc/lib/spirv/SOURCES  |  2 +
 libclc/clc/lib/spirv64/SOURCES|  2 +
 libclc/generic/lib/integer/add_sat.cl | 74 +--
 libclc/generic/lib/integer/sub_sat.cl | 62 +---
 libclc/generic/lib/math/clc_ldexp.cl  |  3 +-
 11 files changed, 56 insertions(+), 129 deletions(-)
 create mode 100644 libclc/clc/include/clc/integer/clc_add_sat.h
 create mode 100644 libclc/clc/include/clc/integer/clc_sub_sat.h
 create mode 100644 libclc/clc/lib/generic/integer/clc_add_sat.cl
 create mode 100644 libclc/clc/lib/generic/integer/clc_sub_sat.cl

diff --git a/libclc/clc/include/clc/integer/clc_add_sat.h 
b/libclc/clc/include/clc/integer/clc_add_sat.h
new file mode 100644
index 00..8db19627f18e31
--- /dev/null
+++ b/libclc/clc/include/clc/integer/clc_add_sat.h
@@ -0,0 +1,12 @@
+#ifndef __CLC_INTEGER_CLC_ADD_SAT_H__
+#define __CLC_INTEGER_CLC_ADD_SAT_H__
+
+#define __CLC_FUNCTION __clc_add_sat
+#define __CLC_BODY 
+
+#include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION
+
+#endif // __CLC_INTEGER_CLC_ADD_SAT_H__
diff --git a/libclc/clc/include/clc/integer/clc_sub_sat.h 
b/libclc/clc/include/clc/integer/clc_sub_sat.h
new file mode 100644
index 00..95a8fd8873e996
--- /dev/null
+++ b/libclc/clc/include/clc/integer/clc_sub_sat.h
@@ -0,0 +1,12 @@
+#ifndef __CLC_INTEGER_CLC_SUB_SAT_H__
+#define __CLC_INTEGER_CLC_SUB_SAT_H__
+
+#define __CLC_FUNCTION __clc_sub_sat
+#define __CLC_BODY 
+
+#include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION
+
+#endif // __CLC_INTEGER_CLC_SUB_SAT_H__
diff --git a/libclc/clc/lib/clspv/SOURCES b/libclc/clc/lib/clspv/SOURCES
index 66818590100630..6efa3c59b53e70 100644
--- a/libclc/clc/lib/clspv/SOURCES
+++ b/libclc/clc/lib/clspv/SOURCES
@@ -1,3 +1,5 @@
+../generic/integer/clc_add_sat.cl
+../generic/integer/clc_sub_sat.cl
 ../generic/math/clc_ceil.cl
 ../generic/math/clc_copysign.cl
 ../generic/math/clc_fabs.cl
diff --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES
index 9feda65c45f4bf..1ef6636be90b62 100644
--- a/libclc/clc/lib/generic/SOURCES
+++ b/libclc/clc/lib/generic/SOURCES
@@ -4,6 +4,8 @@ common/clc_smoothstep.cl
 geometric/clc_dot.cl
 integer/clc_abs.cl
 integer/clc_abs_diff.cl
+integer/clc_add_sat.cl
+integer/clc_sub_sat.cl
 math/clc_ceil.cl
 math/clc_copysign.cl
 math/clc_fabs.cl
diff --git a/libclc/clc/lib/generic/integer/clc_add_sat.cl 
b/libclc/clc/lib/generic/integer/clc_add_sat.cl
new file mode 100644
index 00..344c105720e080
--- /dev/null
+++ b/libclc/clc/lib/generic/integer/clc_add_sat.cl
@@ -0,0 +1,7 @@
+#include 
+
+#define FUNCTION __clc_add_sat
+#define __CLC_FUNCTION(x) __builtin_elementwise_add_sat
+#define __CLC_BODY 
+
+#include 
diff --git a/libclc/clc/lib/generic/integer/clc_sub_sat.cl 
b/libclc/clc/lib/generic/integer/clc_sub_sat.cl
new file mode 100644
index 00..184713531fdbe7
--- /dev/null
+++ b/libclc/clc/lib/generic/integer/clc_sub_sat.cl
@@ -0,0 +1,7 @@
+#include 
+
+#define FUNCTION __clc_sub_sat
+#define __CLC_FUNCTION(x) __builtin_elementwise_sub_sat
+#define __CLC_BODY 
+
+#include 
diff --git a/libclc/clc/lib/spirv/SOURCES b/libclc/clc/lib/spirv/SOURCES
index 509236d587cd01..a87223e8c622c5 100644
--- a/libclc/clc/lib/spirv/SOURCES
+++ b/libclc/clc/lib/spirv/SOURCES
@@ -2,6 +2,8 @@
 ../generic/common/clc_radians.cl
 ../generic/common/clc_smoothstep.cl
 ../generic/geometric/clc_dot.cl
+../generic/integer/clc_add_sat.cl
+../generic/integer/clc_sub_sat.cl
 ../generic/math/clc_ceil.cl
 ../generic/math/clc_copysign.cl
 ../generic/math/clc_fabs.cl
diff --git a/libclc/clc/lib/spirv64/SOURCES b/libclc/clc/lib/spirv64/SOURCES
index 509236d587cd01..a87223e8c622c5 100644
--- a/libclc/clc/lib/spirv64/SOURCES
+++ b/libclc/clc/lib/spirv64/SOURCES
@@ -2,6 +2,8 @@
 ../generic/common/clc_radians.cl
 ../generic/common/clc_smoothstep.cl
 ../generic/geometric/clc_dot.cl
+../generic/integer/clc_add_sat.cl
+../generic/integer/clc_sub_sat.cl
 ../generic/math/clc_ceil.cl
 ../generic/math/clc_copysign.cl
 ../generic/math/clc

[clang] [clang-format] Add AlignAfterOpenBracketOptions (PR #108332)

2025-01-29 Thread Björn Schäpers via cfe-commits


@@ -1169,6 +1181,18 @@ template <> struct MappingTraits {
 IO.mapOptional("WhitespaceSensitiveMacros",
Style.WhitespaceSensitiveMacros);
 
+// If AlignAfterOpenBracket was specified but AlignAfterOpenBracketBreak
+// was not, initialize the latter for backwards compatibility.
+if ((Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak ||
+ Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) &&
+Style.AlignAfterOpenBracketBreak ==
+FormatStyle::AlignAfterOpenBracketCustom()) {

HazardyKnusperkeks wrote:

Ok, got it.

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


[clang] [Clang] Add fake use emission to Clang with -fextend-lifetimes (PR #110102)

2025-01-29 Thread Stephen Tozer via cfe-commits

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


[libclc] [libclc] Move (add|sub)_sat to CLC; optimize (PR #124903)

2025-01-29 Thread Matt Arsenault via cfe-commits

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


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


[clang] Reland "[HIP] Use original file path for CUID" (#108771) (PR #111885)

2025-01-29 Thread Yaxun Liu via cfe-commits

yxsamliu wrote:

ping

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


[clang] [AArch64][Clang] Update untyped sme intrinsics with fp8 variants (PR #124543)

2025-01-29 Thread Jonathan Thackray via cfe-commits

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

LGTM

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


[clang] [C++20][Modules][Serialization] Delay marking pending incomplete decl chains until the end of `finishPendingActions`. (PR #121245)

2025-01-29 Thread Matheus Izvekov via cfe-commits

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

LGTM, Thanks!

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


[clang] [llvm] [mlir] Fix typo "tranpose" (PR #124929)

2025-01-29 Thread Jay Foad via cfe-commits

https://github.com/jayfoad created 
https://github.com/llvm/llvm-project/pull/124929

None

>From 03ea8ad4f2a7b6589539dbc137c356455225fc15 Mon Sep 17 00:00:00 2001
From: Jay Foad 
Date: Wed, 29 Jan 2025 14:49:05 +
Subject: [PATCH] Fix typo "tranpose"

---
 clang/lib/Headers/amxtf32transposeintrin.h |  2 +-
 llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp |  2 +-
 mlir/docs/Canonicalization.md  |  2 +-
 .../Linalg/TransformOps/LinalgTransformOps.td  |  2 +-
 mlir/include/mlir/Dialect/Vector/IR/VectorOps.td   |  4 ++--
 .../Conversion/VectorToArmSME/VectorToArmSME.cpp   |  2 +-
 .../lib/Conversion/VectorToXeGPU/VectorToXeGPU.cpp |  2 +-
 .../ArmSME/Transforms/VectorLegalization.cpp   |  4 ++--
 mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp |  2 +-
 mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp|  2 +-
 .../Dialect/Linalg/Transforms/TransposeConv2D.cpp  |  2 +-
 .../SparseTensor/Transforms/SparseGPUCodegen.cpp   |  2 +-
 mlir/lib/Dialect/Vector/IR/VectorOps.cpp   |  4 ++--
 .../Vector/Transforms/VectorDropLeadUnitDim.cpp| 14 +++---
 .../Dialect/Vector/Transforms/VectorTransforms.cpp |  4 ++--
 .../test/Dialect/Vector/vector-unroll-options.mlir |  4 ++--
 16 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/clang/lib/Headers/amxtf32transposeintrin.h 
b/clang/lib/Headers/amxtf32transposeintrin.h
index 60336f953ecb7a..e1b90c1adfb22a 100644
--- a/clang/lib/Headers/amxtf32transposeintrin.h
+++ b/clang/lib/Headers/amxtf32transposeintrin.h
@@ -8,7 +8,7 @@
  */
 #ifndef __IMMINTRIN_H
 #error 
\
-"Never use  directly; include  
instead."
+"Never use  directly; include  
instead."
 #endif // __IMMINTRIN_H
 
 #ifndef __AMX_TF32TRANSPOSEINTRIN_H
diff --git a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp 
b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
index db9aa7e18f5e7a..cfb552c65e0c6f 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
@@ -2269,7 +2269,7 @@ OpRef HvxSelector::perfect(ShuffleMask SM, OpRef Va, 
ResultStack &Results) {
   // For example, with the inputs as above, the result will be:
   //   0 8  2 A  4 C  6 E
   //   1 9  3 B  5 D  7 F
-  // Now, this result can be tranposed again, but with the group size of 2:
+  // Now, this result can be transposed again, but with the group size of 2:
   //   08 19  4C 5D
   //   2A 3B  6E 7F
   // If we then transpose that result, but with the group size of 4, we get:
diff --git a/mlir/docs/Canonicalization.md b/mlir/docs/Canonicalization.md
index 03fd174229afe9..6e59a4128093a2 100644
--- a/mlir/docs/Canonicalization.md
+++ b/mlir/docs/Canonicalization.md
@@ -71,7 +71,7 @@ For example, a pattern that transform
   outs(%init1 : tensor<2x1x3xf32>)
   dimensions = [1, 0, 2]
   %out = linalg.transpose
-  ins(%tranpose: tensor<2x1x3xf32>)
+  ins(%transpose: tensor<2x1x3xf32>)
   outs(%init2 : tensor<3x1x2xf32>)
   permutation = [2, 1, 0]
 ```
diff --git 
a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td 
b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
index 081bf9b6d3b239..e86d1754897759 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
@@ -1007,7 +1007,7 @@ def PackTransposeOp : Op` type($res)";
 }
 
-/// Vector dialect matrix tranposition op that operates on flattened 1-D
+/// Vector dialect matrix transposition op that operates on flattened 1-D
 /// MLIR vectors. This is the counterpart of llvm.matrix.transpose in MLIR.
 /// This may seem redundant with vector.transpose but it serves the purposes of
 /// more progressive lowering and localized type conversion on the path:
@@ -2799,7 +2799,7 @@ def Vector_FlatTransposeOp : Vector_Op<"flat_transpose", 
[Pure,
   let description = [{
 This is the counterpart of llvm.matrix.transpose in MLIR. It serves
 the purposes of more progressive lowering and localized type conversion.
-Higher levels typically lower matrix tranpositions into 'vector.transpose'
+Higher levels typically lower matrix transpositions into 'vector.transpose'
 operations. Subsequent rewriting rule progressively lower these operations
 into 'vector.flat_transpose' operations to bring the operations closer
 to the hardware ISA.
diff --git a/mlir/lib/Conversion/VectorToArmSME/VectorToArmSME.cpp 
b/mlir/lib/Conversion/VectorToArmSME/VectorToArmSME.cpp
index 55965d9c2a531d..4be0fffe8b7285 100644
--- a/mlir/lib/Conversion/VectorToArmSME/VectorToArmSME.cpp
+++ b/mlir/lib/Conversion/VectorToArmSME/VectorToArmSME.cpp
@@ -332,7 +332,7 @@ struct SplatOpToArmSMELowering : public 
OpRewritePattern {
 ///   %transposed_src = arm_sme.tile_load %alloca[%c0, %c0]
 /// layout : memref, vector<[4]x[4]xi32>
 ///
-/// NOTE: Tranposing v

[clang] [llvm] [mlir] Fix typo "tranpose" (PR #124929)

2025-01-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-x86

Author: Jay Foad (jayfoad)


Changes



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


16 Files Affected:

- (modified) clang/lib/Headers/amxtf32transposeintrin.h (+1-1) 
- (modified) llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp (+1-1) 
- (modified) mlir/docs/Canonicalization.md (+1-1) 
- (modified) 
mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/Vector/IR/VectorOps.td (+2-2) 
- (modified) mlir/lib/Conversion/VectorToArmSME/VectorToArmSME.cpp (+1-1) 
- (modified) mlir/lib/Conversion/VectorToXeGPU/VectorToXeGPU.cpp (+1-1) 
- (modified) mlir/lib/Dialect/ArmSME/Transforms/VectorLegalization.cpp (+2-2) 
- (modified) mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/TransposeConv2D.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp 
(+1-1) 
- (modified) mlir/lib/Dialect/Vector/IR/VectorOps.cpp (+2-2) 
- (modified) mlir/lib/Dialect/Vector/Transforms/VectorDropLeadUnitDim.cpp 
(+7-7) 
- (modified) mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp (+2-2) 
- (modified) mlir/test/Dialect/Vector/vector-unroll-options.mlir (+2-2) 


``diff
diff --git a/clang/lib/Headers/amxtf32transposeintrin.h 
b/clang/lib/Headers/amxtf32transposeintrin.h
index 60336f953ecb7a..e1b90c1adfb22a 100644
--- a/clang/lib/Headers/amxtf32transposeintrin.h
+++ b/clang/lib/Headers/amxtf32transposeintrin.h
@@ -8,7 +8,7 @@
  */
 #ifndef __IMMINTRIN_H
 #error 
\
-"Never use  directly; include  
instead."
+"Never use  directly; include  
instead."
 #endif // __IMMINTRIN_H
 
 #ifndef __AMX_TF32TRANSPOSEINTRIN_H
diff --git a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp 
b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
index db9aa7e18f5e7a..cfb552c65e0c6f 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
@@ -2269,7 +2269,7 @@ OpRef HvxSelector::perfect(ShuffleMask SM, OpRef Va, 
ResultStack &Results) {
   // For example, with the inputs as above, the result will be:
   //   0 8  2 A  4 C  6 E
   //   1 9  3 B  5 D  7 F
-  // Now, this result can be tranposed again, but with the group size of 2:
+  // Now, this result can be transposed again, but with the group size of 2:
   //   08 19  4C 5D
   //   2A 3B  6E 7F
   // If we then transpose that result, but with the group size of 4, we get:
diff --git a/mlir/docs/Canonicalization.md b/mlir/docs/Canonicalization.md
index 03fd174229afe9..6e59a4128093a2 100644
--- a/mlir/docs/Canonicalization.md
+++ b/mlir/docs/Canonicalization.md
@@ -71,7 +71,7 @@ For example, a pattern that transform
   outs(%init1 : tensor<2x1x3xf32>)
   dimensions = [1, 0, 2]
   %out = linalg.transpose
-  ins(%tranpose: tensor<2x1x3xf32>)
+  ins(%transpose: tensor<2x1x3xf32>)
   outs(%init2 : tensor<3x1x2xf32>)
   permutation = [2, 1, 0]
 ```
diff --git 
a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td 
b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
index 081bf9b6d3b239..e86d1754897759 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
@@ -1007,7 +1007,7 @@ def PackTransposeOp : Op` type($res)";
 }
 
-/// Vector dialect matrix tranposition op that operates on flattened 1-D
+/// Vector dialect matrix transposition op that operates on flattened 1-D
 /// MLIR vectors. This is the counterpart of llvm.matrix.transpose in MLIR.
 /// This may seem redundant with vector.transpose but it serves the purposes of
 /// more progressive lowering and localized type conversion on the path:
@@ -2799,7 +2799,7 @@ def Vector_FlatTransposeOp : Vector_Op<"flat_transpose", 
[Pure,
   let description = [{
 This is the counterpart of llvm.matrix.transpose in MLIR. It serves
 the purposes of more progressive lowering and localized type conversion.
-Higher levels typically lower matrix tranpositions into 'vector.transpose'
+Higher levels typically lower matrix transpositions into 'vector.transpose'
 operations. Subsequent rewriting rule progressively lower these operations
 into 'vector.flat_transpose' operations to bring the operations closer
 to the hardware ISA.
diff --git a/mlir/lib/Conversion/VectorToArmSME/VectorToArmSME.cpp 
b/mlir/lib/Conversion/VectorToArmSME/VectorToArmSME.cpp
index 55965d9c2a531d..4be0fffe8b7285 100644
--- a/mlir/lib/Conversion/VectorToArmSME/VectorToArmSME.cpp
+++ b/mlir/lib/Conversion/VectorToArmSME/VectorToArmSME.cpp
@@ -332,7 +332,7 @@ struct SplatOpToArmSMELowering : public 
OpRewritePattern {
 ///   %transposed_src = arm_sme.tile_load %alloca[%c0, %c0]
 ///   

[clang] [llvm] [mlir] Fix typo "tranpose" (PR #124929)

2025-01-29 Thread Benjamin Maxwell via cfe-commits

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


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


[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2025-01-29 Thread Matt Arsenault via cfe-commits


@@ -0,0 +1,21 @@
+// TYPE sign(TYPE x) {
+//   if (isnan(x)) {
+// return 0.0F;
+//   }
+//   if (x > 0.0F) {
+// return 1.0F;
+//   }
+//   if (x < 0.0F) {
+// return -1.0F;
+//   }
+//   return x; /* -0.0 or +0.0 */
+// }
+_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_sign(__CLC_GENTYPE x) {
+  __CLC_BIT_INTN x_isnan = __clc_isnan(x);
+  __CLC_BIT_INTN x_isgreater_zero = x > __CLC_FP_LIT(0.0);
+  __CLC_BIT_INTN x_isless_zero = x < __CLC_FP_LIT(0.0);
+  __CLC_GENTYPE sel0 = __clc_select(x, __CLC_FP_LIT(1.0), x_isgreater_zero);
+  __CLC_GENTYPE sel1 = __clc_select(sel0, __CLC_FP_LIT(-1.0), x_isless_zero);
+  __CLC_GENTYPE sel2 = __clc_select(sel1, __CLC_FP_LIT(0.0), x_isnan);
+  return sel2;
+}

arsenm wrote:

The CTS isn't going to care about the sign bit of nan as it's meaningless. 
Alive needs to care about getting the signbit handling correct for nan in 
copysign, but we don't need it to (i.e. it doesn't matter it's not giving 
bit-identical results to the other implementation) 

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


[clang] [Fuchsia] Support PGO (PR #120323)

2025-01-29 Thread Paul Kirth via cfe-commits

ilovepi wrote:

We already have full support for PGO in other CMake cache files. This PR is 
adding that support to the files we use when building the Fuchsia toolchain. 

you can find details on the existing support here 
https://llvm.org/docs/HowToBuildWithPGO.html

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


[clang] [clang] Diagnose default arguments defined in different scopes (PR #124844)

2025-01-29 Thread via cfe-commits


@@ -5145,6 +5145,10 @@ def err_addr_ovl_not_func_ptrref : Error<
 def err_addr_ovl_no_qualifier : Error<
   "cannot form member pointer of type %0 without '&' and class name">;
 
+def err_ovl_ambiguous_default_arg
+: Error<"function call relies on ambiguous default argument %select{|for "
+"parameter '%1'}0">;
+

cor3ntin wrote:

```suggestion
def err_ovl_ambiguous_default_arg : Error<
"ambiguous default argument %select{|for parameter '%1'}0">;

```

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


[clang] [clang] Diagnose default arguments defined in different scopes (PR #124844)

2025-01-29 Thread via cfe-commits


@@ -10960,6 +10960,10 @@ OverloadCandidateSet::BestViableFunction(Sema &S, 
SourceLocation Loc,
 S.diagnoseEquivalentInternalLinkageDeclarations(Loc, Best->Function,
 EquivalentCands);
 
+  // [over.match.best]/4 is checked for in Sema::ConvertArgumentsForCall,
+  // because not every function call goes through our overload resolution
+  // machinery, even if the Standard says it supposed to.
+

cor3ntin wrote:

do we have test for something like that

```
namespace A {
extern "C" void f(long = 0); // viable candidate
}
namespace B {
extern "C" void f(long = 0); // viable candidate
}

using A::f;
using B::f;

void f(int) {} // best candidate

void g() {
f(0); // should not diagnose
}
```

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


[clang] [clang] Diagnose default arguments defined in different scopes (PR #124844)

2025-01-29 Thread via cfe-commits

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


[clang] [clang] Diagnose default arguments defined in different scopes (PR #124844)

2025-01-29 Thread via cfe-commits


@@ -488,6 +490,20 @@ bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, 
FunctionDecl *Old,
   continue;
 }
 
+if (PrevForDefaultArgs->getLexicalDeclContext()->getPrimaryContext() !=
+ScopeDC->getPrimaryContext() &&
+!New->isCXXClassMember())
+  // If previous declaration is lexically in a different scope,
+  // we don't inherit its default arguments, except for out-of-line
+  // declarations of member functions.
+  //
+  // extern "C" and local functions can have default arguments across
+  // different scopes, but diagnosing that early would reject well-formed
+  // code (_N5001_.[over.match.best]/4.) Instead, they are checked
+  // in ConvertArgumentsForCall, after the best viable function has been
+  // selected.
+  continue;
+

cor3ntin wrote:

Move the comment immediately above the if

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


[clang] [clang] Diagnose default arguments defined in different scopes (PR #124844)

2025-01-29 Thread via cfe-commits

https://github.com/cor3ntin commented:

Thanks for working on this, I left a few comments

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


[clang] [X86][AVX10] Disable m[no-]avx10.1 and switch m[no-]avx10.2 to alias of 512 bit options (PR #124511)

2025-01-29 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

> I've been playing around and found that `-mavx10.2 -mno-avx10.2-512` enables 
> `avx10.1-512` but `-mavx10.2-512 -mno-avx10.2-512` obviously doesn't. Does it 
> make sense? It happens because when options match, they are eliminated before 
> processing. But this is a problem not related to the PR.

The old behavior is "correct". Using "" because I think it is just an 
implementation trick. Though the compliance to it is not important, we decide 
to remove the -256/-512 options after discussed with GCC folks, to further 
reduce some confusions. We have to keep 10.1 options for a while, because it's 
risky to switch avx10.1 to alias of avx10.1-512 directly.

Let me know whether you are happy with this solution or not.

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


[clang] [clang-format] Fix erroneous BraceWrapping.BeforeLambdaBody column calcs (PR #76673)

2025-01-29 Thread James Grant via cfe-commits


@@ -366,8 +366,14 @@ bool ContinuationIndenter::mustBreak(const LineState 
&State) {
   const auto &CurrentState = State.Stack.back();
   if (Style.BraceWrapping.BeforeLambdaBody && Current.CanBreakBefore &&
   Current.is(TT_LambdaLBrace) && Previous.isNot(TT_LineComment)) {
-auto LambdaBodyLength = getLengthToMatchingParen(Current, State.Stack);
-return LambdaBodyLength > getColumnLimit(State);
+if (Current.MatchingParen->MustBreakBefore)

jamesg-nz wrote:

@HazardyKnusperkeks - sorry late response. After looking into it, I don't 
believe there's an issue.

The code I was talking about above: 
https://github.com/llvm/llvm-project/blob/0e01c72c5645259d9a08a1a7ed39cb5cc41ce311/clang/lib/Format/TokenAnnotator.cpp#L5297-L5299

Results in `MustBreakBefore` being set for the token (the left lambda brace), 
which therefore results in `CanBreakBefore` being set. The code exists as 
there's conditions (e.g. 
[`Left.is(TT_PointerOrReference)`](https://github.com/llvm/llvm-project/blob/0e01c72c5645259d9a08a1a7ed39cb5cc41ce311/clang/lib/Format/TokenAnnotator.cpp#L5523-L5524))
 in `TokenAnnotator::canBreakBefore()` which return `false` for the left lambda 
brace in lambdas like these:

```c++
auto select = [this]() -> const Library::Object * { return 
MyAssignment::SelectFromList(this); };
auto select = [this]() -> const Library::Object & { return 
MyAssignment::SelectFromList(this); };
auto select = [this]() -> std::unique_ptr { return 
MyAssignment::SelectFromList(this); };"
```

It's the fact it sets `CanBreakBefore` that matters so it enters the lambda 
section in `ContinuationIndenter::mustBreak()`.

Just checking `Current.MatchingParen->MustBreakBefore` inside is sufficient as 
TokenAnnotator::mustBreakBefore() returns `true` when it is called for the 
right lambda:
https://github.com/llvm/llvm-project/blob/0e01c72c5645259d9a08a1a7ed39cb5cc41ce311/clang/lib/Format/TokenAnnotator.cpp#L5283-L5293

Thus there is no need to look at `Current.MustBreakBefore`. However the generic 
condition that checks `Current.MustBreakBefore` for all tokens is in the 
condition for the next `if()` statement down, so could move the lambda `if()` 
statement down beneath that. But there's no need to do this at the moment.

So this PR looks OK as-is with respect to this.

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


[clang] [AArch64] Enable vscale_range with +sme (PR #124466)

2025-01-29 Thread David Green via cfe-commits

https://github.com/davemgreen updated 
https://github.com/llvm/llvm-project/pull/124466

>From c43c26262c25ffb99ee411c05d19739d83cf1c05 Mon Sep 17 00:00:00 2001
From: David Green 
Date: Sun, 26 Jan 2025 13:47:58 +
Subject: [PATCH 1/2] [AArch64] Enable vscale_range with +sme

If we have +sme but not +sve, we would not set vscale_range on functions. It
should be valid to apply it with the same range with just +sme, which can help
improve the performance of generated code.
---
 clang/lib/Basic/Targets/AArch64.cpp  |  2 +-
 .../AArch64/sme-intrinsics/aarch64-sme-attrs.cpp | 16 
 .../CodeGen/arm-sve-vector-bits-vscale-range.c   |  1 +
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 0b899137bbb5c7..e9afe0fb4ee456 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -708,7 +708,7 @@ AArch64TargetInfo::getVScaleRange(const LangOptions 
&LangOpts) const {
 return std::pair(
 LangOpts.VScaleMin ? LangOpts.VScaleMin : 1, LangOpts.VScaleMax);
 
-  if (hasFeature("sve"))
+  if (hasFeature("sve") || hasFeature("sme"))
 return std::pair(1, 16);
 
   return std::nullopt;
diff --git a/clang/test/CodeGen/AArch64/sme-intrinsics/aarch64-sme-attrs.cpp 
b/clang/test/CodeGen/AArch64/sme-intrinsics/aarch64-sme-attrs.cpp
index 54762c8b414124..cabd9d01e46652 100644
--- a/clang/test/CodeGen/AArch64/sme-intrinsics/aarch64-sme-attrs.cpp
+++ b/clang/test/CodeGen/AArch64/sme-intrinsics/aarch64-sme-attrs.cpp
@@ -300,19 +300,19 @@ int test_variadic_template() __arm_inout("za") {
   preserves_za_decl);
 }
 
-// CHECK: attributes #[[SM_ENABLED]] = { mustprogress noinline nounwind 
"aarch64_pstate_sm_enabled" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" }
+// CHECK: attributes #[[SM_ENABLED]] = { mustprogress noinline nounwind 
vscale_range(1,16) "aarch64_pstate_sm_enabled" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" }
 // CHECK: attributes #[[NORMAL_DECL]] = { "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" }
 // CHECK: attributes #[[SM_ENABLED_DECL]] = { "aarch64_pstate_sm_enabled" 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+bf16,+sme" }
-// CHECK: attributes #[[SM_COMPATIBLE]] = { mustprogress noinline nounwind 
"aarch64_pstate_sm_compatible" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" }
+// CHECK: attributes #[[SM_COMPATIBLE]] = { mustprogress noinline nounwind 
vscale_range(1,16) "aarch64_pstate_sm_compatible" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" }
 // CHECK: attributes #[[SM_COMPATIBLE_DECL]] = { 
"aarch64_pstate_sm_compatible" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" }
-// CHECK: attributes #[[SM_BODY]] = { mustprogress noinline nounwind 
"aarch64_pstate_sm_body" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" }
-// CHECK: attributes #[[ZA_SHARED]] = { mustprogress noinline nounwind 
"aarch64_inout_za" "no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+bf16,+sme" }
+// CHECK: attributes #[[SM_BODY]] = { mustprogress noinline nounwind 
vscale_range(1,16) "aarch64_pstate_sm_body" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" }
+// CHECK: attributes #[[ZA_SHARED]] = { mustprogress noinline nounwind 
vscale_range(1,16) "aarch64_inout_za" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" }
 // CHECK: attributes #[[ZA_SHARED_DECL]] = { "aarch64_inout_za" 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+bf16,+sme" }
-// CHECK: attributes #[[ZA_PRESERVED]] = { mustprogress noinline nounwind 
"aarch64_preserves_za" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" }
+// CHECK: attributes #[[ZA_PRESERVED]] = { mustprogress noinline nounwind 
vscale_range(1,16) "aarch64_preserves_za" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" }
 // CHECK: attributes #[[ZA_PRESERVED_DECL]] = { "aarch64_preserves_za" 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+bf16,+sme" }
-// CHECK: attributes #[[ZA_NEW]] = { mustprogress noinline nounwind 
"aarch64_new_za" "no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+bf16,+sme" }
-// CHECK: attributes #[[ZA_AGNOSTIC]] = { mustprogress noinline nounwind 
"aarch64_za_state_agnostic" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+bf16,+sme" }
-// CHECK: attributes #[[NORMAL_DEF]] = { mustprogress noinline nounwind 
"no-trapp

[clang] [clang][SME] Account for C++ lambdas in SME builtin diagnostics (PR #124750)

2025-01-29 Thread Benjamin Maxwell via cfe-commits

https://github.com/MacDue updated 
https://github.com/llvm/llvm-project/pull/124750

>From cb83182da6b017397111be606c88a4eeecb4ce9d Mon Sep 17 00:00:00 2001
From: Benjamin Maxwell 
Date: Tue, 28 Jan 2025 13:34:54 +
Subject: [PATCH 1/3] [clang][SME] Account for C++ lambdas in SME builtin
 diagnostics

A C++ lambda does not inherit attributes from the parent function. So
the SME builtin diagnostics should look at the lambda's attributes, not
the parent function's.

The fix is very simple and just adds the missing "AllowLambda" flag to
the function decl lookups.
---
 clang/lib/Sema/SemaARM.cpp|  9 ++--
 .../aarch64-incompat-sm-builtin-calls.cpp | 47 +++
 2 files changed, 53 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Sema/aarch64-incompat-sm-builtin-calls.cpp

diff --git a/clang/lib/Sema/SemaARM.cpp b/clang/lib/Sema/SemaARM.cpp
index 2620bbc97ba02a..df865d1b7df8c1 100644
--- a/clang/lib/Sema/SemaARM.cpp
+++ b/clang/lib/Sema/SemaARM.cpp
@@ -650,7 +650,8 @@ static ArmSMEState getSMEState(unsigned BuiltinID) {
 
 bool SemaARM::CheckSMEBuiltinFunctionCall(unsigned BuiltinID,
   CallExpr *TheCall) {
-  if (const FunctionDecl *FD = SemaRef.getCurFunctionDecl()) {
+  if (const FunctionDecl *FD =
+  SemaRef.getCurFunctionDecl(/*AllowLambda=*/true)) {
 std::optional BuiltinType;
 
 switch (BuiltinID) {
@@ -690,7 +691,8 @@ bool SemaARM::CheckSMEBuiltinFunctionCall(unsigned 
BuiltinID,
 
 bool SemaARM::CheckSVEBuiltinFunctionCall(unsigned BuiltinID,
   CallExpr *TheCall) {
-  if (const FunctionDecl *FD = SemaRef.getCurFunctionDecl()) {
+  if (const FunctionDecl *FD =
+  SemaRef.getCurFunctionDecl(/*AllowLambda=*/true)) {
 std::optional BuiltinType;
 
 switch (BuiltinID) {
@@ -719,7 +721,8 @@ bool SemaARM::CheckSVEBuiltinFunctionCall(unsigned 
BuiltinID,
 bool SemaARM::CheckNeonBuiltinFunctionCall(const TargetInfo &TI,
unsigned BuiltinID,
CallExpr *TheCall) {
-  if (const FunctionDecl *FD = SemaRef.getCurFunctionDecl()) {
+  if (const FunctionDecl *FD =
+  SemaRef.getCurFunctionDecl(/*AllowLambda=*/true)) {
 
 switch (BuiltinID) {
 default:
diff --git a/clang/test/Sema/aarch64-incompat-sm-builtin-calls.cpp 
b/clang/test/Sema/aarch64-incompat-sm-builtin-calls.cpp
new file mode 100644
index 00..12ef7ad06b68b1
--- /dev/null
+++ b/clang/test/Sema/aarch64-incompat-sm-builtin-calls.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1  -triple aarch64-none-linux-gnu -target-feature +sve \
+// RUN:   -target-feature +sme -target-feature +neon -x c++ -std=c++20 
-Waarch64-sme-attributes -fsyntax-only -verify %s
+
+// REQUIRES: aarch64-registered-target
+
+#include 
+#include 
+
+void use_streaming_builtin_in_lambda(uint32_t slice_base, svbool_t pg, const 
void *ptr) __arm_streaming __arm_out("za")
+{
+  [&]{
+/// The lambda is its own function and does not inherit the SME attributes 
(so this should error).
+// expected-error@+1 {{builtin can only be called from a streaming 
function}}
+svld1_hor_za64(0, slice_base, pg, ptr);
+  }();
+}
+
+void use_streaming_builtin(uint32_t slice_base, svbool_t pg, const void *ptr) 
__arm_streaming __arm_out("za")
+{
+  /// Without the lambda the same builtin is okay (as the SME attributes 
apply).
+  svld1_hor_za64(0, slice_base, pg, ptr);
+}
+
+int16x8_t use_neon_builtin_sm(int16x8_t splat) __arm_streaming_compatible {
+  // expected-error@+1 {{builtin can only be called from a non-streaming 
function}}
+  return (int16x8_t)__builtin_neon_vqaddq_v((int8x16_t)splat, 
(int8x16_t)splat, 33);
+}
+
+int16x8_t use_neon_builtin_sm_in_lambda(int16x8_t splat) 
__arm_streaming_compatible {
+  return [&]{
+/// This should not error (as we switch out of streaming mode to execute 
the lambda).
+/// Note: The result int16x8_t is spilled and reloaded as a q-register.
+return (int16x8_t)__builtin_neon_vqaddq_v((int8x16_t)splat, 
(int8x16_t)splat, 33);
+  }();
+}
+
+float use_incomp_sve_builtin_sm() __arm_streaming {
+  // expected-error@+1 {{builtin can only be called from a non-streaming 
function}}
+  return svadda(svptrue_b32(), 0, svdup_f32(1));
+}
+
+float incomp_sve_sm_fadda_sm_in_lambda(void) __arm_streaming {
+  return [&]{
+/// This should work like the Neon builtin.
+return svadda(svptrue_b32(), 0, svdup_f32(1));
+  }();
+}

>From 0a525bec8ee682a220414025f251413bdade1df4 Mon Sep 17 00:00:00 2001
From: Benjamin Maxwell 
Date: Tue, 28 Jan 2025 15:07:22 +
Subject: [PATCH 2/3] Fixups

---
 .../Sema/aarch64-incompat-sm-builtin-calls.c  | 128 -
 .../aarch64-incompat-sm-builtin-calls.cpp | 129 +-
 2 files changed, 126 insertions(+), 131 deletions(-)
 delete mode 100644 clang/test/Sema/aarch64-incompat-sm-builtin-calls.c

diff --git a/clang/test/Sema/aarch64-incom

[clang] [clang][SME] Account for C++ lambdas in SME builtin diagnostics (PR #124750)

2025-01-29 Thread Benjamin Maxwell via cfe-commits

MacDue wrote:

> Please add some tests for lambdas with streaming attributes, for example:
> 
> ```
> void f() { auto x = []__arm_locally_streaming {}; x(); }
> ```

Done :+1: 

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


[clang] [Clang] disallow attributes on void parameters (PR #124920)

2025-01-29 Thread Erich Keane via cfe-commits


@@ -7986,6 +7986,12 @@ void Parser::ParseParameterDeclarationClause(
 if (getLangOpts().HLSL)
   MaybeParseHLSLAnnotations(DS.getAttributes());
 
+if (ParmDeclarator.getDeclarationAttributes().size() &&

erichkeane wrote:

```suggestion
if (!ParmDeclarator.getDeclarationAttributes().empty() &&
```

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


[clang] [Clang] disallow attributes on void parameters (PR #124920)

2025-01-29 Thread via cfe-commits

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


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


[clang] [Clang] disallow attributes on void parameters (PR #124920)

2025-01-29 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk updated 
https://github.com/llvm/llvm-project/pull/124920

>From bd731e4be65fc9c1746aa6a8f63d206eb54bb2be Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Wed, 29 Jan 2025 15:17:06 +0200
Subject: [PATCH 1/3] [Clang] disallow attributes on void parameters

---
 clang/docs/ReleaseNotes.rst| 2 ++
 clang/lib/Parse/ParseDecl.cpp  | 7 +++
 clang/test/Parser/cxx0x-attributes.cpp | 9 +
 3 files changed, 18 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7fafe2807bd388..0c87e52007d546 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -100,6 +100,8 @@ Removed Compiler Flags
 Attribute Changes in Clang
 --
 
+- Clang now disallows the use of attributes on void parameters. (#GH108819)
+
 Improvements to Clang's diagnostics
 ---
 
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index f136d5007e8a5f..0b88dd4449b1e2 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -7986,6 +7986,13 @@ void Parser::ParseParameterDeclarationClause(
 if (getLangOpts().HLSL)
   MaybeParseHLSLAnnotations(DS.getAttributes());
 
+if (ParmDeclarator.getIdentifier() == nullptr &&
+ParmDeclarator.getDeclarationAttributes().size() &&
+ParmDeclarator.getDeclSpec().getTypeSpecType() == DeclSpec::TST_void) {
+  SourceRange AttrRange = ParmDeclarator.getDeclarationAttributes().Range;
+  Diag(AttrRange.getBegin(), diag::err_attributes_not_allowed) << 
AttrRange;
+}
+
 if (Tok.is(tok::kw_requires)) {
   // User tried to define a requires clause in a parameter declaration,
   // which is surely not a function declaration.
diff --git a/clang/test/Parser/cxx0x-attributes.cpp 
b/clang/test/Parser/cxx0x-attributes.cpp
index fad3010c98b9c2..13fcdd142fa841 100644
--- a/clang/test/Parser/cxx0x-attributes.cpp
+++ b/clang/test/Parser/cxx0x-attributes.cpp
@@ -453,3 +453,12 @@ namespace P2361 {
 }
 
 alignas(int) struct AlignAsAttribute {}; // expected-error {{misplaced 
attributes; expected attributes here}}
+
+namespace GH108819 {
+void a([[maybe_unused]] void) {} // expected-error {{an 
attribute list cannot appear here}} \
+ // expected-warning {{use of 
the 'maybe_unused' attribute is a C++17 extension}}
+void b([[deprecated]] void) {}   // expected-error {{an 
attribute list cannot appear here}} \
+ // expected-warning {{use of 
the 'deprecated' attribute is a C++14 extension}}
+void c([[clang::lifetimebound]] void) {} // expected-error {{an 
attribute list cannot appear here}}
+void d([[clang::annotate("a", "b", 1)]] void) {} // expected-error {{an 
attribute list cannot appear here}}
+}

>From 063f76730ebfd289f5340d0d8477a43a5ea965c2 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Wed, 29 Jan 2025 15:54:48 +0200
Subject: [PATCH 2/3] remove unnecessary name check

---
 clang/lib/Parse/ParseDecl.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 0b88dd4449b1e2..934c16c9591520 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -7986,8 +7986,7 @@ void Parser::ParseParameterDeclarationClause(
 if (getLangOpts().HLSL)
   MaybeParseHLSLAnnotations(DS.getAttributes());
 
-if (ParmDeclarator.getIdentifier() == nullptr &&
-ParmDeclarator.getDeclarationAttributes().size() &&
+if (ParmDeclarator.getDeclarationAttributes().size() &&
 ParmDeclarator.getDeclSpec().getTypeSpecType() == DeclSpec::TST_void) {
   SourceRange AttrRange = ParmDeclarator.getDeclarationAttributes().Range;
   Diag(AttrRange.getBegin(), diag::err_attributes_not_allowed) << 
AttrRange;

>From 3f3431513ad59111794953d27e64608b3ce2e6e1 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Wed, 29 Jan 2025 16:07:18 +0200
Subject: [PATCH 3/3] use empty instead of size

---
 clang/lib/Parse/ParseDecl.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 934c16c9591520..963b59565953d4 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -7986,7 +7986,7 @@ void Parser::ParseParameterDeclarationClause(
 if (getLangOpts().HLSL)
   MaybeParseHLSLAnnotations(DS.getAttributes());
 
-if (ParmDeclarator.getDeclarationAttributes().size() &&
+if (!ParmDeclarator.getDeclarationAttributes().empty() &&
 ParmDeclarator.getDeclSpec().getTypeSpecType() == DeclSpec::TST_void) {
   SourceRange AttrRange = ParmDeclarator.getDeclarationAttributes().Range;
   Diag(AttrRange.getBegin(), diag::err_attributes_not_allowed) << 
AttrRange;

___
cfe-commits ma

[clang] [Clang] disallow attributes on void parameters (PR #124920)

2025-01-29 Thread Oleksandr T. via cfe-commits


@@ -7986,6 +7986,12 @@ void Parser::ParseParameterDeclarationClause(
 if (getLangOpts().HLSL)
   MaybeParseHLSLAnnotations(DS.getAttributes());
 
+if (ParmDeclarator.getDeclarationAttributes().size() &&

a-tarasyuk wrote:

@erichkeane thanks. changed to use `empty`

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


[clang] [Clang] disallow attributes on void parameters (PR #124920)

2025-01-29 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman commented:

This is a semantic restriction, not a parsing restriction, right?

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


[clang] [Clang] disallow attributes on void parameters (PR #124920)

2025-01-29 Thread Aaron Ballman via cfe-commits

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


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


[clang] [Clang] disallow attributes on void parameters (PR #124920)

2025-01-29 Thread Aaron Ballman via cfe-commits


@@ -453,3 +453,12 @@ namespace P2361 {
 }
 
 alignas(int) struct AlignAsAttribute {}; // expected-error {{misplaced 
attributes; expected attributes here}}
+
+namespace GH108819 {
+void a([[maybe_unused]] void) {} // expected-error {{an 
attribute list cannot appear here}} \

AaronBallman wrote:

I think this is a confusing diagnostic -- an attribute list *can* appear here. 
The problem is that an attribute which appertains to a declaration cannot 
appertain to a void parameter. I think that should be handled in 
SemaDeclAttr.cpp when doing the usual appertainment checks.

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


[clang] [Clang] disallow attributes on void parameters (PR #124920)

2025-01-29 Thread Oleksandr T. via cfe-commits


@@ -453,3 +453,12 @@ namespace P2361 {
 }
 
 alignas(int) struct AlignAsAttribute {}; // expected-error {{misplaced 
attributes; expected attributes here}}
+
+namespace GH108819 {
+void a([[maybe_unused]] void) {} // expected-error {{an 
attribute list cannot appear here}} \

a-tarasyuk wrote:

Thanks for the feedback, I'll check `SemaDeclAttr`. should a different message 
be used here instead?

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


[clang] [AArch64] Refactor implementation of FP8 types (NFC) (PR #123604)

2025-01-29 Thread Timm Baeder via cfe-commits

tbaederr wrote:

Is `__mfp8` a floating type? `isFloatingType()` on it returns `false`, was that 
the case before as well?

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


[clang] [flang] [llvm] [Clang] Remove ARCMigrate (PR #119269)

2025-01-29 Thread Aaron Ballman via cfe-commits

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

LGTM but please wait for @rjmccall to sign off before landing.

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


[clang] [C++20][Modules][Serialization] Delay marking pending incomplete decl chains until the end of `finishPendingActions`. (PR #121245)

2025-01-29 Thread Dmitry Polukhin via cfe-commits

https://github.com/dmpolukhin commented:

LGTM but let @ChuanqiXu9 approve.

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


[clang] [C++20][Modules][Serialization] Delay marking pending incomplete decl chains until the end of `finishPendingActions`. (PR #121245)

2025-01-29 Thread Dmitry Polukhin via cfe-commits

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


[clang] [C++20][Modules][Serialization] Delay marking pending incomplete decl chains until the end of `finishPendingActions`. (PR #121245)

2025-01-29 Thread Dmitry Polukhin via cfe-commits


@@ -0,0 +1,90 @@
+// RUN: rm -rf %t

dmpolukhin wrote:

Please add a comment that the test results in `llvm_unreachable` in debug 
builds so debug build should be used to investigate problems with the test.

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


[clang] [analyzer][docs] CSA release notes for clang-20 (PR #124798)

2025-01-29 Thread Balazs Benics via cfe-commits

https://github.com/steakhal updated 
https://github.com/llvm/llvm-project/pull/124798

>From 65f0bce634bce28430fa2c722ee0a396a8935bba Mon Sep 17 00:00:00 2001
From: Balazs Benics 
Date: Tue, 28 Jan 2025 18:26:37 +0100
Subject: [PATCH] [analyzer][docs] Release notes for clang-20

The commits were gathered using:
```sh
git log --reverse --oneline llvmorg-20-init..llvm/main \
  clang/{lib/StaticAnalyzer,include/clang/StaticAnalyzer} | grep -v NFC | grep 
-v OpenACC | grep -v -i revert
```

After this I categorized the changes and dropped the less user-facing
commits.

FYI, I also ignored Webkit changes because I assue it's fairly specific
for them, and they likely already know what they ship xD.

I used the `LLVM_ENABLE_SPHINX=ON` and `LLVM_ENABLE_DOXYGEN=ON` cmake
options to enable the `docs-clang-html` build target, which generates
the html into `build/tools/clang/docs/html/ReleaseNotes.html` of which I
attach the screenshots to let you judge if it looks all good or not.

I also used Grammarly this time to check for blatant typos.
---
 clang/docs/ReleaseNotes.rst | 106 +++-
 1 file changed, 93 insertions(+), 13 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d8a94703bd9c57..9a25694b3bd867 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1356,30 +1356,62 @@ Static Analyzer
 New features
 
 
-- Now CSA models `__builtin_*_overflow` functions. (#GH102602)
+- The ``__builtin_*_overflow`` functions are now properly modeled. (#GH102602)
 
-- MallocChecker now checks for ``ownership_returns(class, idx)`` and 
``ownership_takes(class, idx)``
-  attributes with class names different from "malloc". Clang static analyzer 
now reports an error
-  if class of allocation and deallocation function mismatches.
+- ``unix.Malloc`` now checks for ``ownership_returns(class, idx)`` and 
``ownership_takes(class, idx)``
+  attributes with class names different from "malloc". It now reports an error
+  if the class of allocation and deallocation function mismatches.
   `Documentation 
`__.
 
 - Function effects, e.g. the ``nonblocking`` and ``nonallocating`` 
"performance constraint"
   attributes, are now verified. For example, for functions declared with the 
``nonblocking``
-  attribute, the compiler can generate warnings about the use of any language 
features, or calls to
+  attribute, the compiler can generate warnings about the use of any language 
features or calls to
   other functions, which may block.
 
 - Introduced ``-warning-suppression-mappings`` flag to control diagnostic
-  suppressions per file. See `documentation 
_` for details.
+  suppressions per file. See `documentation 
`__ for details.
+
+- Started to model GCC asm statements in some basic way. (#GH103714, #GH109838)
 
 Crash and bug fixes
 ^^^
 
 - In loops where the loop condition is opaque (i.e. the analyzer cannot
   determine whether it's true or false), the analyzer will no longer assume
-  execution paths that perform more that two iterations. These unjustified
+  execution paths that perform more than two iterations. These unjustified
   assumptions caused false positive reports (e.g. 100+ out-of-bounds reports in
   the FFMPEG codebase) in loops where the programmer intended only two or three
   steps but the analyzer wasn't able to understand that the loop is limited.
+  Read the `RFC 
`_
+  for details. (#GH119388)
+
+- In clang-19, the ``crosscheck-with-z3-timeout-threshold`` was set to 300ms,
+  but it is now reset back to 15000, aka. 15 seconds. This is to reduce the
+  number of flaky diagnostics due to Z3 query timeouts.
+  If you are affected, read the details at #GH118291 carefully.
+
+- Same as the previous point, but for ``crosscheck-with-z3-rlimit-threshold``
+  and ``crosscheck-with-z3-eqclass-timeout-threshold``.
+  This option is now set to zero, aka. disabled by default. (#GH118291)
+
+- Fixed a crash in the ``unix.Stream`` checker when modeling ``fread``. 
(#GH108393)
+
+- Fixed a crash in the ``core.StackAddressEscape`` checker related to 
``alloca``.
+  Fixes (#GH107852).
+
+- Fixed a crash when invoking a function pointer cast from some non-function 
pointer. (#GH111390)
+
+- Fixed a crash when modeling some ``ArrayInitLoopExpr``. Fixes (#GH112813).
+
+- Fixed a crash in loop unrolling. Fixes (#GH121201).
+
+- The iteration orders of some internal representations of symbols were changed
+  to make their internal ordering more stable. This should improve determinism.
+  This also reduces the number of flaky reports exposed by the Z3 query 
timeouts.
+  (#GH121749)
+
+- The ``unix.BlockInCriticalSection`` now recognizes the ``l

[clang] [C++20][Modules][Serialization] Delay marking pending incomplete decl chains until the end of `finishPendingActions`. (PR #121245)

2025-01-29 Thread Michael Park via cfe-commits

https://github.com/mpark updated 
https://github.com/llvm/llvm-project/pull/121245

>From f1871418523dbd2915e4245e655d283114595730 Mon Sep 17 00:00:00 2001
From: Michael Park 
Date: Tue, 28 Jan 2025 22:01:37 -0800
Subject: [PATCH 1/3] [C++20][Modules][Serialization] Add a unit test for
 #121245.

---
 clang/test/Modules/pr121245.cpp | 93 +
 1 file changed, 93 insertions(+)
 create mode 100644 clang/test/Modules/pr121245.cpp

diff --git a/clang/test/Modules/pr121245.cpp b/clang/test/Modules/pr121245.cpp
new file mode 100644
index 00..0e276ad0e435d1
--- /dev/null
+++ b/clang/test/Modules/pr121245.cpp
@@ -0,0 +1,93 @@
+// If this test fails, it should be investigated under Debug builds.
+// Before the PR, this test was encountering an `llvm_unreachable()`.
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-01.h \
+// RUN:  -fcxx-exceptions -o %t/hu-01.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-02.h \
+// RUN:  -Wno-experimental-header-units -fcxx-exceptions \
+// RUN:  -fmodule-file=%t/hu-01.pcm -o %t/hu-02.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-03.h \
+// RUN:  -Wno-experimental-header-units -fcxx-exceptions \
+// RUN:  -fmodule-file=%t/hu-01.pcm -o %t/hu-03.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-04.h \
+// RUN:  -Wno-experimental-header-units -fcxx-exceptions \
+// RUN:  -fmodule-file=%t/hu-01.pcm -o %t/hu-04.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-05.h \
+// RUN:  -Wno-experimental-header-units -fcxx-exceptions \
+// RUN:  -fmodule-file=%t/hu-03.pcm -fmodule-file=%t/hu-04.pcm \
+// RUN:  -fmodule-file=%t/hu-01.pcm -o %t/hu-05.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-obj %t/main.cpp \
+// RUN:  -Wno-experimental-header-units -fcxx-exceptions \
+// RUN:  -fmodule-file=%t/hu-02.pcm -fmodule-file=%t/hu-05.pcm \
+// RUN:  -fmodule-file=%t/hu-04.pcm -fmodule-file=%t/hu-03.pcm \
+// RUN:  -fmodule-file=%t/hu-01.pcm
+
+//--- hu-01.h
+template 
+struct A {
+  A() {}
+  ~A() {}
+};
+
+template 
+struct EBO : T {
+  EBO() = default;
+};
+
+template 
+struct HT : EBO> {};
+
+//--- hu-02.h
+import "hu-01.h";
+
+inline void f() {
+  HT();
+}
+
+//--- hu-03.h
+import "hu-01.h";
+
+struct C {
+  C();
+
+  HT _;
+};
+
+//--- hu-04.h
+import "hu-01.h";
+
+void g(HT = {});
+
+//--- hu-05.h
+import "hu-03.h";
+import "hu-04.h";
+import "hu-01.h";
+
+struct B {
+  virtual ~B() = default;
+
+  virtual void f() {
+HT();
+  }
+};
+
+//--- main.cpp
+import "hu-02.h";
+import "hu-05.h";
+import "hu-03.h";
+
+int main() {
+  f();
+  C();
+  B();
+}

>From ac5ff8f1d93be542ce8f5a11e0c9dd1d9c9902bf Mon Sep 17 00:00:00 2001
From: Michael Park 
Date: Fri, 27 Dec 2024 17:52:19 -0800
Subject: [PATCH 2/3] [C++20][Modules][Serialization] Delay marking pending
 incomplete decl chains until the end of `finishPendingActions`.

---
 clang/lib/Serialization/ASTReader.cpp | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index f524251c48ddd7..69e6703dbdeb1c 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -10186,12 +10186,12 @@ void ASTReader::visitTopLevelModuleMaps(
 }
 
 void ASTReader::finishPendingActions() {
-  while (
-  !PendingIdentifierInfos.empty() || !PendingDeducedFunctionTypes.empty() 
||
-  !PendingDeducedVarTypes.empty() || !PendingIncompleteDeclChains.empty() 
||
-  !PendingDeclChains.empty() || !PendingMacroIDs.empty() ||
-  !PendingDeclContextInfos.empty() || !PendingUpdateRecords.empty() ||
-  !PendingObjCExtensionIvarRedeclarations.empty()) {
+  while (!PendingIdentifierInfos.empty() ||
+ !PendingDeducedFunctionTypes.empty() ||
+ !PendingDeducedVarTypes.empty() || !PendingDeclChains.empty() ||
+ !PendingMacroIDs.empty() || !PendingDeclContextInfos.empty() ||
+ !PendingUpdateRecords.empty() ||
+ !PendingObjCExtensionIvarRedeclarations.empty()) {
 // If any identifiers with corresponding top-level declarations have
 // been loaded, load those declarations now.
 using TopLevelDeclsMap =
@@ -10239,13 +10239,6 @@ void ASTReader::finishPendingActions() {
 }
 PendingDeducedVarTypes.clear();
 
-// For each decl chain that we wanted to complete while deserializing, mark
-// it as "still needs to be completed".
-for (unsigned I = 0; I != PendingIncompleteDeclChains.size(); ++I) {
-  markIncompleteDeclChain(PendingIncompleteDeclChains[I]);
-}
-PendingIncompleteDeclChains.clear();
-
 // Load pending declaration chains.
 for (unsigned I = 0; I != PendingDeclChains.size(); ++I)
   loadPendingDeclChain(PendingDeclChains[I].first,
@@ -10483,6 +10476,

[clang] Optimize -Wunsafe-buffer-usage. (PR #124554)

2025-01-29 Thread via cfe-commits


@@ -31,27 +35,34 @@
 #define FIXABLE_GADGET(name) GADGET(name)
 #endif
 
+/// A subset of the safe gadgets that may return multiple results.
+#ifndef FIXABLE_GADGET_MULTY_RES
+#define FIXABLE_GADGET_MULTY_RES(name) GADGET(name)
+#endif
+
 WARNING_GADGET(Increment)
 WARNING_GADGET(Decrement)
-WARNING_GADGET(ArraySubscript)
 WARNING_GADGET(PointerArithmetic)
 WARNING_GADGET(UnsafeBufferUsageAttr)
-WARNING_GADGET(UnsafeBufferUsageCtorAttr)
 WARNING_GADGET(DataInvocation)
-WARNING_OPTIONAL_GADGET(UnsafeLibcFunctionCall)
-WARNING_OPTIONAL_GADGET(SpanTwoParamConstructor) // Uses of `std::span(arg0, 
arg1)`
+WARNING_OPTIONAL_GADGET_CTX(ArraySubscript)
+WARNING_OPTIONAL_GADGET_CTX(UnsafeBufferUsageCtorAttr)
+WARNING_OPTIONAL_GADGET_HANDLER(UnsafeLibcFunctionCall)
+WARNING_OPTIONAL_GADGET_HANDLER(SpanTwoParamConstructor) // Uses of 
`std::span(arg0, arg1)`
 FIXABLE_GADGET(ULCArraySubscript)  // `DRE[any]` in an Unspecified 
Lvalue Context
 FIXABLE_GADGET(DerefSimplePtrArithFixable)
 FIXABLE_GADGET(PointerDereference)
-FIXABLE_GADGET(UPCAddressofArraySubscript) // '&DRE[any]' in an Unspecified 
Pointer Context
-FIXABLE_GADGET(UPCStandalonePointer)
-FIXABLE_GADGET(UPCPreIncrement)// '++Ptr' in an Unspecified 
Pointer Context
-FIXABLE_GADGET(UUCAddAssign)// 'Ptr += n' in an Unspecified 
Untyped Context
-FIXABLE_GADGET(PtrToPtrAssignment)
-FIXABLE_GADGET(CArrayToPtrAssignment)
+FIXABLE_GADGET_MULTY_RES(UPCAddressofArraySubscript) // '&DRE[any]' in an 
Unspecified Pointer Context

ivanaivanovska wrote:

Done. 

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


[clang] Optimize -Wunsafe-buffer-usage. (PR #124554)

2025-01-29 Thread via cfe-commits


@@ -79,21 +81,39 @@ static std::string getDREAncestorString(const DeclRefExpr 
*DRE,
 } // namespace
 #endif /* NDEBUG */
 
-namespace clang::ast_matchers {
+class CustomMatcher {
+public:
+  virtual bool matches(const DynTypedNode &DynNode, ASTContext &Ctx,
+   const UnsafeBufferUsageHandler &Handler) = 0;
+  virtual ~CustomMatcher() = default;
+};
+
+struct MatchResult {

ivanaivanovska wrote:

Changed to a class.

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


[clang] Optimize -Wunsafe-buffer-usage. (PR #124554)

2025-01-29 Thread via cfe-commits


@@ -79,21 +81,39 @@ static std::string getDREAncestorString(const DeclRefExpr 
*DRE,
 } // namespace
 #endif /* NDEBUG */
 
-namespace clang::ast_matchers {
+class CustomMatcher {

ivanaivanovska wrote:

Done.

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


[clang] Optimize -Wunsafe-buffer-usage. (PR #124554)

2025-01-29 Thread via cfe-commits


@@ -79,21 +81,39 @@ static std::string getDREAncestorString(const DeclRefExpr 
*DRE,
 } // namespace
 #endif /* NDEBUG */
 
-namespace clang::ast_matchers {
+class CustomMatcher {
+public:
+  virtual bool matches(const DynTypedNode &DynNode, ASTContext &Ctx,
+   const UnsafeBufferUsageHandler &Handler) = 0;
+  virtual ~CustomMatcher() = default;
+};
+
+struct MatchResult {
+public:
+  std::map

ivanaivanovska wrote:

Done.

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


[clang] Optimize -Wunsafe-buffer-usage. (PR #124554)

2025-01-29 Thread via cfe-commits


@@ -79,21 +81,39 @@ static std::string getDREAncestorString(const DeclRefExpr 
*DRE,
 } // namespace
 #endif /* NDEBUG */
 
-namespace clang::ast_matchers {
+class CustomMatcher {

ivanaivanovska wrote:

Done.

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


[clang] Optimize -Wunsafe-buffer-usage. (PR #124554)

2025-01-29 Thread via cfe-commits


@@ -186,106 +205,202 @@ class MatchDescendantVisitor : public 
DynamicRecursiveASTVisitor {
 return DynamicRecursiveASTVisitor::TraverseStmt(Node);
   }
 
+  void set_ast_context(ASTContext &Context) { ActiveASTContext = &Context; }
+
+  void set_handler(const UnsafeBufferUsageHandler &NewHandler) {
+Handler = &NewHandler;
+  }
+
 private:
   // Sets 'Matched' to true if 'Matcher' matches 'Node'
   //
   // Returns 'true' if traversal should continue after this function
   // returns, i.e. if no match is found or 'Bind' is 'BK_All'.
   template  bool match(const T &Node) {
-internal::BoundNodesTreeBuilder RecursiveBuilder(*Builder);
-
-if (Matcher->matches(DynTypedNode::create(Node), Finder,
- &RecursiveBuilder)) {
-  ResultBindings.addMatch(RecursiveBuilder);
+if (Matcher->matches(DynTypedNode::create(Node), *ActiveASTContext,
+ *Handler)) {
   Matches = true;
-  if (Bind != internal::ASTMatchFinder::BK_All)
+  if (!BindAll)
 return false; // Abort as soon as a match is found.
 }
 return true;
   }
 
-  const internal::DynTypedMatcher *const Matcher;
-  internal::ASTMatchFinder *const Finder;
-  internal::BoundNodesTreeBuilder *const Builder;
-  internal::BoundNodesTreeBuilder ResultBindings;
-  const internal::ASTMatchFinder::BindKind Bind;
+  CustomMatcher *const Matcher;
+  /// Defines how bindings are processed on recursive matches.

ivanaivanovska wrote:

Done.

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


[clang] Optimize -Wunsafe-buffer-usage. (PR #124554)

2025-01-29 Thread via cfe-commits


@@ -186,106 +205,202 @@ class MatchDescendantVisitor : public 
DynamicRecursiveASTVisitor {
 return DynamicRecursiveASTVisitor::TraverseStmt(Node);
   }
 
+  void set_ast_context(ASTContext &Context) { ActiveASTContext = &Context; }
+
+  void set_handler(const UnsafeBufferUsageHandler &NewHandler) {
+Handler = &NewHandler;
+  }
+
 private:
   // Sets 'Matched' to true if 'Matcher' matches 'Node'
   //
   // Returns 'true' if traversal should continue after this function
   // returns, i.e. if no match is found or 'Bind' is 'BK_All'.
   template  bool match(const T &Node) {
-internal::BoundNodesTreeBuilder RecursiveBuilder(*Builder);
-
-if (Matcher->matches(DynTypedNode::create(Node), Finder,
- &RecursiveBuilder)) {
-  ResultBindings.addMatch(RecursiveBuilder);
+if (Matcher->matches(DynTypedNode::create(Node), *ActiveASTContext,
+ *Handler)) {
   Matches = true;
-  if (Bind != internal::ASTMatchFinder::BK_All)
+  if (!BindAll)
 return false; // Abort as soon as a match is found.
 }
 return true;
   }
 
-  const internal::DynTypedMatcher *const Matcher;
-  internal::ASTMatchFinder *const Finder;
-  internal::BoundNodesTreeBuilder *const Builder;
-  internal::BoundNodesTreeBuilder ResultBindings;
-  const internal::ASTMatchFinder::BindKind Bind;
+  CustomMatcher *const Matcher;
+  /// Defines how bindings are processed on recursive matches.
+  /// true: Create results for all combinations of bindings that match.
+  /// false: Stop at the first match and only bind the first match.
+  const bool BindAll;
   bool Matches;
   bool ignoreUnevaluatedContext;
+  ASTContext *ActiveASTContext;
+  const UnsafeBufferUsageHandler *Handler;
 };
 
 // Because we're dealing with raw pointers, let's define what we mean by that.
-static auto hasPointerType() {
-  return hasType(hasCanonicalType(pointerType()));
+static auto hasPointerType(const Expr &E) {

ivanaivanovska wrote:

Done.

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


[clang] Optimize -Wunsafe-buffer-usage. (PR #124554)

2025-01-29 Thread via cfe-commits


@@ -79,21 +81,39 @@ static std::string getDREAncestorString(const DeclRefExpr 
*DRE,
 } // namespace
 #endif /* NDEBUG */
 
-namespace clang::ast_matchers {
+class CustomMatcher {
+public:
+  virtual bool matches(const DynTypedNode &DynNode, ASTContext &Ctx,
+   const UnsafeBufferUsageHandler &Handler) = 0;
+  virtual ~CustomMatcher() = default;
+};
+
+struct MatchResult {
+public:
+  std::map
+  Nodes; // DynTypedNode needed to store different types of Nodes, not
+ // necessarily sharing the same base.
+
+  template  const T *getNodeAs(StringRef ID) const {
+auto It = Nodes.find(std::string(ID));
+if (It == Nodes.end()) {
+  return nullptr;
+}
+return It->second.get();
+  }
+};
+
 // A `RecursiveASTVisitor` that traverses all descendants of a given node "n"
 // except for those belonging to a different callable of "n".
 class MatchDescendantVisitor : public DynamicRecursiveASTVisitor {
 public:
   // Creates an AST visitor that matches `Matcher` on all
   // descendants of a given node "n" except for the ones
   // belonging to a different callable of "n".
-  MatchDescendantVisitor(const internal::DynTypedMatcher *Matcher,
- internal::ASTMatchFinder *Finder,
- internal::BoundNodesTreeBuilder *Builder,
- internal::ASTMatchFinder::BindKind Bind,
+  MatchDescendantVisitor(CustomMatcher &Matcher, bool BindAll,
  const bool ignoreUnevaluatedContext)
-  : Matcher(Matcher), Finder(Finder), Builder(Builder), Bind(Bind),
-Matches(false), ignoreUnevaluatedContext(ignoreUnevaluatedContext) {
+  : Matcher(&Matcher), BindAll(BindAll), Matches(false),

ivanaivanovska wrote:

Changed to FindAll.

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


[clang] Optimize -Wunsafe-buffer-usage. (PR #124554)

2025-01-29 Thread via cfe-commits


@@ -186,106 +205,202 @@ class MatchDescendantVisitor : public 
DynamicRecursiveASTVisitor {
 return DynamicRecursiveASTVisitor::TraverseStmt(Node);
   }
 
+  void set_ast_context(ASTContext &Context) { ActiveASTContext = &Context; }

ivanaivanovska wrote:

Done.

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


[clang] Optimize -Wunsafe-buffer-usage. (PR #124554)

2025-01-29 Thread via cfe-commits


@@ -1986,112 +2327,142 @@ class DerefSimplePtrArithFixableGadget : public 
FixableGadget {
   }
 };
 
-/// Scan the function and return a list of gadgets found with provided kits.
-static void findGadgets(const Stmt *S, ASTContext &Ctx,
-const UnsafeBufferUsageHandler &Handler,
-bool EmitSuggestions, FixableGadgetList 
&FixableGadgets,
-WarningGadgetList &WarningGadgets,
-DeclUseTracker &Tracker) {
+class EvaluatedStmtMatcher : public CustomMatcher {
 
-  struct GadgetFinderCallback : MatchFinder::MatchCallback {
-GadgetFinderCallback(FixableGadgetList &FixableGadgets,
- WarningGadgetList &WarningGadgets,
- DeclUseTracker &Tracker)
-: FixableGadgets(FixableGadgets), WarningGadgets(WarningGadgets),
-  Tracker(Tracker) {}
-
-void run(const MatchFinder::MatchResult &Result) override {
-  // In debug mode, assert that we've found exactly one gadget.
-  // This helps us avoid conflicts in .bind() tags.
-#if NDEBUG
-#define NEXT return
-#else
-  [[maybe_unused]] int numFound = 0;
-#define NEXT ++numFound
-#endif
+public:
+  WarningGadgetList &WarningGadgets;
 
-  if (const auto *DRE = Result.Nodes.getNodeAs("any_dre")) {
-Tracker.discoverUse(DRE);
-NEXT;
-  }
+  EvaluatedStmtMatcher(WarningGadgetList &WarningGadgets)
+  : WarningGadgets(WarningGadgets) {}
 
-  if (const auto *DS = Result.Nodes.getNodeAs("any_ds")) {
-Tracker.discoverDecl(DS);
-NEXT;
-  }
+  bool matches(const DynTypedNode &DynNode, ASTContext &Ctx,
+   const UnsafeBufferUsageHandler &Handler) override {
+const Stmt *S = DynNode.get();
+if (!S)
+  return false;
+
+MatchResult Result;
+#define WARNING_GADGET(name)   
\

ivanaivanovska wrote:

Done. (I kept the original macros and added the missing parameters where 
needed.)

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


[clang] [Clang] disallow attributes on void parameters (PR #124920)

2025-01-29 Thread via cfe-commits


@@ -7986,6 +7986,13 @@ void Parser::ParseParameterDeclarationClause(
 if (getLangOpts().HLSL)
   MaybeParseHLSLAnnotations(DS.getAttributes());
 
+if (ParmDeclarator.getIdentifier() == nullptr &&

cor3ntin wrote:

I don't think checking checking for an identifier makes sense, the type is 
enough

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


[clang] [llvm] [LLVM][AMDGPU] Add Intrinsic and Builtin for ds_bpermute_fi_b32 (PR #124616)

2025-01-29 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`openmp-offload-libc-amdgpu-runtime` running on `omp-vega20-1` while building 
`clang,llvm` at step 7 "Add check check-offload".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/73/builds/12659


Here is the relevant piece of the build log for the reference

```
Step 7 (Add check check-offload) failure: test (failure)
 TEST 'libomptarget :: amdgcn-amd-amdhsa :: 
libc/global_ctor_dtor.cpp' FAILED 
Exit Code: 2

Command Output (stdout):
--
# RUN: at line 1
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/clang++
 -fopenmp-I 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test 
-I 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -L 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 -L /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib -L 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
  -nogpulib 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib
  -fopenmp-targets=amdgcn-amd-amdhsa 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/libc/global_ctor_dtor.cpp
 -o 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/libc/Output/global_ctor_dtor.cpp.tmp
 -Xoffload-linker -lc -Xoffload-linker -lm 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a
 && 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/libc/Output/global_ctor_dtor.cpp.tmp
 | 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/FileCheck
 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/libc/global_ctor_dtor.cpp
# executed command: 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/clang++
 -fopenmp -I 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test 
-I 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -L 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 -L /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib -L 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -nogpulib 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib
 -fopenmp-targets=amdgcn-amd-amdhsa 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/libc/global_ctor_dtor.cpp
 -o 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/libc/Output/global_ctor_dtor.cpp.tmp
 -Xoffload-linker -lc -Xoffload-linker -lm 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a
# executed command: 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/libc/Output/global_ctor_dtor.cpp.tmp
# note: command had no output on stdout or stderr
# error: command failed with exit status: -11
# executed command: 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/FileCheck
 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/libc/global_ctor_dtor.cpp
# .---command stderr
# | FileCheck error: '' is empty.
# | FileCheck command line:  
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/FileCheck
 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/libc/global_ctor_dtor.cpp
# `-
# error: command failed with exit status: 2

--




```



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


[clang] [Clang] disallow attributes on void parameters (PR #124920)

2025-01-29 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk updated 
https://github.com/llvm/llvm-project/pull/124920

>From bd731e4be65fc9c1746aa6a8f63d206eb54bb2be Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Wed, 29 Jan 2025 15:17:06 +0200
Subject: [PATCH 1/2] [Clang] disallow attributes on void parameters

---
 clang/docs/ReleaseNotes.rst| 2 ++
 clang/lib/Parse/ParseDecl.cpp  | 7 +++
 clang/test/Parser/cxx0x-attributes.cpp | 9 +
 3 files changed, 18 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7fafe2807bd388..0c87e52007d546 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -100,6 +100,8 @@ Removed Compiler Flags
 Attribute Changes in Clang
 --
 
+- Clang now disallows the use of attributes on void parameters. (#GH108819)
+
 Improvements to Clang's diagnostics
 ---
 
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index f136d5007e8a5f..0b88dd4449b1e2 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -7986,6 +7986,13 @@ void Parser::ParseParameterDeclarationClause(
 if (getLangOpts().HLSL)
   MaybeParseHLSLAnnotations(DS.getAttributes());
 
+if (ParmDeclarator.getIdentifier() == nullptr &&
+ParmDeclarator.getDeclarationAttributes().size() &&
+ParmDeclarator.getDeclSpec().getTypeSpecType() == DeclSpec::TST_void) {
+  SourceRange AttrRange = ParmDeclarator.getDeclarationAttributes().Range;
+  Diag(AttrRange.getBegin(), diag::err_attributes_not_allowed) << 
AttrRange;
+}
+
 if (Tok.is(tok::kw_requires)) {
   // User tried to define a requires clause in a parameter declaration,
   // which is surely not a function declaration.
diff --git a/clang/test/Parser/cxx0x-attributes.cpp 
b/clang/test/Parser/cxx0x-attributes.cpp
index fad3010c98b9c2..13fcdd142fa841 100644
--- a/clang/test/Parser/cxx0x-attributes.cpp
+++ b/clang/test/Parser/cxx0x-attributes.cpp
@@ -453,3 +453,12 @@ namespace P2361 {
 }
 
 alignas(int) struct AlignAsAttribute {}; // expected-error {{misplaced 
attributes; expected attributes here}}
+
+namespace GH108819 {
+void a([[maybe_unused]] void) {} // expected-error {{an 
attribute list cannot appear here}} \
+ // expected-warning {{use of 
the 'maybe_unused' attribute is a C++17 extension}}
+void b([[deprecated]] void) {}   // expected-error {{an 
attribute list cannot appear here}} \
+ // expected-warning {{use of 
the 'deprecated' attribute is a C++14 extension}}
+void c([[clang::lifetimebound]] void) {} // expected-error {{an 
attribute list cannot appear here}}
+void d([[clang::annotate("a", "b", 1)]] void) {} // expected-error {{an 
attribute list cannot appear here}}
+}

>From 063f76730ebfd289f5340d0d8477a43a5ea965c2 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Wed, 29 Jan 2025 15:54:48 +0200
Subject: [PATCH 2/2] remove unnecessary name check

---
 clang/lib/Parse/ParseDecl.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 0b88dd4449b1e2..934c16c9591520 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -7986,8 +7986,7 @@ void Parser::ParseParameterDeclarationClause(
 if (getLangOpts().HLSL)
   MaybeParseHLSLAnnotations(DS.getAttributes());
 
-if (ParmDeclarator.getIdentifier() == nullptr &&
-ParmDeclarator.getDeclarationAttributes().size() &&
+if (ParmDeclarator.getDeclarationAttributes().size() &&
 ParmDeclarator.getDeclSpec().getTypeSpecType() == DeclSpec::TST_void) {
   SourceRange AttrRange = ParmDeclarator.getDeclarationAttributes().Range;
   Diag(AttrRange.getBegin(), diag::err_attributes_not_allowed) << 
AttrRange;

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


[clang] [Clang] disallow attributes on void parameters (PR #124920)

2025-01-29 Thread Oleksandr T. via cfe-commits


@@ -7986,6 +7986,13 @@ void Parser::ParseParameterDeclarationClause(
 if (getLangOpts().HLSL)
   MaybeParseHLSLAnnotations(DS.getAttributes());
 
+if (ParmDeclarator.getIdentifier() == nullptr &&

a-tarasyuk wrote:

@cor3ntin thanks for the feedback. I've removed it.

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


[clang] [Clang] disallow attributes on void parameters (PR #124920)

2025-01-29 Thread Erich Keane via cfe-commits

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


[clang] [Clang] disallow attributes on void parameters (PR #124920)

2025-01-29 Thread Erich Keane via cfe-commits

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

1 nit, else LGTM.

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


  1   2   3   4   5   >