[clang-tools-extra] [clangd] Support `-specs` arguments when querying the driver. (PR #70285)

2023-11-03 Thread Nathan Ridge via cfe-commits

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

Thanks!

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


[clang-tools-extra] de75008 - [clangd] Support `-specs` arguments when querying the driver. (#70285)

2023-11-03 Thread via cfe-commits

Author: Chris Carlon
Date: 2023-11-03T03:03:23-04:00
New Revision: de750085547ed26d2ad9432ffdbd083864c0ad9b

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

LOG: [clangd] Support `-specs` arguments when querying the driver. (#70285)

Similarly to commit 3935a29, forward spec file arguments to the driver
if they appear in the compile database. Spec files can affect the
include search path.

fixes clangd/clangd#1410

Added: 


Modified: 
clang-tools-extra/clangd/SystemIncludeExtractor.cpp
clang-tools-extra/clangd/test/system-include-extractor.test

Removed: 




diff  --git a/clang-tools-extra/clangd/SystemIncludeExtractor.cpp 
b/clang-tools-extra/clangd/SystemIncludeExtractor.cpp
index a86f152c3bf364e..ea98c7d948a2f6d 100644
--- a/clang-tools-extra/clangd/SystemIncludeExtractor.cpp
+++ b/clang-tools-extra/clangd/SystemIncludeExtractor.cpp
@@ -89,13 +89,14 @@ struct DriverArgs {
   std::string ISysroot;
   std::string Target;
   std::string Stdlib;
+  llvm::SmallVector Specs;
 
   bool operator==(const DriverArgs &RHS) const {
 return std::tie(Driver, StandardIncludes, StandardCXXIncludes, Lang,
-Sysroot, ISysroot, Target, Stdlib) ==
+Sysroot, ISysroot, Target, Stdlib, Specs) ==
std::tie(RHS.Driver, RHS.StandardIncludes, RHS.StandardCXXIncludes,
-RHS.Lang, RHS.Sysroot, RHS.ISysroot, RHS.Target,
-RHS.Stdlib);
+RHS.Lang, RHS.Sysroot, RHS.ISysroot, RHS.Target, 
RHS.Stdlib,
+RHS.Specs);
   }
 
   DriverArgs(const tooling::CompileCommand &Cmd, llvm::StringRef File) {
@@ -145,6 +146,17 @@ struct DriverArgs {
   Stdlib = Cmd.CommandLine[I + 1];
   } else if (Arg.consume_front("-stdlib=")) {
 Stdlib = Arg.str();
+  } else if (Arg.startswith("-specs=")) {
+// clang requires a single token like `-specs=file` or `--specs=file`,
+// but gcc will accept two tokens like `--specs file`. Since the
+// compilation database is presumably correct, we just forward the 
flags
+// as-is.
+Specs.push_back(Arg.str());
+  } else if (Arg.startswith("--specs=")) {
+Specs.push_back(Arg.str());
+  } else if (Arg == "--specs" && I + 1 < E) {
+Specs.push_back(Arg.str());
+Specs.push_back(Cmd.CommandLine[I + 1]);
   }
 }
 
@@ -186,6 +198,11 @@ struct DriverArgs {
   Args.append({"-target", Target});
 if (!Stdlib.empty())
   Args.append({"--stdlib", Stdlib});
+
+for (llvm::StringRef Spec : Specs) {
+  Args.push_back(Spec);
+}
+
 return Args;
   }
 
@@ -210,7 +227,7 @@ template <> struct DenseMapInfo {
 return Driver;
   }
   static unsigned getHashValue(const DriverArgs &Val) {
-return llvm::hash_value(std::tuple{
+unsigned FixedFieldsHash = llvm::hash_value(std::tuple{
 Val.Driver,
 Val.StandardIncludes,
 Val.StandardCXXIncludes,
@@ -220,6 +237,11 @@ template <> struct DenseMapInfo {
 Val.Target,
 Val.Stdlib,
 });
+
+unsigned SpecsHash =
+llvm::hash_combine_range(Val.Specs.begin(), Val.Specs.end());
+
+return llvm::hash_combine(FixedFieldsHash, SpecsHash);
   }
   static bool isEqual(const DriverArgs &LHS, const DriverArgs &RHS) {
 return LHS == RHS;

diff  --git a/clang-tools-extra/clangd/test/system-include-extractor.test 
b/clang-tools-extra/clangd/test/system-include-extractor.test
index cbb3018b2fa7349..4ccc0936713246b 100644
--- a/clang-tools-extra/clangd/test/system-include-extractor.test
+++ b/clang-tools-extra/clangd/test/system-include-extractor.test
@@ -19,6 +19,10 @@
 # RUN: echo '[ -z "${args##*"-isysroot /isysroot"*}" ] || exit' >> 
%t.dir/bin/my_driver.sh
 # RUN: echo '[ -z "${args##*"-target arm-linux-gnueabihf"*}" ] || exit' >> 
%t.dir/bin/my_driver.sh
 # RUN: echo '[ -z "${args##*"--stdlib libc++"*}" ] || exit' >> 
%t.dir/bin/my_driver.sh
+# RUN: echo '[ -z "${args##*"-specs=test.spec"*}" ] || exit' >> 
%t.dir/bin/my_driver.sh
+# RUN: echo '[ -z "${args##*"--specs=test2.spec"*}" ] || exit' >> 
%t.dir/bin/my_driver.sh
+# Check that clangd drops other flags like -lc++, which don't affect includes
+# RUN: echo '[ -n "${args##*"-lc++"*}" ] || exit' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'echo line to ignore >&2' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'printf "Target: arm-linux-gnueabihf\r\n" >&2' >> 
%t.dir/bin/my_driver.sh
 # RUN: echo 'printf "#include <...> search starts here:\r\n" >&2' >> 
%t.dir/bin/my_driver.sh
@@ -38,7 +42,7 @@
 
 # Generate a compile_commands.json that will query the mock driver we've
 # created. Which should add a.h and b.h into include search path.
-# RUN: echo '[{"directory": "%/t.dir", "command": "my_driver.sh the-file.cpp 

[clang-tools-extra] [clangd] Support `-specs` arguments when querying the driver. (PR #70285)

2023-11-03 Thread Nathan Ridge via cfe-commits

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


[PATCH] D151730: [RISCV] Support target attribute for function

2023-11-03 Thread Piyou Chen via Phabricator via cfe-commits
BeMg added inline comments.



Comment at: clang/lib/Basic/Targets/RISCV.cpp:370
+ std::vector &Features) {
+  Features.push_back("__RISCV_TargetAttrNeedOverride");
+  auto RII = llvm::RISCVISAInfo::parseArchString(

craig.topper wrote:
> Why do we need "__RISCV_TargetAttrNeedOverride"?
My idea is using `__RISCV_TargetAttrNeedOverride` to distinguish the 
module-level feature and target attribute feature.

The module-level feature will merge with target attribute feature in 
https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/ASTContext.cpp#L13481.
 And be used/refine inside RISCVTargetInfo::initFeatureMap.

After merge, It could find the target attribute feature start point by 
analyzing FeatureVec, but I prefer use the `__RISCV_TargetAttrNeedOverride` to 
do this job.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151730

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


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

2023-11-03 Thread Fangrui Song via cfe-commits


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

MaskRay wrote:

GCC just doesn't support msan :)

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


[clang] [clang-repl] [test] Make an XFAIL more precise (PR #70991)

2023-11-03 Thread via cfe-commits

dyung wrote:

> > > If you still need help reproducing or debugging the issue on our bot, 
> > > please let me know.
> > 
> > 
> > Thanks, much appreciated. Can you test if 
> > [mstorsjo@clang-repl-xfail](https://github.com/mstorsjo/llvm-project/commit/clang-repl-xfail)
> >  seems to run correctly in this environment? Otherwise I'll try to push it 
> > tomorrow and see how it fares on the bot.

It failed, but due to a typo in the XFAIL you added:
```
target={{.*}-ps4, target={{.*}-ps5
```
These should have balanced braces. If I add the missing braces, the test passes 
with an XFAIL on the bot.

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


[llvm] [clang] [WebAssembly] Mark externref as not being valid vector elements (PR #71069)

2023-11-03 Thread Paulo Matos via cfe-commits

pmatos wrote:

> @pmatos If you don't want to go all the way to target extension types, is it 
> possible to gracefully handle this in wasm's TTI cost model? Return an 
> invalid or very high cost in this case?

Unfortunately that actually doesn't work. We never get to the point of 
calculating a cost because before doing that we calculate in 
`SLPVectorizerPass::tryToVectorizeList` we call `TTI->getNumberOfParts(VecTy)`. 
It's deep inside getNumberOfParts that we fail because we cannot calculate how 
many parts there are. Which is fair enough, since we build a vector of 
externref that can't be built. Only later in the function we try to calculate 
the cost but by then we have asserted long before.

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


[clang] [clang][TSA] Make RequiresCapability a DeclOrType attribute (PR #67095)

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


tbaederr wrote:

It's pretty easy to get an error like:
```
./tsa.c:77:18: error: incompatible function pointer types assigning to 'int 
(*)(int) __attribute__((requires_capability(blah)))' from 'int (void)' 
[-Wincompatible-function-pointer-types]
   77 | function_ptr = foo2;
  |  ^ 
```

but as soon as I change `foo2` to also take an int parameter, the error 
vanishes completely.

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


[clang] [clang][TSA] Make RequiresCapability a DeclOrType attribute (PR #67095)

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


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

>From c0708670eac0a079c878e94093897a708ece044d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Fri, 22 Sep 2023 08:42:05 +0200
Subject: [PATCH 1/5] [clang][TSA] Make RequiresCapability a DeclOrType
 attribute

---
 clang/include/clang/Basic/Attr.td |  6 +++---
 clang/test/Sema/warn-thread-safety-analysis.c | 11 +++
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 60b54c155e5..8963c2d3c660768 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3331,7 +3331,7 @@ def ReleaseCapability : InheritableAttr {
   let Documentation = [ReleaseCapabilityDocs];
 }
 
-def RequiresCapability : InheritableAttr {
+def RequiresCapability : DeclOrTypeAttr {
   let Spellings = [Clang<"requires_capability", 0>,
Clang<"exclusive_locks_required", 0>,
Clang<"requires_shared_capability", 0>,
@@ -3340,8 +3340,8 @@ def RequiresCapability : InheritableAttr {
   let LateParsed = 1;
   let TemplateDependent = 1;
   let ParseArgumentsAsUnevaluated = 1;
-  let InheritEvenIfAlreadyPresent = 1;
-  let Subjects = SubjectList<[Function]>;
+  /*let InheritEvenIfAlreadyPresent = 1;*/
+  /*let Subjects = SubjectList<[Function]>;*/
   let Accessors = [Accessor<"isShared", [Clang<"requires_shared_capability", 
0>,
  Clang<"shared_locks_required", 0>]>];
   let Documentation = [Undocumented];
diff --git a/clang/test/Sema/warn-thread-safety-analysis.c 
b/clang/test/Sema/warn-thread-safety-analysis.c
index 642ea88ec3c96f7..cd852efac21cb81 100644
--- a/clang/test/Sema/warn-thread-safety-analysis.c
+++ b/clang/test/Sema/warn-thread-safety-analysis.c
@@ -136,6 +136,17 @@ int main(void) {
 // Cleanup happens automatically -> no warning.
   }
 
+  /// Function pointers
+  {
+int __attribute__((requires_capability(&mu1))) (*function_ptr)(int) = 
Foo_fun1;
+
+function_ptr(5); // expected-warning {{calling function 'function_ptr' 
requires holding mutex 'mu1'}}
+
+mutex_exclusive_lock(&mu1);
+int five = function_ptr(5);
+mutex_exclusive_unlock(&mu1);
+  }
+
   return 0;
 }
 

>From a4be29c2a872cfaa1738bf1fee329a2c46473486 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Tue, 26 Sep 2023 09:57:41 +0200
Subject: [PATCH 2/5] Restrict to functions and function pointer decls

---
 clang/include/clang/Basic/Attr.td |  2 +-
 clang/lib/Sema/SemaDeclAttr.cpp   | 10 ++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 8963c2d3c660768..3f0c39e982017fa 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3340,7 +3340,7 @@ def RequiresCapability : DeclOrTypeAttr {
   let LateParsed = 1;
   let TemplateDependent = 1;
   let ParseArgumentsAsUnevaluated = 1;
-  /*let InheritEvenIfAlreadyPresent = 1;*/
+  let InheritEvenIfAlreadyPresent = 1;
   /*let Subjects = SubjectList<[Function]>;*/
   let Accessors = [Accessor<"isShared", [Clang<"requires_shared_capability", 
0>,
  Clang<"shared_locks_required", 0>]>];
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 842a01a88cd3c6d..dd053b73be635bb 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -8187,6 +8187,16 @@ static void handleRequiresCapabilityAttr(Sema &S, Decl 
*D,
   if (!AL.checkAtLeastNumArgs(S, 1))
 return;
 
+  // We allow this on function declaration as well as
+  // variable declarations of function pointer type.
+  if (!D->isFunctionPointerType() && !isa(D)) {
+// FIXME: Diagnostic should say "functions and function pointer decls" now 
I
+// guess.
+S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
+<< AL << AL.isRegularKeywordAttribute() << ExpectedFunction;
+return;
+  }
+
   // check that all arguments are lockable objects
   SmallVector Args;
   checkAttrArgsAreCapabilityObjs(S, D, AL, Args);

>From 5032a3d25ee404884965a8cc8e20685ccf20b51a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Fri, 13 Oct 2023 10:23:43 +0200
Subject: [PATCH 3/5] Add processing to SemaType.cpp

---
 clang/include/clang/Basic/Attr.td |  2 +-
 clang/lib/Sema/SemaDeclAttr.cpp   | 10 --
 clang/lib/Sema/SemaType.cpp   | 30 ++
 3 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 3f0c39e982017fa..bce0e2f2ac9f167 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3341,7 

[clang] clang: Add pragma clang fp reciprocal (PR #68267)

2023-11-03 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm updated 
https://github.com/llvm/llvm-project/pull/68267

>From db9b84992dbd6d75dc5c23b11d63c195400d5bc1 Mon Sep 17 00:00:00 2001
From: Matt Arsenault 
Date: Thu, 31 Aug 2023 17:33:35 -0400
Subject: [PATCH] clang: Add pragma clang fp reciprocal

Just follow allow with the reassociate pragma. This
allows locally setting the arcp fast math flag. Previously you
could only access this through the global -freciprocal-math.
---
 clang/docs/LanguageExtensions.rst |  16 +++
 clang/docs/ReleaseNotes.rst   |   2 +
 .../clang/Basic/DiagnosticParseKinds.td   |   3 +-
 .../clang/Basic/DiagnosticSemaKinds.td|   2 +-
 clang/include/clang/Basic/PragmaKinds.h   |   9 ++
 clang/include/clang/Sema/Sema.h   |   5 +-
 clang/lib/Parse/ParsePragma.cpp   |  52 ---
 clang/lib/Sema/SemaAttr.cpp   |  18 ++-
 clang/test/CodeGen/fp-reciprocal-pragma.cpp   | 130 ++
 clang/test/Parser/pragma-fp-contract.c|  15 ++
 clang/test/Parser/pragma-fp.cpp   |   4 +-
 .../test/Sema/eval-method-with-unsafe-math.c  |  32 +
 12 files changed, 259 insertions(+), 29 deletions(-)
 create mode 100644 clang/test/CodeGen/fp-reciprocal-pragma.cpp

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 30e288f986782fd..090600275956be0 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -4617,6 +4617,22 @@ The pragma can take two values: ``on`` and ``off``.
 float v = t + z;
   }
 
+``#pragma clang fp reciprocal`` allows control over using reciprocal
+approximations in floating point expressions. When enabled, this
+pragma allows the expression ``x / y`` to be approximated as ``x *
+(1.0 / y)``.  This pragma can be used to disable reciprocal
+approximation when it is otherwise enabled for the translation unit
+with the ``-freciprocal-math`` flag or other fast-math options. The
+pragma can take two values: ``on`` and ``off``.
+
+.. code-block:: c++
+
+  float f(float x, float y)
+  {
+// Enable floating point reciprocal approximation
+#pragma clang fp reciprocal(on)
+return x / y;
+  }
 
 ``#pragma clang fp contract`` specifies whether the compiler should
 contract a multiply and an addition (or subtraction) into a fused FMA
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4696836b3a00caa..ad28acf61226136 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -218,6 +218,8 @@ Non-comprehensive list of changes in this release
   For scalable vectors, e.g., SVE or RISC-V V, the number of elements is not 
known at compile-time and is
   determined at runtime.
 
+* Added ``#pragma clang fp reciprocal``.
+
 New Compiler Flags
 --
 
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index de180344fcc5c74..2f3bef33f936883 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1569,12 +1569,13 @@ def note_pragma_loop_invalid_vectorize_option : Note<
   "vectorize_width(X, scalable) where X is an integer, or 
vectorize_width('fixed' or 'scalable')">;
 
 def err_pragma_fp_invalid_option : Error<
-  "%select{invalid|missing}0 option%select{ %1|}0; expected 'contract', 
'reassociate' or 'exceptions'">;
+  "%select{invalid|missing}0 option%select{ %1|}0; expected 'contract', 
'reassociate', 'reciprocal', or 'exceptions'">;
 def err_pragma_fp_invalid_argument : Error<
   "unexpected argument '%0' to '#pragma clang fp %1'; expected "
   "%select{"
   "'fast' or 'on' or 'off'|"
   "'on' or 'off'|"
+  "'on' or 'off'|"
   "'ignore', 'maytrap' or 'strict'|"
   "'source', 'double' or 'extended'}2">;
 
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 474afc2fb99c1f0..d23d3dd8b592ec9 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6755,7 +6755,7 @@ def warn_floatingpoint_eq : Warning<
 
 def err_setting_eval_method_used_in_unsafe_context : Error <
   "%select{'#pragma clang fp eval_method'|option 'ffp-eval-method'}0 cannot be 
used with "
-  "%select{option 'fapprox-func'|option 'mreassociate'|option 
'freciprocal'|option 'ffp-eval-method'|'#pragma clang fp reassociate'}1">;
+  "%select{option 'fapprox-func'|option 'mreassociate'|option 
'freciprocal'|option 'ffp-eval-method'|'#pragma clang fp reassociate'|'#pragma 
clang fp reciprocal'}1">;
 
 def warn_remainder_division_by_zero : Warning<
   "%select{remainder|division}0 by zero is undefined">,
diff --git a/clang/include/clang/Basic/PragmaKinds.h 
b/clang/include/clang/Basic/PragmaKinds.h
index 176bbc9ac7caaec..a4789ccde5ec3c1 100644
--- a/clang/include/clang/Basic/PragmaKinds.h
+++ b/clang/include/clang/Basic/PragmaKinds.h
@@ -34,6 +34,15 @@ enum Pragm

[clang] [AMDGPU] const-fold imm operands of amdgcn_update_dpp intrinsic (PR #71139)

2023-11-03 Thread Pravin Jagtap via cfe-commits

https://github.com/pravinjagtap updated 
https://github.com/llvm/llvm-project/pull/71139

>From c28e9f9fb753e41bc539fa4c45bd7896d7c5d04d Mon Sep 17 00:00:00 2001
From: Pravin Jagtap 
Date: Fri, 3 Nov 2023 00:04:14 -0400
Subject: [PATCH 1/2] [AMDGPU] const-fold imm operands of amdgcn_update_dpp
 intrinsic

---
 clang/lib/CodeGen/CGBuiltin.cpp  | 16 +++-
 clang/test/CodeGenHIP/dpp-const-fold.hip | 48 
 2 files changed, 62 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/CodeGenHIP/dpp-const-fold.hip

diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index e047d31c012116f..a4049cbc79d303d 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17632,8 +17632,20 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned 
BuiltinID,
   case AMDGPU::BI__builtin_amdgcn_mov_dpp:
   case AMDGPU::BI__builtin_amdgcn_update_dpp: {
 llvm::SmallVector Args;
-for (unsigned I = 0; I != E->getNumArgs(); ++I)
-  Args.push_back(EmitScalarExpr(E->getArg(I)));
+for (unsigned I = 0; I != E->getNumArgs(); ++I) {
+  llvm::Value *Arg = EmitScalarExpr(E->getArg(I));
+  // Except first two input operands, all other are imm operands for dpp
+  // intrinsic.
+  if (llvm::is_contained(std::initializer_list{2, 3, 4, 5}, I)) {
+// If this is required to be a constant, constant fold it so that we
+// know that the generated intrinsic gets a ConstantInt.
+std::optional Result =
+E->getArg(I)->getIntegerConstantExpr(getContext());
+assert(Result && "Expected argument to be a constant");
+Arg = llvm::ConstantInt::get(getLLVMContext(), *Result);
+  }
+  Args.push_back(Arg);
+}
 assert(Args.size() == 5 || Args.size() == 6);
 if (Args.size() == 5)
   Args.insert(Args.begin(), llvm::PoisonValue::get(Args[0]->getType()));
diff --git a/clang/test/CodeGenHIP/dpp-const-fold.hip 
b/clang/test/CodeGenHIP/dpp-const-fold.hip
new file mode 100644
index 000..1d1d135fb06239a
--- /dev/null
+++ b/clang/test/CodeGenHIP/dpp-const-fold.hip
@@ -0,0 +1,48 @@
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang --offload-arch=gfx906 -S -o - -emit-llvm --cuda-device-only \
+// RUN:   %s | FileCheck %s
+
+constexpr static int OpCtrl()
+{
+return 15 + 1;
+}
+
+constexpr static int RowMask()
+{
+return 3 + 1;
+}
+
+constexpr static int BankMask()
+{
+return 2 + 1;
+}
+
+constexpr static bool BountCtrl()
+{
+return true & false;
+}
+
+// CHECK: call i32 @llvm.amdgcn.update.dpp.i32(i32 %1, i32 %2, i32 16, i32 0, 
i32 0, i1 false)
+__attribute__((global)) void test_update_dpp_const_fold_imm_operand_2(int* 
out, int a, int b)
+{
+  *out = __builtin_amdgcn_update_dpp(a, b, OpCtrl(), 0, 0, false);
+}
+
+// CHECK: call i32 @llvm.amdgcn.update.dpp.i32(i32 %1, i32 %2, i32 0, i32 4, 
i32 0, i1 false)
+__attribute__((global)) void test_update_dpp_const_fold_imm_operand_3(int* 
out, int a, int b)
+{
+  *out = __builtin_amdgcn_update_dpp(a, b, 0, RowMask(), 0, false);
+}
+
+// CHECK: call i32 @llvm.amdgcn.update.dpp.i32(i32 %1, i32 %2, i32 0, i32 0, 
i32 3, i1 false)
+__attribute__((global)) void test_update_dpp_const_fold_imm_operand_4(int* 
out, int a, int b)
+{
+  *out = __builtin_amdgcn_update_dpp(a, b, 0, 0, BankMask(), false);
+}
+
+// CHECK: call i32 @llvm.amdgcn.update.dpp.i32(i32 %1, i32 %2, i32 0, i32 0, 
i32 0, i1 false)
+__attribute__((global)) void test_update_dpp_const_fold_imm_operand_5(int* 
out, int a, int b)
+{
+  *out = __builtin_amdgcn_update_dpp(a, b, 0, 0, 0, BountCtrl());
+}

>From 3f9364ccf22dc7484f8473eb084998f753edbdf8 Mon Sep 17 00:00:00 2001
From: Pravin Jagtap 
Date: Fri, 3 Nov 2023 04:21:39 -0400
Subject: [PATCH 2/2] removed the hardcoded look up for imm arguments

---
 clang/lib/CodeGen/CGBuiltin.cpp | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index a4049cbc79d303d..30c9451a9a7953b 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17632,11 +17632,18 @@ Value 
*CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID,
   case AMDGPU::BI__builtin_amdgcn_mov_dpp:
   case AMDGPU::BI__builtin_amdgcn_update_dpp: {
 llvm::SmallVector Args;
+// Find out if any arguments are required to be integer constant
+// expressions.
+unsigned ICEArguments = 0;
+ASTContext::GetBuiltinTypeError Error;
+getContext().GetBuiltinType(BuiltinID, Error, &ICEArguments);
+assert(Error == ASTContext::GE_None && "Should not codegen an error");
 for (unsigned I = 0; I != E->getNumArgs(); ++I) {
-  llvm::Value *Arg = EmitScalarExpr(E->getArg(I));
-  // Except first two input operands, all other are imm operands for dpp
-  // intrinsic.
-  if (llvm::is_contained(std::initializer_list{2, 3, 4, 5}, I)) {
+  llvm::Value* Arg = nullptr;
+  // If t

[clang] clang: Add pragma clang fp reciprocal (PR #68267)

2023-11-03 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 8e2b3309a975748649a504620a9600da9fe3c837 
db9b84992dbd6d75dc5c23b11d63c195400d5bc1 -- 
clang/test/CodeGen/fp-reciprocal-pragma.cpp 
clang/include/clang/Basic/PragmaKinds.h clang/include/clang/Sema/Sema.h 
clang/lib/Parse/ParsePragma.cpp clang/lib/Sema/SemaAttr.cpp 
clang/test/Parser/pragma-fp-contract.c clang/test/Parser/pragma-fp.cpp 
clang/test/Sema/eval-method-with-unsafe-math.c
``





View the diff from clang-format here.


``diff
diff --git a/clang/include/clang/Basic/PragmaKinds.h 
b/clang/include/clang/Basic/PragmaKinds.h
index a4789ccde5ec..42f049f7323d 100644
--- a/clang/include/clang/Basic/PragmaKinds.h
+++ b/clang/include/clang/Basic/PragmaKinds.h
@@ -36,13 +36,12 @@ enum PragmaFloatControlKind {
 };
 
 enum PragmaFPKind {
-  PFK_Contract, // #pragma clang fp contract
+  PFK_Contract,// #pragma clang fp contract
   PFK_Reassociate, // #pragma clang fp reassociate
   PFK_Reciprocal,  // #pragma clang fp reciprocal
-  PFK_Exceptions, // #pragma clang fp exceptions
-  PFK_EvalMethod // #pragma clang fp eval_method
+  PFK_Exceptions,  // #pragma clang fp exceptions
+  PFK_EvalMethod   // #pragma clang fp eval_method
 };
-
 }
 
 #endif
diff --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp
index f0d366aaa134..9a515bf333aa 100644
--- a/clang/lib/Parse/ParsePragma.cpp
+++ b/clang/lib/Parse/ParsePragma.cpp
@@ -3219,8 +3219,7 @@ void PragmaFPHandler::HandlePragma(Preprocessor &PP,
 IdentifierInfo *OptionInfo = Tok.getIdentifierInfo();
 
 auto FlagKind =
-llvm::StringSwitch>(
-OptionInfo->getName())
+llvm::StringSwitch>(OptionInfo->getName())
 .Case("contract", PFK_Contract)
 .Case("reassociate", PFK_Reassociate)
 .Case("exceptions", PFK_Exceptions)
@@ -3265,11 +3264,9 @@ void PragmaFPHandler::HandlePragma(Preprocessor &PP,
 << PP.getSpelling(Tok) << OptionInfo->getName() << *FlagKind;
 return;
   }
-} else if (FlagKind == PFK_Reassociate ||
-   FlagKind == PFK_Reciprocal) {
-  auto &Value = FlagKind == PFK_Reassociate
-? AnnotValue->ReassociateValue
-: AnnotValue->ReciprocalValue;
+} else if (FlagKind == PFK_Reassociate || FlagKind == PFK_Reciprocal) {
+  auto &Value = FlagKind == PFK_Reassociate ? AnnotValue->ReassociateValue
+: AnnotValue->ReciprocalValue;
   Value = llvm::StringSwitch>(
   II->getName())
   .Case("on", LangOptions::FPModeKind::FPM_On)

``




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


[clang] [AMDGPU] const-fold imm operands of amdgcn_update_dpp intrinsic (PR #71139)

2023-11-03 Thread Pravin Jagtap via cfe-commits


@@ -17632,8 +17632,20 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned 
BuiltinID,
   case AMDGPU::BI__builtin_amdgcn_mov_dpp:
   case AMDGPU::BI__builtin_amdgcn_update_dpp: {
 llvm::SmallVector Args;
-for (unsigned I = 0; I != E->getNumArgs(); ++I)
-  Args.push_back(EmitScalarExpr(E->getArg(I)));
+for (unsigned I = 0; I != E->getNumArgs(); ++I) {
+  llvm::Value *Arg = EmitScalarExpr(E->getArg(I));
+  // Except first two input operands, all other are imm operands for dpp
+  // intrinsic.
+  if (llvm::is_contained(std::initializer_list{2, 3, 4, 5}, I)) {

pravinjagtap wrote:

How about doing it in a separate patch for all the builtins and keeping this 
only for dpp?

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


[clang] [clang][Interp] Implement builtin_expect (PR #69713)

2023-11-03 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?B=C3=A4der?= 
Message-ID:
In-Reply-To: 


tbaederr wrote:

Ping

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


[clang] [clang][TSA] Make RequiresCapability a DeclOrType attribute (PR #67095)

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


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

>From c0708670eac0a079c878e94093897a708ece044d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Fri, 22 Sep 2023 08:42:05 +0200
Subject: [PATCH 1/6] [clang][TSA] Make RequiresCapability a DeclOrType
 attribute

---
 clang/include/clang/Basic/Attr.td |  6 +++---
 clang/test/Sema/warn-thread-safety-analysis.c | 11 +++
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 60b54c155e5..8963c2d3c660768 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3331,7 +3331,7 @@ def ReleaseCapability : InheritableAttr {
   let Documentation = [ReleaseCapabilityDocs];
 }
 
-def RequiresCapability : InheritableAttr {
+def RequiresCapability : DeclOrTypeAttr {
   let Spellings = [Clang<"requires_capability", 0>,
Clang<"exclusive_locks_required", 0>,
Clang<"requires_shared_capability", 0>,
@@ -3340,8 +3340,8 @@ def RequiresCapability : InheritableAttr {
   let LateParsed = 1;
   let TemplateDependent = 1;
   let ParseArgumentsAsUnevaluated = 1;
-  let InheritEvenIfAlreadyPresent = 1;
-  let Subjects = SubjectList<[Function]>;
+  /*let InheritEvenIfAlreadyPresent = 1;*/
+  /*let Subjects = SubjectList<[Function]>;*/
   let Accessors = [Accessor<"isShared", [Clang<"requires_shared_capability", 
0>,
  Clang<"shared_locks_required", 0>]>];
   let Documentation = [Undocumented];
diff --git a/clang/test/Sema/warn-thread-safety-analysis.c 
b/clang/test/Sema/warn-thread-safety-analysis.c
index 642ea88ec3c96f7..cd852efac21cb81 100644
--- a/clang/test/Sema/warn-thread-safety-analysis.c
+++ b/clang/test/Sema/warn-thread-safety-analysis.c
@@ -136,6 +136,17 @@ int main(void) {
 // Cleanup happens automatically -> no warning.
   }
 
+  /// Function pointers
+  {
+int __attribute__((requires_capability(&mu1))) (*function_ptr)(int) = 
Foo_fun1;
+
+function_ptr(5); // expected-warning {{calling function 'function_ptr' 
requires holding mutex 'mu1'}}
+
+mutex_exclusive_lock(&mu1);
+int five = function_ptr(5);
+mutex_exclusive_unlock(&mu1);
+  }
+
   return 0;
 }
 

>From a4be29c2a872cfaa1738bf1fee329a2c46473486 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Tue, 26 Sep 2023 09:57:41 +0200
Subject: [PATCH 2/6] Restrict to functions and function pointer decls

---
 clang/include/clang/Basic/Attr.td |  2 +-
 clang/lib/Sema/SemaDeclAttr.cpp   | 10 ++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 8963c2d3c660768..3f0c39e982017fa 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3340,7 +3340,7 @@ def RequiresCapability : DeclOrTypeAttr {
   let LateParsed = 1;
   let TemplateDependent = 1;
   let ParseArgumentsAsUnevaluated = 1;
-  /*let InheritEvenIfAlreadyPresent = 1;*/
+  let InheritEvenIfAlreadyPresent = 1;
   /*let Subjects = SubjectList<[Function]>;*/
   let Accessors = [Accessor<"isShared", [Clang<"requires_shared_capability", 
0>,
  Clang<"shared_locks_required", 0>]>];
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 842a01a88cd3c6d..dd053b73be635bb 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -8187,6 +8187,16 @@ static void handleRequiresCapabilityAttr(Sema &S, Decl 
*D,
   if (!AL.checkAtLeastNumArgs(S, 1))
 return;
 
+  // We allow this on function declaration as well as
+  // variable declarations of function pointer type.
+  if (!D->isFunctionPointerType() && !isa(D)) {
+// FIXME: Diagnostic should say "functions and function pointer decls" now 
I
+// guess.
+S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
+<< AL << AL.isRegularKeywordAttribute() << ExpectedFunction;
+return;
+  }
+
   // check that all arguments are lockable objects
   SmallVector Args;
   checkAttrArgsAreCapabilityObjs(S, D, AL, Args);

>From 5032a3d25ee404884965a8cc8e20685ccf20b51a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Fri, 13 Oct 2023 10:23:43 +0200
Subject: [PATCH 3/6] Add processing to SemaType.cpp

---
 clang/include/clang/Basic/Attr.td |  2 +-
 clang/lib/Sema/SemaDeclAttr.cpp   | 10 --
 clang/lib/Sema/SemaType.cpp   | 30 ++
 3 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 3f0c39e982017fa..bce0e2f2ac9f167 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/

[clang] [clang][Interp] Implement IntegralAP::truncate() (PR #69912)

2023-11-03 Thread Timm Baeder via cfe-commits

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

>From def4af21f38857311d3f6209d3b731f21c4d3a12 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Mon, 23 Oct 2023 12:23:45 +0200
Subject: [PATCH] [clang][Interp] Implement IntegralAP::truncate()

---
 clang/lib/AST/Interp/IntegralAP.h |  5 ++---
 clang/test/AST/Interp/intap.cpp   | 16 
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/clang/lib/AST/Interp/IntegralAP.h 
b/clang/lib/AST/Interp/IntegralAP.h
index 9aefea6d0c47ed9..1f535d420bcd54b 100644
--- a/clang/lib/AST/Interp/IntegralAP.h
+++ b/clang/lib/AST/Interp/IntegralAP.h
@@ -140,9 +140,8 @@ template  class IntegralAP final {
 return NameStr;
   }
 
-  IntegralAP truncate(unsigned bitWidth) const {
-assert(false);
-return V;
+  IntegralAP truncate(unsigned BitWidth) const {
+return IntegralAP(V.trunc(BitWidth));
   }
 
   IntegralAP toUnsigned() const {
diff --git a/clang/test/AST/Interp/intap.cpp b/clang/test/AST/Interp/intap.cpp
index 02a860eb0986c15..db9f516131af474 100644
--- a/clang/test/AST/Interp/intap.cpp
+++ b/clang/test/AST/Interp/intap.cpp
@@ -121,4 +121,20 @@ namespace AddSubOffset {
   static_assert(*P2 == 1,"");
 }
 
+namespace Bitfields {
+  struct S1 {
+unsigned _BitInt(128) a : 2;
+  };
+  constexpr S1 s1{100}; // ref-warning {{changes value from 100 to 0}} \
+// expected-warning {{changes value from 100 to 0}}
+  constexpr S1 s12{3};
+  static_assert(s12.a == 3, "");
+
+  struct S2 {
+unsigned __int128 a : 2;
+  };
+  constexpr S2 s2{100}; // ref-warning {{changes value from 100 to 0}} \
+// expected-warning {{changes value from 100 to 0}}
+}
+
 #endif

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


[llvm] [clang] [NFC] Remove Type::getInt8PtrTy (PR #71029)

2023-11-03 Thread Paulo Matos via cfe-commits

pmatos wrote:

> I have a similar concern with @arsenm about making the default address space 
> 0. Can't we just use the already existing `PointerType::getUnqual()`, instead 
> of introducing the default address space 0?

True, we could indeed just call `PointerType::getUnqual()` instead of just 
`PointerType::get()`.

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


[clang] 05d52a4 - [analyzer][NFC] Add a test case to PR 70792 for Issue 59493 and 54533 (#71073)

2023-11-03 Thread via cfe-commits

Author: Ella Ma
Date: 2023-11-03T17:10:31+08:00
New Revision: 05d52a415b394f46e3503dd253d6a9e2701c6d4c

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

LOG: [analyzer][NFC] Add a test case to PR 70792 for Issue 59493 and 54533 
(#71073)

Following PR #70792 for issue #70464 
Adding test cases for issue #59493 and #54533

Added: 


Modified: 
clang/test/Analysis/issue-70464.cpp

Removed: 




diff  --git a/clang/test/Analysis/issue-70464.cpp 
b/clang/test/Analysis/issue-70464.cpp
index f3b3072eb919823..a2ce9a7310e472c 100644
--- a/clang/test/Analysis/issue-70464.cpp
+++ b/clang/test/Analysis/issue-70464.cpp
@@ -66,3 +66,89 @@ struct Derived : Base {
 void entry() { Derived test; }
 
 } // namespace delegate_ctor_call
+
+// Additional test case from issue #59493
+namespace init_list_array {
+
+struct Base {
+  int foox[5];
+};
+
+class Derived1 : public Base {
+public:
+  Derived1() : Base{{1,4,5,3,2}} {
+// The dereference to this->foox below should be initialized properly.
+clang_analyzer_dump(this->foox[0]); // expected-warning{{1 S32b}}
+clang_analyzer_dump(this->foox[1]); // expected-warning{{4 S32b}}
+clang_analyzer_dump(this->foox[2]); // expected-warning{{5 S32b}}
+clang_analyzer_dump(this->foox[3]); // expected-warning{{3 S32b}}
+clang_analyzer_dump(this->foox[4]); // expected-warning{{2 S32b}}
+clang_analyzer_dump(foox[0]); // expected-warning{{1 S32b}}
+clang_analyzer_dump(foox[1]); // expected-warning{{4 S32b}}
+clang_analyzer_dump(foox[2]); // expected-warning{{5 S32b}}
+clang_analyzer_dump(foox[3]); // expected-warning{{3 S32b}}
+clang_analyzer_dump(foox[4]); // expected-warning{{2 S32b}}
+  }
+};
+
+void entry1() { Derived1 test; }
+
+class Derived2 : public Base {
+public:
+  Derived2() : Base{{0}} {
+// The dereference to this->foox below should be initialized properly.
+clang_analyzer_dump(this->foox[0]); // expected-warning{{0 S32b}}
+clang_analyzer_dump(this->foox[1]); // expected-warning{{0 S32b}}
+clang_analyzer_dump(this->foox[2]); // expected-warning{{0 S32b}}
+clang_analyzer_dump(this->foox[3]); // expected-warning{{0 S32b}}
+clang_analyzer_dump(this->foox[4]); // expected-warning{{0 S32b}}
+clang_analyzer_dump(foox[0]); // expected-warning{{0 S32b}}
+clang_analyzer_dump(foox[1]); // expected-warning{{0 S32b}}
+clang_analyzer_dump(foox[2]); // expected-warning{{0 S32b}}
+clang_analyzer_dump(foox[3]); // expected-warning{{0 S32b}}
+clang_analyzer_dump(foox[4]); // expected-warning{{0 S32b}}
+  }
+};
+
+void entry2() { Derived2 test; }
+
+} // namespace init_list_array
+
+namespace init_list_struct {
+
+struct Base {
+  struct { int a; int b; } foox;
+};
+
+class Derived : public Base {
+public:
+  Derived() : Base{{42, 24}} {
+// The dereference to this->foox below should be initialized properly.
+clang_analyzer_dump(this->foox.a); // expected-warning{{42 S32b}}
+clang_analyzer_dump(this->foox.b); // expected-warning{{24 S32b}}
+clang_analyzer_dump(foox.a); // expected-warning{{42 S32b}}
+clang_analyzer_dump(foox.b); // expected-warning{{24 S32b}}
+  }
+};
+
+} // namespace init_list_struct
+
+// Additional test case from issue 54533
+namespace init_list_enum {
+
+struct Base {
+  enum : unsigned char { ZERO = 0, FORTY_TWO = 42 } foox;
+};
+
+class Derived : public Base {
+public:
+  Derived() : Base{FORTY_TWO} {
+// The dereference to this->foox below should be initialized properly.
+clang_analyzer_dump(this->foox); // expected-warning{{42 S32b}}
+clang_analyzer_dump(foox); // expected-warning{{42 S32b}}
+  }
+};
+
+void entry() { Derived test; }
+
+} // namespace init_list_enum



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


[clang] [analyzer][NFC] Add a test case to PR-70792 for Issue-59493 (PR #71073)

2023-11-03 Thread Ella Ma via cfe-commits

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


[clang] Clang/MIPS: Use -mnan value for -mabs if not specified (PR #71157)

2023-11-03 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa created 
https://github.com/llvm/llvm-project/pull/71157

On most hardware, FCSR.ABS2008 is set the value same with FCSR.NAN2008. Let's 
use this behaivor by default.

With this commit, `clang -target mips -mnan=2008 -c fabs.c` will imply 
`-mabs=2008`.

And of course, `clang -mnan=2008 -mabs=legacy` can continue workable like 
previous.

>From feabd6fd561ff7af2f21b7c649fe8a4cc1ac6343 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Fri, 3 Nov 2023 03:30:52 -0400
Subject: [PATCH] Clang/MIPS: Use -mnan value for -mabs if not specified

On most hardware, FCSR.ABS2008 is set the value same with FCSR.NAN2008.
Let's use this behaivor by default.

With this commit, `clang -target mips -mnan=2008 -c fabs.c` will
imply `-mabs=2008`.

And of course, `clang -mnan=2008 -mabs=legacy` can continue workable
like previous.
---
 clang/lib/Driver/ToolChains/Arch/Mips.cpp | 8 ++--
 clang/test/Driver/mips-features.c | 8 
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Arch/Mips.cpp 
b/clang/lib/Driver/ToolChains/Arch/Mips.cpp
index f9f14c01b2b9f01..fe9d112b8800b17 100644
--- a/clang/lib/Driver/ToolChains/Arch/Mips.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/Mips.cpp
@@ -221,6 +221,7 @@ void mips::getMIPSTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   bool IsN64 = ABIName == "64";
   bool IsPIC = false;
   bool NonPIC = false;
+  bool HasNaN2008Opt = false;
 
   Arg *LastPICArg = Args.getLastArg(options::OPT_fPIC, options::OPT_fno_PIC,
 options::OPT_fpic, options::OPT_fno_pic,
@@ -285,9 +286,10 @@ void mips::getMIPSTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   if (Arg *A = Args.getLastArg(options::OPT_mnan_EQ)) {
 StringRef Val = StringRef(A->getValue());
 if (Val == "2008") {
-  if (mips::getIEEE754Standard(CPUName) & mips::Std2008)
+  if (mips::getIEEE754Standard(CPUName) & mips::Std2008) {
 Features.push_back("+nan2008");
-  else {
+HasNaN2008Opt = true;
+  } else {
 Features.push_back("-nan2008");
 D.Diag(diag::warn_target_unsupported_nan2008) << CPUName;
   }
@@ -323,6 +325,8 @@ void mips::getMIPSTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   D.Diag(diag::err_drv_unsupported_option_argument)
   << A->getSpelling() << Val;
 }
+  } else if (HasNaN2008Opt) {
+Features.push_back("+abs2008");
   }
 
   AddTargetFeature(Args, Features, options::OPT_msingle_float,
diff --git a/clang/test/Driver/mips-features.c 
b/clang/test/Driver/mips-features.c
index 5ae566774959f18..fc1b5894f539377 100644
--- a/clang/test/Driver/mips-features.c
+++ b/clang/test/Driver/mips-features.c
@@ -214,6 +214,14 @@
 // RUN: -mnan=legacy -mnan=2008 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NAN2008 %s
 // CHECK-NAN2008: "-target-feature" "+nan2008"
+// CHECK-NAN2008: "-target-feature" "+abs2008"
+//
+// -mnan=2008 -mabs=legacy
+// RUN: %clang -target mips-linux-gnu -march=mips32r3 -### -c %s \
+// RUN: -mabs=legacy -mnan=2008 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ABSLEGACYNAN2008 %s
+// CHECK-ABSLEGACYNAN2008: "-target-feature" "+nan2008"
+// CHECK-ABSLEGACYNAN2008: "-target-feature" "-abs2008"
 //
 // -mnan=legacy
 // RUN: %clang -target mips-linux-gnu -march=mips32r3 -### -c %s \

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


[clang] Clang/MIPS: Use -mnan value for -mabs if not specified (PR #71157)

2023-11-03 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: YunQiang Su (wzssyqa)


Changes

On most hardware, FCSR.ABS2008 is set the value same with FCSR.NAN2008. Let's 
use this behaivor by default.

With this commit, `clang -target mips -mnan=2008 -c fabs.c` will imply 
`-mabs=2008`.

And of course, `clang -mnan=2008 -mabs=legacy` can continue workable like 
previous.

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


2 Files Affected:

- (modified) clang/lib/Driver/ToolChains/Arch/Mips.cpp (+6-2) 
- (modified) clang/test/Driver/mips-features.c (+8) 


``diff
diff --git a/clang/lib/Driver/ToolChains/Arch/Mips.cpp 
b/clang/lib/Driver/ToolChains/Arch/Mips.cpp
index f9f14c01b2b9f01..fe9d112b8800b17 100644
--- a/clang/lib/Driver/ToolChains/Arch/Mips.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/Mips.cpp
@@ -221,6 +221,7 @@ void mips::getMIPSTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   bool IsN64 = ABIName == "64";
   bool IsPIC = false;
   bool NonPIC = false;
+  bool HasNaN2008Opt = false;
 
   Arg *LastPICArg = Args.getLastArg(options::OPT_fPIC, options::OPT_fno_PIC,
 options::OPT_fpic, options::OPT_fno_pic,
@@ -285,9 +286,10 @@ void mips::getMIPSTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   if (Arg *A = Args.getLastArg(options::OPT_mnan_EQ)) {
 StringRef Val = StringRef(A->getValue());
 if (Val == "2008") {
-  if (mips::getIEEE754Standard(CPUName) & mips::Std2008)
+  if (mips::getIEEE754Standard(CPUName) & mips::Std2008) {
 Features.push_back("+nan2008");
-  else {
+HasNaN2008Opt = true;
+  } else {
 Features.push_back("-nan2008");
 D.Diag(diag::warn_target_unsupported_nan2008) << CPUName;
   }
@@ -323,6 +325,8 @@ void mips::getMIPSTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   D.Diag(diag::err_drv_unsupported_option_argument)
   << A->getSpelling() << Val;
 }
+  } else if (HasNaN2008Opt) {
+Features.push_back("+abs2008");
   }
 
   AddTargetFeature(Args, Features, options::OPT_msingle_float,
diff --git a/clang/test/Driver/mips-features.c 
b/clang/test/Driver/mips-features.c
index 5ae566774959f18..fc1b5894f539377 100644
--- a/clang/test/Driver/mips-features.c
+++ b/clang/test/Driver/mips-features.c
@@ -214,6 +214,14 @@
 // RUN: -mnan=legacy -mnan=2008 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NAN2008 %s
 // CHECK-NAN2008: "-target-feature" "+nan2008"
+// CHECK-NAN2008: "-target-feature" "+abs2008"
+//
+// -mnan=2008 -mabs=legacy
+// RUN: %clang -target mips-linux-gnu -march=mips32r3 -### -c %s \
+// RUN: -mabs=legacy -mnan=2008 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ABSLEGACYNAN2008 %s
+// CHECK-ABSLEGACYNAN2008: "-target-feature" "+nan2008"
+// CHECK-ABSLEGACYNAN2008: "-target-feature" "-abs2008"
 //
 // -mnan=legacy
 // RUN: %clang -target mips-linux-gnu -march=mips32r3 -### -c %s \

``




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


[libunwind] MIPS/libunwind: Use -mfp64 if compiler is FPXX (PR #68521)

2023-11-03 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa updated 
https://github.com/llvm/llvm-project/pull/68521

>From 6053822322fd1594b46bf77c8b168ad802a7c534 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Sun, 8 Oct 2023 07:12:45 -0400
Subject: [PATCH] MIPS/libunwind: Use -mfp64 if compiler is FPXX

Libunwind supports FP64 and FP32 modes, but not FPXX.
The reason is that, FP64 and FP32 have different way to save/restore
FPRs. If libunwind is built as FPXX, we have no idea which one should
we use.

If libunwind is built as FP64, it will interoperatable with FPXX/FP64
APPs, and if it is built as FP32, it will interoperatable with
FP32/FPXX. Currently most of O32 APPs are FPXX or FP64, while few are FP32.

So if the compiler is FPXX, which is the default value of most toolchain,
let's switch it to FP64.
---
 libunwind/CMakeLists.txt | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index 84f8ce296a7410b..387d4b43b5746a6 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -21,6 +21,7 @@ set(LIBUNWIND_LIBCXX_PATH 
"${CMAKE_CURRENT_LIST_DIR}/../libcxx" CACHE PATH
 "Specify path to libc++ source.")
 
 include(GNUInstallDirs)
+include(CheckSymbolExists)
 
 
#===
 # Setup CMake Options
@@ -101,6 +102,20 @@ endif()
 option(LIBUNWIND_HIDE_SYMBOLS
   "Do not export any symbols from the static library." 
${LIBUNWIND_DEFAULT_HIDE_SYMBOLS})
 
+# If toolchain is FPXX, we switch to FP64 to save the full FPRs. See:
+# 
https://web.archive.org/web/20180828210612/https://dmz-portal.mips.com/wiki/MIPS_O32_ABI_-_FR0_and_FR1_Interlinking
+check_symbol_exists(__mips_hard_float "" __MIPSHF)
+check_symbol_exists(_ABIO32 "" __MIPS_O32)
+if (__MIPSHF AND __MIPS_O32)
+  file(WRITE 
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/mips_is_fpxx.c
+"#if __mips_fpr != 0\n"
+"# error\n"
+"#endif\n")
+  try_compile(MIPS_FPABI_FPXX ${CMAKE_BINARY_DIR}
+${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/mips_is_fpxx.c
+CMAKE_FLAGS -DCMAKE_C_LINK_EXECUTABLE='echo')
+endif()
+
 
#===
 # Configure System
 
#===
@@ -184,6 +199,10 @@ if (WIN32)
   add_compile_flags_if_supported(-Wno-dll-attribute-on-redeclaration)
 endif()
 
+if (MIPS_FPABI_FPXX)
+  add_compile_flags(-mfp64)
+endif()
+
 # Get feature flags.
 # Exceptions
 # Catches C++ exceptions only and tells the compiler to assume that extern C

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


[clang] [clang-repl] [test] Make an XFAIL more precise (PR #70991)

2023-11-03 Thread Martin Storsjö via cfe-commits

mstorsjo wrote:

> > > > If you still need help reproducing or debugging the issue on our bot, 
> > > > please let me know.
> > > 
> > > 
> > > Thanks, much appreciated. Can you test if 
> > > [mstorsjo@clang-repl-xfail](https://github.com/mstorsjo/llvm-project/commit/clang-repl-xfail)
> > >  seems to run correctly in this environment? Otherwise I'll try to push 
> > > it tomorrow and see how it fares on the bot.
> 
> It failed, but due to a typo in the XFAIL you added:
> 
> ```
> target={{.*}-ps4, target={{.*}-ps5
> ```
> 
> These should have balanced braces. If I add the missing braces, the test 
> passes with an XFAIL on the bot.

Oh, oops - but thanks for checking and verifying with the typo fixed. I'll try 
to reland this change now then, with that fixed. Thanks again!

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


[clang-tools-extra] [clang] [lldb] [clang][NFC] Refactor `TagTypeKind` (PR #71160)

2023-11-03 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clangd

@llvm/pr-subscribers-clang-codegen

Author: Vlad Serebrennikov (Endilll)


Changes

This patch converts TagTypeKind into scoped enum. Among other benefits, this 
allows us to forward-declare it where necessary.

I plan to land this patch as soon as pre-commit CI passes, probably not waiting 
for Windows bot.

---

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


63 Files Affected:

- (modified) clang-tools-extra/clang-doc/BitcodeReader.cpp (+6-6) 
- (modified) clang-tools-extra/clang-doc/Generators.cpp (+5-5) 
- (modified) clang-tools-extra/clang-doc/Representation.h (+1-1) 
- (modified) clang-tools-extra/clang-doc/YAMLGenerator.cpp (+5-5) 
- (modified) clang-tools-extra/clangd/refactor/InsertionPoint.cpp (+1-1) 
- (modified) clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp (+1-1) 
- (modified) clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp (+1-1) 
- (modified) clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp (+1-1) 
- (modified) clang-tools-extra/unittests/clang-doc/MergeTest.cpp (+3-3) 
- (modified) clang-tools-extra/unittests/clang-doc/SerializeTest.cpp (+13-13) 
- (modified) clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp (+1-1) 
- (modified) clang/include/clang/AST/ASTContext.h (+3-2) 
- (modified) clang/include/clang/AST/Decl.h (+8-6) 
- (modified) clang/include/clang/AST/Type.h (+6-6) 
- (modified) clang/lib/AST/ASTContext.cpp (+6-6) 
- (modified) clang/lib/AST/Decl.cpp (+6-6) 
- (modified) clang/lib/AST/DeclCXX.cpp (+11-11) 
- (modified) clang/lib/AST/DeclTemplate.cpp (+1-1) 
- (modified) clang/lib/AST/MicrosoftMangle.cpp (+54-50) 
- (modified) clang/lib/AST/RecordLayoutBuilder.cpp (+6-3) 
- (modified) clang/lib/AST/Type.cpp (+20-15) 
- (modified) clang/lib/CodeGen/CGObjCMac.cpp (+6-8) 
- (modified) clang/lib/CodeGen/CGOpenMPRuntime.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp (+1-1) 
- (modified) clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp (+18-19) 
- (modified) clang/lib/Frontend/Rewrite/RewriteObjC.cpp (+16-16) 
- (modified) clang/lib/Index/IndexSymbol.cpp (+5-5) 
- (modified) clang/lib/Index/USRGeneration.cpp (+31-15) 
- (modified) clang/lib/Sema/HLSLExternalSemaSource.cpp (+3-3) 
- (modified) clang/lib/Sema/Sema.cpp (+3-2) 
- (modified) clang/lib/Sema/SemaCodeComplete.cpp (+14-13) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+62-50) 
- (modified) clang/lib/Sema/SemaDeclAttr.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+14-11) 
- (modified) clang/lib/Sema/SemaDeclObjC.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaExprCXX.cpp (+4-5) 
- (modified) clang/lib/Sema/SemaStmt.cpp (+3-2) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+10-6) 
- (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+2-2) 
- (modified) clang/lib/Sema/SemaType.cpp (+21-9) 
- (modified) clang/lib/Sema/TreeTransform.h (+6-4) 
- (modified) clang/lib/Serialization/ASTReaderDecl.cpp (+2-2) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+1-1) 
- (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+2-1) 
- (modified) 
clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp (+1-1) 
- (modified) 
clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp 
(+1-1) 
- (modified) clang/tools/libclang/CIndexCXX.cpp (+9-5) 
- (modified) clang/unittests/AST/ASTImporterTest.cpp (+3-2) 
- (modified) clang/utils/ClangVisualizers/clang.natvis (+5-5) 
- (modified) lldb/source/Plugins/Language/ObjC/NSDictionary.cpp (+2-1) 
- (modified) 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
 (+2-2) 
- (modified) lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp (+3-3) 
- (modified) lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp (+4-4) 
- (modified) lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp (+5-5) 
- (modified) 
lldb/source/Plugins/RegisterTypeBuilder/RegisterTypeBuilderClang.cpp (+2-1) 
- (modified) lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp (+7-7) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
(+6-5) 
- (modified) lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp 
(+12-11) 
- (modified) lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp 
(+4-4) 
- (modified) lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp (+7-7) 
- (modified) lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp 
(+2-1) 
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+3-2) 
- (modified) lldb/unittests/Symbol/TestTypeSystemClang.cpp (+17-10) 


``diff
diff --git a/clang-tools-extra/clang-doc/BitcodeReader.cpp 
b/clang-tools-extra/clang-doc/BitcodeReader.cpp
index 9ac60fa73a782b4..cc7719f4630f00a 100644
--- a/clang-tools-extra/clang-doc/BitcodeReader.cpp
+++ b/clang-tools-extra/clang-doc/BitcodeReader.cpp
@@ -68,12 +68,12 @@ llvm::Error decodeRecord(const Record &R, AccessSpecifi

[clang] e9db60c - Reapply [clang-repl] [test] Make an XFAIL more precise (#70991)

2023-11-03 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2023-11-03T11:30:08+02:00
New Revision: e9db60c05e2fb96ff40cbb1f78790abc5de9237e

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

LOG: Reapply [clang-repl] [test] Make an XFAIL more precise (#70991)

The const.cpp testcase fails when running in MSVC mode, while it does
succeed in MinGW mode.

In MSVC mode, there are more constructor invocations than expected, as
the printout looks like this:

A(1), this = 02559793
A(1), this = 02559793
f: this = 02559793, val = 1
A(1), this = 02559793
f: this = 02559793, val = 1
~A, this = 02559793, val = 1
~A, this = 02559793, val = 1
~A, this = 02559793, val = 1

While the expected printout looks like this:

A(1), this = 02C903E1
f: this = 02C903E1, val = 1
f: this = 02C903E1, val = 1
~A, this = 02C903E1, val = 1

Reapplying with the XFAIL pattern expanded to include PS4/PS5
triples as well, which also seem to have the same behaviour
as MSVC.

Added: 


Modified: 
clang/test/Interpreter/const.cpp

Removed: 




diff  --git a/clang/test/Interpreter/const.cpp 
b/clang/test/Interpreter/const.cpp
index 4b6ce65e3643e64..ca141d69f84d302 100644
--- a/clang/test/Interpreter/const.cpp
+++ b/clang/test/Interpreter/const.cpp
@@ -1,6 +1,6 @@
 // UNSUPPORTED: system-aix
 // see https://github.com/llvm/llvm-project/issues/68092
-// XFAIL: system-windows
+// XFAIL: target={{.*}}-windows-msvc, target={{.*}}-ps4, target={{.*}}-ps5
 
 // RUN: cat %s | clang-repl | FileCheck %s
 // RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s



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


[PATCH] D64087: [clang] Correct source locations for instantiations of out-of-line defaulted special member functions. (PR25683)

2023-11-03 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

This patch appears to introduce a bug in some source ranges.
Reported the regression at https://github.com/llvm/llvm-project/issues/71161.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64087

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


[clang] [NFC] [Serializer] Pack information in serializer (PR #69287)

2023-11-03 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

I'd like to land this in the next week if no objection come in. Since this may 
be safe.

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


[clang] 539e076 - Fix MSVC "not all control paths return a value" warnings. NFC.

2023-11-03 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2023-11-03T09:50:09Z
New Revision: 539e076e1c99f4fba7f139f819f8e95b09ee8faf

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

LOG: Fix MSVC "not all control paths return a value" warnings. NFC.

Added: 


Modified: 
clang/include/clang/Basic/Linkage.h
clang/lib/AST/Decl.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Linkage.h 
b/clang/include/clang/Basic/Linkage.h
index 9cf36e522947fa8..fcf56b93b9781d7 100644
--- a/clang/include/clang/Basic/Linkage.h
+++ b/clang/include/clang/Basic/Linkage.h
@@ -100,6 +100,7 @@ inline bool isExternallyVisible(Linkage L) {
   case Linkage::External:
 return true;
   }
+  llvm_unreachable("Unhandled Linkage enum");
 }
 
 inline Linkage getFormalLinkage(Linkage L) {

diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index e8062b680fbc3ab..42ba8582c46de84 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -1934,6 +1934,7 @@ bool NamedDecl::hasLinkage() const {
   case Linkage::External:
 return true;
   }
+  llvm_unreachable("Unhandled Linkage enum");
 }
 
 NamedDecl *NamedDecl::getUnderlyingDeclImpl() {



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


[clang] 89a336a - Revert "Reapply [clang-repl] [test] Make an XFAIL more precise (#70991)"

2023-11-03 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2023-11-03T11:55:33+02:00
New Revision: 89a336add722f57f61c99b3eafab1c89f943db5e

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

LOG: Revert "Reapply [clang-repl] [test] Make an XFAIL more precise (#70991)"

This reverts commit e9db60c05e2fb96ff40cbb1f78790abc5de9237e.
This was still failing (unexpectedly passing) on some Sony PS
buildbots.

The issue is that the clang-repl testcases don't depend on what
the default target triple is, but what the host triple is,
which is used for JIT purposes.

Added: 


Modified: 
clang/test/Interpreter/const.cpp

Removed: 




diff  --git a/clang/test/Interpreter/const.cpp 
b/clang/test/Interpreter/const.cpp
index ca141d69f84d302..4b6ce65e3643e64 100644
--- a/clang/test/Interpreter/const.cpp
+++ b/clang/test/Interpreter/const.cpp
@@ -1,6 +1,6 @@
 // UNSUPPORTED: system-aix
 // see https://github.com/llvm/llvm-project/issues/68092
-// XFAIL: target={{.*}}-windows-msvc, target={{.*}}-ps4, target={{.*}}-ps5
+// XFAIL: system-windows
 
 // RUN: cat %s | clang-repl | FileCheck %s
 // RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s



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


[clang-tools-extra] [clangd] Check for valid location in ExtractionContext::exprIsValidOutside (PR #71162)

2023-11-03 Thread Björn Pettersson via cfe-commits

https://github.com/bjope created https://github.com/llvm/llvm-project/pull/71162

If the code has a call to an implicitly declared function, an expression could 
end up referencing declarations without valid source locations. So when doing 
the exprIsValidOutside check we could end up calling 
SourceManager::isPointWithin using invalid source locations, and then a debug 
build would crash with an assertion failure in 
SourceManager::isBeforeInTranslationUnit.

This patch make sure that we deal with the invalid locations (by considering a 
ReferencedDecl with invalid location as not being inside the Scope).

From 1fb659fa15568ec8256824339860de724853c6e3 Mon Sep 17 00:00:00 2001
From: Bjorn Pettersson 
Date: Thu, 2 Nov 2023 22:00:52 +0100
Subject: [PATCH] [clangd] Check for valid source location in
 ExtractionContext::exprIsValidOutside

If the code has a call to an implicitly declared function, an
expression could end up referencing declarations without valid
source locations. So when doing the exprIsValidOutside check we
could end up calling SourceManager::isPointWithin using invalid
source locations, and then a debug build would crash with an
assertion failure in SourceManager::isBeforeInTranslationUnit.

This patch make sure that we deal with the invalid locations
(by considering a ReferencedDecl with invalid location as not
being inside the Scope).
---
 .../clangd/refactor/tweaks/ExtractVariable.cpp|  3 ++-
 clang-tools-extra/clangd/test/implicit-function.test  | 11 +++
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 clang-tools-extra/clangd/test/implicit-function.test

diff --git a/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
index 1e4edc6d6b4bb39..79bf962544242bb 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
@@ -176,7 +176,8 @@ bool ExtractionContext::exprIsValidOutside(const 
clang::Stmt *Scope) const {
   SourceLocation ScopeBegin = Scope->getBeginLoc();
   SourceLocation ScopeEnd = Scope->getEndLoc();
   for (const Decl *ReferencedDecl : ReferencedDecls) {
-if (SM.isPointWithin(ReferencedDecl->getBeginLoc(), ScopeBegin, ScopeEnd) 
&&
+if (ReferencedDecl->getBeginLoc().isValid() &&
+SM.isPointWithin(ReferencedDecl->getBeginLoc(), ScopeBegin, ScopeEnd) 
&&
 SM.isPointWithin(ReferencedDecl->getEndLoc(), ScopeBegin, ScopeEnd))
   return false;
   }
diff --git a/clang-tools-extra/clangd/test/implicit-function.test 
b/clang-tools-extra/clangd/test/implicit-function.test
new file mode 100644
index 000..85731f358b4ae8e
--- /dev/null
+++ b/clang-tools-extra/clangd/test/implicit-function.test
@@ -0,0 +1,11 @@
+// RUN: cp %s %t.c
+// RUN: not clangd -enable-config=0 -log=verbose -check=%t.c 2>&1 | FileCheck 
-strict-whitespace %s
+
+// Regression test for a situation when we used to hit an assertion failure
+// due to missing source location (for the implicit function declaration).
+
+// CHECK-DAG: [-Wimplicit-function-declaration] Line {{.*}}: call to 
undeclared function 'foo'
+// CHECK-DAG: [init_element_not_constant] Line {{.*}}: initializer element is 
not a compile-time constant
+// CHECK: All checks completed, 2 errors
+
+int x = foo();

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


[clang-tools-extra] [clangd] Check for valid location in ExtractionContext::exprIsValidOutside (PR #71162)

2023-11-03 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clangd

Author: Björn Pettersson (bjope)


Changes

If the code has a call to an implicitly declared function, an expression could 
end up referencing declarations without valid source locations. So when doing 
the exprIsValidOutside check we could end up calling 
SourceManager::isPointWithin using invalid source locations, and then a debug 
build would crash with an assertion failure in 
SourceManager::isBeforeInTranslationUnit.

This patch make sure that we deal with the invalid locations (by considering a 
ReferencedDecl with invalid location as not being inside the Scope).

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


2 Files Affected:

- (modified) clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp 
(+2-1) 
- (added) clang-tools-extra/clangd/test/implicit-function.test (+11) 


``diff
diff --git a/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
index 1e4edc6d6b4bb39..79bf962544242bb 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
@@ -176,7 +176,8 @@ bool ExtractionContext::exprIsValidOutside(const 
clang::Stmt *Scope) const {
   SourceLocation ScopeBegin = Scope->getBeginLoc();
   SourceLocation ScopeEnd = Scope->getEndLoc();
   for (const Decl *ReferencedDecl : ReferencedDecls) {
-if (SM.isPointWithin(ReferencedDecl->getBeginLoc(), ScopeBegin, ScopeEnd) 
&&
+if (ReferencedDecl->getBeginLoc().isValid() &&
+SM.isPointWithin(ReferencedDecl->getBeginLoc(), ScopeBegin, ScopeEnd) 
&&
 SM.isPointWithin(ReferencedDecl->getEndLoc(), ScopeBegin, ScopeEnd))
   return false;
   }
diff --git a/clang-tools-extra/clangd/test/implicit-function.test 
b/clang-tools-extra/clangd/test/implicit-function.test
new file mode 100644
index 000..85731f358b4ae8e
--- /dev/null
+++ b/clang-tools-extra/clangd/test/implicit-function.test
@@ -0,0 +1,11 @@
+// RUN: cp %s %t.c
+// RUN: not clangd -enable-config=0 -log=verbose -check=%t.c 2>&1 | FileCheck 
-strict-whitespace %s
+
+// Regression test for a situation when we used to hit an assertion failure
+// due to missing source location (for the implicit function declaration).
+
+// CHECK-DAG: [-Wimplicit-function-declaration] Line {{.*}}: call to 
undeclared function 'foo'
+// CHECK-DAG: [init_element_not_constant] Line {{.*}}: initializer element is 
not a compile-time constant
+// CHECK: All checks completed, 2 errors
+
+int x = foo();

``




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


[clang-tools-extra] [clangd] Check for valid location in ExtractionContext::exprIsValidOutside (PR #71162)

2023-11-03 Thread Björn Pettersson via cfe-commits

bjope wrote:

Hi reviewers. I don't know much about clangd so looking for feedback on this 
patch to know if it is the correct thing to do.
Not sure exactly who knows this part of the code, so please let me know if 
someone else should review this!

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


[clang] [AArch64] Implement reinterpret builtins for SVE vector tuples (PR #69598)

2023-11-03 Thread Momchil Velikov via cfe-commits

momchil-velikov wrote:

Rebased a couple of times to resolve merge conflicts.

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


[clang] 2b1948c - [NFC][OpenMP][Clang]Update OpenMP clang tests

2023-11-03 Thread Dominik Adamski via cfe-commits

Author: Dominik Adamski
Date: 2023-11-03T05:13:06-05:00
New Revision: 2b1948c2be0e935bdd2e764ae1a2b84c405fdc04

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

LOG: [NFC][OpenMP][Clang]Update OpenMP clang tests

Replace hardcoded constants by regular expressions

Added: 


Modified: 
clang/test/OpenMP/cancel_codegen.cpp
clang/test/OpenMP/parallel_codegen.cpp

Removed: 




diff  --git a/clang/test/OpenMP/cancel_codegen.cpp 
b/clang/test/OpenMP/cancel_codegen.cpp
index 53580e0c2b0293f..03024cf331b2717 100644
--- a/clang/test/OpenMP/cancel_codegen.cpp
+++ b/clang/test/OpenMP/cancel_codegen.cpp
@@ -1026,25 +1026,25 @@ for (int i = 0; i < argc; ++i) {
 // CHECK3-NEXT:call void @llvm.experimental.noalias.scope.decl(metadata 
[[META8:![0-9]+]])
 // CHECK3-NEXT:call void @llvm.experimental.noalias.scope.decl(metadata 
[[META10:![0-9]+]])
 // CHECK3-NEXT:call void @llvm.experimental.noalias.scope.decl(metadata 
[[META12:![0-9]+]])
-// CHECK3-NEXT:store i32 [[TMP2]], ptr [[DOTGLOBAL_TID__ADDR_I]], align 4, 
!noalias !14
-// CHECK3-NEXT:store ptr [[TMP5]], ptr [[DOTPART_ID__ADDR_I]], align 8, 
!noalias !14
-// CHECK3-NEXT:store ptr null, ptr [[DOTPRIVATES__ADDR_I]], align 8, 
!noalias !14
-// CHECK3-NEXT:store ptr null, ptr [[DOTCOPY_FN__ADDR_I]], align 8, 
!noalias !14
-// CHECK3-NEXT:store ptr [[TMP3]], ptr [[DOTTASK_T__ADDR_I]], align 8, 
!noalias !14
-// CHECK3-NEXT:store ptr [[TMP7]], ptr [[__CONTEXT_ADDR_I]], align 8, 
!noalias !14
-// CHECK3-NEXT:[[TMP8:%.*]] = load ptr, ptr [[__CONTEXT_ADDR_I]], align 8, 
!noalias !14
+// CHECK3-NEXT:store i32 [[TMP2]], ptr [[DOTGLOBAL_TID__ADDR_I]], align 4, 
!noalias ![[NOALIAS0:[0-9]+]]
+// CHECK3-NEXT:store ptr [[TMP5]], ptr [[DOTPART_ID__ADDR_I]], align 8, 
!noalias ![[NOALIAS0]]
+// CHECK3-NEXT:store ptr null, ptr [[DOTPRIVATES__ADDR_I]], align 8, 
!noalias ![[NOALIAS0]]
+// CHECK3-NEXT:store ptr null, ptr [[DOTCOPY_FN__ADDR_I]], align 8, 
!noalias ![[NOALIAS0]]
+// CHECK3-NEXT:store ptr [[TMP3]], ptr [[DOTTASK_T__ADDR_I]], align 8, 
!noalias ![[NOALIAS0]]
+// CHECK3-NEXT:store ptr [[TMP7]], ptr [[__CONTEXT_ADDR_I]], align 8, 
!noalias ![[NOALIAS0]]
+// CHECK3-NEXT:[[TMP8:%.*]] = load ptr, ptr [[__CONTEXT_ADDR_I]], align 8, 
!noalias ![[NOALIAS0]]
 // CHECK3-NEXT:[[OMP_GLOBAL_THREAD_NUM_I:%.*]] = call i32 
@__kmpc_global_thread_num(ptr @[[GLOB12:[0-9]+]])
 // CHECK3-NEXT:[[TMP9:%.*]] = call i32 @__kmpc_cancel(ptr @[[GLOB1]], i32 
[[OMP_GLOBAL_THREAD_NUM_I]], i32 4)
 // CHECK3-NEXT:[[TMP10:%.*]] = icmp ne i32 [[TMP9]], 0
 // CHECK3-NEXT:br i1 [[TMP10]], label [[DOTCANCEL_EXIT_I:%.*]], label 
[[DOTCANCEL_CONTINUE_I:%.*]]
 // CHECK3:   .cancel.exit.i:
-// CHECK3-NEXT:store i32 1, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias 
!14
+// CHECK3-NEXT:store i32 1, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias 
![[NOALIAS1:[0-9]+]]
 // CHECK3-NEXT:br label [[DOTOMP_OUTLINED__EXIT:%.*]]
 // CHECK3:   .cancel.continue.i:
-// CHECK3-NEXT:store i32 0, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias 
!14
+// CHECK3-NEXT:store i32 0, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias 
![[NOALIAS1]]
 // CHECK3-NEXT:br label [[DOTOMP_OUTLINED__EXIT]]
 // CHECK3:   .omp_outlined..exit:
-// CHECK3-NEXT:[[CLEANUP_DEST_I:%.*]] = load i32, ptr 
[[CLEANUP_DEST_SLOT_I]], align 4, !noalias !14
+// CHECK3-NEXT:[[CLEANUP_DEST_I:%.*]] = load i32, ptr 
[[CLEANUP_DEST_SLOT_I]], align 4, !noalias ![[NOALIAS1]]
 // CHECK3-NEXT:ret i32 0
 //
 //

diff  --git a/clang/test/OpenMP/parallel_codegen.cpp 
b/clang/test/OpenMP/parallel_codegen.cpp
index 5c98761be0808ef..d545b4a9d9fa887 100644
--- a/clang/test/OpenMP/parallel_codegen.cpp
+++ b/clang/test/OpenMP/parallel_codegen.cpp
@@ -812,7 +812,7 @@ int main (int argc, char **argv) {
 //
 //
 // CHECK3-LABEL: define {{[^@]+}}@_Z5tmainIPPcEiT_..omp_par
-// CHECK3-SAME: (ptr noalias [[TID_ADDR:%.*]], ptr noalias [[ZERO_ADDR:%.*]], 
ptr [[TMP0:%.*]]) #[[ATTR1]] {
+// CHECK3-SAME: (ptr noalias [[TID_ADDR:%.*]], ptr noalias [[ZERO_ADDR:%.*]], 
ptr [[TMP0:%.*]]) #[[ATTR2:[0-9]+]]
 // CHECK3-NEXT:  omp.par.entry:
 // CHECK3-NEXT:[[GEP__RELOADED:%.*]] = getelementptr { ptr, ptr }, ptr 
[[TMP0]], i32 0, i32 0
 // CHECK3-NEXT:[[LOADGEP__RELOADED:%.*]] = load ptr, ptr 
[[GEP__RELOADED]], align 8
@@ -956,7 +956,7 @@ int main (int argc, char **argv) {
 //
 //
 // CHECK4-LABEL: define {{[^@]+}}@_Z5tmainIPPcEiT_..omp_par
-// CHECK4-SAME: (ptr noalias [[TID_ADDR:%.*]], ptr noalias [[ZERO_ADDR:%.*]], 
ptr [[TMP0:%.*]]) #[[ATTR1]] !dbg [[DBG57:![0-9]+]] {
+// CHECK4-SAME: (ptr noalias [[TID_ADDR:%.*]], ptr noalias [[ZERO_ADDR:%.*]], 
ptr [[TMP0:%.*]]) #[[ATTR2:[0-9]+]] !dbg [[DBG57:![0-9]+]] {
 // CHECK4-NEXT

[clang] [llvm] Reapply #2 [clang-repl] [test] Make an XFAIL more precise (#70991) (PR #71168)

2023-11-03 Thread Martin Storsjö via cfe-commits

https://github.com/mstorsjo created 
https://github.com/llvm/llvm-project/pull/71168

The const.cpp testcase fails when running in MSVC mode, while it does succeed 
in MinGW mode.

In MSVC mode, there are more constructor invocations than expected, as the 
printout looks like this:

A(1), this = 02559793
A(1), this = 02559793
f: this = 02559793, val = 1
A(1), this = 02559793
f: this = 02559793, val = 1
~A, this = 02559793, val = 1
~A, this = 02559793, val = 1
~A, this = 02559793, val = 1

While the expected printout looks like this:

A(1), this = 02C903E1
f: this = 02C903E1, val = 1
f: this = 02C903E1, val = 1
~A, this = 02C903E1, val = 1

Reapplying with the XFAIL changed to check the host triple, not the target 
triple. On an MSVC based build of Clang, but with the default target triple set 
to PS4/PS5, we will still see the failure. And a Linux based build of Clang 
that targets PS4/PS5 won't see the issue.

From 2fb453c2cdcf982aa2dd50208329785f8c338d45 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 
Date: Thu, 2 Nov 2023 09:51:33 +0200
Subject: [PATCH] Reapply #2 [clang-repl] [test] Make an XFAIL more precise
 (#70991)

The const.cpp testcase fails when running in MSVC mode, while it does
succeed in MinGW mode.

In MSVC mode, there are more constructor invocations than expected, as
the printout looks like this:

A(1), this = 02559793
A(1), this = 02559793
f: this = 02559793, val = 1
A(1), this = 02559793
f: this = 02559793, val = 1
~A, this = 02559793, val = 1
~A, this = 02559793, val = 1
~A, this = 02559793, val = 1

While the expected printout looks like this:

A(1), this = 02C903E1
f: this = 02C903E1, val = 1
f: this = 02C903E1, val = 1
~A, this = 02C903E1, val = 1

Reapplying with the XFAIL changed to check the host triple,
not the target triple. On an MSVC based build of Clang, but
with the default target triple set to PS4/PS5, we will still
see the failure. And a Linux based build of Clang that targets
PS4/PS5 won't see the issue.
---
 clang/test/Interpreter/const.cpp  | 2 +-
 llvm/test/lit.cfg.py  | 4 
 llvm/utils/lit/lit/llvm/config.py | 1 +
 3 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/clang/test/Interpreter/const.cpp b/clang/test/Interpreter/const.cpp
index 4b6ce65e3643e64..86358c1a54fbdde 100644
--- a/clang/test/Interpreter/const.cpp
+++ b/clang/test/Interpreter/const.cpp
@@ -1,6 +1,6 @@
 // UNSUPPORTED: system-aix
 // see https://github.com/llvm/llvm-project/issues/68092
-// XFAIL: system-windows
+// XFAIL: host={{.*}}-windows-msvc
 
 // RUN: cat %s | clang-repl | FileCheck %s
 // RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index ab245b71cdd16a5..022d1aedbdcdbb6 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -477,10 +477,6 @@ def have_cxx_shared_library():
 if not config.target_triple.startswith(("nvptx", "xcore")):
 config.available_features.add("object-emission")
 
-# Allow checking for specific details in the host triple
-if config.host_triple:
-config.available_features.add('host=%s' % config.host_triple)
-
 if config.have_llvm_driver:
 config.available_features.add("llvm-driver")
 
diff --git a/llvm/utils/lit/lit/llvm/config.py 
b/llvm/utils/lit/lit/llvm/config.py
index 16cc2968034bf74..79094b839e772e7 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -97,6 +97,7 @@ def __init__(self, lit_config, config):
 # part of the standard header.  But currently they aren't)
 host_triple = getattr(config, "host_triple", None)
 target_triple = getattr(config, "target_triple", None)
+features.add("host=%s" % host_triple)
 features.add("target=%s" % target_triple)
 if host_triple and host_triple == target_triple:
 features.add("native")

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


[clang] [llvm] Reapply #2 [clang-repl] [test] Make an XFAIL more precise (#70991) (PR #71168)

2023-11-03 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Martin Storsjö (mstorsjo)


Changes

The const.cpp testcase fails when running in MSVC mode, while it does succeed 
in MinGW mode.

In MSVC mode, there are more constructor invocations than expected, as the 
printout looks like this:

A(1), this = 02559793
A(1), this = 02559793
f: this = 02559793, val = 1
A(1), this = 02559793
f: this = 02559793, val = 1
~A, this = 02559793, val = 1
~A, this = 02559793, val = 1
~A, this = 02559793, val = 1

While the expected printout looks like this:

A(1), this = 02C903E1
f: this = 02C903E1, val = 1
f: this = 02C903E1, val = 1
~A, this = 02C903E1, val = 1

Reapplying with the XFAIL changed to check the host triple, not the target 
triple. On an MSVC based build of Clang, but with the default target triple set 
to PS4/PS5, we will still see the failure. And a Linux based build of Clang 
that targets PS4/PS5 won't see the issue.

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


3 Files Affected:

- (modified) clang/test/Interpreter/const.cpp (+1-1) 
- (modified) llvm/test/lit.cfg.py (-4) 
- (modified) llvm/utils/lit/lit/llvm/config.py (+1) 


``diff
diff --git a/clang/test/Interpreter/const.cpp b/clang/test/Interpreter/const.cpp
index 4b6ce65e3643e64..86358c1a54fbdde 100644
--- a/clang/test/Interpreter/const.cpp
+++ b/clang/test/Interpreter/const.cpp
@@ -1,6 +1,6 @@
 // UNSUPPORTED: system-aix
 // see https://github.com/llvm/llvm-project/issues/68092
-// XFAIL: system-windows
+// XFAIL: host={{.*}}-windows-msvc
 
 // RUN: cat %s | clang-repl | FileCheck %s
 // RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index ab245b71cdd16a5..022d1aedbdcdbb6 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -477,10 +477,6 @@ def have_cxx_shared_library():
 if not config.target_triple.startswith(("nvptx", "xcore")):
 config.available_features.add("object-emission")
 
-# Allow checking for specific details in the host triple
-if config.host_triple:
-config.available_features.add('host=%s' % config.host_triple)
-
 if config.have_llvm_driver:
 config.available_features.add("llvm-driver")
 
diff --git a/llvm/utils/lit/lit/llvm/config.py 
b/llvm/utils/lit/lit/llvm/config.py
index 16cc2968034bf74..79094b839e772e7 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -97,6 +97,7 @@ def __init__(self, lit_config, config):
 # part of the standard header.  But currently they aren't)
 host_triple = getattr(config, "host_triple", None)
 target_triple = getattr(config, "target_triple", None)
+features.add("host=%s" % host_triple)
 features.add("target=%s" % target_triple)
 if host_triple and host_triple == target_triple:
 features.add("native")

``




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


[llvm] [clang] Reapply #2 [clang-repl] [test] Make an XFAIL more precise (#70991) (PR #71168)

2023-11-03 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-platform-windows

Author: Martin Storsjö (mstorsjo)


Changes

The const.cpp testcase fails when running in MSVC mode, while it does succeed 
in MinGW mode.

In MSVC mode, there are more constructor invocations than expected, as the 
printout looks like this:

A(1), this = 02559793
A(1), this = 02559793
f: this = 02559793, val = 1
A(1), this = 02559793
f: this = 02559793, val = 1
~A, this = 02559793, val = 1
~A, this = 02559793, val = 1
~A, this = 02559793, val = 1

While the expected printout looks like this:

A(1), this = 02C903E1
f: this = 02C903E1, val = 1
f: this = 02C903E1, val = 1
~A, this = 02C903E1, val = 1

Reapplying with the XFAIL changed to check the host triple, not the target 
triple. On an MSVC based build of Clang, but with the default target triple set 
to PS4/PS5, we will still see the failure. And a Linux based build of Clang 
that targets PS4/PS5 won't see the issue.

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


3 Files Affected:

- (modified) clang/test/Interpreter/const.cpp (+1-1) 
- (modified) llvm/test/lit.cfg.py (-4) 
- (modified) llvm/utils/lit/lit/llvm/config.py (+1) 


``diff
diff --git a/clang/test/Interpreter/const.cpp b/clang/test/Interpreter/const.cpp
index 4b6ce65e3643e64..86358c1a54fbdde 100644
--- a/clang/test/Interpreter/const.cpp
+++ b/clang/test/Interpreter/const.cpp
@@ -1,6 +1,6 @@
 // UNSUPPORTED: system-aix
 // see https://github.com/llvm/llvm-project/issues/68092
-// XFAIL: system-windows
+// XFAIL: host={{.*}}-windows-msvc
 
 // RUN: cat %s | clang-repl | FileCheck %s
 // RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index ab245b71cdd16a5..022d1aedbdcdbb6 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -477,10 +477,6 @@ def have_cxx_shared_library():
 if not config.target_triple.startswith(("nvptx", "xcore")):
 config.available_features.add("object-emission")
 
-# Allow checking for specific details in the host triple
-if config.host_triple:
-config.available_features.add('host=%s' % config.host_triple)
-
 if config.have_llvm_driver:
 config.available_features.add("llvm-driver")
 
diff --git a/llvm/utils/lit/lit/llvm/config.py 
b/llvm/utils/lit/lit/llvm/config.py
index 16cc2968034bf74..79094b839e772e7 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -97,6 +97,7 @@ def __init__(self, lit_config, config):
 # part of the standard header.  But currently they aren't)
 host_triple = getattr(config, "host_triple", None)
 target_triple = getattr(config, "target_triple", None)
+features.add("host=%s" % host_triple)
 features.add("target=%s" % target_triple)
 if host_triple and host_triple == target_triple:
 features.add("native")

``




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


[llvm] [clang] Reapply #2 [clang-repl] [test] Make an XFAIL more precise (#70991) (PR #71168)

2023-11-03 Thread Martin Storsjö via cfe-commits

mstorsjo wrote:

Posting for a second review instead of just relanding the patch as is; in order 
to check the host triple, I had to add the `host=triple` string; it was 
previously only available for tests under `llvm/test`, but let's move it to the 
common llvm test configuration just like the `target=triple` strings, so that 
it is available for tests under clang as well.

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


[clang] 2b1948c - [NFC][OpenMP][Clang]Update OpenMP clang tests

2023-11-03 Thread Dominik Adamski via cfe-commits

Author: Dominik Adamski
Date: 2023-11-03T05:13:06-05:00
New Revision: 2b1948c2be0e935bdd2e764ae1a2b84c405fdc04

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

LOG: [NFC][OpenMP][Clang]Update OpenMP clang tests

Replace hardcoded constants by regular expressions

Added: 


Modified: 
clang/test/OpenMP/cancel_codegen.cpp
clang/test/OpenMP/parallel_codegen.cpp

Removed: 




diff  --git a/clang/test/OpenMP/cancel_codegen.cpp 
b/clang/test/OpenMP/cancel_codegen.cpp
index 53580e0c2b0293f..03024cf331b2717 100644
--- a/clang/test/OpenMP/cancel_codegen.cpp
+++ b/clang/test/OpenMP/cancel_codegen.cpp
@@ -1026,25 +1026,25 @@ for (int i = 0; i < argc; ++i) {
 // CHECK3-NEXT:call void @llvm.experimental.noalias.scope.decl(metadata 
[[META8:![0-9]+]])
 // CHECK3-NEXT:call void @llvm.experimental.noalias.scope.decl(metadata 
[[META10:![0-9]+]])
 // CHECK3-NEXT:call void @llvm.experimental.noalias.scope.decl(metadata 
[[META12:![0-9]+]])
-// CHECK3-NEXT:store i32 [[TMP2]], ptr [[DOTGLOBAL_TID__ADDR_I]], align 4, 
!noalias !14
-// CHECK3-NEXT:store ptr [[TMP5]], ptr [[DOTPART_ID__ADDR_I]], align 8, 
!noalias !14
-// CHECK3-NEXT:store ptr null, ptr [[DOTPRIVATES__ADDR_I]], align 8, 
!noalias !14
-// CHECK3-NEXT:store ptr null, ptr [[DOTCOPY_FN__ADDR_I]], align 8, 
!noalias !14
-// CHECK3-NEXT:store ptr [[TMP3]], ptr [[DOTTASK_T__ADDR_I]], align 8, 
!noalias !14
-// CHECK3-NEXT:store ptr [[TMP7]], ptr [[__CONTEXT_ADDR_I]], align 8, 
!noalias !14
-// CHECK3-NEXT:[[TMP8:%.*]] = load ptr, ptr [[__CONTEXT_ADDR_I]], align 8, 
!noalias !14
+// CHECK3-NEXT:store i32 [[TMP2]], ptr [[DOTGLOBAL_TID__ADDR_I]], align 4, 
!noalias ![[NOALIAS0:[0-9]+]]
+// CHECK3-NEXT:store ptr [[TMP5]], ptr [[DOTPART_ID__ADDR_I]], align 8, 
!noalias ![[NOALIAS0]]
+// CHECK3-NEXT:store ptr null, ptr [[DOTPRIVATES__ADDR_I]], align 8, 
!noalias ![[NOALIAS0]]
+// CHECK3-NEXT:store ptr null, ptr [[DOTCOPY_FN__ADDR_I]], align 8, 
!noalias ![[NOALIAS0]]
+// CHECK3-NEXT:store ptr [[TMP3]], ptr [[DOTTASK_T__ADDR_I]], align 8, 
!noalias ![[NOALIAS0]]
+// CHECK3-NEXT:store ptr [[TMP7]], ptr [[__CONTEXT_ADDR_I]], align 8, 
!noalias ![[NOALIAS0]]
+// CHECK3-NEXT:[[TMP8:%.*]] = load ptr, ptr [[__CONTEXT_ADDR_I]], align 8, 
!noalias ![[NOALIAS0]]
 // CHECK3-NEXT:[[OMP_GLOBAL_THREAD_NUM_I:%.*]] = call i32 
@__kmpc_global_thread_num(ptr @[[GLOB12:[0-9]+]])
 // CHECK3-NEXT:[[TMP9:%.*]] = call i32 @__kmpc_cancel(ptr @[[GLOB1]], i32 
[[OMP_GLOBAL_THREAD_NUM_I]], i32 4)
 // CHECK3-NEXT:[[TMP10:%.*]] = icmp ne i32 [[TMP9]], 0
 // CHECK3-NEXT:br i1 [[TMP10]], label [[DOTCANCEL_EXIT_I:%.*]], label 
[[DOTCANCEL_CONTINUE_I:%.*]]
 // CHECK3:   .cancel.exit.i:
-// CHECK3-NEXT:store i32 1, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias 
!14
+// CHECK3-NEXT:store i32 1, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias 
![[NOALIAS1:[0-9]+]]
 // CHECK3-NEXT:br label [[DOTOMP_OUTLINED__EXIT:%.*]]
 // CHECK3:   .cancel.continue.i:
-// CHECK3-NEXT:store i32 0, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias 
!14
+// CHECK3-NEXT:store i32 0, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias 
![[NOALIAS1]]
 // CHECK3-NEXT:br label [[DOTOMP_OUTLINED__EXIT]]
 // CHECK3:   .omp_outlined..exit:
-// CHECK3-NEXT:[[CLEANUP_DEST_I:%.*]] = load i32, ptr 
[[CLEANUP_DEST_SLOT_I]], align 4, !noalias !14
+// CHECK3-NEXT:[[CLEANUP_DEST_I:%.*]] = load i32, ptr 
[[CLEANUP_DEST_SLOT_I]], align 4, !noalias ![[NOALIAS1]]
 // CHECK3-NEXT:ret i32 0
 //
 //

diff  --git a/clang/test/OpenMP/parallel_codegen.cpp 
b/clang/test/OpenMP/parallel_codegen.cpp
index 5c98761be0808ef..d545b4a9d9fa887 100644
--- a/clang/test/OpenMP/parallel_codegen.cpp
+++ b/clang/test/OpenMP/parallel_codegen.cpp
@@ -812,7 +812,7 @@ int main (int argc, char **argv) {
 //
 //
 // CHECK3-LABEL: define {{[^@]+}}@_Z5tmainIPPcEiT_..omp_par
-// CHECK3-SAME: (ptr noalias [[TID_ADDR:%.*]], ptr noalias [[ZERO_ADDR:%.*]], 
ptr [[TMP0:%.*]]) #[[ATTR1]] {
+// CHECK3-SAME: (ptr noalias [[TID_ADDR:%.*]], ptr noalias [[ZERO_ADDR:%.*]], 
ptr [[TMP0:%.*]]) #[[ATTR2:[0-9]+]]
 // CHECK3-NEXT:  omp.par.entry:
 // CHECK3-NEXT:[[GEP__RELOADED:%.*]] = getelementptr { ptr, ptr }, ptr 
[[TMP0]], i32 0, i32 0
 // CHECK3-NEXT:[[LOADGEP__RELOADED:%.*]] = load ptr, ptr 
[[GEP__RELOADED]], align 8
@@ -956,7 +956,7 @@ int main (int argc, char **argv) {
 //
 //
 // CHECK4-LABEL: define {{[^@]+}}@_Z5tmainIPPcEiT_..omp_par
-// CHECK4-SAME: (ptr noalias [[TID_ADDR:%.*]], ptr noalias [[ZERO_ADDR:%.*]], 
ptr [[TMP0:%.*]]) #[[ATTR1]] !dbg [[DBG57:![0-9]+]] {
+// CHECK4-SAME: (ptr noalias [[TID_ADDR:%.*]], ptr noalias [[ZERO_ADDR:%.*]], 
ptr [[TMP0:%.*]]) #[[ATTR2:[0-9]+]] !dbg [[DBG57:![0-9]+]] {
 // CHECK4-NEXT

[clang] 3289ecf - [𝘀𝗽𝗿] changes introduced through rebase

2023-11-03 Thread Mehdi Amini via cfe-commits

Author: Mehdi Amini
Date: 2023-11-03T03:23:43-07:00
New Revision: 3289ecff8e8f5022cb6a40777392c98f1bcf5780

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

LOG: [𝘀𝗽𝗿] changes introduced through rebase

Created using spr 1.3.4

[skip ci]

Added: 


Modified: 
clang/test/OpenMP/cancel_codegen.cpp
clang/test/OpenMP/parallel_codegen.cpp
llvm/lib/IR/ConstantFold.cpp
mlir/include/mlir/Conversion/Passes.td
mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp
mlir/test/Conversion/VectorToLLVM/vector-mask-to-llvm.mlir
mlir/test/Conversion/VectorToLLVM/vector-reduction-to-llvm.mlir
mlir/test/Conversion/VectorToLLVM/vector-scalable-memcpy.mlir
mlir/test/Conversion/VectorToLLVM/vector-to-llvm.mlir

Removed: 
mlir/test/Conversion/VectorToLLVM/typed-pointers.mlir



diff  --git a/clang/test/OpenMP/cancel_codegen.cpp 
b/clang/test/OpenMP/cancel_codegen.cpp
index 53580e0c2b0293f..03024cf331b2717 100644
--- a/clang/test/OpenMP/cancel_codegen.cpp
+++ b/clang/test/OpenMP/cancel_codegen.cpp
@@ -1026,25 +1026,25 @@ for (int i = 0; i < argc; ++i) {
 // CHECK3-NEXT:call void @llvm.experimental.noalias.scope.decl(metadata 
[[META8:![0-9]+]])
 // CHECK3-NEXT:call void @llvm.experimental.noalias.scope.decl(metadata 
[[META10:![0-9]+]])
 // CHECK3-NEXT:call void @llvm.experimental.noalias.scope.decl(metadata 
[[META12:![0-9]+]])
-// CHECK3-NEXT:store i32 [[TMP2]], ptr [[DOTGLOBAL_TID__ADDR_I]], align 4, 
!noalias !14
-// CHECK3-NEXT:store ptr [[TMP5]], ptr [[DOTPART_ID__ADDR_I]], align 8, 
!noalias !14
-// CHECK3-NEXT:store ptr null, ptr [[DOTPRIVATES__ADDR_I]], align 8, 
!noalias !14
-// CHECK3-NEXT:store ptr null, ptr [[DOTCOPY_FN__ADDR_I]], align 8, 
!noalias !14
-// CHECK3-NEXT:store ptr [[TMP3]], ptr [[DOTTASK_T__ADDR_I]], align 8, 
!noalias !14
-// CHECK3-NEXT:store ptr [[TMP7]], ptr [[__CONTEXT_ADDR_I]], align 8, 
!noalias !14
-// CHECK3-NEXT:[[TMP8:%.*]] = load ptr, ptr [[__CONTEXT_ADDR_I]], align 8, 
!noalias !14
+// CHECK3-NEXT:store i32 [[TMP2]], ptr [[DOTGLOBAL_TID__ADDR_I]], align 4, 
!noalias ![[NOALIAS0:[0-9]+]]
+// CHECK3-NEXT:store ptr [[TMP5]], ptr [[DOTPART_ID__ADDR_I]], align 8, 
!noalias ![[NOALIAS0]]
+// CHECK3-NEXT:store ptr null, ptr [[DOTPRIVATES__ADDR_I]], align 8, 
!noalias ![[NOALIAS0]]
+// CHECK3-NEXT:store ptr null, ptr [[DOTCOPY_FN__ADDR_I]], align 8, 
!noalias ![[NOALIAS0]]
+// CHECK3-NEXT:store ptr [[TMP3]], ptr [[DOTTASK_T__ADDR_I]], align 8, 
!noalias ![[NOALIAS0]]
+// CHECK3-NEXT:store ptr [[TMP7]], ptr [[__CONTEXT_ADDR_I]], align 8, 
!noalias ![[NOALIAS0]]
+// CHECK3-NEXT:[[TMP8:%.*]] = load ptr, ptr [[__CONTEXT_ADDR_I]], align 8, 
!noalias ![[NOALIAS0]]
 // CHECK3-NEXT:[[OMP_GLOBAL_THREAD_NUM_I:%.*]] = call i32 
@__kmpc_global_thread_num(ptr @[[GLOB12:[0-9]+]])
 // CHECK3-NEXT:[[TMP9:%.*]] = call i32 @__kmpc_cancel(ptr @[[GLOB1]], i32 
[[OMP_GLOBAL_THREAD_NUM_I]], i32 4)
 // CHECK3-NEXT:[[TMP10:%.*]] = icmp ne i32 [[TMP9]], 0
 // CHECK3-NEXT:br i1 [[TMP10]], label [[DOTCANCEL_EXIT_I:%.*]], label 
[[DOTCANCEL_CONTINUE_I:%.*]]
 // CHECK3:   .cancel.exit.i:
-// CHECK3-NEXT:store i32 1, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias 
!14
+// CHECK3-NEXT:store i32 1, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias 
![[NOALIAS1:[0-9]+]]
 // CHECK3-NEXT:br label [[DOTOMP_OUTLINED__EXIT:%.*]]
 // CHECK3:   .cancel.continue.i:
-// CHECK3-NEXT:store i32 0, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias 
!14
+// CHECK3-NEXT:store i32 0, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias 
![[NOALIAS1]]
 // CHECK3-NEXT:br label [[DOTOMP_OUTLINED__EXIT]]
 // CHECK3:   .omp_outlined..exit:
-// CHECK3-NEXT:[[CLEANUP_DEST_I:%.*]] = load i32, ptr 
[[CLEANUP_DEST_SLOT_I]], align 4, !noalias !14
+// CHECK3-NEXT:[[CLEANUP_DEST_I:%.*]] = load i32, ptr 
[[CLEANUP_DEST_SLOT_I]], align 4, !noalias ![[NOALIAS1]]
 // CHECK3-NEXT:ret i32 0
 //
 //

diff  --git a/clang/test/OpenMP/parallel_codegen.cpp 
b/clang/test/OpenMP/parallel_codegen.cpp
index 5c98761be0808ef..d545b4a9d9fa887 100644
--- a/clang/test/OpenMP/parallel_codegen.cpp
+++ b/clang/test/OpenMP/parallel_codegen.cpp
@@ -812,7 +812,7 @@ int main (int argc, char **argv) {
 //
 //
 // CHECK3-LABEL: define {{[^@]+}}@_Z5tmainIPPcEiT_..omp_par
-// CHECK3-SAME: (ptr noalias [[TID_ADDR:%.*]], ptr noalias [[ZERO_ADDR:%.*]], 
ptr [[TMP0:%.*]]) #[[ATTR1]] {
+// CHECK3-SAME: (ptr noalias [[TID_ADDR:%.*]], ptr noalias [[ZERO_ADDR:%.*]], 
ptr [[TMP0:%.*]]) #[[ATTR2:[0-9]+]]
 // CHECK3-NEXT:  omp.par.entry:
 // CHECK3-NEXT:[[GEP__RELOADED:%.*]] = getelementptr { ptr, ptr }, ptr 
[[TMP0]], i32 0, i32 0
 // CHECK3-NEXT:

[clang] [NFC] [Serializer] Pack information in serializer (PR #69287)

2023-11-03 Thread Vassil Vassilev via cfe-commits

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

LGTM, thank you!

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


[clang] [LoongArch] Fix ABI mismatch with g++ when handling empty unions (PR #71025)

2023-11-03 Thread via cfe-commits

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


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


[llvm] [clang] Fix python escapes (PR #71170)

2023-11-03 Thread Nathan Sidwell via cfe-commits

https://github.com/urnathan created 
https://github.com/llvm/llvm-project/pull/71170

With Fedora 39, I encountered 2 new python warnings:

/home/nathan/gh/llvm/push/strict-aliasing/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py:28:
 SyntaxWarning: invalid escape sequence '\*'
  self.implementationContent += """

/home/nathan/gh/llvm/push/strict-aliasing/llvm/test/lit.cfg.py:274: 
SyntaxWarning: invalid escape sequence '\d'
  match = re.search("release (\d+)\.(\d+)", ptxas_out)

Use raw strings here. I guess python got pickier or something?

While there, might as well fix the blank line caused by """NEWLINE ...
""" by dropping its first char.

>From 9b5cb1ac8d4b9a2aaa4c06e41620e38b6c3cae8c Mon Sep 17 00:00:00 2001
From: Nathan Sidwell 
Date: Thu, 2 Nov 2023 18:14:05 -0400
Subject: [PATCH] Fix python escapes

With Fedora 39, I encountered 2 new python warnings:

/home/nathan/gh/llvm/push/strict-aliasing/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py:28:
 SyntaxWarning: invalid escape sequence '\*'
  self.implementationContent += """

/home/nathan/gh/llvm/push/strict-aliasing/llvm/test/lit.cfg.py:274: 
SyntaxWarning: invalid escape sequence '\d'
  match = re.search("release (\d+)\.(\d+)", ptxas_out)

Use raw strings here. I guess python got pickier or something?

May as well fix the blank line caused by """NEWLINE
...
"""
---
 clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py | 4 ++--
 llvm/test/lit.cfg.py| 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py 
b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
index dafb332961ede86..54cfd0741f9d122 100755
--- a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
+++ b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
@@ -25,7 +25,7 @@ def __init__(self, templateClasses):
 
 def GeneratePrologue(self):
 
-self.implementationContent += """
+self.implementationContent += R"""
 /*===- Generated file ---*- C++ 
-*-===*\
 |*
*|
 |* Introspection of available AST node SourceLocations
*|
@@ -58,7 +58,7 @@ def GeneratePrologue(self):
 private:
 std::vector &TLRG;
 };
-"""
+"""[1:]
 
 def GenerateBaseGetLocationsDeclaration(self, CladeName):
 InstanceDecoration = "*"
diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index ab245b71cdd16a5..cf050bbfe3b1413 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -271,7 +271,7 @@ def ptxas_version(ptxas):
 ptxas_cmd = subprocess.Popen([ptxas, "--version"], stdout=subprocess.PIPE)
 ptxas_out = ptxas_cmd.stdout.read().decode("ascii")
 ptxas_cmd.wait()
-match = re.search("release (\d+)\.(\d+)", ptxas_out)
+match = re.search(R"release (\d+)\.(\d+)", ptxas_out)
 if match:
 return (int(match.group(1)), int(match.group(2)))
 print("couldn't determine ptxas version")

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


[llvm] [clang] [NFC] Remove Type::getInt8PtrTy (PR #71029)

2023-11-03 Thread Paulo Matos via cfe-commits

https://github.com/pmatos updated 
https://github.com/llvm/llvm-project/pull/71029

>From bb652ca71a8f7ff5c362fef2fdf2d265fa77e45e Mon Sep 17 00:00:00 2001
From: Paulo Matos 
Date: Fri, 3 Nov 2023 12:03:07 +0100
Subject: [PATCH] [NFC] Remove Type::getInt8PtrTy

Replace this with PointerType::getUnqual().
Followup to the opaque pointer transition. Fixes an in-code TODO item.
---
 clang/lib/CodeGen/CGGPUBuiltin.cpp| 12 ++---
 clang/lib/CodeGen/CodeGenTypes.cpp|  2 +-
 clang/lib/CodeGen/CoverageMappingGen.cpp  |  2 +-
 .../clang-linker-wrapper/OffloadWrapper.cpp   | 38 +++
 llvm/examples/BrainF/BrainF.cpp   |  2 +-
 llvm/include/llvm/IR/Type.h   |  5 --
 .../llvm/ProfileData/InstrProfData.inc| 12 ++---
 llvm/lib/Analysis/StackSafetyAnalysis.cpp |  4 +-
 llvm/lib/Bitcode/Writer/BitcodeWriter.cpp |  2 +-
 llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp|  2 +-
 llvm/lib/CodeGen/DwarfEHPrepare.cpp   |  4 +-
 llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp  |  8 ++--
 llvm/lib/CodeGen/SafeStack.cpp|  2 +-
 llvm/lib/CodeGen/ShadowStackGCLowering.cpp|  2 +-
 llvm/lib/CodeGen/SjLjEHPrepare.cpp|  2 +-
 llvm/lib/CodeGen/StackProtector.cpp   |  4 +-
 llvm/lib/CodeGen/TargetLoweringBase.cpp   |  8 ++--
 llvm/lib/ExecutionEngine/ExecutionEngine.cpp  |  2 +-
 llvm/lib/Frontend/Offloading/Utility.cpp  |  4 +-
 llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 14 +++---
 llvm/lib/IR/Type.cpp  |  4 --
 .../Target/AArch64/AArch64ISelLowering.cpp|  4 +-
 .../AMDGPU/AMDGPULowerModuleLDSPass.cpp   |  2 +-
 .../AMDGPUOpenCLEnqueuedBlockLowering.cpp |  2 +-
 llvm/lib/Target/ARM/ARMISelLowering.cpp   |  4 +-
 .../Target/BPF/BPFAbstractMemberAccess.cpp|  2 +-
 llvm/lib/Target/DirectX/DXILOpBuilder.cpp |  2 +-
 llvm/lib/Target/PowerPC/PPCISelLowering.cpp   |  2 +-
 llvm/lib/Target/X86/X86ISelLowering.cpp   |  4 +-
 llvm/lib/Target/X86/X86ISelLoweringCall.cpp   |  4 +-
 llvm/lib/Target/X86/X86WinEHState.cpp | 12 ++---
 llvm/lib/Target/XCore/XCoreISelLowering.cpp   |  2 +-
 llvm/lib/Transforms/CFGuard/CFGuard.cpp   |  2 +-
 llvm/lib/Transforms/Coroutines/CoroElide.cpp  |  2 +-
 llvm/lib/Transforms/Coroutines/CoroInstr.h|  4 +-
 llvm/lib/Transforms/Coroutines/CoroSplit.cpp  |  8 ++--
 .../Instrumentation/AddressSanitizer.cpp  |  4 +-
 .../Instrumentation/DataFlowSanitizer.cpp |  8 ++--
 .../Instrumentation/GCOVProfiling.cpp |  2 +-
 .../Instrumentation/InstrProfiling.cpp| 10 ++--
 .../Instrumentation/PGOInstrumentation.cpp|  2 +-
 .../Transforms/Scalar/LoopDataPrefetch.cpp|  2 +-
 .../Scalar/RewriteStatepointsForGC.cpp|  2 +-
 .../Scalar/StraightLineStrengthReduce.cpp |  2 +-
 llvm/lib/Transforms/Utils/CodeExtractor.cpp   |  2 +-
 .../Utils/EntryExitInstrumenter.cpp   |  4 +-
 .../lib/Transforms/Utils/EscapeEnumerator.cpp |  2 +-
 llvm/lib/Transforms/Utils/InlineFunction.cpp  |  4 +-
 .../lib/Transforms/Utils/LowerGlobalDtors.cpp |  2 +-
 llvm/lib/Transforms/Utils/ModuleUtils.cpp |  2 +-
 llvm/lib/Transforms/Utils/SanitizerStats.cpp  |  6 +--
 llvm/tools/bugpoint/Miscompilation.cpp|  4 +-
 .../Analysis/CGSCCPassManagerTest.cpp | 16 +++
 llvm/unittests/Analysis/LazyCallGraphTest.cpp | 48 +--
 .../unittests/Analysis/MemoryBuiltinsTest.cpp |  2 +-
 .../Analysis/ScalarEvolutionTest.cpp  |  2 +-
 .../Frontend/OpenMPIRBuilderTest.cpp  |  4 +-
 llvm/unittests/FuzzMutate/OperationsTest.cpp  |  4 +-
 llvm/unittests/Linker/LinkModulesTest.cpp | 14 +++---
 59 files changed, 165 insertions(+), 174 deletions(-)

diff --git a/clang/lib/CodeGen/CGGPUBuiltin.cpp 
b/clang/lib/CodeGen/CGGPUBuiltin.cpp
index 75fb06de938425d..daa2b9c14f99a35 100644
--- a/clang/lib/CodeGen/CGGPUBuiltin.cpp
+++ b/clang/lib/CodeGen/CGGPUBuiltin.cpp
@@ -23,8 +23,8 @@ using namespace CodeGen;
 
 namespace {
 llvm::Function *GetVprintfDeclaration(llvm::Module &M) {
-  llvm::Type *ArgTypes[] = {llvm::Type::getInt8PtrTy(M.getContext()),
-llvm::Type::getInt8PtrTy(M.getContext())};
+  llvm::Type *ArgTypes[] = {llvm::PointerType::getUnqual(M.getContext()),
+llvm::PointerType::getUnqual(M.getContext())};
   llvm::FunctionType *VprintfFuncType = llvm::FunctionType::get(
   llvm::Type::getInt32Ty(M.getContext()), ArgTypes, false);
 
@@ -45,8 +45,8 @@ llvm::Function *GetVprintfDeclaration(llvm::Module &M) {
 llvm::Function *GetOpenMPVprintfDeclaration(CodeGenModule &CGM) {
   const char *Name = "__llvm_omp_vprintf";
   llvm::Module &M = CGM.getModule();
-  llvm::Type *ArgTypes[] = {llvm::Type::getInt8PtrTy(M.getContext()),
-llvm::Type::getInt8PtrTy(M.getContext()),
+  llvm::Type *ArgTypes[] = {llvm::PointerType::getUnqual(M.getContext()),
+llvm::PointerType::getUnqu

[llvm] [clang] [NFC] Remove Type::getInt8PtrTy (PR #71029)

2023-11-03 Thread Paulo Matos via cfe-commits

pmatos wrote:

I pushed forced a change using PointerType::getUnqual. Would this be more 
acceptable? It certainly looks cleaner to my eyes than having 
`PointerType::get(Ctx, 0)` everywhere.

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


[llvm] [clang] Recommit changes to global checks (PR #71171)

2023-11-03 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Henrik G. Olsson (hnrklssn)


Changes

Recommits the changes from https://reviews.llvm.org/D148216.
Explicitly named globals are now matched literally, instead of emitting a 
capture group for the name. This resolves  #70047.
Metadata and annotations, on the other hand, are captured and matched against 
by default, since their identifiers are not stable.

The reasons for revert (#63746) have been fixed:
The first issue, that of duplicated checkers, has already been resolved in 
#70050.
This PR resolves the second issue listed in #63746, regarding the order 
of named and unnamed globals. This is fixed by recording the index of 
substrings containing global values, and sorting the checks according to that 
index before emitting them. This results in global value checks being emitted 
in the order they were seen instead of being grouped separately.



---

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


21 Files Affected:

- (added) clang/test/utils/update_cc_test_checks/Inputs/annotations.c (+6) 
- (added) clang/test/utils/update_cc_test_checks/Inputs/annotations.c.expected 
(+21) 
- (added) 
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.all.expected
 (+258) 
- (modified) 
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
 (+6-1) 
- (added) 
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.all.expected
 (+129) 
- (modified) 
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
 (+6-1) 
- (added) clang/test/utils/update_cc_test_checks/annotations.test (+4) 
- (modified) clang/test/utils/update_cc_test_checks/check-globals.test (+7-7) 
- (modified) clang/test/utils/update_cc_test_checks/generated-funcs.test 
(+14-2) 
- (modified) 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.generated.globals.expected
 (+1-1) 
- (modified) 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.nogenerated.globals.expected
 (+1-1) 
- (modified) 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.generated.globals.expected
 (+1-1) 
- (modified) 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.nogenerated.globals.expected
 (+1-1) 
- (modified) 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/global_regex.ll.expected
 (+1-1) 
- (modified) 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
 (+58-58) 
- (added) 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.noglobals.expected
 (+244) 
- (added) 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.transitiveglobals.expected
 (+305) 
- (modified) 
llvm/test/tools/UpdateTestChecks/update_test_checks/various_ir_values.test (+6) 
- (modified) llvm/utils/UpdateTestChecks/common.py (+181-19) 
- (modified) llvm/utils/update_cc_test_checks.py (+13-7) 
- (modified) llvm/utils/update_test_checks.py (+9-3) 


``diff
diff --git a/clang/test/utils/update_cc_test_checks/Inputs/annotations.c 
b/clang/test/utils/update_cc_test_checks/Inputs/annotations.c
new file mode 100644
index 000..f09b0f788e9b128
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/Inputs/annotations.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fblocks 
-ftrivial-auto-var-init=zero %s -emit-llvm -o - | FileCheck %s
+
+int foo() {
+int x = x + 1;
+return x;
+}
diff --git 
a/clang/test/utils/update_cc_test_checks/Inputs/annotations.c.expected 
b/clang/test/utils/update_cc_test_checks/Inputs/annotations.c.expected
new file mode 100644
index 000..1eb82f6eb5ddccc
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/Inputs/annotations.c.expected
@@ -0,0 +1,21 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 4
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fblocks 
-ftrivial-auto-var-init=zero %s -emit-llvm -o - | FileCheck %s
+
+// CHECK-LABEL: define dso_local i32 @foo(
+// CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[X:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 0, ptr [[X]], align 4, !annotation 
[[META2:![0-9]+]]
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr [[X]], align 4
+// CHECK-NEXT:[[ADD:%.*]] = add nsw i32 [[TMP0]], 1
+// CHECK-NEXT:store i32 [[ADD]], ptr [[X]], align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[X]], align 4
+// CHECK-NEXT:ret i32 [[TMP1]]
+//
+int foo() {
+int x = x + 1;
+return x;
+}
+//.
+// CHECK: [[META2]] = !{!"auto-init"}
+//.
diff --git 
a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.all.expected
 
b/clang/test/utils/update_cc_test_checks

[clang] [llvm] Fix python escapes (PR #71170)

2023-11-03 Thread via cfe-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
01689175251f2624fb9d07757aa21e3f7850..9b5cb1ac8d4b9a2aaa4c06e41620e38b6c3cae8c
 clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py llvm/test/lit.cfg.py
``





View the diff from darker here.


``diff
--- clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py 2023-11-02 
23:50:23.00 +
+++ clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py 2023-11-03 
11:12:15.508539 +
@@ -56,11 +56,13 @@
 }
 
 private:
 std::vector &TLRG;
 };
-"""[1:]
+"""[
+1:
+]
 
 def GenerateBaseGetLocationsDeclaration(self, CladeName):
 InstanceDecoration = "*"
 if CladeName in self.RefClades:
 InstanceDecoration = "&"

``




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


[clang] [llvm] Recommit changes to global checks (PR #71171)

2023-11-03 Thread via cfe-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
01689175251f2624fb9d07757aa21e3f7850..f6c2574edbd1d4fa586b7577149c67cd104d36dc
 llvm/utils/UpdateTestChecks/common.py llvm/utils/update_cc_test_checks.py 
llvm/utils/update_test_checks.py
``





View the diff from darker here.


``diff
--- UpdateTestChecks/common.py  2023-11-03 10:38:04.00 +
+++ UpdateTestChecks/common.py  2023-11-03 11:15:21.113937 +
@@ -1686,29 +1686,34 @@
 if extract(line, nameless_value)[0] in transitively_visible
 ]
 
 
 METADATA_FILTERS = [
-(r"(?<=\")(\w+ )?(\w+ version )[\d.]+(?: \([^)]+\))?", r"{{.*}}\2{{.*}}"), 
# preface with glob also, to capture optional CLANG_VENDOR
+(
+r"(?<=\")(\w+ )?(\w+ version )[\d.]+(?: \([^)]+\))?",
+r"{{.*}}\2{{.*}}",
+),  # preface with glob also, to capture optional CLANG_VENDOR
 (r'(!DIFile\(filename: ".+", directory: )".+"', r"\1{{.*}}"),
 ]
-METADATA_FILTERS_RE = [(re.compile(f),r) for (f,r) in METADATA_FILTERS]
+METADATA_FILTERS_RE = [(re.compile(f), r) for (f, r) in METADATA_FILTERS]
 
 
 def filter_unstable_metadata(line):
-for (f,replacement) in METADATA_FILTERS_RE:
+for f, replacement in METADATA_FILTERS_RE:
 line = f.sub(replacement, line)
 return line
+
 
 def flush_current_checks(output_lines, new_lines_w_index, comment_marker):
 if not new_lines_w_index:
 return
 output_lines.append(comment_marker + SEPARATOR)
 new_lines_w_index.sort()
 for _, line in new_lines_w_index:
 output_lines.append(line)
 new_lines_w_index.clear()
+
 
 def add_global_checks(
 glob_val_dict,
 comment_marker,
 prefix_list,
@@ -1717,11 +1722,11 @@
 preserve_names,
 is_before_functions,
 global_check_setting,
 ):
 printed_prefixes = set()
-output_lines_loc = {} # Allows GLOB and GLOBNAMED to be sorted correctly
+output_lines_loc = {}  # Allows GLOB and GLOBNAMED to be sorted correctly
 for nameless_value in global_nameless_values:
 if nameless_value.is_before_functions != is_before_functions:
 continue
 for p in prefix_list:
 global_vars_seen = {}
@@ -1744,11 +1749,14 @@
 
 check_lines = []
 global_vars_seen_before = [key for key in 
global_vars_seen.keys()]
 lines_w_index = 
glob_val_dict[checkprefix][nameless_value.check_prefix]
 lines_w_index = filter_globals_according_to_preference(
-lines_w_index, global_vars_seen_before, nameless_value, 
global_check_setting
+lines_w_index,
+global_vars_seen_before,
+nameless_value,
+global_check_setting,
 )
 for i, line in lines_w_index:
 if _global_value_regex:
 matched = False
 for regex in _global_value_regex:
@@ -1769,11 +1777,13 @@
 continue
 
 if not checkprefix in output_lines_loc:
 output_lines_loc[checkprefix] = []
 if not nameless_value.interlaced_with_previous:
-flush_current_checks(output_lines, 
output_lines_loc[checkprefix], comment_marker)
+flush_current_checks(
+output_lines, output_lines_loc[checkprefix], 
comment_marker
+)
 for check_line in check_lines:
 output_lines_loc[checkprefix].append(check_line)
 
 printed_prefixes.add((checkprefix, 
nameless_value.check_prefix))
 
@@ -1788,11 +1798,13 @@
 if p[0] is None:
 continue
 for checkprefix in p[0]:
 if checkprefix not in output_lines_loc:
 continue
-flush_current_checks(output_lines, 
output_lines_loc[checkprefix], comment_marker)
+flush_current_checks(
+output_lines, output_lines_loc[checkprefix], comment_marker
+)
 break
 output_lines.append(comment_marker + SEPARATOR)
 return printed_prefixes
 
 
--- update_cc_test_checks.py2023-11-03 10:35:29.00 +
+++ update_cc_test_checks.py2023-11-03 11:15:21.389578 +
@@ -437,11 +437,11 @@
 func,
 global_vars_seen_dict,
 is_filtered=builder.is_filtered(),
 )
 
-if ti.args.check_globals != 'none':
+if ti.args.check_globals != "none":
 generated_prefixes.extend(
 common.add_global_checks(
 builder.global_var_dict(),
 "//",
 run_list,
@

[llvm] [clang] Fix python escapes (PR #71170)

2023-11-03 Thread Nathan Sidwell via cfe-commits

https://github.com/urnathan updated 
https://github.com/llvm/llvm-project/pull/71170

>From 9b5cb1ac8d4b9a2aaa4c06e41620e38b6c3cae8c Mon Sep 17 00:00:00 2001
From: Nathan Sidwell 
Date: Thu, 2 Nov 2023 18:14:05 -0400
Subject: [PATCH 1/2] Fix python escapes

With Fedora 39, I encountered 2 new python warnings:

/home/nathan/gh/llvm/push/strict-aliasing/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py:28:
 SyntaxWarning: invalid escape sequence '\*'
  self.implementationContent += """

/home/nathan/gh/llvm/push/strict-aliasing/llvm/test/lit.cfg.py:274: 
SyntaxWarning: invalid escape sequence '\d'
  match = re.search("release (\d+)\.(\d+)", ptxas_out)

Use raw strings here. I guess python got pickier or something?

May as well fix the blank line caused by """NEWLINE
...
"""
---
 clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py | 4 ++--
 llvm/test/lit.cfg.py| 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py 
b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
index dafb332961ede86..54cfd0741f9d122 100755
--- a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
+++ b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
@@ -25,7 +25,7 @@ def __init__(self, templateClasses):
 
 def GeneratePrologue(self):
 
-self.implementationContent += """
+self.implementationContent += R"""
 /*===- Generated file ---*- C++ 
-*-===*\
 |*
*|
 |* Introspection of available AST node SourceLocations
*|
@@ -58,7 +58,7 @@ def GeneratePrologue(self):
 private:
 std::vector &TLRG;
 };
-"""
+"""[1:]
 
 def GenerateBaseGetLocationsDeclaration(self, CladeName):
 InstanceDecoration = "*"
diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index ab245b71cdd16a5..cf050bbfe3b1413 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -271,7 +271,7 @@ def ptxas_version(ptxas):
 ptxas_cmd = subprocess.Popen([ptxas, "--version"], stdout=subprocess.PIPE)
 ptxas_out = ptxas_cmd.stdout.read().decode("ascii")
 ptxas_cmd.wait()
-match = re.search("release (\d+)\.(\d+)", ptxas_out)
+match = re.search(R"release (\d+)\.(\d+)", ptxas_out)
 if match:
 return (int(match.group(1)), int(match.group(2)))
 print("couldn't determine ptxas version")

>From 0cf6eb5b293752525cace1dee1ba26e143386809 Mon Sep 17 00:00:00 2001
From: Nathan Sidwell 
Date: Fri, 3 Nov 2023 07:44:11 -0400
Subject: [PATCH 2/2] Lower case raw string

---
 clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py | 2 +-
 llvm/test/lit.cfg.py| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py 
b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
index 54cfd0741f9d122..a6843f70adedae9 100755
--- a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
+++ b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
@@ -25,7 +25,7 @@ def __init__(self, templateClasses):
 
 def GeneratePrologue(self):
 
-self.implementationContent += R"""
+self.implementationContent += r"""
 /*===- Generated file ---*- C++ 
-*-===*\
 |*
*|
 |* Introspection of available AST node SourceLocations
*|
diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index cf050bbfe3b1413..5f4cff424f073b8 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -271,7 +271,7 @@ def ptxas_version(ptxas):
 ptxas_cmd = subprocess.Popen([ptxas, "--version"], stdout=subprocess.PIPE)
 ptxas_out = ptxas_cmd.stdout.read().decode("ascii")
 ptxas_cmd.wait()
-match = re.search(R"release (\d+)\.(\d+)", ptxas_out)
+match = re.search(r"release (\d+)\.(\d+)", ptxas_out)
 if match:
 return (int(match.group(1)), int(match.group(2)))
 print("couldn't determine ptxas version")

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


[clang] [AArch64] Implement reinterpret builtins for SVE vector tuples (PR #69598)

2023-11-03 Thread Momchil Velikov via cfe-commits

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


[clang] clang: Add pragma clang fp reciprocal (PR #68267)

2023-11-03 Thread Zahira Ammarguellat via cfe-commits

zahiraam wrote:

> Just follow allow with the reassociate pragma.

What does that mean?

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


[clang] [analyzer][NFC] Rework SVal kind representation (PR #71039)

2023-11-03 Thread Balazs Benics via cfe-commits

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

>From 3bc43ab005aa76a43644d4d93286215b490cc8fa Mon Sep 17 00:00:00 2001
From: Balazs Benics 
Date: Thu, 2 Nov 2023 10:21:03 +0100
Subject: [PATCH 1/2] [analyzer][NFC] Rework SVal kind representation

The goal of this patch is to refine how the `SVal` base and sub-kinds
are represented by forming one unified enum describing the possible SVals.
This means that the `unsigned SVal::Kind` and the attached bit-packing
semantics would be replaced by a single unified enum.
This is more conventional and leads to a better debugging experience by default.
This eases the need of using debug pretty-printers, or the use of
runtime functions doing the printing for us like we do today by calling
`Val.dump()` whenever we inspect the values.

Previously, the first 2 bits of the `unsigned SVal::Kind` discriminated
the following quartet: `UndefinedVal`, `UnknownVal`, `Loc`, or `NonLoc`.
The rest of the upper bits represented the sub-kind, where the value
represented the index among only the `Loc`s or `NonLoc`s, effectively
attaching 2 meanings of the upper bits depending on the base-kind.
We don't need to pack these bits, as we have plenty even if we would use
just a plan-old `unsigned char`.

Consequently, in this patch, I propose to lay out all the (non-abstract)
`SVal` kinds into a single enum, along with some metadata (`BEGIN_Loc`,
`END_Loc`, `BEGIN_NonLoc`, `END_NonLoc`) artificial enum values, similar
how we do with the `MemRegions`.

Note that in the unified `SVal::Kind` enum, to differentiate
`nonloc::ConcreteInt` from `loc::ConcreteInt`, I had to prefix them with
`Loc` and `NonLoc` to resolve this ambiguity.
This should not surface in general, because I'm replacing the
`nonloc::Kind` enum items with `inline constexpr` global constants to
mimic the original behavior - and offer nicer spelling to these enum
values.

Some `SVal` constructors were not marked explicit, which I now mark as
such to follow best practices, and marked others as `/*implicit*/` to
clarify the intent.
During refactoring, I also found at least one function not marked
`LLVM_ATTRIBUTE_RETURNS_NONNULL`, so I did that.

The `TypeRetrievingVisitor` visitor had some accidental dead code,
namely: `VisitNonLocConcreteInt` and `VisitLocConcreteInt`.

Previously, the `SValVisitor` expected visit handlers of
`VisitNonLocX(nonloc::X)` and `VisitLocX(loc::X)`, where
I felt that envoding `NonLoc` and `Loc` in the name is not necessary as
the type of the parameter would select the right overload anyways, so I
simplified the naming of those visit functions.

The rest of the diff is a lot of times just formatting, because
`getKind()` by nature, frequently appears in switches, which means that
the whole switch gets automatically reformatted. I could probably undo
the formatting, but I didn't want to deviate from the rule unless
explicitly requested.
---
 .../StaticAnalyzer/Checkers/SValExplainer.h   |  10 +-
 .../Core/PathSensitive/SValVisitor.h  |  57 ++---
 .../Core/PathSensitive/SVals.def  |  38 ++-
 .../StaticAnalyzer/Core/PathSensitive/SVals.h | 225 ++
 clang/lib/StaticAnalyzer/Core/SValBuilder.cpp |  28 +--
 clang/lib/StaticAnalyzer/Core/SVals.cpp   |  87 ---
 .../Core/SimpleConstraintManager.cpp  |   4 +-
 .../StaticAnalyzer/Core/SimpleSValBuilder.cpp |  73 +++---
 clang/lib/StaticAnalyzer/Core/Store.cpp   |   2 +-
 9 files changed, 220 insertions(+), 304 deletions(-)

diff --git a/clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h 
b/clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
index 3ae28c1dba3eb5a..43a70f596a4da28 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
+++ b/clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
@@ -65,7 +65,7 @@ class SValExplainer : public FullSValVisitor {
 return "undefined value";
   }
 
-  std::string VisitLocMemRegionVal(loc::MemRegionVal V) {
+  std::string VisitMemRegionVal(loc::MemRegionVal V) {
 const MemRegion *R = V.getRegion();
 // Avoid the weird "pointer to pointee of ...".
 if (auto SR = dyn_cast(R)) {
@@ -76,7 +76,7 @@ class SValExplainer : public FullSValVisitor {
 return "pointer to " + Visit(R);
   }
 
-  std::string VisitLocConcreteInt(loc::ConcreteInt V) {
+  std::string VisitConcreteInt(loc::ConcreteInt V) {
 const llvm::APSInt &I = V.getValue();
 std::string Str;
 llvm::raw_string_ostream OS(Str);
@@ -84,11 +84,11 @@ class SValExplainer : public FullSValVisitor {
 return Str;
   }
 
-  std::string VisitNonLocSymbolVal(nonloc::SymbolVal V) {
+  std::string VisitSymbolVal(nonloc::SymbolVal V) {
 return Visit(V.getSymbol());
   }
 
-  std::string VisitNonLocConcreteInt(nonloc::ConcreteInt V) {
+  std::string VisitConcreteInt(nonloc::ConcreteInt V) {
 const llvm::APSInt &I = V.getValue();
 std::string Str;
 llvm::raw_string_ostream OS(Str);
@@ -97,7

[clang] [analyzer][NFC] Rework SVal kind representation (PR #71039)

2023-11-03 Thread Balazs Benics via cfe-commits

steakhal wrote:

> But I have to point out that this patch doesn't address the fact that `const 
> void* Data` is not friendly to debuggers, especially with type information 
> encoded in another member. So even with this patch applied, someone would 
> still have to write (and maintain) a custom formatter on debugger side to 
> display `Data` correctly.
> 
> If you refactor `const void* Data` to be a `llvm::PointerUnion`, then it will 
> be picked up automatically (`PointerUnion` is a popular type, so I've already 
> written a formatter for it.) Together with removing `BaseBits` from `Kind` 
> and making the latter non-packed, `SVal` will have a debugger-friendly layout.

What other ways are to make a `const void *` debugger-friendly - other than 
`llvm::PointerUnion`?
I've considered using plain-old unions, but I found that approach pretty ugly, 
and I'm not even sure if it would help debugging experience.

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


[clang] [Clang][SME2] Add outer product and accumulate/subtract builtins (PR #71176)

2023-11-03 Thread Kerry McLaughlin via cfe-commits

https://github.com/kmclaughlin-arm created 
https://github.com/llvm/llvm-project/pull/71176

Adds the following SME2 builtins:
 - svmop(a|s)_za32,
 - svbmop(a|s)_za32

See https://github.com/ARM-software/acle/pull/217

>From b8560b9a4496db32b730ba5715fcd7febf27b98d Mon Sep 17 00:00:00 2001
From: Kerry McLaughlin 
Date: Thu, 2 Nov 2023 17:02:32 +
Subject: [PATCH] [Clang][SME2] Add outer product and accumulate/subtract
 builtins

Adds the following SME2 builtins:
 - svmop(a|s)_za32,
 - svbmop(a|s)_za32

See https://github.com/ARM-software/acle/pull/217
---
 clang/include/clang/Basic/arm_sme.td  |  15 ++
 clang/include/clang/Basic/arm_sve_sme_incl.td |   2 +-
 .../aarch64-sme2-intrinsics/acle_sme2_mop.c   | 170 ++
 .../aarch64-sme2-intrinsics/acle_sme2_imm.cpp |  18 ++
 4 files changed, 204 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mop.c
 create mode 100644 clang/test/Sema/aarch64-sme2-intrinsics/acle_sme2_imm.cpp

diff --git a/clang/include/clang/Basic/arm_sme.td 
b/clang/include/clang/Basic/arm_sme.td
index 8d85327a86b1aaf..822c9c5621a8f18 100644
--- a/clang/include/clang/Basic/arm_sme.td
+++ b/clang/include/clang/Basic/arm_sme.td
@@ -263,3 +263,18 @@ multiclass ZAFPOuterProd {
 
 defm SVMOPA : ZAFPOuterProd<"mopa">;
 defm SVMOPS : ZAFPOuterProd<"mops">;
+
+
+// SME2 - UMOPA, SMOPA, UMOPS, SMOPS, BMOPA, BMOPS
+
+let TargetGuard = "sme2" in {
+  def SVSMOPA  : Inst<"svmopa_za32[_{d}]_m", "viPPdd", "s", MergeNone, 
"aarch64_sme_smopa_za32", [IsSharedZA, IsStreaming], [ImmCheck<0, 
ImmCheck0_3>]>;
+  def SVUSMOPA : Inst<"svmopa_za32[_{d}]_m", "viPPdd", "Us", MergeNone, 
"aarch64_sme_umopa_za32", [IsSharedZA, IsStreaming], [ImmCheck<0, 
ImmCheck0_3>]>;
+
+  def SVSMOPS  : Inst<"svmops_za32[_{d}]_m", "viPPdd", "s", MergeNone, 
"aarch64_sme_smops_za32", [IsSharedZA, IsStreaming], [ImmCheck<0, 
ImmCheck0_3>]>;
+  def SVUSMOPS : Inst<"svmops_za32[_{d}]_m", "viPPdd", "Us", MergeNone, 
"aarch64_sme_umops_za32", [IsSharedZA, IsStreaming], [ImmCheck<0, 
ImmCheck0_3>]>;
+
+  def SVBMOPA : Inst<"svbmopa_za32[_{d}]_m", "viPPdd", "iUi", MergeNone, 
"aarch64_sme_bmopa_za32", [IsSharedZA, IsStreaming], [ImmCheck<0, 
ImmCheck0_3>]>;
+
+  def SVBMOPS : Inst<"svbmops_za32[_{d}]_m", "viPPdd", "iUi", MergeNone, 
"aarch64_sme_bmops_za32", [IsSharedZA, IsStreaming], [ImmCheck<0, 
ImmCheck0_3>]>;
+}
diff --git a/clang/include/clang/Basic/arm_sve_sme_incl.td 
b/clang/include/clang/Basic/arm_sve_sme_incl.td
index 3a7a5b51b25801e..22a2a3c5434d657 100644
--- a/clang/include/clang/Basic/arm_sve_sme_incl.td
+++ b/clang/include/clang/Basic/arm_sve_sme_incl.td
@@ -257,7 +257,7 @@ class ImmCheck {
 }
 
 class Inst ft, list ch, MemEltType met> {
+   list ft, list ch, MemEltType met = 
MemEltTyDefault> {
   string Name = n;
   string Prototype = p;
   string Types = t;
diff --git a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mop.c 
b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mop.c
new file mode 100644
index 000..bb804a523c449d3
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mop.c
@@ -0,0 +1,170 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+
+// REQUIRES: aarch64-registered-target
+
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 
-target-feature +sve -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | 
opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 
-target-feature +sve -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - -x 
c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s 
-check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sme2 -target-feature +sve -S -disable-O0-optnone -Werror -Wall 
-emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sme2 -target-feature +sve -S -disable-O0-optnone -Werror -Wall 
-emit-llvm -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | 
FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 
-target-feature +sve -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+// MOPA
+
+// CHECK-LABEL: @test_svmopa_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.convert.from.svbool.nxv8i1( [[PN:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  
@llvm.aarch64.sve.convert.from.svbool.nxv8i1( [[PM:%.*

[clang] [Clang][SME2] Add outer product and accumulate/subtract builtins (PR #71176)

2023-11-03 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Kerry McLaughlin (kmclaughlin-arm)


Changes

Adds the following SME2 builtins:
 - svmop(a|s)_za32,
 - svbmop(a|s)_za32

See https://github.com/ARM-software/acle/pull/217

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


4 Files Affected:

- (modified) clang/include/clang/Basic/arm_sme.td (+15) 
- (modified) clang/include/clang/Basic/arm_sve_sme_incl.td (+1-1) 
- (added) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mop.c (+170) 
- (added) clang/test/Sema/aarch64-sme2-intrinsics/acle_sme2_imm.cpp (+18) 


``diff
diff --git a/clang/include/clang/Basic/arm_sme.td 
b/clang/include/clang/Basic/arm_sme.td
index 8d85327a86b1aaf..822c9c5621a8f18 100644
--- a/clang/include/clang/Basic/arm_sme.td
+++ b/clang/include/clang/Basic/arm_sme.td
@@ -263,3 +263,18 @@ multiclass ZAFPOuterProd {
 
 defm SVMOPA : ZAFPOuterProd<"mopa">;
 defm SVMOPS : ZAFPOuterProd<"mops">;
+
+
+// SME2 - UMOPA, SMOPA, UMOPS, SMOPS, BMOPA, BMOPS
+
+let TargetGuard = "sme2" in {
+  def SVSMOPA  : Inst<"svmopa_za32[_{d}]_m", "viPPdd", "s", MergeNone, 
"aarch64_sme_smopa_za32", [IsSharedZA, IsStreaming], [ImmCheck<0, 
ImmCheck0_3>]>;
+  def SVUSMOPA : Inst<"svmopa_za32[_{d}]_m", "viPPdd", "Us", MergeNone, 
"aarch64_sme_umopa_za32", [IsSharedZA, IsStreaming], [ImmCheck<0, 
ImmCheck0_3>]>;
+
+  def SVSMOPS  : Inst<"svmops_za32[_{d}]_m", "viPPdd", "s", MergeNone, 
"aarch64_sme_smops_za32", [IsSharedZA, IsStreaming], [ImmCheck<0, 
ImmCheck0_3>]>;
+  def SVUSMOPS : Inst<"svmops_za32[_{d}]_m", "viPPdd", "Us", MergeNone, 
"aarch64_sme_umops_za32", [IsSharedZA, IsStreaming], [ImmCheck<0, 
ImmCheck0_3>]>;
+
+  def SVBMOPA : Inst<"svbmopa_za32[_{d}]_m", "viPPdd", "iUi", MergeNone, 
"aarch64_sme_bmopa_za32", [IsSharedZA, IsStreaming], [ImmCheck<0, 
ImmCheck0_3>]>;
+
+  def SVBMOPS : Inst<"svbmops_za32[_{d}]_m", "viPPdd", "iUi", MergeNone, 
"aarch64_sme_bmops_za32", [IsSharedZA, IsStreaming], [ImmCheck<0, 
ImmCheck0_3>]>;
+}
diff --git a/clang/include/clang/Basic/arm_sve_sme_incl.td 
b/clang/include/clang/Basic/arm_sve_sme_incl.td
index 3a7a5b51b25801e..22a2a3c5434d657 100644
--- a/clang/include/clang/Basic/arm_sve_sme_incl.td
+++ b/clang/include/clang/Basic/arm_sve_sme_incl.td
@@ -257,7 +257,7 @@ class ImmCheck {
 }
 
 class Inst ft, list ch, MemEltType met> {
+   list ft, list ch, MemEltType met = 
MemEltTyDefault> {
   string Name = n;
   string Prototype = p;
   string Types = t;
diff --git a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mop.c 
b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mop.c
new file mode 100644
index 000..bb804a523c449d3
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mop.c
@@ -0,0 +1,170 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+
+// REQUIRES: aarch64-registered-target
+
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 
-target-feature +sve -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | 
opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 
-target-feature +sve -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - -x 
c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s 
-check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sme2 -target-feature +sve -S -disable-O0-optnone -Werror -Wall 
-emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sme2 -target-feature +sve -S -disable-O0-optnone -Werror -Wall 
-emit-llvm -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | 
FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2 
-target-feature +sve -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+// MOPA
+
+// CHECK-LABEL: @test_svmopa_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.convert.from.svbool.nxv8i1( [[PN:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  
@llvm.aarch64.sve.convert.from.svbool.nxv8i1( [[PM:%.*]])
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.smopa.za32.nxv8i16(i32 3, 
 [[TMP0]],  [[TMP1]],  
[[ZN:%.*]],  [[ZM:%.*]])
+// CHECK-NEXT:ret void
+//
+// CPP-CHECK-LABEL: @_Z15test_svmopa_s16u10__SVBool_tS_u11__SVInt16_tS0_(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.convert.from.svbool.nxv8i1( [[PN:%.*]])
+// CPP-CHECK-NEXT:   

[clang] [analyzer][NFC] Rework SVal kind representation (PR #71039)

2023-11-03 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

> What other ways are to make a const void * debugger-friendly - other than 
> llvm::PointerUnion?

I'm not aware of any that wouldn't require writing a custom formatter. 
Ultimately it boils to how can I extract type information. For 
`llvm::PointerUnion` I'm matching discriminator against template argument list 
after jumping through some hoops to get discriminator as a number. If this 
patch allows me to extract type information based on prefix or suffix of `Kind` 
enumerator, then it's probably as easy as you can get it without a radical 
change. But read on, there's more to this.

> I've considered using plain-old unions, but I found that approach pretty 
> ugly, and I'm not even sure if it would help debugging experience.

Given I extracted type information from `Kind`, now I need a handle to type to 
cast the pointer to.

In order to declare a union, you have to specify type of every member. It's 
possible to extract type from such declaration, saving debugger the time to run 
global search for a type by name, which in my experience is about two orders of 
magnitudes more expensive operation than anything else formatter usually does 
(anecdotal evidence of 100 ms per search). So in order to keep debugger 
responsive with formatters enabled, I'm avoiding global searches as much as I 
can.

For debuggers having union with all possible types listed is strictly an 
improvement over status quo, but I get why this is ugly.

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


[llvm] [clang-tools-extra] [clang] Improve selection of conditional branch on amdgcn.ballot!=0 condition in SelectionDAG. (PR #68714)

2023-11-03 Thread Valery Pykhtin via cfe-commits

vpykhtin wrote:

> Though, on second thought, shouldn't there be some wave64 tests?

I added a couple of ballot.i64 in wave32 mode tests to 
AMDGPU/GlobalISel/llvm.amdgcn.ballot.i32.ll and 
AMDGPU/llvm.amdgcn.ballot.i32.ll with the 
https://github.com/llvm/llvm-project/pull/68714/commits/6e865d146af0236ff42c53b6a96c01b23fe3c096

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


[llvm] [clang] [LLVM][AArch64] Add ASM constraints for reduced GPR register ranges. (PR #70970)

2023-11-03 Thread Paul Walker via cfe-commits

https://github.com/paulwalker-arm updated 
https://github.com/llvm/llvm-project/pull/70970

>From 4bd5f30bf5f3f55cbca0c49a612cf0fa0122046e Mon Sep 17 00:00:00 2001
From: Paul Walker 
Date: Wed, 1 Nov 2023 17:33:10 +
Subject: [PATCH] [LLVM][AArch64] Add ASM constraints for reduced GPR register
 ranges.

The patch adds the follow ASM constraints:
  Uci => w8-w11/x8-x11
  Ucj => w12-w15/x12-x15

These constraints are required for SME load/store instructions
where a reduced set of GPRs are used to specify ZA array vectors.

NOTE: GCC has agreed to use the same constraint syntax.
---
 clang/docs/ReleaseNotes.rst   |  2 +
 clang/lib/Basic/Targets/AArch64.cpp   |  6 ++
 clang/test/CodeGen/aarch64-inline-asm.c   | 15 
 llvm/docs/LangRef.rst |  2 +
 .../Target/AArch64/AArch64ISelLowering.cpp| 34 +++-
 .../AArch64/inlineasm-Uc-constraint.ll| 78 +++
 6 files changed, 136 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/CodeGen/AArch64/inlineasm-Uc-constraint.ll

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4696836b3a00caa..afe7e2e79c2d087 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -738,6 +738,8 @@ Arm and AArch64 Support
   This affects C++ functions with SVE ACLE parameters. Clang will use the old
   manglings if ``-fclang-abi-compat=17`` or lower is  specified.
 
+- New AArch64 asm constraints have been added for r8-r11(Uci) and r12-r15(Ucj).
+
 Android Support
 ^^^
 
diff --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index fe5a7af97b7753c..c71af71eba60ce2 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -1306,6 +1306,12 @@ bool AArch64TargetInfo::validateAsmConstraint(
   Name += 2;
   return true;
 }
+if (Name[1] == 'c' && (Name[2] == 'i' || Name[2] == 'j')) {
+  // Gpr registers ("Uci"=w8-11, "Ucj"=w12-15)
+  Info.setAllowsRegister();
+  Name += 2;
+  return true;
+}
 // Ump: A memory address suitable for ldp/stp in SI, DI, SF and DF modes.
 // Utf: A memory address suitable for ldp/stp in TF mode.
 // Usa: An absolute symbolic address.
diff --git a/clang/test/CodeGen/aarch64-inline-asm.c 
b/clang/test/CodeGen/aarch64-inline-asm.c
index 439fb9e33f9ae15..75e9a8c46b87692 100644
--- a/clang/test/CodeGen/aarch64-inline-asm.c
+++ b/clang/test/CodeGen/aarch64-inline-asm.c
@@ -80,3 +80,18 @@ void test_tied_earlyclobber(void) {
   asm("" : "+&r"(a));
   // CHECK: call i32 asm "", "=&{x1},0"(i32 %0)
 }
+
+void test_reduced_gpr_constraints(int var32, long var64) {
+  asm("add w0, w0, %0" : : "Uci"(var32) : "w0");
+// CHECK: [[ARG1:%.+]] = load i32, ptr
+// CHECK: call void asm sideeffect "add w0, w0, $0", "@3Uci,~{w0}"(i32 
[[ARG1]])
+  asm("add x0, x0, %0" : : "Uci"(var64) : "x0");
+// CHECK: [[ARG1:%.+]] = load i64, ptr
+// CHECK: call void asm sideeffect "add x0, x0, $0", "@3Uci,~{x0}"(i64 
[[ARG1]])
+  asm("add w0, w0, %0" : : "Ucj"(var32) : "w0");
+// CHECK: [[ARG2:%.+]] = load i32, ptr
+// CHECK: call void asm sideeffect "add w0, w0, $0", "@3Ucj,~{w0}"(i32 
[[ARG2]])
+  asm("add x0, x0, %0" : : "Ucj"(var64) : "x0");
+// CHECK: [[ARG2:%.+]] = load i64, ptr
+// CHECK: call void asm sideeffect "add x0, x0, $0", "@3Ucj,~{x0}"(i64 
[[ARG2]])
+}
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 6fd483276a301c7..1e9d42ed0a06079 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -5094,6 +5094,8 @@ AArch64:
   offsets). (However, LLVM currently does this for the ``m`` constraint as
   well.)
 - ``r``: A 32 or 64-bit integer register (W* or X*).
+- ``Uci``: Like r, but restricted to registers 8 to 11 inclusive.
+- ``Ucj``: Like r, but restricted to registers 12 to 15 inclusive.
 - ``w``: A 32, 64, or 128-bit floating-point, SIMD or SVE vector register.
 - ``x``: Like w, but restricted to registers 0 to 15 inclusive.
 - ``y``: Like w, but restricted to SVE vector registers Z0 to Z7 inclusive.
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 94901c2d1a65688..f5193a9f2adf30c 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -10195,6 +10195,31 @@ getPredicateRegisterClass(PredicateConstraint 
Constraint, EVT VT) {
   llvm_unreachable("Missing PredicateConstraint!");
 }
 
+enum class ReducedGprConstraint { Uci, Ucj };
+
+static std::optional
+parseReducedGprConstraint(StringRef Constraint) {
+  return StringSwitch>(Constraint)
+  .Case("Uci", ReducedGprConstraint::Uci)
+  .Case("Ucj", ReducedGprConstraint::Ucj)
+  .Default(std::nullopt);
+}
+
+static const TargetRegisterClass *
+getReducedGprRegisterClass(ReducedGprConstraint Constraint, EVT VT) {
+  if (!VT.isScalarInteger() || VT.getFixedSizeInBits() > 64)
+return nullptr;
+
+  switch (Constra

[clang] [llvm] [LLVM][AArch64] Add ASM constraints for reduced GPR register ranges. (PR #70970)

2023-11-03 Thread Paul Walker via cfe-commits

paulwalker-arm wrote:

Rebased after pushing NFC refactoring commit.

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


[clang] [llvm] [AIX][TOC] Add -mtocdata/-mno-tocdata options on AIX (PR #67999)

2023-11-03 Thread via cfe-commits


@@ -0,0 +1,29 @@
+; RUN: llc -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck %s --check-prefix 
CHECK
+; RUN: llc -mtriple powerpc64-ibm-aix-xcoff < %s | FileCheck %s --check-prefix 
CHECK
+

diggerlin wrote:

also need to add test scenario `--filetype=obj` 

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


[clang] [llvm] [AIX][TOC] Add -mtocdata/-mno-tocdata options on AIX (PR #67999)

2023-11-03 Thread via cfe-commits

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


[clang] [clang] Emit bad shift warnings (PR #70307)

2023-11-03 Thread Budimir Aranđelović via cfe-commits


@@ -11773,7 +11786,25 @@ QualType Sema::CheckShiftOperands(ExprResult &LHS, 
ExprResult &RHS,
   isScopedEnumerationType(RHSType)) {
 return InvalidOperands(Loc, LHS, RHS);
   }
-  DiagnoseBadShiftValues(*this, LHS, RHS, Loc, Opc, LHSType);
+
+  BadShiftValueKind BSVKind =
+  DiagnoseBadShiftValues(*this, LHS, RHS, Loc, Opc, LHSType);
+  if (ExprEvalContexts.back().isConstantEvaluated()) {

budimirarandjelovicsyrmia wrote:

This solution originally was posted on 
[Phabricator](https://reviews.llvm.org/D141192). I reviewed commit and found 
that it makes more sense to diagnose bad shift values inside function 
DiagnoseBadShiftValues(...) instead in mentioned IF. If there are no more 
questions, I will edit this part of code.

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


[clang] [NFC] [Serializer] Pack information in serializer (PR #69287)

2023-11-03 Thread Chuanqi Xu via cfe-commits

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

>From c841e9cbd9510c401def4d10df6da408ae496180 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Fri, 3 Nov 2023 21:54:25 +0800
Subject: [PATCH] [NFC] [Serializer] Pack information in serializer

Previously, the boolean values will occupy spaces that can contain
integers. It wastes the spaces especially if the boolean values are
serialized consecutively. The patch tries to pack such consecutive
boolean values (and enum values) so that we can save more spaces and so
the times.

Before the patch, we need 4.478s (in my machine) to build the std module
(https://libcxx.llvm.org/Modules.html) with 28712 bytes for size of the
BMI. After the patch, the time becomes to 4.374s and the size becomes to
27388 bytes for the size of the BMI.

This is intended to be a NFC patch.

This patch doesn't optimize all such cases. We can do it later after we
have consensus on this.
---
 clang/include/clang/AST/DeclBase.h|   2 +-
 clang/include/clang/Serialization/ASTReader.h |  47 ++
 clang/include/clang/Serialization/ASTWriter.h |  53 +++
 clang/lib/Serialization/ASTReaderDecl.cpp | 230 +
 clang/lib/Serialization/ASTWriter.cpp |  32 +-
 clang/lib/Serialization/ASTWriterDecl.cpp | 448 --
 clang/test/Modules/decl-params-determinisim.m |  16 +-
 7 files changed, 471 insertions(+), 357 deletions(-)

diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index f784fa73af5bad5..fdc59ac7419d9e3 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -211,7 +211,7 @@ class alignas(8) Decl {
   /// The kind of ownership a declaration has, for visibility purposes.
   /// This enumeration is designed such that higher values represent higher
   /// levels of name hiding.
-  enum class ModuleOwnershipKind : unsigned {
+  enum class ModuleOwnershipKind : unsigned char {
 /// This declaration is not owned by a module.
 Unowned,
 
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index 531ad94f0906ac0..bafbe779d60acff 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -2407,6 +2407,53 @@ class ASTReader
   bool isProcessingUpdateRecords() { return ProcessingUpdateRecords; }
 };
 
+/// A simple helper class to unpack an integer to bits and consuming
+/// the bits in order.
+class BitsUnpacker {
+  constexpr static uint32_t BitsIndexUpbound = 32;
+
+public:
+  BitsUnpacker(uint32_t V) { updateValue(V); }
+  BitsUnpacker(const BitsUnpacker &) = delete;
+  BitsUnpacker(BitsUnpacker &&) = delete;
+  BitsUnpacker operator=(const BitsUnpacker &) = delete;
+  BitsUnpacker operator=(BitsUnpacker &&) = delete;
+  ~BitsUnpacker() {
+#ifndef NDEBUG
+while (isValid())
+  assert(!getNextBit() && "There are unprocessed bits!");
+#endif
+  }
+
+  void updateValue(uint32_t V) {
+Value = V;
+CurrentBitsIndex = 0;
+  }
+
+  bool getNextBit() {
+assert(isValid());
+return Value & (1 << CurrentBitsIndex++);
+  }
+
+  uint32_t getNextBits(uint32_t Width) {
+assert(isValid());
+assert(Width < BitsIndexUpbound);
+uint32_t Ret = (Value >> CurrentBitsIndex) & ((1 << Width) - 1);
+CurrentBitsIndex += Width;
+return Ret;
+  }
+
+  bool canGetNextNBits(uint32_t Width) const {
+return CurrentBitsIndex + Width < BitsIndexUpbound;
+  }
+
+private:
+  bool isValid() const { return CurrentBitsIndex < BitsIndexUpbound; }
+
+  uint32_t Value;
+  uint32_t CurrentBitsIndex = ~0;
+};
+
 } // namespace clang
 
 #endif // LLVM_CLANG_SERIALIZATION_ASTREADER_H
diff --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index 98445d40ebd82c3..3019bbc2ddc9cc7 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -830,6 +830,59 @@ class PCHGenerator : public SemaConsumer {
   bool hasEmittedPCH() const { return Buffer->IsComplete; }
 };
 
+/// A simple helper class to pack several bits in order into (a) 32 bit
+/// integer(s).
+class BitsPacker {
+  constexpr static uint32_t BitIndexUpbound = 32u;
+
+public:
+  BitsPacker() = default;
+  BitsPacker(const BitsPacker &) = delete;
+  BitsPacker(BitsPacker &&) = delete;
+  BitsPacker operator=(const BitsPacker &) = delete;
+  BitsPacker operator=(BitsPacker &&) = delete;
+  ~BitsPacker() {
+assert(!hasUnconsumedValues() && "There are unprocessed bits!");
+  }
+
+  void addBit(bool Value) { addBits(Value, 1); }
+  void addBits(uint32_t Value, uint32_t BitsWidth) {
+assert(BitsWidth < BitIndexUpbound);
+assert((Value < (1u << BitsWidth)) && "Passing narrower bit width!");
+
+if (CurrentBitIndex + BitsWidth >= BitIndexUpbound) {
+  Values.push_back(0);
+  CurrentBitIndex = 0;
+}
+
+assert(CurrentBitIndex < BitIndexUpbound);
+Val

[clang] [NFC] [Serializer] Pack information in serializer (PR #69287)

2023-11-03 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

Thanks for reviewing : )

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


[clang] 48be81e - [NFC] [Serializer] Pack information in serializer (#69287)

2023-11-03 Thread via cfe-commits

Author: Chuanqi Xu
Date: 2023-11-03T21:59:44+08:00
New Revision: 48be81e172911eb8cdae8a1ffd0166edfb2cfc04

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

LOG: [NFC] [Serializer] Pack information in serializer (#69287)

Previously, the boolean values will occupy spaces that can contain
integers. It wastes the spaces especially if the boolean values are
serialized consecutively. The patch tries to pack such consecutive
boolean values (and enum values) so that we can save more spaces and so
the times.

Before the patch, we need 4.478s (in my machine) to build the std module
(https://libcxx.llvm.org/Modules.html) with 28712 bytes for size of the
BMI. After the patch, the time becomes to 4.374s and the size becomes to
27388 bytes for the size of the BMI.

This is intended to be a NFC patch.

This patch doesn't optimize all such cases. We can do it later after we
have consensus on this.

Added: 


Modified: 
clang/include/clang/AST/DeclBase.h
clang/include/clang/Serialization/ASTReader.h
clang/include/clang/Serialization/ASTWriter.h
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/Modules/decl-params-determinisim.m

Removed: 




diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index f784fa73af5bad5..fdc59ac7419d9e3 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -211,7 +211,7 @@ class alignas(8) Decl {
   /// The kind of ownership a declaration has, for visibility purposes.
   /// This enumeration is designed such that higher values represent higher
   /// levels of name hiding.
-  enum class ModuleOwnershipKind : unsigned {
+  enum class ModuleOwnershipKind : unsigned char {
 /// This declaration is not owned by a module.
 Unowned,
 

diff  --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index 531ad94f0906ac0..bafbe779d60acff 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -2407,6 +2407,53 @@ class ASTReader
   bool isProcessingUpdateRecords() { return ProcessingUpdateRecords; }
 };
 
+/// A simple helper class to unpack an integer to bits and consuming
+/// the bits in order.
+class BitsUnpacker {
+  constexpr static uint32_t BitsIndexUpbound = 32;
+
+public:
+  BitsUnpacker(uint32_t V) { updateValue(V); }
+  BitsUnpacker(const BitsUnpacker &) = delete;
+  BitsUnpacker(BitsUnpacker &&) = delete;
+  BitsUnpacker operator=(const BitsUnpacker &) = delete;
+  BitsUnpacker operator=(BitsUnpacker &&) = delete;
+  ~BitsUnpacker() {
+#ifndef NDEBUG
+while (isValid())
+  assert(!getNextBit() && "There are unprocessed bits!");
+#endif
+  }
+
+  void updateValue(uint32_t V) {
+Value = V;
+CurrentBitsIndex = 0;
+  }
+
+  bool getNextBit() {
+assert(isValid());
+return Value & (1 << CurrentBitsIndex++);
+  }
+
+  uint32_t getNextBits(uint32_t Width) {
+assert(isValid());
+assert(Width < BitsIndexUpbound);
+uint32_t Ret = (Value >> CurrentBitsIndex) & ((1 << Width) - 1);
+CurrentBitsIndex += Width;
+return Ret;
+  }
+
+  bool canGetNextNBits(uint32_t Width) const {
+return CurrentBitsIndex + Width < BitsIndexUpbound;
+  }
+
+private:
+  bool isValid() const { return CurrentBitsIndex < BitsIndexUpbound; }
+
+  uint32_t Value;
+  uint32_t CurrentBitsIndex = ~0;
+};
+
 } // namespace clang
 
 #endif // LLVM_CLANG_SERIALIZATION_ASTREADER_H

diff  --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index 98445d40ebd82c3..3019bbc2ddc9cc7 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -830,6 +830,59 @@ class PCHGenerator : public SemaConsumer {
   bool hasEmittedPCH() const { return Buffer->IsComplete; }
 };
 
+/// A simple helper class to pack several bits in order into (a) 32 bit
+/// integer(s).
+class BitsPacker {
+  constexpr static uint32_t BitIndexUpbound = 32u;
+
+public:
+  BitsPacker() = default;
+  BitsPacker(const BitsPacker &) = delete;
+  BitsPacker(BitsPacker &&) = delete;
+  BitsPacker operator=(const BitsPacker &) = delete;
+  BitsPacker operator=(BitsPacker &&) = delete;
+  ~BitsPacker() {
+assert(!hasUnconsumedValues() && "There are unprocessed bits!");
+  }
+
+  void addBit(bool Value) { addBits(Value, 1); }
+  void addBits(uint32_t Value, uint32_t BitsWidth) {
+assert(BitsWidth < BitIndexUpbound);
+assert((Value < (1u << BitsWidth)) && "Passing narrower bit width!");
+
+if (CurrentBitIndex + BitsWidth >= BitIndexUpbound) {
+  Values.push_back(0);
+  CurrentBitIndex = 0;
+}
+

[clang] [NFC] [Serializer] Pack information in serializer (PR #69287)

2023-11-03 Thread Chuanqi Xu via cfe-commits

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-11-03 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:2205-2206
   "bit-field%select{| %1}2">;
+def err_reference_bind_to_bitfield_in_cce : Error<
+  "reference cannot bind to bit-field in converted constant expression">;
 def err_reference_bind_to_vector_element : Error<

aaron.ballman wrote:
> This change seems somewhat orthogonal to the rest of the patch; should this 
> be split out? Also, there doesn't appear to be test coverage for the new 
> diagnostic.
Separated into https://github.com/llvm/llvm-project/pull/71077

The problem showed up after one of rebasings when C++20 mode was turned on for 
`CXX/drs/dr12xx.cpp` test in [that 
commit](https://github.com/llvm/llvm-project/commit/653a82e95257a7cd3f22c24e40d54459a6608429).



Comment at: clang/lib/AST/ItaniumMangle.cpp:4397
+// argument.
+// As proposed in https://github.com/itanium-cxx-abi/cxx-abi/issues/111.
+auto *SNTTPE = cast(E);

aaron.ballman wrote:
> bolshakov-a wrote:
> > bolshakov-a wrote:
> > > efriedma wrote:
> > > > bolshakov-a wrote:
> > > > > erichkeane wrote:
> > > > > > erichkeane wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > We should get this nailed down. It was proposed in Nov 2020 and 
> > > > > > > > the issue is still open. CC @rjmccall 
> > > > > > > This definitely needs to happen.  @rjmccall or @eli.friedman ^^ 
> > > > > > > Any idea what the actual mangling should be?
> > > > > > This is still an open, and we need @rjmccall @eli.friedman or @asl 
> > > > > > to help out here.
> > > > > Ping @efriedma, @rjmccall, @asl.
> > > > I'm not really familiar with the mangling implications for this 
> > > > particular construct, nor am I actively involved with the Itanium ABI 
> > > > specification, so I'm not sure how I can help you directly.
> > > > 
> > > > That said, as a general opinion, I don't think it's worth waiting for 
> > > > updates to the Itanuim ABI  document to be merged; such updates are 
> > > > happening slowly at the moment, and having a consistent mangling is 
> > > > clearly an improvement even if it's not specified.  My suggested plan 
> > > > of action:
> > > > 
> > > > - Make sure you're satisfied the proposed mangling doesn't have any 
> > > > holes you're concerned about (i.e. it produces a unique mangling for 
> > > > all the relevant cases).  If you're not sure, I can try to spend some 
> > > > time understanding this, but it doesn't sound like you have any 
> > > > concerns about this.
> > > > - Put a note on the issue in the Itanium ABI repo that you're planning 
> > > > to go ahead with using this mangling in clang.  Also send an email 
> > > > directly to @rjmccall and @rsmith in case they miss the notifications.
> > > > - Go ahead with this.
> > > > Put a note on the issue in the Itanium ABI repo that you're planning to 
> > > > go ahead with using this mangling in clang. Also send an email directly 
> > > > to @rjmccall and @rsmith in case they miss the notifications.
> > > 
> > > I'm sorry for noting one more time that Richard already pushed these 
> > > changes in clang upstream, but they had been just reverted.
> > > 
> > > Maybe, I should make a PR into Itanium API repository, but I probably 
> > > need some time to dig into the theory and all the discussions. But yes, 
> > > even NTTP argument mangling rules are not still merged: 
> > > https://github.com/itanium-cxx-abi/cxx-abi/pull/140
> > @aaron.ballman, @erichkeane, seems like it is already fixed in the ABI 
> > document:
> > > Typically, only references to function template parameters occurring 
> > > within the dependent signature of the template are mangled this way. In 
> > > other contexts, template instantiation replaces references to template 
> > > parameters with the actual template arguments, and mangling should mangle 
> > > such references exactly as if they were that template argument.
> > 
> > https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.template-param
> > 
> > See also [the discussion in the 
> > issue](https://github.com/itanium-cxx-abi/cxx-abi/issues/111#issuecomment-1567486892).
> Okay, I think I agree that this is already addressed in the ABI document. I 
> think we can drop the comment referencing the ABI issue, wdyt?
Ok, dropped.



Comment at: clang/lib/Sema/SemaTemplate.cpp:7968
+  case APValue::FixedPoint:
+return FixedPointLiteral::CreateFromRawInt(
+S.Context, Val.getFixedPoint().getValue(), T, Loc,

aaron.ballman wrote:
> What should happen if `T` isn't a fixed point type? (Should we assert here?)
I don't expect that it will happen. Non-type template argument is a constant 
expression converted to the type of the template parameter. Hence, a value 
produced by such an expression should correspond to the NTTP type.

Should an assert be placed here, it should be placed in the other `switch` 
branches as well, I think. The proble

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-11-03 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 557997.
bolshakov-a added a comment.

Fixes after review.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/drs/dr12xx.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Index/USR/structural-value-tpl-arg.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7218,6 +7218,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::StructuralValue:
+return eTemplateArgumentKindStructuralValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -856,6 +856,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindStructuralValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -626,13 +626,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2";>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1";>P1907R1
+  
+
+  Clang 18 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. declared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1";>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3";>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::StructuralValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1574,6 +1574,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::StructuralValue:
+if (Expr *E = TAL.getSourceStructuralValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false

[clang] [flang] [flang][windows] Add option to link against specific MSVC CRT (PR #70833)

2023-11-03 Thread David Truby via cfe-commits


@@ -281,3 +281,26 @@ add_flang_library(FortranRuntime
 
   INSTALL_WITH_TOOLCHAIN
 )
+
+if (DEFINED MSVC)
+  set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
+  add_flang_library(FortranRuntime.static ${sources}

DavidTruby wrote:

The plain FortranRuntime library is linked by the Runtime tests, which need to 
be built against whatever the user built LLVM with, which we can't necessarily 
find out that easily I think. It should not have INSTALL_WITH_TOOLCHAIN set 
though, I'll remove that

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


[clang] [flang] [flang][windows] Add option to link against specific MSVC CRT (PR #70833)

2023-11-03 Thread David Truby via cfe-commits

https://github.com/DavidTruby updated 
https://github.com/llvm/llvm-project/pull/70833

>From 9e84729cada6c032c64934ee519e605407aab049 Mon Sep 17 00:00:00 2001
From: David Truby 
Date: Tue, 31 Oct 2023 15:07:13 +
Subject: [PATCH 1/7] [flang][windows] Add option to link against specific MSVC
 CRT

Currently flang's runtime libraries are only built for the specific CRT
that LLVM itself was built against. This patch adds the cmake logic for
building a separate runtime for each CRT configuration and adds a flag
for selecting a CRT configuration to link against.
---
 clang/include/clang/Driver/Options.td  |  2 +-
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 42 +--
 clang/lib/Driver/ToolChains/CommonArgs.h   |  2 +-
 clang/lib/Driver/ToolChains/Darwin.cpp |  2 +-
 clang/lib/Driver/ToolChains/DragonFly.cpp  |  2 +-
 clang/lib/Driver/ToolChains/FreeBSD.cpp|  2 +-
 clang/lib/Driver/ToolChains/Gnu.cpp|  2 +-
 clang/lib/Driver/ToolChains/Haiku.cpp  |  2 +-
 clang/lib/Driver/ToolChains/MSVC.cpp   |  2 +-
 clang/lib/Driver/ToolChains/MinGW.cpp  |  2 +-
 clang/lib/Driver/ToolChains/NetBSD.cpp |  2 +-
 clang/lib/Driver/ToolChains/OpenBSD.cpp|  2 +-
 clang/lib/Driver/ToolChains/Solaris.cpp|  2 +-
 flang/lib/Decimal/CMakeLists.txt   | 23 +++
 flang/runtime/CMakeLists.txt   | 23 +++
 flang/runtime/FortranMain/CMakeLists.txt   | 18 +
 flang/test/Driver/driver-help-hidden.f90   |  2 +
 flang/test/Driver/driver-help.f90  |  2 +
 flang/test/Driver/linker-flags.f90 | 47 ++
 19 files changed, 157 insertions(+), 24 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c8b730e0f7ecd84..66d4794714c9529 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2842,7 +2842,7 @@ def fms_compatibility_version
"version number to report in _MSC_VER (0 = don't define it "
"(default))">;
 def fms_runtime_lib_EQ : Joined<["-"], "fms-runtime-lib=">, Group,
-  Flags<[]>, Visibility<[ClangOption, CLOption]>,
+  Flags<[]>, Visibility<[ClangOption, CLOption, FlangOption]>,
   Values<"static,static_dbg,dll,dll_dbg">,
   HelpText<"Select Windows run-time library">,
   DocBrief<[{
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index ad012d3d0d4b46f..1cac9a179eb960f 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -976,12 +976,46 @@ bool tools::addOpenMPRuntime(ArgStringList &CmdArgs, 
const ToolChain &TC,
   return true;
 }
 
-void tools::addFortranRuntimeLibs(const ToolChain &TC,
+void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
   llvm::opt::ArgStringList &CmdArgs) {
   if (TC.getTriple().isKnownWindowsMSVCEnvironment()) {
-CmdArgs.push_back("Fortran_main.lib");
-CmdArgs.push_back("FortranRuntime.lib");
-CmdArgs.push_back("FortranDecimal.lib");
+CmdArgs.push_back(Args.MakeArgString(
+"/DEFAULTLIB:" + TC.getCompilerRTBasename(Args, "builtins")));
+unsigned RTOptionID = options::OPT__SLASH_MT;
+if (auto *rtl = Args.getLastArg(options::OPT_fms_runtime_lib_EQ)) {
+  RTOptionID = llvm::StringSwitch(rtl->getValue())
+   .Case("static", options::OPT__SLASH_MT)
+   .Case("static_dbg", options::OPT__SLASH_MTd)
+   .Case("dll", options::OPT__SLASH_MD)
+   .Case("dll_dbg", options::OPT__SLASH_MDd)
+   .Default(options::OPT__SLASH_MT);
+}
+switch(RTOptionID) {
+case options::OPT__SLASH_MT:
+  CmdArgs.push_back("/DEFAULTLIB:libcmt");
+  CmdArgs.push_back("Fortran_main.static.lib");
+  CmdArgs.push_back("FortranRuntime.static.lib");
+  CmdArgs.push_back("FortranDecimal.static.lib");
+  break;
+case options::OPT__SLASH_MTd:
+  CmdArgs.push_back("/DEFAULTLIB:libcmtd");
+  CmdArgs.push_back("Fortran_main.static_debug.lib");
+  CmdArgs.push_back("FortranRuntime.static_debug.lib");
+  CmdArgs.push_back("FortranDecimal.static_debug.lib");
+  break;
+case options::OPT__SLASH_MD:
+  CmdArgs.push_back("/DEFAULTLIB:msvcrt");
+  CmdArgs.push_back("Fortran_main.dynamic.lib");
+  CmdArgs.push_back("FortranRuntime.dynamic.lib");
+  CmdArgs.push_back("FortranDecimal.dynamic.lib");
+  break;
+case options::OPT__SLASH_MDd:
+  CmdArgs.push_back("/DEFAULTLIB:msvcrtd");
+  CmdArgs.push_back("Fortran_main.dynamic_debug.lib");
+  CmdArgs.push_back("FortranRuntime.dynamic_debug.lib");
+  CmdArgs.push_back("FortranDecimal.dynamic_debug.lib");
+  break;
+}
   } else {
 CmdArgs.push_back("-lFortran_main");
 CmdArgs.push_back("-lFortranRuntime");
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.

[clang] [flang] [flang][windows] Add option to link against specific MSVC CRT (PR #70833)

2023-11-03 Thread David Truby via cfe-commits

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


[clang] Fix to attribute plugins reaching an unreachable (PR #70877)

2023-11-03 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> Can you please add a more detailed description of the problem and what the 
> fix actually is. The description is what ends up in the git log and it is 
> important that we have enough details there to understand the PR and what 
> changes it makes.
> 
> I do not see a test, can this fix be tested?

We could add a test with a `// REQUIRES: plugins, examples` line on the RUN 
line. We don't have very many tests for plugins in Clang currently, but adding 
one here would help catch regressions.


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


[clang] [llvm] [AArch64][SVE2.1] Add intrinsics for quadword loads/stores with unscaled offset (PR #70474)

2023-11-03 Thread David Sherwood via cfe-commits

https://github.com/david-arm commented:

Thanks for this! I've not done an exhaustive review, but I'll leave the 
comments I have so far.

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


[clang] [llvm] [AArch64][SVE2.1] Add intrinsics for quadword loads/stores with unscaled offset (PR #70474)

2023-11-03 Thread David Sherwood via cfe-commits

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


[clang] [llvm] [AArch64][SVE2.1] Add intrinsics for quadword loads/stores with unscaled offset (PR #70474)

2023-11-03 Thread David Sherwood via cfe-commits


@@ -9702,17 +9727,34 @@ Value *CodeGenFunction::EmitSVEMaskedStore(const 
CallExpr *E,
   auto VectorTy = cast(Ops.back()->getType());
   auto MemoryTy = llvm::ScalableVectorType::get(MemEltTy, VectorTy);
 
-  Value *Predicate = EmitSVEPredicateCast(Ops[0], MemoryTy);
+  auto PredTy = MemoryTy;
+  auto AddrMemoryTy = MemoryTy;
+  bool IsTruncatingStore = true;

david-arm wrote:

Same comment as in EmitSVEMaskedLoad. Perhaps better just to have a IsQuadStore 
boolean, since it's an exceptional case and unlikely to have commonality with 
other instructions?

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


[clang] [llvm] [AArch64][SVE2.1] Add intrinsics for quadword loads/stores with unscaled offset (PR #70474)

2023-11-03 Thread David Sherwood via cfe-commits


@@ -2614,6 +2619,37 @@ def int_aarch64_sve_ld1_pn_x4 : 
SVE2p1_Load_PN_X4_Intrinsic;
 def int_aarch64_sve_ldnt1_pn_x2 : SVE2p1_Load_PN_X2_Intrinsic;
 def int_aarch64_sve_ldnt1_pn_x4 : SVE2p1_Load_PN_X4_Intrinsic;
 
+//
+// SVE2.1 - Contiguous loads to quadword (single vector)
+//
+
+class SVE2p1_Single_Load_Quadword
+: DefaultAttrsIntrinsic<[llvm_anyvector_ty],
+[llvm_nxv1i1_ty, llvm_ptr_ty],
+[IntrReadMem]>;

david-arm wrote:

I think this should also have IntrArgMemOnly too, similar to 
AdvSIMD_1Vec_Load_Intrinsic.

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


[llvm] [clang] [AArch64][SVE2.1] Add intrinsics for quadword loads/stores with unscaled offset (PR #70474)

2023-11-03 Thread David Sherwood via cfe-commits


@@ -9671,28 +9677,47 @@ Value *CodeGenFunction::EmitSVEMaskedLoad(const 
CallExpr *E,
   // The vector type that is returned may be different from the
   // eventual type loaded from memory.
   auto VectorTy = cast(ReturnTy);
-  auto MemoryTy = llvm::ScalableVectorType::get(MemEltTy, VectorTy);
+  llvm::ScalableVectorType *MemoryTy = nullptr;
+  llvm::ScalableVectorType *PredTy = nullptr;
+  bool IsExtendingLoad = true;

david-arm wrote:

I personally think using this variable is misleading because aarch64_sve_ld1uwq 
is actually an extending load - we're extending from 32-bit memory elements to 
128-bit integer elements. So it looks odd when we set this to false. Perhaps 
it's better to just explicitly have a variable called `IsQuadLoad` and use that 
instead rather than try to generalise this. The quad-word loads are a really 
just an exception here because we're working around the lack of a  type. So you'd have something like

  case Intrinsic::aarch64_sve_ld1uwq:
IsQuadLoad = true;
...
  default:
IsQuadLoad = false;


  Function *F =
  CGM.getIntrinsic(IntrinsicID, IsQuadLoad ? VectorTy : MemoryTy);\

...

  if (IsQuadLoad)
return Load;

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


[llvm] [clang] [AArch64][SVE2.1] Add intrinsics for quadword loads/stores with unscaled offset (PR #70474)

2023-11-03 Thread David Sherwood via cfe-commits


@@ -9702,17 +9727,34 @@ Value *CodeGenFunction::EmitSVEMaskedStore(const 
CallExpr *E,
   auto VectorTy = cast(Ops.back()->getType());
   auto MemoryTy = llvm::ScalableVectorType::get(MemEltTy, VectorTy);
 
-  Value *Predicate = EmitSVEPredicateCast(Ops[0], MemoryTy);
+  auto PredTy = MemoryTy;
+  auto AddrMemoryTy = MemoryTy;
+  bool IsTruncatingStore = true;
+  ;

david-arm wrote:

Extra ; here

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


[llvm] [clang] [AArch64][SVE2.1] Add intrinsics for quadword loads/stores with unscaled offset (PR #70474)

2023-11-03 Thread David Sherwood via cfe-commits


@@ -9671,28 +9677,47 @@ Value *CodeGenFunction::EmitSVEMaskedLoad(const 
CallExpr *E,
   // The vector type that is returned may be different from the
   // eventual type loaded from memory.
   auto VectorTy = cast(ReturnTy);
-  auto MemoryTy = llvm::ScalableVectorType::get(MemEltTy, VectorTy);
+  llvm::ScalableVectorType *MemoryTy = nullptr;
+  llvm::ScalableVectorType *PredTy = nullptr;
+  bool IsExtendingLoad = true;
+  switch (IntrinsicID) {
+  case Intrinsic::aarch64_sve_ld1uwq:
+  case Intrinsic::aarch64_sve_ld1udq:
+MemoryTy = llvm::ScalableVectorType::get(MemEltTy, 1);
+PredTy =
+llvm::ScalableVectorType::get(IntegerType::get(getLLVMContext(), 1), 
1);

david-arm wrote:

You can just do 
llvm::ScalableVectorType::get(Type::getInt1Ty(getLLVMContext()), 1);

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


[llvm] [clang] [AArch64][SVE2.1] Add intrinsics for quadword loads/stores with unscaled offset (PR #70474)

2023-11-03 Thread David Sherwood via cfe-commits


@@ -2614,6 +2619,37 @@ def int_aarch64_sve_ld1_pn_x4 : 
SVE2p1_Load_PN_X4_Intrinsic;
 def int_aarch64_sve_ldnt1_pn_x2 : SVE2p1_Load_PN_X2_Intrinsic;
 def int_aarch64_sve_ldnt1_pn_x4 : SVE2p1_Load_PN_X4_Intrinsic;
 
+//
+// SVE2.1 - Contiguous loads to quadword (single vector)
+//
+
+class SVE2p1_Single_Load_Quadword
+: DefaultAttrsIntrinsic<[llvm_anyvector_ty],
+[llvm_nxv1i1_ty, llvm_ptr_ty],
+[IntrReadMem]>;
+def int_aarch64_sve_ld1uwq : SVE2p1_Single_Load_Quadword;
+def int_aarch64_sve_ld1udq : SVE2p1_Single_Load_Quadword;
+
+//
+// SVE2.1 - Contiguous store from quadword (single vector)
+//
+
+class SVE2p1_Single_Store_Quadword
+: DefaultAttrsIntrinsic<[],
+[llvm_anyvector_ty, llvm_nxv1i1_ty, llvm_ptr_ty],
+[IntrArgMemOnly]>;

david-arm wrote:

This also needs the IntrWriteMem flag otherwise we could end up incorrectly 
rescheduling stores in the wrong place.

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


[clang] Fix to attribute plugins reaching an unreachable (PR #70877)

2023-11-03 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman commented:

As far as the changes go, they look correct to me. Thank you for the fix! Can 
you try adding test coverage for the change?

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


[llvm] [clang] [NFC] Remove Type::getInt8PtrTy (PR #71029)

2023-11-03 Thread Youngsuk Kim via cfe-commits

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


[llvm] [clang] [NFC] Remove Type::getInt8PtrTy (PR #71029)

2023-11-03 Thread Youngsuk Kim via cfe-commits


@@ -1514,7 +1514,7 @@ static void CreateGCRelocates(ArrayRef 
LiveVariables,
   auto getGCRelocateDecl = [&](Type *Ty) {
 assert(isHandledGCPointerType(Ty, GC));
 auto AS = Ty->getScalarType()->getPointerAddressSpace();
-Type *NewTy = Type::getInt8PtrTy(M->getContext(), AS);
+Type *NewTy = PointerType::getUnqual(M->getContext(), AS);

JOE1994 wrote:

Thank you for the update 👍 

The following update is needed to avoid build failure.
```suggestion
Type *NewTy = PointerType::get(M->getContext(), AS);
```

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


[llvm] [compiler-rt] [clang] [AArch64][SME] Add support for sme-fa64 (PR #70809)

2023-11-03 Thread Dinar Temirbulatov via cfe-commits

dtemirbulatov wrote:

LGTM.

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


[clang] [clang][TSA] Make RequiresCapability a DeclOrType attribute (PR #67095)

2023-11-03 Thread Aaron Ballman via cfe-commits
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= 
Message-ID:
In-Reply-To: 



@@ -1894,6 +1894,8 @@ void TypePrinter::printAttributedAfter(const 
AttributedType *T,
   case attr::ArmMveStrictPolymorphism:
 OS << "__clang_arm_mve_strict_polymorphism";
 break;
+  case attr::RequiresCapability:
+OS << "requires_capability(blah)";

AaronBallman wrote:

`blah`?

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


[clang] [clang][TSA] Make RequiresCapability a DeclOrType attribute (PR #67095)

2023-11-03 Thread Aaron Ballman via cfe-commits
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= 
Message-ID:
In-Reply-To: 



@@ -8938,6 +8957,11 @@ static void processTypeAttrs(TypeProcessingState &state, 
QualType &type,
   attr.setUsedAsTypeAttr();
   break;
 }
+case ParsedAttr::AT_RequiresCapability: {
+  HandleRequiresCapabilityAttr(state, type, attr);
+  attr.setUsedAsTypeAttr();
+  break;
+}

AaronBallman wrote:

Okay, maybe we do want to do this change separately. I think I was wrong about 
modeling after this; I think we want it to be done like 
`handleFunctionTypeAttr()` and `FUNCTION_TYPE_ATTRS_CASELIST` so that it 
becomes part of the `FunctionType` itself. That's what would get us the 
diagnostics on type mismatches (we look through `AttributedType` as sugar: 
https://github.com/llvm/llvm-project/blob/28b7e281d4eaea0d5d56b1a4cf7a550be746a007/clang/include/clang/AST/Type.h#L4999)

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


[clang] [compiler-rt] [llvm] [AArch64][SME] Add support for sme-fa64 (PR #70809)

2023-11-03 Thread Dinar Temirbulatov via cfe-commits

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

LGTM.

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


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

2023-11-03 Thread Aaron Ballman via cfe-commits

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

LGTM! Thank you for the fix!

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


[clang] Remove warnings from -Wchar-subscripts for known positive constants (PR #69061)

2023-11-03 Thread Aaron Ballman via cfe-commits

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

LGTM, thank you for the fix!

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


[clang] Remove warnings from -Wchar-subscripts for known positive constants (PR #69061)

2023-11-03 Thread via cfe-commits

wheatman wrote:

Thank you for the review.
I don't have write access, so unless @shafik has more comments, could one of 
you merge it in

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


[llvm] [clang] Fix python escapes (PR #71170)

2023-11-03 Thread Nathan Sidwell via cfe-commits

https://github.com/urnathan updated 
https://github.com/llvm/llvm-project/pull/71170

>From 9b5cb1ac8d4b9a2aaa4c06e41620e38b6c3cae8c Mon Sep 17 00:00:00 2001
From: Nathan Sidwell 
Date: Thu, 2 Nov 2023 18:14:05 -0400
Subject: [PATCH 1/3] Fix python escapes

With Fedora 39, I encountered 2 new python warnings:

/home/nathan/gh/llvm/push/strict-aliasing/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py:28:
 SyntaxWarning: invalid escape sequence '\*'
  self.implementationContent += """

/home/nathan/gh/llvm/push/strict-aliasing/llvm/test/lit.cfg.py:274: 
SyntaxWarning: invalid escape sequence '\d'
  match = re.search("release (\d+)\.(\d+)", ptxas_out)

Use raw strings here. I guess python got pickier or something?

May as well fix the blank line caused by """NEWLINE
...
"""
---
 clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py | 4 ++--
 llvm/test/lit.cfg.py| 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py 
b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
index dafb332961ede86..54cfd0741f9d122 100755
--- a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
+++ b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
@@ -25,7 +25,7 @@ def __init__(self, templateClasses):
 
 def GeneratePrologue(self):
 
-self.implementationContent += """
+self.implementationContent += R"""
 /*===- Generated file ---*- C++ 
-*-===*\
 |*
*|
 |* Introspection of available AST node SourceLocations
*|
@@ -58,7 +58,7 @@ def GeneratePrologue(self):
 private:
 std::vector &TLRG;
 };
-"""
+"""[1:]
 
 def GenerateBaseGetLocationsDeclaration(self, CladeName):
 InstanceDecoration = "*"
diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index ab245b71cdd16a5..cf050bbfe3b1413 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -271,7 +271,7 @@ def ptxas_version(ptxas):
 ptxas_cmd = subprocess.Popen([ptxas, "--version"], stdout=subprocess.PIPE)
 ptxas_out = ptxas_cmd.stdout.read().decode("ascii")
 ptxas_cmd.wait()
-match = re.search("release (\d+)\.(\d+)", ptxas_out)
+match = re.search(R"release (\d+)\.(\d+)", ptxas_out)
 if match:
 return (int(match.group(1)), int(match.group(2)))
 print("couldn't determine ptxas version")

>From 0cf6eb5b293752525cace1dee1ba26e143386809 Mon Sep 17 00:00:00 2001
From: Nathan Sidwell 
Date: Fri, 3 Nov 2023 07:44:11 -0400
Subject: [PATCH 2/3] Lower case raw string

---
 clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py | 2 +-
 llvm/test/lit.cfg.py| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py 
b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
index 54cfd0741f9d122..a6843f70adedae9 100755
--- a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
+++ b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
@@ -25,7 +25,7 @@ def __init__(self, templateClasses):
 
 def GeneratePrologue(self):
 
-self.implementationContent += R"""
+self.implementationContent += r"""
 /*===- Generated file ---*- C++ 
-*-===*\
 |*
*|
 |* Introspection of available AST node SourceLocations
*|
diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index cf050bbfe3b1413..5f4cff424f073b8 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -271,7 +271,7 @@ def ptxas_version(ptxas):
 ptxas_cmd = subprocess.Popen([ptxas, "--version"], stdout=subprocess.PIPE)
 ptxas_out = ptxas_cmd.stdout.read().decode("ascii")
 ptxas_cmd.wait()
-match = re.search(R"release (\d+)\.(\d+)", ptxas_out)
+match = re.search(r"release (\d+)\.(\d+)", ptxas_out)
 if match:
 return (int(match.group(1)), int(match.group(2)))
 print("couldn't determine ptxas version")

>From c483141c81052828a1a3793377b0bffdb2300a65 Mon Sep 17 00:00:00 2001
From: Nathan Sidwell 
Date: Fri, 3 Nov 2023 08:18:33 -0400
Subject: [PATCH 3/3] lose [1:]

---
 clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py 
b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
index a6843f70adedae9..7671f9691c09610 100755
--- a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
+++ b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
@@ -58,7 +58,7 @@ def GeneratePrologue(self):
 private:
 std::vector &TLRG;
 };
-"""[1:]
+"""
 
 def GenerateBaseGetLocationsDeclaration(self, CladeName):
 InstanceDecoration = "*"

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm

[llvm] [clang] Fix python escapes (PR #71170)

2023-11-03 Thread Nathan Sidwell via cfe-commits

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


[clang] clang: Add pragma clang fp reciprocal (PR #68267)

2023-11-03 Thread Yaxun Liu via cfe-commits


@@ -0,0 +1,130 @@
+// RUN: %clang_cc1 -O3 -triple %itanium_abi_triple -emit-llvm -o - %s | 
FileCheck -check-prefixes=CHECK,DEFAULT %s
+// RUN: %clang_cc1 -O3 -triple %itanium_abi_triple -freciprocal-math 
-emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,FLAG %s
+
+float base(float a, float b, float c) {
+// CHECK-LABEL: _Z4basefff
+// FLAG: %[[A:.+]] = fdiv arcp float %b, %c
+// FLAG: %[[M:.+]] = fdiv arcp float %[[A]], %b
+// FLAG-NEXT: fadd arcp float %[[M]], %c
+
+// DEFAULT: %[[A:.+]] = fdiv float %b, %c
+// DEFAULT: %[[M:.+]] = fdiv float %[[A]], %b
+// DEFAULT-NEXT: fadd float %[[M]], %c
+  a = b / c;
+  return a / b + c;
+}
+
+// Simple case
+float fp_recip_simple(float a, float b, float c) {
+// CHECK-LABEL: _Z15fp_recip_simplefff
+// CHECK: %[[A:.+]] = fdiv arcp float %b, %c
+// CHECK: %[[M:.+]] = fdiv arcp float %[[A]], %b
+// CHECK-NEXT: fadd arcp float %[[M]], %c
+#pragma clang fp reciprocal(on)
+  a = b / c;
+  return a / b + c;
+}
+
+// Test interaction with -freciprocal-math
+float fp_recip_disable(float a, float b, float c) {
+// CHECK-LABEL: _Z16fp_recip_disablefff
+// CHECK: %[[A:.+]] = fdiv float %b, %c
+// CHECK: %[[M:.+]] = fdiv float %[[A]], %b
+// CHECK-NEXT: fadd float %[[M]], %c
+#pragma clang fp reciprocal(off)
+  a = b / c;
+  return a / b + c;
+}
+
+float fp_recip_with_reassoc_simple(float a, float b, float c) {
+// CHECK-LABEL: _Z28fp_recip_with_reassoc_simplefff
+// CHECK: %[[A:.+]] = fmul reassoc arcp float %b, %c
+// CHECK: %[[M:.+]] = fdiv reassoc arcp float %b, %[[A]]
+// CHECK-NEXT: fadd reassoc arcp float %[[M]], %c
+#pragma clang fp reciprocal(on) reassociate(on)
+  a = b / c;
+  return a / b + c;
+}
+
+// arcp pragma should only apply to its scope
+float fp_recip_scoped(float a, float b, float c) {
+  // CHECK-LABEL: _Z15fp_recip_scopedfff
+  // DEFAULT: %[[M:.+]] = fdiv float %a, %b
+  // DEFAULT-NEXT: fadd float %[[M]], %c
+  // FLAG: %[[M:.+]] = fdiv arcp float %a, %b
+  // FLAG-NEXT: fadd arcp float %[[M]], %c
+  {
+#pragma clang fp reciprocal(on)
+  }
+  return a / b + c;
+}
+
+// arcp pragma should apply to templates as well
+class Foo {};
+Foo operator+(Foo, Foo);
+template 
+T template_recip(T a, T b, T c) {
+#pragma clang fp reciprocal(on)
+  return ((a / b) - c) + c;
+}
+
+float fp_recip_template(float a, float b, float c) {
+  // CHECK-LABEL: _Z17fp_recip_templatefff
+  // CHECK: %[[A1:.+]] = fdiv arcp float %a, %b
+  // CHECK-NEXT: %[[A2:.+]] = fsub arcp float %[[A1]], %c
+  // CHECK-NEXT: fadd arcp float %[[A2]], %c
+  return template_recip(a, b, c);
+}
+
+// File Scoping should work across functions
+#pragma clang fp reciprocal(on)
+float fp_file_scope_on(float a, float b, float c) {
+  // CHECK-LABEL: _Z16fp_file_scope_onfff
+  // CHECK: %[[M1:.+]] = fdiv arcp float %a, %c
+  // CHECK-NEXT: %[[M2:.+]] = fdiv arcp float %b, %c
+  // CHECK-NEXT: fadd arcp float %[[M1]], %[[M2]]
+  return (a / c) + (b / c);
+}
+
+// Inner pragma has precedence
+float fp_file_scope_stop(float a, float b, float c) {
+  // CHECK-LABEL: _Z18fp_file_scope_stopfff
+  // CHECK: %[[A:.+]] = fdiv arcp float %a, %a
+  // CHECK: %[[M1:.+]] = fdiv float %[[A]], %c
+  // CHECK-NEXT: %[[M2:.+]] = fdiv float %b, %c
+  // CHECK-NEXT: fsub float %[[M1]], %[[M2]]
+  a = a / a;
+  {
+#pragma clang fp reciprocal(off)
+return (a / c) - (b / c);
+  }
+}
+
+#pragma clang fp reciprocal(off)
+float fp_recip_off(float a, float b, float c) {
+  // CHECK-LABEL: _Z12fp_recip_of
+  // CHECK: %[[D1:.+]] = fdiv float %a, %c
+  // CHECK-NEXT: %[[D2:.+]] = fdiv float %b, %c
+  // CHECK-NEXT: fadd float %[[D1]], %[[D2]]
+  return (a / c) + (b / c);
+}
+
+// Takes latest flag
+float fp_recip_many(float a, float b, float c) {
+// CHECK-LABEL: _Z13fp_recip_manyfff
+// CHECK: %[[D1:.+]] = fdiv arcp float %a, %c
+// CHECK-NEXT: %[[D2:.+]] = fdiv arcp float %b, %c
+// CHECK-NEXT: fadd arcp float %[[D1]], %[[D2]]
+#pragma clang fp reciprocal(off) reciprocal(on)
+  return (a / c) + (b / c);
+}
+
+// Pragma does not propagate through called functions
+float helper_func(float a, float b, float c) { return a + b + c; }
+float fp_recip_call_helper(float a, float b, float c) {
+// CHECK-LABEL: _Z20fp_recip_call_helperfff
+// CHECK: %[[S1:.+]] = fadd float %a, %b
+// CHECK-NEXT: fadd float %[[S1]], %c
+#pragma clang fp reciprocal(on)
+  return helper_func(a, b, c);
+}

yxsamliu wrote:

need a test for interaction between pragma for reassociate and recriprocal, 
e.g. both on

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


[clang] [Clang][SVE2] Add builtins for moving multi-vectors to/from ZA (PR #71191)

2023-11-03 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Kerry McLaughlin (kmclaughlin-arm)


Changes

Adds the following SME2 builtins:
 - svread_hor/ver,
 - svwrite_hor/ver,
 - svread_za64,
 - svwrite_za64

See https://github.com/ARM-software/acle/pull/217

---

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


5 Files Affected:

- (modified) clang/include/clang/Basic/arm_sme.td (+46) 
- (modified) clang/include/clang/Basic/arm_sve_sme_incl.td (+1-1) 
- (added) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_read.c (+1422) 
- (added) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write.c (+1097) 
- (added) clang/test/Sema/aarch64-sme2-intrinsics/acle_sme2_imm.cpp (+57) 


``diff
diff --git a/clang/include/clang/Basic/arm_sme.td 
b/clang/include/clang/Basic/arm_sme.td
index 8d85327a86b1aaf..d81859ba39dfd7c 100644
--- a/clang/include/clang/Basic/arm_sme.td
+++ b/clang/include/clang/Basic/arm_sme.td
@@ -263,3 +263,49 @@ multiclass ZAFPOuterProd {
 
 defm SVMOPA : ZAFPOuterProd<"mopa">;
 defm SVMOPS : ZAFPOuterProd<"mops">;
+
+
+// SME2 - MOVA
+
+//
+// 2 and 4 vector-group read/write intrinsics.
+//
+
+multiclass WriteHV_VG checks> {
+  let TargetGuard = "sme2" in {
+def NAME # _VG2_H : Inst<"svwrite_hor_" # n # "_vg2", "vim2", t, 
MergeNone, i # "_hor_vg2", [IsSharedZA, IsStreaming], checks>;
+def NAME # _VG2_V : Inst<"svwrite_ver_" # n # "_vg2", "vim2", t, 
MergeNone, i # "_ver_vg2", [IsSharedZA, IsStreaming], checks>;
+def NAME # _VG4_H : Inst<"svwrite_hor_" # n # "_vg4", "vim4", t, 
MergeNone, i # "_hor_vg4", [IsSharedZA, IsStreaming], checks>;
+def NAME # _VG4_V : Inst<"svwrite_ver_" # n # "_vg4", "vim4", t, 
MergeNone, i # "_ver_vg4", [IsSharedZA, IsStreaming], checks>;
+  }
+}
+
+defm SVWRITE_ZA8  : WriteHV_VG<"za8[_{d}]",  "cUc",   "aarch64_sme_write", 
[ImmCheck<0, ImmCheck0_0>]>;
+defm SVWRITE_ZA16 : WriteHV_VG<"za16[_{d}]", "sUshb", "aarch64_sme_write", 
[ImmCheck<0, ImmCheck0_1>]>;
+defm SVWRITE_ZA32 : WriteHV_VG<"za32[_{d}]", "iUif",  "aarch64_sme_write", 
[ImmCheck<0, ImmCheck0_3>]>;
+defm SVWRITE_ZA64 : WriteHV_VG<"za64[_{d}]", "lUld",  "aarch64_sme_write", 
[ImmCheck<0, ImmCheck0_7>]>;
+
+multiclass ReadHV_VG checks> {
+  let TargetGuard = "sme2" in {
+def NAME # _VG2_H : Inst<"svread_hor_" # n # "_vg2", "2im", t, MergeNone, 
i # "_hor_vg2", [IsSharedZA, IsPreservesZA, IsStreaming], checks>;
+def NAME # _VG2_V : Inst<"svread_ver_" # n # "_vg2", "2im", t, MergeNone, 
i # "_ver_vg2", [IsSharedZA, IsPreservesZA, IsStreaming], checks>;
+def NAME # _VG4_H : Inst<"svread_hor_" # n # "_vg4", "4im", t, MergeNone, 
i # "_hor_vg4", [IsSharedZA, IsPreservesZA, IsStreaming], checks>;
+def NAME # _VG4_V : Inst<"svread_ver_" # n # "_vg4", "4im", t, MergeNone, 
i # "_ver_vg4", [IsSharedZA, IsPreservesZA, IsStreaming], checks>;
+  }
+}
+
+defm SVREAD_ZA8  : ReadHV_VG<"za8_{d}",  "cUc",   "aarch64_sme_read", 
[ImmCheck<0, ImmCheck0_0>]>;
+defm SVREAD_ZA16 : ReadHV_VG<"za16_{d}", "sUshb", "aarch64_sme_read", 
[ImmCheck<0, ImmCheck0_1>]>;
+defm SVREAD_ZA32 : ReadHV_VG<"za32_{d}", "iUif",  "aarch64_sme_read", 
[ImmCheck<0, ImmCheck0_3>]>;
+defm SVREAD_ZA64 : ReadHV_VG<"za64_{d}", "lUld",  "aarch64_sme_read", 
[ImmCheck<0, ImmCheck0_7>]>;
+
+//
+// Single vector-group read/write intrinsics.
+//
+
+let TargetGuard = "sme2" in {
+  def SVWRITE_ZA64_VG1x2 : Inst<"svwrite_za64[_{d}]_vg1x2", "vm2", "lUld", 
MergeNone, "aarch64_sme_write_vg1x2", [IsSharedZA, IsStreaming], []>;
+  def SVWRITE_ZA64_VG1x4 : Inst<"svwrite_za64[_{d}]_vg1x4", "vm4", "lUld", 
MergeNone, "aarch64_sme_write_vg1x4", [IsSharedZA, IsStreaming], []>;
+  def SVREAD_ZA64_VG1x2  : Inst<"svread_za64_{d}_vg1x2","2m",  "lUld", 
MergeNone, "aarch64_sme_read_vg1x2",  [IsSharedZA, IsPreservesZA, IsStreaming], 
[]>;
+  def SVREAD_ZA64_VG1x4  : Inst<"svread_za64_{d}_vg1x4","4m",  "lUld", 
MergeNone, "aarch64_sme_read_vg1x4",  [IsSharedZA, IsPreservesZA, IsStreaming], 
[]>;
+}
diff --git a/clang/include/clang/Basic/arm_sve_sme_incl.td 
b/clang/include/clang/Basic/arm_sve_sme_incl.td
index 3a7a5b51b25801e..22a2a3c5434d657 100644
--- a/clang/include/clang/Basic/arm_sve_sme_incl.td
+++ b/clang/include/clang/Basic/arm_sve_sme_incl.td
@@ -257,7 +257,7 @@ class ImmCheck {
 }
 
 class Inst ft, list ch, MemEltType met> {
+   list ft, list ch, MemEltType met = 
MemEltTyDefault> {
   string Name = n;
   string Prototype = p;
   string Types = t;
diff --git a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_read.c 
b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_read.c
new file mode 100644
index 000..706403e5180ad4b
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_read.c
@@ -0,0 +1,1422 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: aarch64-registered-target
+
+/

[clang] de88371 - [LLVM][AArch64] Add ASM constraints for reduced GPR register ranges. (#70970)

2023-11-03 Thread via cfe-commits

Author: Paul Walker
Date: 2023-11-03T15:34:45Z
New Revision: de88371d9d62eac598f8603b9a2aee6cbce4fe21

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

LOG: [LLVM][AArch64] Add ASM constraints for reduced GPR register ranges. 
(#70970)

[LLVM][AArch64] Add ASM constraints for reduced GPR register ranges.

The patch adds the follow ASM constraints:
  Uci => w8-w11/x8-x11
  Ucj => w12-w15/x12-x15

These constraints are required for SME load/store instructions
where a reduced set of GPRs are used to specify ZA array vectors.

NOTE: GCC has agreed to use the same constraint syntax.

Added: 
llvm/test/CodeGen/AArch64/inlineasm-Uc-constraint.ll

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Basic/Targets/AArch64.cpp
clang/test/CodeGen/aarch64-inline-asm.c
llvm/docs/LangRef.rst
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4696836b3a00caa..afe7e2e79c2d087 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -738,6 +738,8 @@ Arm and AArch64 Support
   This affects C++ functions with SVE ACLE parameters. Clang will use the old
   manglings if ``-fclang-abi-compat=17`` or lower is  specified.
 
+- New AArch64 asm constraints have been added for r8-r11(Uci) and r12-r15(Ucj).
+
 Android Support
 ^^^
 

diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index fe5a7af97b7753c..c71af71eba60ce2 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -1306,6 +1306,12 @@ bool AArch64TargetInfo::validateAsmConstraint(
   Name += 2;
   return true;
 }
+if (Name[1] == 'c' && (Name[2] == 'i' || Name[2] == 'j')) {
+  // Gpr registers ("Uci"=w8-11, "Ucj"=w12-15)
+  Info.setAllowsRegister();
+  Name += 2;
+  return true;
+}
 // Ump: A memory address suitable for ldp/stp in SI, DI, SF and DF modes.
 // Utf: A memory address suitable for ldp/stp in TF mode.
 // Usa: An absolute symbolic address.

diff  --git a/clang/test/CodeGen/aarch64-inline-asm.c 
b/clang/test/CodeGen/aarch64-inline-asm.c
index 439fb9e33f9ae15..75e9a8c46b87692 100644
--- a/clang/test/CodeGen/aarch64-inline-asm.c
+++ b/clang/test/CodeGen/aarch64-inline-asm.c
@@ -80,3 +80,18 @@ void test_tied_earlyclobber(void) {
   asm("" : "+&r"(a));
   // CHECK: call i32 asm "", "=&{x1},0"(i32 %0)
 }
+
+void test_reduced_gpr_constraints(int var32, long var64) {
+  asm("add w0, w0, %0" : : "Uci"(var32) : "w0");
+// CHECK: [[ARG1:%.+]] = load i32, ptr
+// CHECK: call void asm sideeffect "add w0, w0, $0", "@3Uci,~{w0}"(i32 
[[ARG1]])
+  asm("add x0, x0, %0" : : "Uci"(var64) : "x0");
+// CHECK: [[ARG1:%.+]] = load i64, ptr
+// CHECK: call void asm sideeffect "add x0, x0, $0", "@3Uci,~{x0}"(i64 
[[ARG1]])
+  asm("add w0, w0, %0" : : "Ucj"(var32) : "w0");
+// CHECK: [[ARG2:%.+]] = load i32, ptr
+// CHECK: call void asm sideeffect "add w0, w0, $0", "@3Ucj,~{w0}"(i32 
[[ARG2]])
+  asm("add x0, x0, %0" : : "Ucj"(var64) : "x0");
+// CHECK: [[ARG2:%.+]] = load i64, ptr
+// CHECK: call void asm sideeffect "add x0, x0, $0", "@3Ucj,~{x0}"(i64 
[[ARG2]])
+}

diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 6fd483276a301c7..1e9d42ed0a06079 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -5094,6 +5094,8 @@ AArch64:
   offsets). (However, LLVM currently does this for the ``m`` constraint as
   well.)
 - ``r``: A 32 or 64-bit integer register (W* or X*).
+- ``Uci``: Like r, but restricted to registers 8 to 11 inclusive.
+- ``Ucj``: Like r, but restricted to registers 12 to 15 inclusive.
 - ``w``: A 32, 64, or 128-bit floating-point, SIMD or SVE vector register.
 - ``x``: Like w, but restricted to registers 0 to 15 inclusive.
 - ``y``: Like w, but restricted to SVE vector registers Z0 to Z7 inclusive.

diff  --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 94901c2d1a65688..f5193a9f2adf30c 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -10195,6 +10195,31 @@ getPredicateRegisterClass(PredicateConstraint 
Constraint, EVT VT) {
   llvm_unreachable("Missing PredicateConstraint!");
 }
 
+enum class ReducedGprConstraint { Uci, Ucj };
+
+static std::optional
+parseReducedGprConstraint(StringRef Constraint) {
+  return StringSwitch>(Constraint)
+  .Case("Uci", ReducedGprConstraint::Uci)
+  .Case("Ucj", ReducedGprConstraint::Ucj)
+  .Default(std::nullopt);
+}
+
+static const TargetRegisterClass *
+getReducedGprRegisterClass(ReducedGprConstraint Constraint, EVT VT) {
+  if (!VT.isScalarInteger() || VT.getFixedSizeInBits(

[llvm] [clang] [LLVM][AArch64] Add ASM constraints for reduced GPR register ranges. (PR #70970)

2023-11-03 Thread Paul Walker via cfe-commits

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


[clang-tools-extra] 51018d1 - [clang-tidy] Improve modernize-make-shared check (#70600)

2023-11-03 Thread via cfe-commits

Author: Piotr Zegar
Date: 2023-11-03T16:39:09+01:00
New Revision: 51018d1a90542a407c78868e6be29a2492c18f5a

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

LOG: [clang-tidy] Improve modernize-make-shared check (#70600)

Improved modernize-make-shared check to support
std::shared_ptr implementations that inherit the
reset method from a base class.
In GCC that class is called __shared_ptr.

Fixes #64481

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst

clang-tools-extra/test/clang-tidy/checkers/modernize/Inputs/smart-ptr/shared_ptr.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
index 2f9f47d3f6c3e85..71fd8eca300c1b2 100644
--- a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -96,14 +96,18 @@ void 
MakeSmartPtrCheck::registerMatchers(ast_matchers::MatchFinder *Finder) {
   this);
 
   Finder->addMatcher(
-  traverse(TK_AsIs,
-   cxxMemberCallExpr(
-   thisPointerType(getSmartPointerTypeMatcher()),
-   callee(cxxMethodDecl(hasName("reset"))),
-   hasArgument(0, cxxNewExpr(CanCallCtor, unless(IsPlacement))
-  .bind(NewExpression)),
-   unless(isInTemplateInstantiation()))
-   .bind(ResetCall)),
+  traverse(
+  TK_AsIs,
+  cxxMemberCallExpr(
+  unless(isInTemplateInstantiation()),
+  hasArgument(0, cxxNewExpr(CanCallCtor, unless(IsPlacement))
+ .bind(NewExpression)),
+  callee(cxxMethodDecl(hasName("reset"))),
+  anyOf(thisPointerType(getSmartPointerTypeMatcher()),
+on(ignoringImplicit(anyOf(
+hasType(getSmartPointerTypeMatcher()),
+hasType(pointsTo(getSmartPointerTypeMatcher(
+  .bind(ResetCall)),
   this);
 }
 

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index ecfb3aa9267f140..f9671a65a26fca3 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -331,6 +331,11 @@ Changes in existing checks
   iterators initialized by free functions like ``begin``, ``end``, or ``size``
   and avoid crash for array of dependent array.
 
+- Improved :doc:`modernize-make-shared
+  ` check to support
+  ``std::shared_ptr`` implementations that inherit the ``reset`` method from a
+  base class.
+
 - Improved :doc:`modernize-return-braced-init-list
   ` check to ignore
   false-positives when constructing the container with ``count`` copies of

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/Inputs/smart-ptr/shared_ptr.h
 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/Inputs/smart-ptr/shared_ptr.h
index 0f4f2a97095b56f..337cb28228b09c4 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/Inputs/smart-ptr/shared_ptr.h
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/Inputs/smart-ptr/shared_ptr.h
@@ -1,24 +1,33 @@
 namespace std {
 
 template 
-class shared_ptr {
+class __shared_ptr {
+protected:
+  __shared_ptr();
+  __shared_ptr(type *ptr);
+  ~__shared_ptr();
 public:
-  shared_ptr();
-  shared_ptr(type *ptr);
-  shared_ptr(const shared_ptr &t) {}
-  shared_ptr(shared_ptr &&t) {}
-  ~shared_ptr();
   type &operator*() { return *ptr; }
   type *operator->() { return ptr; }
   type *release();
   void reset();
   void reset(type *pt);
-  shared_ptr &operator=(shared_ptr &&);
-  template 
-  shared_ptr &operator=(shared_ptr &&);
 
 private:
   type *ptr;
 };
 
+template 
+class shared_ptr : public __shared_ptr {
+public:
+  shared_ptr();
+  shared_ptr(type *ptr);
+  shared_ptr(const shared_ptr &t);
+  shared_ptr(shared_ptr &&t);
+  ~shared_ptr();
+  shared_ptr &operator=(shared_ptr &&);
+  template 
+  shared_ptr &operator=(shared_ptr &&);
+};
+
 }  // namespace std



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


[clang-tools-extra] [clang-tidy] Improve modernize-make-shared check (PR #70600)

2023-11-03 Thread Piotr Zegar via cfe-commits

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


[clang] [analyzer][NFC] Rework SVal kind representation (PR #71039)

2023-11-03 Thread Gábor Horváth via cfe-commits

https://github.com/Xazax-hun approved this pull request.


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


[flang] [clang] [compiler-rt] [llvm] [clang-tools-extra] [Bazel][Clang Tidy] Include builtin headers with clang-tidy (PR #67626)

2023-11-03 Thread Matthew Stephenson via cfe-commits

https://github.com/erl4ng commented:

+1

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


  1   2   3   >