[clang] [compiler-rt] [llvm] [FMV][AArch64] Remove feature sha1 from FMV. (PR #108383)

2024-09-23 Thread Alexandros Lamprineas via cfe-commits

labrinea wrote:

ping

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


[clang] [clang-repl] Simplify the value printing logic to enable out-of-process. (PR #107737)

2024-09-23 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev updated 
https://github.com/llvm/llvm-project/pull/107737

>From d2096a6445b803a74bd8cb56653f4ca1791d1d9f Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Fri, 6 Sep 2024 09:52:36 +
Subject: [PATCH 1/5] [clang-repl] Simplify the value printing logic to enable
 out-of-process.

This patch improves the design of the IncrementalParser and Interpreter classes.
Now the incremental parser is only responsible for building the partial
translation unit declaration and the AST, while the Interpreter fills in the
lower level llvm::Module and other JIT-related infrastructure. Finally the
Interpreter class now orchestrates the AST and the LLVM IR with the
IncrementalParser and IncrementalExecutor classes.

The design improvement allows us to rework some of the logic that extracts an
interpreter value into the clang::Value object. The new implementation
simplifies use-cases which are used for out-of-process execution by allowing
interpreter to be inherited or customized with an clang::ASTConsumer.

This change will enable completing the pretty printing work which is in
llvm/llvm-project#84769
---
 .../clang/Frontend/MultiplexConsumer.h|   3 +-
 clang/include/clang/Interpreter/Interpreter.h |  53 +-
 clang/lib/Frontend/MultiplexConsumer.cpp  |   7 +
 clang/lib/Interpreter/CMakeLists.txt  |   1 +
 clang/lib/Interpreter/DeviceOffload.cpp   |  10 +-
 clang/lib/Interpreter/DeviceOffload.h |  14 +-
 clang/lib/Interpreter/IncrementalExecutor.cpp |   2 +-
 clang/lib/Interpreter/IncrementalParser.cpp   | 253 +--
 clang/lib/Interpreter/IncrementalParser.h |  45 +-
 clang/lib/Interpreter/Interpreter.cpp | 648 ++
 .../Interpreter/InterpreterValuePrinter.cpp   | 400 +++
 .../Interpreter/CodeCompletionTest.cpp|   2 +-
 .../Interpreter/InterpreterExtensionsTest.cpp |  64 +-
 13 files changed, 707 insertions(+), 795 deletions(-)
 create mode 100644 clang/lib/Interpreter/InterpreterValuePrinter.cpp

diff --git a/clang/include/clang/Frontend/MultiplexConsumer.h 
b/clang/include/clang/Frontend/MultiplexConsumer.h
index 3a7670d7a51aa6..b190750bb29fb8 100644
--- a/clang/include/clang/Frontend/MultiplexConsumer.h
+++ b/clang/include/clang/Frontend/MultiplexConsumer.h
@@ -53,6 +53,7 @@ class MultiplexConsumer : public SemaConsumer {
 public:
   // Takes ownership of the pointers in C.
   MultiplexConsumer(std::vector> C);
+  MultiplexConsumer(std::unique_ptr C);
   ~MultiplexConsumer() override;
 
   // ASTConsumer
@@ -80,7 +81,7 @@ class MultiplexConsumer : public SemaConsumer {
   void InitializeSema(Sema &S) override;
   void ForgetSema() override;
 
-private:
+protected:
   std::vector> Consumers; // Owns these.
   std::unique_ptr MutationListener;
   std::unique_ptr DeserializationListener;
diff --git a/clang/include/clang/Interpreter/Interpreter.h 
b/clang/include/clang/Interpreter/Interpreter.h
index 1234608bb58647..cbb1cfd4ab02a8 100644
--- a/clang/include/clang/Interpreter/Interpreter.h
+++ b/clang/include/clang/Interpreter/Interpreter.h
@@ -14,11 +14,9 @@
 #ifndef LLVM_CLANG_INTERPRETER_INTERPRETER_H
 #define LLVM_CLANG_INTERPRETER_INTERPRETER_H
 
-#include "clang/AST/Decl.h"
 #include "clang/AST/GlobalDecl.h"
 #include "clang/Interpreter/PartialTranslationUnit.h"
 #include "clang/Interpreter/Value.h"
-#include "clang/Sema/Ownership.h"
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ExecutionEngine/JITSymbol.h"
@@ -38,6 +36,9 @@ class ThreadSafeContext;
 namespace clang {
 
 class CompilerInstance;
+class CodeGenerator;
+class CXXRecordDecl;
+class Decl;
 class IncrementalExecutor;
 class IncrementalParser;
 
@@ -77,26 +78,27 @@ class IncrementalCompilerBuilder {
   llvm::StringRef CudaSDKPath;
 };
 
-/// Generate glue code between the Interpreter's built-in runtime and user 
code.
-class RuntimeInterfaceBuilder {
-public:
-  virtual ~RuntimeInterfaceBuilder() = default;
-
-  using TransformExprFunction = ExprResult(RuntimeInterfaceBuilder *Builder,
-   Expr *, ArrayRef);
-  virtual TransformExprFunction *getPrintValueTransformer() = 0;
-};
+class IncrementalAction;
+class InProcessPrintingASTConsumer;
 
 /// Provides top-level interfaces for incremental compilation and execution.
 class Interpreter {
+  friend class Value;
+  friend InProcessPrintingASTConsumer;
+
   std::unique_ptr TSCtx;
+  /// Long-lived, incremental parsing action.
+  std::unique_ptr Act;
   std::unique_ptr IncrParser;
   std::unique_ptr IncrExecutor;
-  std::unique_ptr RuntimeIB;
 
   // An optional parser for CUDA offloading
   std::unique_ptr DeviceParser;
 
+  /// List containing every information about every incrementally parsed piece
+  /// of code.
+  std::list PTUs;
+
   unsigned InitPTUSize = 0;
 
   // This member holds the last result of the value printing. It's a class
@@ -104,15 +106,15 @@ class Interpreter {
   // printing happens, it's in an invalid state.
   Value LastValue;
 
-  // Add

[clang] [clang-tools-extra] [lldb] [llvm] [SystemZ][z/OS] Propagate IsText parameter to open text files as text (PR #107906)

2024-09-23 Thread kadir çetinkaya via cfe-commits

kadircet wrote:

i think limiting this to `RealFileSystem::openFileForRead` LG, but can we make 
sure `IsText` defaults to `false` and we can only set it in `#ifdef __MVS__` 
block to make sure this is really a no-op for other platforms. e.g.:
```cppp
auto OpenFlags = sys::fs::OF_None;
#ifdef __MVS__

  OpenFlags |= sys::fs::OF_Text;

#endif
   Expected FDOrErr = sys::fs::openNativeFileForRead(
  adjustPath(Name, Storage), OpenFlags, &RealName);
```

I'd still prefer doing this inside 
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Support/Unix/Path.inc#L972-L1118
 as we have other utility functions that create file-descriptors and all of 
them end up using these base functions. By having your logic at a layer above 
these, you risk having subtle discrepancies. But I don't know much about zOS or 
why this is needed, so I'll leave management of that risk to you.

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


[clang] [llvm] [CMake] Preserve clang-prebolt (PR #109351)

2024-09-23 Thread Madhur Amilkanthwar via cfe-commits

madhur13490 wrote:

This commit is breaking LTO-PGO-BOLT build while optimizing clang with BOLT. 

```
[3064/3065] Merging BOLT fdata
Using legacy profile format.
Profile from 2 files merged.
[3064/3065] Optimizing Clang with BOLT
BOLT-INFO: shared object or position-independent executable detected
BOLT-INFO: Target architecture: aarch64
BOLT-INFO: BOLT version: 51d1d03b17bb8bf66b6422c4482d8d615ab53409
BOLT-INFO: first alloc address is 0x0
BOLT-INFO: enabling relocation mode
BOLT-INFO: pre-processing profile using branch profile reader
BOLT-WARNING: 1 collisions detected while hashing binary objects. Use -v=1 to 
see the list.
BOLT-INFO: number of removed linker-inserted veneers: 0
BOLT-INFO: 11906 out of 212101 functions in the binary (5.6%) have non-empty 
execution profile
BOLT-INFO: 272 functions with profile could not be optimized
BOLT-INFO: profile for 1 objects was ignored
BOLT-INFO: removed 1 empty block
BOLT-INFO: basic block reordering modified layout of 4273 functions (35.89% of 
profiled, 2.01% of total)
BOLT-INFO: UCE removed 1 blocks and 4 bytes of code
BOLT-INFO: 68 Functions were reordered by LoopInversionPass
:0: error: fixup value out of range
:0: error: fixup value out of range
:0: error: fixup value out of range
:0: error: fixup value out of range
:0: error: fixup value out of range
:0: error: fixup value out of range
:0: error: fixup value out of range
:0: error: fixup value out of range
```

More information on LTO-PGO-BOLT can be found on 
[](https://llvm.org/docs/AdvancedBuilds.html)



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


[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-23 Thread Kito Cheng via cfe-commits


@@ -2841,6 +2841,10 @@ def fcf_protection : Flag<["-"], "fcf-protection">, 
Group,
   Visibility<[ClangOption, CLOption, CC1Option]>,
   Alias, AliasArgs<["full"]>,
   HelpText<"Enable cf-protection in 'full' mode">;
+def fcf_branch_label_scheme_EQ : Joined<["-"], "fcf-branch-label-scheme=">,

kito-cheng wrote:

```suggestion
def mcf_branch_label_scheme_EQ : Joined<["-"], "mcf-branch-label-scheme=">,
```

Use `m` option rather than `f` option since I assume this should apply to 
RISC-V only.

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


[clang] [Clang][Driver] Add option to provide path for multilib's YAML config file (PR #109640)

2024-09-23 Thread Victor Campos via cfe-commits

vhscampos wrote:

LGTM from the Arm target perspective, but not sure about the impact on the 
workflow of other targets. I suggest this waits for others' reviews.

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


[clang] [llvm] [Clang][LLVM][AArch64] Add intrinsic for MOVT SME2 instruction (PR #97602)

2024-09-23 Thread via cfe-commits


@@ -935,7 +935,7 @@ defm FAMIN_4Z4Z : 
sme2_fp_sve_destructive_vector_vg4_multi<"famin", 0b0010101>;
 } //[HasSME2, HasFAMINMAX]
 
 let Predicates = [HasSME2, HasSME_LUTv2] in {

CarolineConcatto wrote:

I will do this in another patch, because it is related to more than one 
intrinsic.

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


[clang] [Clang][Driver] Add option to provide path for multilib's YAML config file (PR #109640)

2024-09-23 Thread Oliver Stannard via cfe-commits

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

Nice cleanup, thanks!

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


[clang] [llvm] [Clang][LLVM][AArch64] Add intrinsic for MOVT SME2 instruction (PR #97602)

2024-09-23 Thread via cfe-commits


@@ -2899,6 +2899,15 @@ let TargetPrefix = "aarch64" in {
   [llvm_i32_ty],
   [IntrNoMem, IntrHasSideEffects]>;
 
+  def int_aarch64_sme_write_lane_zt

CarolineConcatto wrote:

So ZT0 is a register and not a memory.
 I believe the correct way to model this is with IntraHasSideEffects and not 
correct to model this as writing in memory.

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


[clang] [llvm] [Clang][LLVM][AArch64] Add intrinsic for MOVT SME2 instruction (PR #97602)

2024-09-23 Thread via cfe-commits

https://github.com/CarolineConcatto updated 
https://github.com/llvm/llvm-project/pull/97602

>From 70d1ec0e1c1bd896cf753510a8452325b086430e Mon Sep 17 00:00:00 2001
From: Caroline Concatto 
Date: Wed, 3 Jul 2024 15:55:45 +
Subject: [PATCH 1/5] [Clang][LLVM][AArch64] Add intrinsic for MOVT SME2
 instruction

This patch adds these intrinsics:

  // Variants are also available for:
  // [_s8], [_u16], [_s16], [_u32], [_s32], [_u64], [_s64]
  // [_bf16], [_f16], [_f32], [_f64]
  void svwrite_lane_zt[_u8](uint64_t zt0, svuint8_t zt, uint64_t idx) 
__arm_streaming __arm_inout("zt0");
  void svwrite_zt[_u8](uint64_t zt0, svuint8_t zt) __arm_streaming 
__arm_inout("zt0");

according to PR#324[1]
[1]https://github.com/ARM-software/acle/pull/324
---
 clang/include/clang/Basic/arm_sme.td  |   5 +
 .../acle_sme2_write_lane_zt.c | 401 ++
 .../aarch64-sme2-intrinsics/acle_sme2_imm.cpp |  10 +-
 llvm/include/llvm/IR/IntrinsicsAArch64.td |   9 +
 .../Target/AArch64/AArch64ISelLowering.cpp|   2 +
 .../lib/Target/AArch64/AArch64SMEInstrInfo.td |   2 +-
 llvm/lib/Target/AArch64/SMEInstrFormats.td|  42 +-
 .../AArch64/sme2-intrinsics-read-zt.ll| 162 +++
 8 files changed, 630 insertions(+), 3 deletions(-)
 create mode 100644 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write_lane_zt.c
 create mode 100644 llvm/test/CodeGen/AArch64/sme2-intrinsics-read-zt.ll

diff --git a/clang/include/clang/Basic/arm_sme.td 
b/clang/include/clang/Basic/arm_sme.td
index ce8908f566f2fd..ff68e536e99b09 100644
--- a/clang/include/clang/Basic/arm_sme.td
+++ b/clang/include/clang/Basic/arm_sme.td
@@ -817,4 +817,9 @@ multiclass ZAReadzArray{
 
 defm SVREADZ_VG2 :  ZAReadzArray<"2">;
 defm SVREADZ_VG4 :  ZAReadzArray<"4">;
+
+let SMETargetGuard = "sme2,sme-lutv2" in {
+  def SVWRITE_LANE_ZT : SInst<"svwrite_lane_zt[_{d}]", "vidi", 
"cUcsUsiUilUlfhdb", MergeNone, "aarch64_sme_write_lane_zt", [IsStreaming, 
IsInOutZT0], [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_3>]>;
+  def SVWRITE_ZT : SInst<"svwrite_zt[_{d}]", "vid", "cUcsUsiUilUlfhdb", 
MergeNone, "aarch64_sme_write_zt", [IsStreaming, IsInOutZT0], [ImmCheck<0, 
ImmCheck0_0>]>;
+}
 } // let SVETargetGuard = InvalidMode
diff --git 
a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write_lane_zt.c 
b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write_lane_zt.c
new file mode 100644
index 00..9bdc3481953a21
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write_lane_zt.c
@@ -0,0 +1,401 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// RUN: %clang_cc1  -triple aarch64-none-linux-gnu -target-feature +bf16 
-target-feature +sme -target-feature +sme2 -target-feature +sme-lutv2 -O2 
-Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -x c++  -triple aarch64-none-linux-gnu -target-feature 
+bf16 -target-feature +sme -target-feature +sme2 -target-feature  +sme-lutv2  
-O2 -Werror -Wall -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-CXX
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS   -triple aarch64-none-linux-gnu 
-target-feature +bf16 -target-feature +sme -target-feature +sme2 
-target-feature  +sme-lutv2  -O2 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -x c++  -triple 
aarch64-none-linux-gnu -target-feature +bf16 -target-feature +sme 
-target-feature +sme2 -target-feature +sme-lutv2 -O2 -Werror -Wall -emit-llvm 
-o - %s | FileCheck %s -check-prefix CHECK-CXX
+
+// RUN: %clang_cc1  -triple aarch64-none-linux-gnu -target-feature +bf16 
-target-feature +sme -target-feature +sme2 -target-feature +sme-lutv2 -O2 -S 
-Werror -Wall -o /dev/null %s
+// REQUIRES: aarch64-registered-target
+
+#ifdef SVE_OVERLOADED_FORMS
+#define SVE_ACLE_FUNC(A1,A2_UNUSED) A1
+#else
+#define SVE_ACLE_FUNC(A1,A2) A1##A2
+#endif
+
+#include 
+
+// CHECK-LABEL: define dso_local void @test_write_lane_zt_u8_1(
+// CHECK-SAME:  [[V:%.*]]) local_unnamed_addr 
#[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.write.lane.zt.nxv16i8(i32 
0,  [[V]], i32 1)
+// CHECK-NEXT:ret void
+//
+// CHECK-CXX-LABEL: define dso_local void 
@_Z23test_write_lane_zt_u8_1u11__SVUint8_t(
+// CHECK-CXX-SAME:  [[V:%.*]]) local_unnamed_addr 
#[[ATTR0:[0-9]+]] {
+// CHECK-CXX-NEXT:  [[ENTRY:.*:]]
+// CHECK-CXX-NEXT:tail call void 
@llvm.aarch64.sme.write.lane.zt.nxv16i8(i32 0,  [[V]], i32 1)
+// CHECK-CXX-NEXT:ret void
+//
+void test_write_lane_zt_u8_1(svuint8_t v) __arm_streaming __arm_inout("zt0") {
+  SVE_ACLE_FUNC(svwrite_lane_zt, _u8)(0, v, 1);
+}
+
+// CHECK-LABEL: define dso_local void @test_write_lane_zt_s8_2(
+// CHECK-SAME:  [[V:%.*]]) local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.write.lane.zt.nxv16i8(i32 
0,  [[V]], i32 2)
+// CHECK-NEXT:ret void
+//
+// CHECK-CXX-LAB

[clang] bad5444 - [clang][bytecode][NFC] Remove an outdated comment

2024-09-23 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-09-23T11:54:00+02:00
New Revision: bad544461a72cdf0e8301b0e80eef4e6661eee2b

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

LOG: [clang][bytecode][NFC] Remove an outdated comment

Added: 


Modified: 
clang/test/AST/ByteCode/cxx20.cpp

Removed: 




diff  --git a/clang/test/AST/ByteCode/cxx20.cpp 
b/clang/test/AST/ByteCode/cxx20.cpp
index 9bbc3dbe0073d3..68e212ff8933f9 100644
--- a/clang/test/AST/ByteCode/cxx20.cpp
+++ b/clang/test/AST/ByteCode/cxx20.cpp
@@ -596,8 +596,6 @@ namespace ImplicitFunction {
 // both-note {{in call to 'callMe()'}}
 }
 
-/// FIXME: Unfortunately, the similar tests in test/SemaCXX/{compare-cxx2a.cpp 
use member pointers,
-/// which we don't support yet.
 namespace std {
   class strong_ordering {
   public:



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


[clang-tools-extra] Add clang-tidy external examples (PR #106675)

2024-09-23 Thread via cfe-commits

https://github.com/MichelleCDjunaidi updated 
https://github.com/llvm/llvm-project/pull/106675

>From 08324e3586acb16cbf010fd6013c21f2b5faa64e Mon Sep 17 00:00:00 2001
From: MichelleCDjunaidi <87893361+michellecdjuna...@users.noreply.github.com>
Date: Fri, 30 Aug 2024 14:55:16 +0800
Subject: [PATCH 1/9] Add clang-tidy external examples

---
 .../clang-tidy/ExternalClang-TidyExamples.rst | 31 +++
 1 file changed, 31 insertions(+)
 create mode 100644 
clang-tools-extra/docs/clang-tidy/ExternalClang-TidyExamples.rst

diff --git a/clang-tools-extra/docs/clang-tidy/ExternalClang-TidyExamples.rst 
b/clang-tools-extra/docs/clang-tidy/ExternalClang-TidyExamples.rst
new file mode 100644
index 00..735f99b30c7b7d
--- /dev/null
+++ b/clang-tools-extra/docs/clang-tidy/ExternalClang-TidyExamples.rst
@@ -0,0 +1,31 @@
+===
+External Clang-Tidy Examples
+===
+
+Introduction
+
+
+This page provides examples of what people have done with clang-tidy that 
+might serve as useful guides (or starting points) to develop your own checks. 
+They may be helpful even for necessary things such as how to write 
CMakeLists.txt 
+for an out-of-tree plugin of clang-tidy checks.
+
+If you know of (or wrote!) a tool or project using clang-tidy, please post on
+`the Discourse forums (Clang Frontend category)
+`_ to have it added.
+(or if you are already a clang-tidy contributor, feel free to directly commit
+additions). Since the primary purpose of this page is to provide examples
+that can help developers, generally they must have code available.
+
+As clang-tidy shares C++ AST Matchers with Clang diagnostics, `External Clang 
Examples`_ 
+may also be useful to look at.
+
+.. _External Clang Examples: 
https://clang.llvm.org/docs/ExternalClangExamples.html
+
+https://clang.llvm.org/docs/ExternalClangExamples.html
+
+List of projects and tools
+==
+
+``_
+"This folder contains clang-tidy plugins."
\ No newline at end of file

>From b47792347dd6ebab3ac49bc55b0c812db0ee5ba3 Mon Sep 17 00:00:00 2001
From: MichelleCDjunaidi <87893361+michellecdjuna...@users.noreply.github.com>
Date: Fri, 30 Aug 2024 21:22:55 +0800
Subject: [PATCH 2/9] update wording to invite PR

---
 .../clang-tidy/ExternalClang-TidyExamples.rst | 23 ++-
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/clang-tools-extra/docs/clang-tidy/ExternalClang-TidyExamples.rst 
b/clang-tools-extra/docs/clang-tidy/ExternalClang-TidyExamples.rst
index 735f99b30c7b7d..2355b6f119b760 100644
--- a/clang-tools-extra/docs/clang-tidy/ExternalClang-TidyExamples.rst
+++ b/clang-tools-extra/docs/clang-tidy/ExternalClang-TidyExamples.rst
@@ -5,21 +5,22 @@ External Clang-Tidy Examples
 Introduction
 
 
-This page provides examples of what people have done with clang-tidy that 
+This page provides examples of what people have done with `clang-tidy`` that 
 might serve as useful guides (or starting points) to develop your own checks. 
-They may be helpful even for necessary things such as how to write 
CMakeLists.txt 
-for an out-of-tree plugin of clang-tidy checks.
+They may be helpful for necessary things such as how to write CMakeLists.txt 
+for an out-of-tree plugin of `clang-tidy` checks.
 
-If you know of (or wrote!) a tool or project using clang-tidy, please post on
-`the Discourse forums (Clang Frontend category)
-`_ to have it added.
-(or if you are already a clang-tidy contributor, feel free to directly commit
-additions). Since the primary purpose of this page is to provide examples
-that can help developers, generally they must have code available.
+If you know of (or wrote!) a tool or project using clang-tidy, please share it 
+on `the Discourse forums (Clang Frontend category)
+`_ for wider visibility and open a 
+pull-request on `LLVM Github`_ to have it added here. Since the primary 
purpose of 
+this page is to provide examples that can help developers, generally they must 
have 
+code available.
 
-As clang-tidy shares C++ AST Matchers with Clang diagnostics, `External Clang 
Examples`_ 
-may also be useful to look at.
+As `clang-tidy` shares C++ AST Matchers with Clang diagnostics, `External 
Clang Examples`_ 
+may also be useful to look at for examples.
 
+.. _LLVM Github: https://github.com/llvm/llvm-project
 .. _External Clang Examples: 
https://clang.llvm.org/docs/ExternalClangExamples.html
 
 https://clang.llvm.org/docs/ExternalClangExamples.html

>From dab57a6a65b9fcc4fd24d7fd0838f428ad675cd5 Mon Sep 17 00:00:00 2001
From: MichelleCDjunaidi <87893361+michellecdjuna...@users.noreply.github.com>
Date: Fri, 30 Aug 2024 21:38:24 +0800
Subject: [PATCH 3/9] cleanup formatting and wording

---
 .../docs/clang-tidy/ExternalClang-TidyExamples.rst  | 6 +

[clang] [clang] Detect dangling assignment for "Container" case. (PR #108205)

2024-09-23 Thread Gábor Horváth via cfe-commits


@@ -601,17 +601,23 @@ void test() {
   std::optional o4 = std::optional(s); 
 
   // FIXME: should work for assignment cases
-  v1 = {std::string()};
-  o1 = std::string();
+  v1 = {std::string()}; // expected-warning {{object backing the pointer}}
+  o1 = std::string(); // expected-warning {{object backing the pointer}}
 
   // no warning on copying pointers.
   std::vector n1 = {std::string_view()};
+  n1 = {std::string_view()};

Xazax-hun wrote:

Not strictly related to this PR, but we could add some tests for more deeply 
nested containers like `std::vector>`. Regardless 
if we gat warnings for those or not, documenting whether this case works in 
tests have some value. 

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


[clang] [RISCV][FMV] Support target_version (PR #99040)

2024-09-23 Thread Piyou Chen via cfe-commits


@@ -3056,6 +3056,45 @@ bool Sema::checkTargetVersionAttr(SourceLocation 
LiteralLoc, Decl *D,
   enum SecondParam { None };
   enum ThirdParam { Target, TargetClones, TargetVersion };
   llvm::SmallVector Features;
+  if (Context.getTargetInfo().getTriple().isRISCV()) {
+
+llvm::SmallVector AttrStrs;
+AttrStr.split(AttrStrs, ';');
+
+bool IsPriority = false;
+bool IsDefault = false;
+for (auto &AttrStr : AttrStrs) {
+  // Only support arch=+ext,... syntax.

BeMg wrote:

The line `arch=rv64gc` will trigger a warning because it currently doesn't 
support the full architecture.

`unsupported 'arch=rv64gcv' in the 'target_version' attribute string; 
'target_version' attribute ignored`

https://github.com/llvm/llvm-project/blob/b89211cdd27474469b4e6ca1206c12892a85974b/clang/lib/Sema/SemaDeclAttr.cpp#L3089

`target_version("arch=+c;default")` has already new `HasArch` guard, and it 
also emit the warning.

`unsupported 'arch=+c;default' in the 'target_version' attribute string; 
'target_version' attribute ignored`

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


[clang-tools-extra] Add clang-tidy external examples (PR #106675)

2024-09-23 Thread via cfe-commits

MichelleCDjunaidi wrote:

I asked in the forums. 
https://discourse.llvm.org/t/fix-error-in-upstream-doc-generation-due-to-addition-of-new-section/81368.
 Hopefully someone knows what to add...

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


[clang] [clang-repl] Simplify the value printing logic to enable out-of-process. (PR #107737)

2024-09-23 Thread Vassil Vassilev via cfe-commits


@@ -39,11 +44,13 @@ class IncrementalCUDADeviceParser : public 
IncrementalParser {
   ~IncrementalCUDADeviceParser();
 
 protected:
-  IncrementalParser &HostParser;
+  std::unique_ptr DeviceCI;
   int SMVersion;
   llvm::SmallString<1024> PTXCode;
   llvm::SmallVector FatbinContent;
   llvm::IntrusiveRefCntPtr VFS;
+  CodeGenOptions &CodeGenOpts; // intentionally a reference.

vgvassilev wrote:

I think that's important as we are forcibly updating codegen options for the 
incremental use case.

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


[clang] [clang-repl] Simplify the value printing logic to enable out-of-process. (PR #107737)

2024-09-23 Thread Vassil Vassilev via cfe-commits

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


[clang] a72d7ee - [clang-repl] Simplify the value printing logic to enable out-of-process. (#107737)

2024-09-23 Thread via cfe-commits

Author: Vassil Vassilev
Date: 2024-09-23T12:00:43+02:00
New Revision: a72d7eea5413444249670579fecea6823fb3c564

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

LOG: [clang-repl] Simplify the value printing logic to enable out-of-process. 
(#107737)

This patch improves the design of the IncrementalParser and Interpreter
classes. Now the incremental parser is only responsible for building the
partial translation unit declaration and the AST, while the Interpreter
fills in the lower level llvm::Module and other JIT-related
infrastructure. Finally the Interpreter class now orchestrates the AST
and the LLVM IR with the IncrementalParser and IncrementalExecutor
classes.

The design improvement allows us to rework some of the logic that
extracts an interpreter value into the clang::Value object. The new
implementation simplifies use-cases which are used for out-of-process
execution by allowing interpreter to be inherited or customized with an
clang::ASTConsumer.

This change will enable completing the pretty printing work which is in
llvm/llvm-project#84769

Added: 
clang/lib/Interpreter/InterpreterValuePrinter.cpp

Modified: 
clang/include/clang/Frontend/MultiplexConsumer.h
clang/include/clang/Interpreter/Interpreter.h
clang/lib/Frontend/MultiplexConsumer.cpp
clang/lib/Interpreter/CMakeLists.txt
clang/lib/Interpreter/DeviceOffload.cpp
clang/lib/Interpreter/DeviceOffload.h
clang/lib/Interpreter/IncrementalExecutor.cpp
clang/lib/Interpreter/IncrementalParser.cpp
clang/lib/Interpreter/IncrementalParser.h
clang/lib/Interpreter/Interpreter.cpp
clang/unittests/Interpreter/CodeCompletionTest.cpp
clang/unittests/Interpreter/InterpreterExtensionsTest.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/MultiplexConsumer.h 
b/clang/include/clang/Frontend/MultiplexConsumer.h
index 3a7670d7a51aa6..b190750bb29fb8 100644
--- a/clang/include/clang/Frontend/MultiplexConsumer.h
+++ b/clang/include/clang/Frontend/MultiplexConsumer.h
@@ -53,6 +53,7 @@ class MultiplexConsumer : public SemaConsumer {
 public:
   // Takes ownership of the pointers in C.
   MultiplexConsumer(std::vector> C);
+  MultiplexConsumer(std::unique_ptr C);
   ~MultiplexConsumer() override;
 
   // ASTConsumer
@@ -80,7 +81,7 @@ class MultiplexConsumer : public SemaConsumer {
   void InitializeSema(Sema &S) override;
   void ForgetSema() override;
 
-private:
+protected:
   std::vector> Consumers; // Owns these.
   std::unique_ptr MutationListener;
   std::unique_ptr DeserializationListener;

diff  --git a/clang/include/clang/Interpreter/Interpreter.h 
b/clang/include/clang/Interpreter/Interpreter.h
index 1234608bb58647..1230a3a7016fae 100644
--- a/clang/include/clang/Interpreter/Interpreter.h
+++ b/clang/include/clang/Interpreter/Interpreter.h
@@ -14,11 +14,9 @@
 #ifndef LLVM_CLANG_INTERPRETER_INTERPRETER_H
 #define LLVM_CLANG_INTERPRETER_INTERPRETER_H
 
-#include "clang/AST/Decl.h"
 #include "clang/AST/GlobalDecl.h"
 #include "clang/Interpreter/PartialTranslationUnit.h"
 #include "clang/Interpreter/Value.h"
-#include "clang/Sema/Ownership.h"
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ExecutionEngine/JITSymbol.h"
@@ -38,6 +36,9 @@ class ThreadSafeContext;
 namespace clang {
 
 class CompilerInstance;
+class CodeGenerator;
+class CXXRecordDecl;
+class Decl;
 class IncrementalExecutor;
 class IncrementalParser;
 
@@ -77,26 +78,26 @@ class IncrementalCompilerBuilder {
   llvm::StringRef CudaSDKPath;
 };
 
-/// Generate glue code between the Interpreter's built-in runtime and user 
code.
-class RuntimeInterfaceBuilder {
-public:
-  virtual ~RuntimeInterfaceBuilder() = default;
-
-  using TransformExprFunction = ExprResult(RuntimeInterfaceBuilder *Builder,
-   Expr *, ArrayRef);
-  virtual TransformExprFunction *getPrintValueTransformer() = 0;
-};
+class IncrementalAction;
+class InProcessPrintingASTConsumer;
 
 /// Provides top-level interfaces for incremental compilation and execution.
 class Interpreter {
+  friend class Value;
+  friend InProcessPrintingASTConsumer;
+
   std::unique_ptr TSCtx;
+  /// Long-lived, incremental parsing action.
+  std::unique_ptr Act;
   std::unique_ptr IncrParser;
   std::unique_ptr IncrExecutor;
-  std::unique_ptr RuntimeIB;
 
   // An optional parser for CUDA offloading
   std::unique_ptr DeviceParser;
 
+  /// List containing information about each incrementally parsed piece of 
code.
+  std::list PTUs;
+
   unsigned InitPTUSize = 0;
 
   // This member holds the last result of the value printing. It's a class
@@ -104,15 +105,18 @@ class Interpreter {
   // printing happens, it's in an invalid state.
   Value LastValue;
 
-  // Add a call to an Expr to report its result. We query the function from
- 

[clang] [llvm] [RISCV] Mark Zacas as non-experimental (PR #109651)

2024-09-23 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-risc-v

Author: Alex Bradbury (asb)


Changes

The extension has been ratified for some time, but we kept it experimental (see 
#99898) due to
;. The 
ABI issue has been resolved by #101023 so I believe there's no known 
barrier to moving Zacas to non-experimental.

---

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


16 Files Affected:

- (modified) clang/test/Driver/print-supported-extensions-riscv.c (+1-1) 
- (modified) clang/test/Preprocessor/riscv-target-features.c (+9-9) 
- (modified) llvm/docs/RISCVUsage.rst (+5-3) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+2-2) 
- (modified) llvm/lib/TargetParser/Host.cpp (+1-2) 
- (modified) llvm/test/CodeGen/RISCV/atomic-cmpxchg-branch-on-result.ll (+3-3) 
- (modified) llvm/test/CodeGen/RISCV/atomic-cmpxchg.ll (+6-6) 
- (modified) llvm/test/CodeGen/RISCV/atomic-rmw.ll (+6-6) 
- (modified) llvm/test/CodeGen/RISCV/atomic-signext.ll (+2-2) 
- (modified) llvm/test/CodeGen/RISCV/attributes.ll (+2-2) 
- (modified) llvm/test/MC/RISCV/rv32zacas-invalid.s (+1-1) 
- (modified) llvm/test/MC/RISCV/rv32zacas-valid.s (+6-6) 
- (modified) llvm/test/MC/RISCV/rv64zacas-invalid.s (+1-1) 
- (modified) llvm/test/MC/RISCV/rv64zacas-valid.s (+3-3) 
- (modified) llvm/test/MC/RISCV/rvzabha-zacas-valid.s (+6-6) 
- (modified) llvm/unittests/TargetParser/RISCVISAInfoTest.cpp (+1-1) 


``diff
diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 312c462f715d5e..a39c1ab36b1db0 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -35,6 +35,7 @@
 // CHECK-NEXT: za64rs   1.0   'Za64rs' (Reservation Set 
Size of at Most 64 Bytes)
 // CHECK-NEXT: zaamo1.0   'Zaamo' (Atomic Memory 
Operations)
 // CHECK-NEXT: zabha1.0   'Zabha' (Byte and Halfword 
Atomic Memory Operations)
+// CHECK-NEXT: zacas1.0   'Zacas' (Atomic 
Compare-And-Swap Instructions)
 // CHECK-NEXT: zalrsc   1.0   'Zalrsc' 
(Load-Reserved/Store-Conditional)
 // CHECK-NEXT: zama16b  1.0   'Zama16b' (Atomic 16-byte 
misaligned loads, stores and AMOs)
 // CHECK-NEXT: zawrs1.0   'Zawrs' (Wait on Reservation 
Set)
@@ -171,7 +172,6 @@
 // CHECK-NEXT: Experimental extensions
 // CHECK-NEXT: zicfilp  1.0   'Zicfilp' (Landing pad)
 // CHECK-NEXT: zicfiss  1.0   'Zicfiss' (Shadow stack)
-// CHECK-NEXT: zacas1.0   'Zacas' (Atomic 
Compare-And-Swap Instructions)
 // CHECK-NEXT: zalasr   0.1   'Zalasr' (Load-Acquire and 
Store-Release Instructions)
 // CHECK-NEXT: zvbc32e  0.7   'Zvbc32e' (Vector Carryless 
Multiplication with 32-bits elements)
 // CHECK-NEXT: zvkgs0.7   'Zvkgs' (Vector-Scalar GCM 
instructions for Cryptography)
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 60675065495bba..05a8534ba13da1 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -87,6 +87,7 @@
 // CHECK-NOT: __riscv_za64rs {{.*$}}
 // CHECK-NOT: __riscv_zaamo {{.*$}}
 // CHECK-NOT: __riscv_zabha {{.*$}}
+// CHECK-NOT: __riscv_zacas {{.*$}}
 // CHECK-NOT: __riscv_zalrsc {{.*$}}
 // CHECK-NOT: __riscv_zama16b {{.*$}}
 // CHECK-NOT: __riscv_zawrs {{.*$}}
@@ -183,7 +184,6 @@
 // CHECK-NOT: __riscv_ssnpm{{.*$}}
 // CHECK-NOT: __riscv_sspm{{.*$}}
 // CHECK-NOT: __riscv_supm{{.*$}}
-// CHECK-NOT: __riscv_zacas {{.*$}}
 // CHECK-NOT: __riscv_zalasr {{.*$}}
 // CHECK-NOT: __riscv_zfbfmin {{.*$}}
 // CHECK-NOT: __riscv_zicfilp {{.*$}}
@@ -751,6 +751,14 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-ZABHA-EXT %s
 // CHECK-ZABHA-EXT: __riscv_zabha 100{{$}}
 
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32ia_zacas1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64ia_zacas1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
+// CHECK-ZACAS-EXT: __riscv_zacas 100{{$}}
+
 // RUN: %clang --target=riscv32 \
 // RUN:   -march=rv32i_zalrsc1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-ZALRSC-EXT %s
@@ -1630,14 +1638,6 @@
 // CHECK-ZVKT-EXT: __riscv_zvkt 100{{$}}
 
 // Experimental extensions
-// RUN: %clang --target=riscv32 -menable-experimental-extensions \
-// RUN:   -march=rv32ia_zacas1p0 -E -dM %s \
-// RUN:   -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
-// RUN: %clang --target=riscv64 -menable-experimental-extensions \
-// RUN:   -march=rv64ia_zacas1p0 -E -dM %s \

[clang] [llvm] [RISCV] Mark Zacas as non-experimental (PR #109651)

2024-09-23 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Alex Bradbury (asb)


Changes

The extension has been ratified for some time, but we kept it experimental (see 
#99898) due to
;. The 
ABI issue has been resolved by #101023 so I believe there's no known 
barrier to moving Zacas to non-experimental.

---

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


16 Files Affected:

- (modified) clang/test/Driver/print-supported-extensions-riscv.c (+1-1) 
- (modified) clang/test/Preprocessor/riscv-target-features.c (+9-9) 
- (modified) llvm/docs/RISCVUsage.rst (+5-3) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+2-2) 
- (modified) llvm/lib/TargetParser/Host.cpp (+1-2) 
- (modified) llvm/test/CodeGen/RISCV/atomic-cmpxchg-branch-on-result.ll (+3-3) 
- (modified) llvm/test/CodeGen/RISCV/atomic-cmpxchg.ll (+6-6) 
- (modified) llvm/test/CodeGen/RISCV/atomic-rmw.ll (+6-6) 
- (modified) llvm/test/CodeGen/RISCV/atomic-signext.ll (+2-2) 
- (modified) llvm/test/CodeGen/RISCV/attributes.ll (+2-2) 
- (modified) llvm/test/MC/RISCV/rv32zacas-invalid.s (+1-1) 
- (modified) llvm/test/MC/RISCV/rv32zacas-valid.s (+6-6) 
- (modified) llvm/test/MC/RISCV/rv64zacas-invalid.s (+1-1) 
- (modified) llvm/test/MC/RISCV/rv64zacas-valid.s (+3-3) 
- (modified) llvm/test/MC/RISCV/rvzabha-zacas-valid.s (+6-6) 
- (modified) llvm/unittests/TargetParser/RISCVISAInfoTest.cpp (+1-1) 


``diff
diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 312c462f715d5e..a39c1ab36b1db0 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -35,6 +35,7 @@
 // CHECK-NEXT: za64rs   1.0   'Za64rs' (Reservation Set 
Size of at Most 64 Bytes)
 // CHECK-NEXT: zaamo1.0   'Zaamo' (Atomic Memory 
Operations)
 // CHECK-NEXT: zabha1.0   'Zabha' (Byte and Halfword 
Atomic Memory Operations)
+// CHECK-NEXT: zacas1.0   'Zacas' (Atomic 
Compare-And-Swap Instructions)
 // CHECK-NEXT: zalrsc   1.0   'Zalrsc' 
(Load-Reserved/Store-Conditional)
 // CHECK-NEXT: zama16b  1.0   'Zama16b' (Atomic 16-byte 
misaligned loads, stores and AMOs)
 // CHECK-NEXT: zawrs1.0   'Zawrs' (Wait on Reservation 
Set)
@@ -171,7 +172,6 @@
 // CHECK-NEXT: Experimental extensions
 // CHECK-NEXT: zicfilp  1.0   'Zicfilp' (Landing pad)
 // CHECK-NEXT: zicfiss  1.0   'Zicfiss' (Shadow stack)
-// CHECK-NEXT: zacas1.0   'Zacas' (Atomic 
Compare-And-Swap Instructions)
 // CHECK-NEXT: zalasr   0.1   'Zalasr' (Load-Acquire and 
Store-Release Instructions)
 // CHECK-NEXT: zvbc32e  0.7   'Zvbc32e' (Vector Carryless 
Multiplication with 32-bits elements)
 // CHECK-NEXT: zvkgs0.7   'Zvkgs' (Vector-Scalar GCM 
instructions for Cryptography)
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 60675065495bba..05a8534ba13da1 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -87,6 +87,7 @@
 // CHECK-NOT: __riscv_za64rs {{.*$}}
 // CHECK-NOT: __riscv_zaamo {{.*$}}
 // CHECK-NOT: __riscv_zabha {{.*$}}
+// CHECK-NOT: __riscv_zacas {{.*$}}
 // CHECK-NOT: __riscv_zalrsc {{.*$}}
 // CHECK-NOT: __riscv_zama16b {{.*$}}
 // CHECK-NOT: __riscv_zawrs {{.*$}}
@@ -183,7 +184,6 @@
 // CHECK-NOT: __riscv_ssnpm{{.*$}}
 // CHECK-NOT: __riscv_sspm{{.*$}}
 // CHECK-NOT: __riscv_supm{{.*$}}
-// CHECK-NOT: __riscv_zacas {{.*$}}
 // CHECK-NOT: __riscv_zalasr {{.*$}}
 // CHECK-NOT: __riscv_zfbfmin {{.*$}}
 // CHECK-NOT: __riscv_zicfilp {{.*$}}
@@ -751,6 +751,14 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-ZABHA-EXT %s
 // CHECK-ZABHA-EXT: __riscv_zabha 100{{$}}
 
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32ia_zacas1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64ia_zacas1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
+// CHECK-ZACAS-EXT: __riscv_zacas 100{{$}}
+
 // RUN: %clang --target=riscv32 \
 // RUN:   -march=rv32i_zalrsc1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-ZALRSC-EXT %s
@@ -1630,14 +1638,6 @@
 // CHECK-ZVKT-EXT: __riscv_zvkt 100{{$}}
 
 // Experimental extensions
-// RUN: %clang --target=riscv32 -menable-experimental-extensions \
-// RUN:   -march=rv32ia_zacas1p0 -E -dM %s \
-// RUN:   -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
-// RUN: %clang --target=riscv64 -menable-experimental-extensions \
-// RUN:   -march=rv64ia_zacas1p0 -E -dM %s \
-/

[clang] [llvm] [RISCV] Mark Zacas as non-experimental (PR #109651)

2024-09-23 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Alex Bradbury (asb)


Changes

The extension has been ratified for some time, but we kept it experimental (see 
#99898) due to
;. The 
ABI issue has been resolved by #101023 so I believe there's no known 
barrier to moving Zacas to non-experimental.

---

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


16 Files Affected:

- (modified) clang/test/Driver/print-supported-extensions-riscv.c (+1-1) 
- (modified) clang/test/Preprocessor/riscv-target-features.c (+9-9) 
- (modified) llvm/docs/RISCVUsage.rst (+5-3) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+2-2) 
- (modified) llvm/lib/TargetParser/Host.cpp (+1-2) 
- (modified) llvm/test/CodeGen/RISCV/atomic-cmpxchg-branch-on-result.ll (+3-3) 
- (modified) llvm/test/CodeGen/RISCV/atomic-cmpxchg.ll (+6-6) 
- (modified) llvm/test/CodeGen/RISCV/atomic-rmw.ll (+6-6) 
- (modified) llvm/test/CodeGen/RISCV/atomic-signext.ll (+2-2) 
- (modified) llvm/test/CodeGen/RISCV/attributes.ll (+2-2) 
- (modified) llvm/test/MC/RISCV/rv32zacas-invalid.s (+1-1) 
- (modified) llvm/test/MC/RISCV/rv32zacas-valid.s (+6-6) 
- (modified) llvm/test/MC/RISCV/rv64zacas-invalid.s (+1-1) 
- (modified) llvm/test/MC/RISCV/rv64zacas-valid.s (+3-3) 
- (modified) llvm/test/MC/RISCV/rvzabha-zacas-valid.s (+6-6) 
- (modified) llvm/unittests/TargetParser/RISCVISAInfoTest.cpp (+1-1) 


``diff
diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 312c462f715d5e..a39c1ab36b1db0 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -35,6 +35,7 @@
 // CHECK-NEXT: za64rs   1.0   'Za64rs' (Reservation Set 
Size of at Most 64 Bytes)
 // CHECK-NEXT: zaamo1.0   'Zaamo' (Atomic Memory 
Operations)
 // CHECK-NEXT: zabha1.0   'Zabha' (Byte and Halfword 
Atomic Memory Operations)
+// CHECK-NEXT: zacas1.0   'Zacas' (Atomic 
Compare-And-Swap Instructions)
 // CHECK-NEXT: zalrsc   1.0   'Zalrsc' 
(Load-Reserved/Store-Conditional)
 // CHECK-NEXT: zama16b  1.0   'Zama16b' (Atomic 16-byte 
misaligned loads, stores and AMOs)
 // CHECK-NEXT: zawrs1.0   'Zawrs' (Wait on Reservation 
Set)
@@ -171,7 +172,6 @@
 // CHECK-NEXT: Experimental extensions
 // CHECK-NEXT: zicfilp  1.0   'Zicfilp' (Landing pad)
 // CHECK-NEXT: zicfiss  1.0   'Zicfiss' (Shadow stack)
-// CHECK-NEXT: zacas1.0   'Zacas' (Atomic 
Compare-And-Swap Instructions)
 // CHECK-NEXT: zalasr   0.1   'Zalasr' (Load-Acquire and 
Store-Release Instructions)
 // CHECK-NEXT: zvbc32e  0.7   'Zvbc32e' (Vector Carryless 
Multiplication with 32-bits elements)
 // CHECK-NEXT: zvkgs0.7   'Zvkgs' (Vector-Scalar GCM 
instructions for Cryptography)
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 60675065495bba..05a8534ba13da1 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -87,6 +87,7 @@
 // CHECK-NOT: __riscv_za64rs {{.*$}}
 // CHECK-NOT: __riscv_zaamo {{.*$}}
 // CHECK-NOT: __riscv_zabha {{.*$}}
+// CHECK-NOT: __riscv_zacas {{.*$}}
 // CHECK-NOT: __riscv_zalrsc {{.*$}}
 // CHECK-NOT: __riscv_zama16b {{.*$}}
 // CHECK-NOT: __riscv_zawrs {{.*$}}
@@ -183,7 +184,6 @@
 // CHECK-NOT: __riscv_ssnpm{{.*$}}
 // CHECK-NOT: __riscv_sspm{{.*$}}
 // CHECK-NOT: __riscv_supm{{.*$}}
-// CHECK-NOT: __riscv_zacas {{.*$}}
 // CHECK-NOT: __riscv_zalasr {{.*$}}
 // CHECK-NOT: __riscv_zfbfmin {{.*$}}
 // CHECK-NOT: __riscv_zicfilp {{.*$}}
@@ -751,6 +751,14 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-ZABHA-EXT %s
 // CHECK-ZABHA-EXT: __riscv_zabha 100{{$}}
 
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32ia_zacas1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64ia_zacas1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
+// CHECK-ZACAS-EXT: __riscv_zacas 100{{$}}
+
 // RUN: %clang --target=riscv32 \
 // RUN:   -march=rv32i_zalrsc1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-ZALRSC-EXT %s
@@ -1630,14 +1638,6 @@
 // CHECK-ZVKT-EXT: __riscv_zvkt 100{{$}}
 
 // Experimental extensions
-// RUN: %clang --target=riscv32 -menable-experimental-extensions \
-// RUN:   -march=rv32ia_zacas1p0 -E -dM %s \
-// RUN:   -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
-// RUN: %clang --target=riscv64 -menable-experimental-extensions \
-// RUN:   -march=rv64ia_zacas1p0 -E -dM %s \
-// RUN: 

[libclc] [libclc] use default paths with find_program when possible (PR #105969)

2024-09-23 Thread Harald van Dijk via cfe-commits

hvdijk wrote:

Apologies, but I'm having a bit of trouble understanding the scenario that this 
PR addresses. It looks like it's meant to handle the case where 
`LLVM_TOOLS_BINARY_DIR` does not contain the LLVM binaries, is that right? In 
that case, why can `LLVM_TOOLS_BINARY_DIR` not instead be set to a path that 
does contain the LLVM binaries?

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


[clang] [llvm] [RISCV] Mark Zacas as non-experimental (PR #109651)

2024-09-23 Thread Alex Bradbury via cfe-commits

https://github.com/asb created https://github.com/llvm/llvm-project/pull/109651

The extension has been ratified for some time, but we kept it experimental (see 
#99898) due to
. The ABI 
issue has been resolved by #101023 so I believe there's no known barrier to 
moving Zacas to non-experimental.

>From 6e0e21779c13007ec8e102a6171636189550e770 Mon Sep 17 00:00:00 2001
From: Alex Bradbury 
Date: Mon, 23 Sep 2024 12:28:12 +0100
Subject: [PATCH] [RISCV] Mark Zacas as non-experimental

The extension has been ratified for some time, but we kept it
experimental (see #99898) due to
. The
ABI issue has been resolved by #101023 so I believe there's no known
barrier to moving Zacas to non-experimental.
---
 .../Driver/print-supported-extensions-riscv.c  |  2 +-
 .../test/Preprocessor/riscv-target-features.c  | 18 +-
 llvm/docs/RISCVUsage.rst   |  8 +---
 llvm/lib/Target/RISCV/RISCVFeatures.td |  4 ++--
 llvm/lib/TargetParser/Host.cpp |  3 +--
 .../RISCV/atomic-cmpxchg-branch-on-result.ll   |  6 +++---
 llvm/test/CodeGen/RISCV/atomic-cmpxchg.ll  | 12 ++--
 llvm/test/CodeGen/RISCV/atomic-rmw.ll  | 12 ++--
 llvm/test/CodeGen/RISCV/atomic-signext.ll  |  4 ++--
 llvm/test/CodeGen/RISCV/attributes.ll  |  4 ++--
 llvm/test/MC/RISCV/rv32zacas-invalid.s |  2 +-
 llvm/test/MC/RISCV/rv32zacas-valid.s   | 12 ++--
 llvm/test/MC/RISCV/rv64zacas-invalid.s |  2 +-
 llvm/test/MC/RISCV/rv64zacas-valid.s   |  6 +++---
 llvm/test/MC/RISCV/rvzabha-zacas-valid.s   | 12 ++--
 .../TargetParser/RISCVISAInfoTest.cpp  |  2 +-
 16 files changed, 55 insertions(+), 54 deletions(-)

diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 312c462f715d5e..a39c1ab36b1db0 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -35,6 +35,7 @@
 // CHECK-NEXT: za64rs   1.0   'Za64rs' (Reservation Set 
Size of at Most 64 Bytes)
 // CHECK-NEXT: zaamo1.0   'Zaamo' (Atomic Memory 
Operations)
 // CHECK-NEXT: zabha1.0   'Zabha' (Byte and Halfword 
Atomic Memory Operations)
+// CHECK-NEXT: zacas1.0   'Zacas' (Atomic 
Compare-And-Swap Instructions)
 // CHECK-NEXT: zalrsc   1.0   'Zalrsc' 
(Load-Reserved/Store-Conditional)
 // CHECK-NEXT: zama16b  1.0   'Zama16b' (Atomic 16-byte 
misaligned loads, stores and AMOs)
 // CHECK-NEXT: zawrs1.0   'Zawrs' (Wait on Reservation 
Set)
@@ -171,7 +172,6 @@
 // CHECK-NEXT: Experimental extensions
 // CHECK-NEXT: zicfilp  1.0   'Zicfilp' (Landing pad)
 // CHECK-NEXT: zicfiss  1.0   'Zicfiss' (Shadow stack)
-// CHECK-NEXT: zacas1.0   'Zacas' (Atomic 
Compare-And-Swap Instructions)
 // CHECK-NEXT: zalasr   0.1   'Zalasr' (Load-Acquire and 
Store-Release Instructions)
 // CHECK-NEXT: zvbc32e  0.7   'Zvbc32e' (Vector Carryless 
Multiplication with 32-bits elements)
 // CHECK-NEXT: zvkgs0.7   'Zvkgs' (Vector-Scalar GCM 
instructions for Cryptography)
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 60675065495bba..05a8534ba13da1 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -87,6 +87,7 @@
 // CHECK-NOT: __riscv_za64rs {{.*$}}
 // CHECK-NOT: __riscv_zaamo {{.*$}}
 // CHECK-NOT: __riscv_zabha {{.*$}}
+// CHECK-NOT: __riscv_zacas {{.*$}}
 // CHECK-NOT: __riscv_zalrsc {{.*$}}
 // CHECK-NOT: __riscv_zama16b {{.*$}}
 // CHECK-NOT: __riscv_zawrs {{.*$}}
@@ -183,7 +184,6 @@
 // CHECK-NOT: __riscv_ssnpm{{.*$}}
 // CHECK-NOT: __riscv_sspm{{.*$}}
 // CHECK-NOT: __riscv_supm{{.*$}}
-// CHECK-NOT: __riscv_zacas {{.*$}}
 // CHECK-NOT: __riscv_zalasr {{.*$}}
 // CHECK-NOT: __riscv_zfbfmin {{.*$}}
 // CHECK-NOT: __riscv_zicfilp {{.*$}}
@@ -751,6 +751,14 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-ZABHA-EXT %s
 // CHECK-ZABHA-EXT: __riscv_zabha 100{{$}}
 
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32ia_zacas1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64ia_zacas1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
+// CHECK-ZACAS-EXT: __riscv_zacas 100{{$}}
+
 // RUN: %clang --target=riscv32 \
 // RUN:   -march=rv32i_zalrsc1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-ZALRSC-EXT %s
@@ -1630,14 +1638,6 @@
 // CHECK-ZVKT-EXT: __riscv_zvkt 1

[libclc] [libclc] use default paths with find_program when possible (PR #105969)

2024-09-23 Thread Harald van Dijk via cfe-commits


@@ -55,7 +55,7 @@ if( LIBCLC_STANDALONE_BUILD OR CMAKE_SOURCE_DIR STREQUAL 
CMAKE_CURRENT_SOURCE_DI
   # Import required tools
   if( NOT EXISTS ${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR} )
 foreach( tool IN ITEMS clang llvm-as llvm-link opt )
-  find_program( LLVM_TOOL_${tool} ${tool} PATHS ${LLVM_TOOLS_BINARY_DIR} 
NO_DEFAULT_PATH )
+find_program( LLVM_TOOL_${tool} ${tool} PATHS ${LLVM_TOOLS_BINARY_DIR} )

hvdijk wrote:

At 
https://github.com/RossComputerGuy/llvm-project/blob/056e0f9b7c7b788ad0d85a1479000fd1af4f98ce/libclc/CMakeLists.txt#L100-L104
 there is a check for missing tools. This check would not work if using the 
imported targets if LLVM CMake files are installed, but the binaries are 
missing, which because of the way LLVM is split in distros is something that 
can easily happen.

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


[clang] [clang][bytecode] Implement placement-new (PR #107033)

2024-09-23 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

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

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


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'LLVM-Unit :: Support/./SupportTests/4/11' FAILED 

Script(shard):
--
GTEST_OUTPUT=json:/Users/buildbot/buildbot-root/aarch64-darwin/build/unittests/Support/./SupportTests-LLVM-Unit-63461-4-11.json
 GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=11 GTEST_SHARD_INDEX=4 
/Users/buildbot/buildbot-root/aarch64-darwin/build/unittests/Support/./SupportTests
--

Script:
--
/Users/buildbot/buildbot-root/aarch64-darwin/build/unittests/Support/./SupportTests
 --gtest_filter=FileSystemTest.permissions
--
Test Directory: /tmp/lit-tmp-aerykiak/file-system-test-767ba3
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/unittests/Support/Path.cpp:2325:
 Failure
Value of: CheckPermissions(fs::set_gid_on_exe)
  Actual: false
Expected: true

/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/unittests/Support/Path.cpp:2340:
 Failure
Value of: CheckPermissions(fs::set_uid_on_exe | fs::set_gid_on_exe | 
fs::sticky_bit)
  Actual: false
Expected: true

/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/unittests/Support/Path.cpp:2347:
 Failure
Value of: CheckPermissions(fs::all_read | fs::set_uid_on_exe | 
fs::set_gid_on_exe | fs::sticky_bit)
  Actual: false
Expected: true

/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/unittests/Support/Path.cpp:2350:
 Failure
Value of: CheckPermissions(fs::all_perms)
  Actual: false
Expected: true

/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/unittests/Support/Path.cpp:2355:
 Failure
Value of: CheckPermissions(fs::all_perms & ~fs::sticky_bit)
  Actual: false
Expected: true


/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/unittests/Support/Path.cpp:2325
Value of: CheckPermissions(fs::set_gid_on_exe)
  Actual: false
Expected: true

/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/unittests/Support/Path.cpp:2340
Value of: CheckPermissions(fs::set_uid_on_exe | fs::set_gid_on_exe | 
fs::sticky_bit)
  Actual: false
Expected: true

/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/unittests/Support/Path.cpp:2347
Value of: CheckPermissions(fs::all_read | fs::set_uid_on_exe | 
fs::set_gid_on_exe | fs::sticky_bit)
  Actual: false
...

```



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


[clang] [llvm] [RISCV] Mark Zacas as non-experimental (PR #109651)

2024-09-23 Thread Alex Bradbury via cfe-commits

https://github.com/asb updated https://github.com/llvm/llvm-project/pull/109651

>From 6e0e21779c13007ec8e102a6171636189550e770 Mon Sep 17 00:00:00 2001
From: Alex Bradbury 
Date: Mon, 23 Sep 2024 12:28:12 +0100
Subject: [PATCH 1/2] [RISCV] Mark Zacas as non-experimental

The extension has been ratified for some time, but we kept it
experimental (see #99898) due to
. The
ABI issue has been resolved by #101023 so I believe there's no known
barrier to moving Zacas to non-experimental.
---
 .../Driver/print-supported-extensions-riscv.c  |  2 +-
 .../test/Preprocessor/riscv-target-features.c  | 18 +-
 llvm/docs/RISCVUsage.rst   |  8 +---
 llvm/lib/Target/RISCV/RISCVFeatures.td |  4 ++--
 llvm/lib/TargetParser/Host.cpp |  3 +--
 .../RISCV/atomic-cmpxchg-branch-on-result.ll   |  6 +++---
 llvm/test/CodeGen/RISCV/atomic-cmpxchg.ll  | 12 ++--
 llvm/test/CodeGen/RISCV/atomic-rmw.ll  | 12 ++--
 llvm/test/CodeGen/RISCV/atomic-signext.ll  |  4 ++--
 llvm/test/CodeGen/RISCV/attributes.ll  |  4 ++--
 llvm/test/MC/RISCV/rv32zacas-invalid.s |  2 +-
 llvm/test/MC/RISCV/rv32zacas-valid.s   | 12 ++--
 llvm/test/MC/RISCV/rv64zacas-invalid.s |  2 +-
 llvm/test/MC/RISCV/rv64zacas-valid.s   |  6 +++---
 llvm/test/MC/RISCV/rvzabha-zacas-valid.s   | 12 ++--
 .../TargetParser/RISCVISAInfoTest.cpp  |  2 +-
 16 files changed, 55 insertions(+), 54 deletions(-)

diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 312c462f715d5e..a39c1ab36b1db0 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -35,6 +35,7 @@
 // CHECK-NEXT: za64rs   1.0   'Za64rs' (Reservation Set 
Size of at Most 64 Bytes)
 // CHECK-NEXT: zaamo1.0   'Zaamo' (Atomic Memory 
Operations)
 // CHECK-NEXT: zabha1.0   'Zabha' (Byte and Halfword 
Atomic Memory Operations)
+// CHECK-NEXT: zacas1.0   'Zacas' (Atomic 
Compare-And-Swap Instructions)
 // CHECK-NEXT: zalrsc   1.0   'Zalrsc' 
(Load-Reserved/Store-Conditional)
 // CHECK-NEXT: zama16b  1.0   'Zama16b' (Atomic 16-byte 
misaligned loads, stores and AMOs)
 // CHECK-NEXT: zawrs1.0   'Zawrs' (Wait on Reservation 
Set)
@@ -171,7 +172,6 @@
 // CHECK-NEXT: Experimental extensions
 // CHECK-NEXT: zicfilp  1.0   'Zicfilp' (Landing pad)
 // CHECK-NEXT: zicfiss  1.0   'Zicfiss' (Shadow stack)
-// CHECK-NEXT: zacas1.0   'Zacas' (Atomic 
Compare-And-Swap Instructions)
 // CHECK-NEXT: zalasr   0.1   'Zalasr' (Load-Acquire and 
Store-Release Instructions)
 // CHECK-NEXT: zvbc32e  0.7   'Zvbc32e' (Vector Carryless 
Multiplication with 32-bits elements)
 // CHECK-NEXT: zvkgs0.7   'Zvkgs' (Vector-Scalar GCM 
instructions for Cryptography)
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 60675065495bba..05a8534ba13da1 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -87,6 +87,7 @@
 // CHECK-NOT: __riscv_za64rs {{.*$}}
 // CHECK-NOT: __riscv_zaamo {{.*$}}
 // CHECK-NOT: __riscv_zabha {{.*$}}
+// CHECK-NOT: __riscv_zacas {{.*$}}
 // CHECK-NOT: __riscv_zalrsc {{.*$}}
 // CHECK-NOT: __riscv_zama16b {{.*$}}
 // CHECK-NOT: __riscv_zawrs {{.*$}}
@@ -183,7 +184,6 @@
 // CHECK-NOT: __riscv_ssnpm{{.*$}}
 // CHECK-NOT: __riscv_sspm{{.*$}}
 // CHECK-NOT: __riscv_supm{{.*$}}
-// CHECK-NOT: __riscv_zacas {{.*$}}
 // CHECK-NOT: __riscv_zalasr {{.*$}}
 // CHECK-NOT: __riscv_zfbfmin {{.*$}}
 // CHECK-NOT: __riscv_zicfilp {{.*$}}
@@ -751,6 +751,14 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-ZABHA-EXT %s
 // CHECK-ZABHA-EXT: __riscv_zabha 100{{$}}
 
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32ia_zacas1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64ia_zacas1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
+// CHECK-ZACAS-EXT: __riscv_zacas 100{{$}}
+
 // RUN: %clang --target=riscv32 \
 // RUN:   -march=rv32i_zalrsc1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-ZALRSC-EXT %s
@@ -1630,14 +1638,6 @@
 // CHECK-ZVKT-EXT: __riscv_zvkt 100{{$}}
 
 // Experimental extensions
-// RUN: %clang --target=riscv32 -menable-experimental-extensions \
-// RUN:   -march=rv32ia_zacas1p0 -E -dM %s \
-// RUN:   -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
-// RUN: %clang --target=riscv64 -menable-experimental-extensions 

[clang] [clang] Apply the [[gsl::Owner]] or [[gsl::Pointer]] attributes to the STL template specialization declarations. (PR #109653)

2024-09-23 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Haojian Wu (hokein)


Changes

Fixes #109442

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


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+3) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+1) 
- (modified) clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp (+17) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index da5205087fd821..5ca208de5790f6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -268,6 +268,9 @@ Attribute Changes in Clang
 - Introduced a new attribute ``[[clang::coro_await_elidable_argument]]`` on 
function parameters
   to propagate safe elide context to arguments if such function is also under 
a safe elide context.
 
+- Fix a bug where clang doesn't automatically apply the ``[[gsl::Owner]]`` or
+  ``[[gsl::Pointer]]`` to STL explicit template specialization decls. 
(#GH109442)
+
 Improvements to Clang's diagnostics
 ---
 
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 92274cda15e0b7..99423b01114cc6 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -8631,6 +8631,7 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
 return SkipBody->Previous;
 
   Specialization->setInvalidDecl(Invalid);
+  inferGslOwnerPointerAttribute(Specialization);
   return Specialization;
 }
 
diff --git a/clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp 
b/clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp
index 352e1e473580a6..8fb4cc7621fedf 100644
--- a/clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp
+++ b/clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp
@@ -27,6 +27,11 @@ class vector {
 static_assert(sizeof(vector), "");   // Force instantiation.
 static_assert(sizeof(vector::iterator), ""); // Force instantiation.
 
+template <>
+class vector {};
+// CHECK: ClassTemplateSpecializationDecl {{.*}} vector
+// CHECK: OwnerAttr {{.*}}
+
 // If std::container::iterator is a using declaration, attributes are inferred
 // for the underlying class.
 template 
@@ -173,6 +178,18 @@ class reference_wrapper;
 class some_unknown_type;
 // CHECK: CXXRecordDecl {{.*}} some_unknown_type
 
+using size_t = unsigned;
+inline constexpr size_t dynamic_extent = -1;
+template 
+class span;
+// CHECK: CXXRecordDecl {{.*}} span
+// CHECK: PointerAttr {{.*}}
+
+
+template 
+struct span<_Tp, dynamic_extent> {};
+// CHECK: ClassTemplatePartialSpecializationDecl {{.*}} span
+// CHECK: PointerAttr {{.*}}
 } // namespace std
 
 namespace user {

``




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


[clang] [clang] Apply the [[gsl::Owner]] or [[gsl::Pointer]] attributes to the STL template specialization declarations. (PR #109653)

2024-09-23 Thread Haojian Wu via cfe-commits

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

Fixes #109442

>From ff56c38c032496277dd31a1c3f158e6eacb9fd7d Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Mon, 23 Sep 2024 13:50:39 +0200
Subject: [PATCH] [clang] Apply the [[gsl::Owner]] or [[gsl::Pointer]]
 attributes to STL explicit template specialization declarations.

---
 clang/docs/ReleaseNotes.rst |  3 +++
 clang/lib/Sema/SemaTemplate.cpp |  1 +
 .../test/SemaCXX/attr-gsl-owner-pointer-std.cpp | 17 +
 3 files changed, 21 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index da5205087fd821..5ca208de5790f6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -268,6 +268,9 @@ Attribute Changes in Clang
 - Introduced a new attribute ``[[clang::coro_await_elidable_argument]]`` on 
function parameters
   to propagate safe elide context to arguments if such function is also under 
a safe elide context.
 
+- Fix a bug where clang doesn't automatically apply the ``[[gsl::Owner]]`` or
+  ``[[gsl::Pointer]]`` to STL explicit template specialization decls. 
(#GH109442)
+
 Improvements to Clang's diagnostics
 ---
 
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 92274cda15e0b7..99423b01114cc6 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -8631,6 +8631,7 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
 return SkipBody->Previous;
 
   Specialization->setInvalidDecl(Invalid);
+  inferGslOwnerPointerAttribute(Specialization);
   return Specialization;
 }
 
diff --git a/clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp 
b/clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp
index 352e1e473580a6..8fb4cc7621fedf 100644
--- a/clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp
+++ b/clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp
@@ -27,6 +27,11 @@ class vector {
 static_assert(sizeof(vector), "");   // Force instantiation.
 static_assert(sizeof(vector::iterator), ""); // Force instantiation.
 
+template <>
+class vector {};
+// CHECK: ClassTemplateSpecializationDecl {{.*}} vector
+// CHECK: OwnerAttr {{.*}}
+
 // If std::container::iterator is a using declaration, attributes are inferred
 // for the underlying class.
 template 
@@ -173,6 +178,18 @@ class reference_wrapper;
 class some_unknown_type;
 // CHECK: CXXRecordDecl {{.*}} some_unknown_type
 
+using size_t = unsigned;
+inline constexpr size_t dynamic_extent = -1;
+template 
+class span;
+// CHECK: CXXRecordDecl {{.*}} span
+// CHECK: PointerAttr {{.*}}
+
+
+template 
+struct span<_Tp, dynamic_extent> {};
+// CHECK: ClassTemplatePartialSpecializationDecl {{.*}} span
+// CHECK: PointerAttr {{.*}}
 } // namespace std
 
 namespace user {

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


[clang] [llvm] [AArch64] Implement NEON vscale intrinsics (PR #100347)

2024-09-23 Thread via cfe-commits

https://github.com/Lukacma updated 
https://github.com/llvm/llvm-project/pull/100347

>From 4cbec87032166083624251f868ab1c60a7a266b4 Mon Sep 17 00:00:00 2001
From: Marian Lukac 
Date: Wed, 24 Jul 2024 11:16:20 +
Subject: [PATCH 1/3] [AArch64] Implement NEON vscale intrinsics

---
 clang/include/clang/Basic/arm_neon.td |  6 ++
 clang/lib/CodeGen/CGBuiltin.cpp   |  8 +++
 .../acle_neon_fscale.c| 58 +++
 llvm/include/llvm/IR/IntrinsicsAArch64.td |  7 +++
 .../lib/Target/AArch64/AArch64InstrFormats.td | 21 +++
 llvm/lib/Target/AArch64/AArch64InstrInfo.td   |  2 +-
 llvm/test/CodeGen/AArch64/neon-fp8-fscale.ll  | 54 +
 7 files changed, 155 insertions(+), 1 deletion(-)
 create mode 100644 
clang/test/CodeGen/aarch64-neon-fp8-intrinsics/acle_neon_fscale.c
 create mode 100644 llvm/test/CodeGen/AArch64/neon-fp8-fscale.ll

diff --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index 3098fa67e6a512..f930c62a79280f 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -2096,3 +2096,9 @@ let ArchGuard = "defined(__aarch64__) || 
defined(__arm64ec__)", TargetGuard = "r
   def VLDAP1_LANE : WInst<"vldap1_lane", ".(c*!).I", "QUlQlUlldQdPlQPl">;
   def VSTL1_LANE  : WInst<"vstl1_lane", "v*(.!)I", "QUlQlUlldQdPlQPl">;
 }
+
+let ArchGuard = "defined(__aarch64__)", TargetGuard = "fp8" in {
+  // fscale
+  def FSCALE_V128 : WInst<"vscale", "..(.S)", "QdQfQh">;
+  def FSCALE_V64 : WInst<"vscale", "(.q)(.q)(.qS)", "fh">;
+}
\ No newline at end of file
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 5639239359ab82..816899e5c11e38 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -13491,6 +13491,14 @@ Value 
*CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID,
 Int = Intrinsic::aarch64_neon_suqadd;
 return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vuqadd");
   }
+  case NEON::BI__builtin_neon_vscale_f16:
+  case NEON::BI__builtin_neon_vscaleq_f16:
+  case NEON::BI__builtin_neon_vscale_f32:
+  case NEON::BI__builtin_neon_vscaleq_f32:
+  case NEON::BI__builtin_neon_vscaleq_f64: {
+Int = Intrinsic::aarch64_neon_fp8_fscale;
+return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "fscale");
+  }
   }
 }
 
diff --git a/clang/test/CodeGen/aarch64-neon-fp8-intrinsics/acle_neon_fscale.c 
b/clang/test/CodeGen/aarch64-neon-fp8-intrinsics/acle_neon_fscale.c
new file mode 100644
index 00..b50d30876a7c51
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-neon-fp8-intrinsics/acle_neon_fscale.c
@@ -0,0 +1,58 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 4
+#include 
+
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon 
-target-feature +fp8 -O3 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon 
-target-feature +fp8 -S -O3 -o /dev/null %s
+
+// CHECK-LABEL: define dso_local <4 x half> @test_vscale_f16(
+// CHECK-SAME: <4 x half> noundef [[VN:%.*]], <4 x i16> noundef [[VM:%.*]]) 
local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[FSCALE2_I:%.*]] = tail call <4 x half> 
@llvm.aarch64.neon.fp8.fscale.v4f16(<4 x half> [[VN]], <4 x i16> [[VM]])
+// CHECK-NEXT:ret <4 x half> [[FSCALE2_I]]
+//
+float16x4_t test_vscale_f16(float16x4_t vn, int16x4_t vm) {
+  return vscale_f16(vn, vm);
+}
+
+// CHECK-LABEL: define dso_local <8 x half> @test_vscaleq_f16(
+// CHECK-SAME: <8 x half> noundef [[VN:%.*]], <8 x i16> noundef [[VM:%.*]]) 
local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[FSCALE2_I:%.*]] = tail call <8 x half> 
@llvm.aarch64.neon.fp8.fscale.v8f16(<8 x half> [[VN]], <8 x i16> [[VM]])
+// CHECK-NEXT:ret <8 x half> [[FSCALE2_I]]
+//
+float16x8_t test_vscaleq_f16(float16x8_t vn, int16x8_t vm) {
+  return vscaleq_f16(vn, vm);
+
+}
+
+// CHECK-LABEL: define dso_local <2 x float> @test_vscale_f32(
+// CHECK-SAME: <2 x float> noundef [[VN:%.*]], <2 x i32> noundef [[VM:%.*]]) 
local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[FSCALE2_I:%.*]] = tail call <2 x float> 
@llvm.aarch64.neon.fp8.fscale.v2f32(<2 x float> [[VN]], <2 x i32> [[VM]])
+// CHECK-NEXT:ret <2 x float> [[FSCALE2_I]]
+//
+float32x2_t test_vscale_f32(float32x2_t vn, int32x2_t vm) {
+  return vscale_f32(vn, vm);
+
+}
+
+// CHECK-LABEL: define dso_local <4 x float> @test_vscaleq_f32(
+// CHECK-SAME: <4 x float> noundef [[VN:%.*]], <4 x i32> noundef [[VM:%.*]]) 
local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[FSCALE2_I:%.*]] = tail call <4 x float> 
@llvm.aarch64.neon.fp8.fscale.v4f32(<4 x float> [[VN]], <4 x i32> [[VM]])
+// CHECK-NEXT:ret <4 x float> [[FSCALE2_I]]
+//
+float32x4_t test_vscaleq_f32(float32x4_t vn, int32x4_t vm) {
+  return vscaleq_f32(vn, vm);
+
+

[clang] [llvm] [SPARC] Align i128 to 16 bytes in SPARC datalayouts (PR #106951)

2024-09-23 Thread via cfe-commits

https://github.com/koachan updated 
https://github.com/llvm/llvm-project/pull/106951

>From 3eb96009b0b483553c2255893d26e59b8c4f6574 Mon Sep 17 00:00:00 2001
From: Koakuma 
Date: Mon, 2 Sep 2024 12:01:04 +0700
Subject: [PATCH 1/4] [SPARC] Align i128 to 16 bytes in SPARC datalayouts

Align i128s to 16 bytes, following the example at 
https://reviews.llvm.org/D86310.

clang already does this, but do it in backend code too for the benefit of other
frontends (see e.g https://github.com/llvm/llvm-project/issues/102783).
---
 clang/lib/Basic/Targets/Sparc.h  |  6 ++---
 clang/test/CodeGen/target-data.c |  4 +--
 llvm/lib/Target/Sparc/SparcTargetMachine.cpp |  4 +++
 llvm/test/CodeGen/SPARC/data-align.ll| 27 
 4 files changed, 36 insertions(+), 5 deletions(-)
 create mode 100644 llvm/test/CodeGen/SPARC/data-align.ll

diff --git a/clang/lib/Basic/Targets/Sparc.h b/clang/lib/Basic/Targets/Sparc.h
index 3357bee33e1ac7..ee0d3e2b4329eb 100644
--- a/clang/lib/Basic/Targets/Sparc.h
+++ b/clang/lib/Basic/Targets/Sparc.h
@@ -151,7 +151,7 @@ class LLVM_LIBRARY_VISIBILITY SparcV8TargetInfo : public 
SparcTargetInfo {
 public:
   SparcV8TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : SparcTargetInfo(Triple, Opts) {
-resetDataLayout("E-m:e-p:32:32-i64:64-f128:64-n32-S64");
+resetDataLayout("E-m:e-p:32:32-i64:64-i128:128-f128:64-n32-S64");
 // NetBSD / OpenBSD use long (same as llvm default); everyone else uses 
int.
 switch (getTriple().getOS()) {
 default:
@@ -188,7 +188,7 @@ class LLVM_LIBRARY_VISIBILITY SparcV8elTargetInfo : public 
SparcV8TargetInfo {
 public:
   SparcV8elTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : SparcV8TargetInfo(Triple, Opts) {
-resetDataLayout("e-m:e-p:32:32-i64:64-f128:64-n32-S64");
+resetDataLayout("e-m:e-p:32:32-i64:64-i128:128-f128:64-n32-S64");
   }
 };
 
@@ -198,7 +198,7 @@ class LLVM_LIBRARY_VISIBILITY SparcV9TargetInfo : public 
SparcTargetInfo {
   SparcV9TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : SparcTargetInfo(Triple, Opts) {
 // FIXME: Support Sparc quad-precision long double?
-resetDataLayout("E-m:e-i64:64-n32:64-S128");
+resetDataLayout("E-m:e-i64:64-i128:128-n32:64-S128");
 // This is an LP64 platform.
 LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
 
diff --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c
index 41cbd5a0219d5e..8548aa00cfe877 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -28,11 +28,11 @@
 
 // RUN: %clang_cc1 -triple sparc-sun-solaris -emit-llvm -o - %s | \
 // RUN: FileCheck %s --check-prefix=SPARC-V8
-// SPARC-V8: target datalayout = "E-m:e-p:32:32-i64:64-f128:64-n32-S64"
+// SPARC-V8: target datalayout = 
"E-m:e-p:32:32-i64:64-i128:128-f128:64-n32-S64"
 
 // RUN: %clang_cc1 -triple sparcv9-sun-solaris -emit-llvm -o - %s | \
 // RUN: FileCheck %s --check-prefix=SPARC-V9
-// SPARC-V9: target datalayout = "E-m:e-i64:64-n32:64-S128"
+// SPARC-V9: target datalayout = "E-m:e-i64:64-i128:128-n32:64-S128"
 
 // RUN: %clang_cc1 -triple mipsel-linux-gnu -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-32EL
diff --git a/llvm/lib/Target/Sparc/SparcTargetMachine.cpp 
b/llvm/lib/Target/Sparc/SparcTargetMachine.cpp
index fec2d3a35ae6d2..50a96368bbdca9 100644
--- a/llvm/lib/Target/Sparc/SparcTargetMachine.cpp
+++ b/llvm/lib/Target/Sparc/SparcTargetMachine.cpp
@@ -48,6 +48,10 @@ static std::string computeDataLayout(const Triple &T, bool 
is64Bit) {
   // Alignments for 64 bit integers.
   Ret += "-i64:64";
 
+  // Alignments for 128 bit integers.
+  // This is not specified in the ABI document but is the de facto standard.
+  Ret += "-i128:128";
+
   // On SparcV9 128 floats are aligned to 128 bits, on others only to 64.
   // On SparcV9 registers can hold 64 or 32 bits, on others only 32.
   if (is64Bit)
diff --git a/llvm/test/CodeGen/SPARC/data-align.ll 
b/llvm/test/CodeGen/SPARC/data-align.ll
new file mode 100644
index 00..d4a39524da44f6
--- /dev/null
+++ b/llvm/test/CodeGen/SPARC/data-align.ll
@@ -0,0 +1,27 @@
+; RUN: llc < %s -march=sparc | FileCheck %s
+; RUN: llc < %s -march=sparcel | FileCheck %s
+; RUN: llc < %s -march=sparcv9 | FileCheck %s
+
+; CHECK:  .Li8:
+; CHECK-DAG: .size .Li8, 1
+@i8 = private constant i8 42
+
+; CHECK:  .p2align 1
+; CHECK-NEXT: .Li16:
+; CHECK-DAG:  .size .Li16, 2
+@i16 = private constant i16 42
+
+; CHECK:  .p2align 2
+; CHECK-NEXT: .Li32:
+; CHECK-DAG:  .size .Li32, 4
+@i32 = private constant i32 42
+
+; CHECK:  .p2align 3
+; CHECK-NEXT: .Li64:
+; CHECK-DAG:  .size .Li64, 8
+@i64 = private constant i64 42
+
+; CHECK:  .p2align 4
+; CHECK-NEXT: .Li128:
+; CHECK-DAG:  .size .Li128, 16
+@i128 = private constant i128 42

>From 4b40325439810ff7786be100577207693b372f7b Mon Sep 17 00:00:00 2001
From: Koakuma 
Date: Wed, 4 Sep 2024 2

[clang] [llvm] [RISCV] Mark Zacas as non-experimental (PR #109651)

2024-09-23 Thread Alex Bradbury via cfe-commits

https://github.com/asb updated https://github.com/llvm/llvm-project/pull/109651

>From 6e0e21779c13007ec8e102a6171636189550e770 Mon Sep 17 00:00:00 2001
From: Alex Bradbury 
Date: Mon, 23 Sep 2024 12:28:12 +0100
Subject: [PATCH 1/3] [RISCV] Mark Zacas as non-experimental

The extension has been ratified for some time, but we kept it
experimental (see #99898) due to
. The
ABI issue has been resolved by #101023 so I believe there's no known
barrier to moving Zacas to non-experimental.
---
 .../Driver/print-supported-extensions-riscv.c  |  2 +-
 .../test/Preprocessor/riscv-target-features.c  | 18 +-
 llvm/docs/RISCVUsage.rst   |  8 +---
 llvm/lib/Target/RISCV/RISCVFeatures.td |  4 ++--
 llvm/lib/TargetParser/Host.cpp |  3 +--
 .../RISCV/atomic-cmpxchg-branch-on-result.ll   |  6 +++---
 llvm/test/CodeGen/RISCV/atomic-cmpxchg.ll  | 12 ++--
 llvm/test/CodeGen/RISCV/atomic-rmw.ll  | 12 ++--
 llvm/test/CodeGen/RISCV/atomic-signext.ll  |  4 ++--
 llvm/test/CodeGen/RISCV/attributes.ll  |  4 ++--
 llvm/test/MC/RISCV/rv32zacas-invalid.s |  2 +-
 llvm/test/MC/RISCV/rv32zacas-valid.s   | 12 ++--
 llvm/test/MC/RISCV/rv64zacas-invalid.s |  2 +-
 llvm/test/MC/RISCV/rv64zacas-valid.s   |  6 +++---
 llvm/test/MC/RISCV/rvzabha-zacas-valid.s   | 12 ++--
 .../TargetParser/RISCVISAInfoTest.cpp  |  2 +-
 16 files changed, 55 insertions(+), 54 deletions(-)

diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 312c462f715d5e..a39c1ab36b1db0 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -35,6 +35,7 @@
 // CHECK-NEXT: za64rs   1.0   'Za64rs' (Reservation Set 
Size of at Most 64 Bytes)
 // CHECK-NEXT: zaamo1.0   'Zaamo' (Atomic Memory 
Operations)
 // CHECK-NEXT: zabha1.0   'Zabha' (Byte and Halfword 
Atomic Memory Operations)
+// CHECK-NEXT: zacas1.0   'Zacas' (Atomic 
Compare-And-Swap Instructions)
 // CHECK-NEXT: zalrsc   1.0   'Zalrsc' 
(Load-Reserved/Store-Conditional)
 // CHECK-NEXT: zama16b  1.0   'Zama16b' (Atomic 16-byte 
misaligned loads, stores and AMOs)
 // CHECK-NEXT: zawrs1.0   'Zawrs' (Wait on Reservation 
Set)
@@ -171,7 +172,6 @@
 // CHECK-NEXT: Experimental extensions
 // CHECK-NEXT: zicfilp  1.0   'Zicfilp' (Landing pad)
 // CHECK-NEXT: zicfiss  1.0   'Zicfiss' (Shadow stack)
-// CHECK-NEXT: zacas1.0   'Zacas' (Atomic 
Compare-And-Swap Instructions)
 // CHECK-NEXT: zalasr   0.1   'Zalasr' (Load-Acquire and 
Store-Release Instructions)
 // CHECK-NEXT: zvbc32e  0.7   'Zvbc32e' (Vector Carryless 
Multiplication with 32-bits elements)
 // CHECK-NEXT: zvkgs0.7   'Zvkgs' (Vector-Scalar GCM 
instructions for Cryptography)
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 60675065495bba..05a8534ba13da1 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -87,6 +87,7 @@
 // CHECK-NOT: __riscv_za64rs {{.*$}}
 // CHECK-NOT: __riscv_zaamo {{.*$}}
 // CHECK-NOT: __riscv_zabha {{.*$}}
+// CHECK-NOT: __riscv_zacas {{.*$}}
 // CHECK-NOT: __riscv_zalrsc {{.*$}}
 // CHECK-NOT: __riscv_zama16b {{.*$}}
 // CHECK-NOT: __riscv_zawrs {{.*$}}
@@ -183,7 +184,6 @@
 // CHECK-NOT: __riscv_ssnpm{{.*$}}
 // CHECK-NOT: __riscv_sspm{{.*$}}
 // CHECK-NOT: __riscv_supm{{.*$}}
-// CHECK-NOT: __riscv_zacas {{.*$}}
 // CHECK-NOT: __riscv_zalasr {{.*$}}
 // CHECK-NOT: __riscv_zfbfmin {{.*$}}
 // CHECK-NOT: __riscv_zicfilp {{.*$}}
@@ -751,6 +751,14 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-ZABHA-EXT %s
 // CHECK-ZABHA-EXT: __riscv_zabha 100{{$}}
 
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32ia_zacas1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64ia_zacas1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
+// CHECK-ZACAS-EXT: __riscv_zacas 100{{$}}
+
 // RUN: %clang --target=riscv32 \
 // RUN:   -march=rv32i_zalrsc1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-ZALRSC-EXT %s
@@ -1630,14 +1638,6 @@
 // CHECK-ZVKT-EXT: __riscv_zvkt 100{{$}}
 
 // Experimental extensions
-// RUN: %clang --target=riscv32 -menable-experimental-extensions \
-// RUN:   -march=rv32ia_zacas1p0 -E -dM %s \
-// RUN:   -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
-// RUN: %clang --target=riscv64 -menable-experimental-extensions 

[clang] [analyzer][StackAddrEscapeChecker] Fix assert failure for alloca regions (PR #109655)

2024-09-23 Thread Arseniy Zaostrovnykh via cfe-commits

https://github.com/necto created 
https://github.com/llvm/llvm-project/pull/109655

Fixes #107852

Make it explicit that the checker skips alloca regions to avoid the risc of 
producing false positives for code that has advnaced memory management.
StackAddrEscapeChecker already used this strategy when it comes to malloc'ed 
regions, so this change relaxes the assertion and explicitly silents the issues 
related to memory regions generated with alloca.

>From b69749ab1854b0c12a69821c35bff1b866d6f307 Mon Sep 17 00:00:00 2001
From: Arseniy Zaostrovnykh 
Date: Mon, 23 Sep 2024 14:21:31 +0200
Subject: [PATCH] [analyzer][StackAddrEscapeChecker] Fix assert failure for
 alloca regions

Fixes #107852

Make it explicit that the checker skips alloca regions to avoid the risc
of producing false positives for code that has advnaced memory
management.
StackAddrEscapeChecker already used this strategy when it comes to
malloc'ed regions, so this change relaxes the assertion and explicitly
silents the issues related to memory regions generated with alloca.
---
 .../Checkers/StackAddrEscapeChecker.cpp   |  4 +++
 clang/test/Analysis/stack-addr-ps.cpp | 29 ++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
index d8c52941b19366..a76639bb86b208 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
@@ -337,6 +337,10 @@ static std::optional printReferrer(const 
MemRegion *Referrer) {
   // warn_bind_ref_member_to_parameter or
   // warn_init_ptr_member_to_parameter_addr
   return std::nullopt;
+} else if (isa(Referrer)) {
+  // Skip alloca() regions, they indicate advanced memory management
+  // and higher likelihood of CSA false positives.
+  return std::nullopt;
 } else {
   assert(false && "Unexpected referrer region type.");
   return std::nullopt;
diff --git a/clang/test/Analysis/stack-addr-ps.cpp 
b/clang/test/Analysis/stack-addr-ps.cpp
index 35f38fbbfbefdc..1f8b62824772e1 100644
--- a/clang/test/Analysis/stack-addr-ps.cpp
+++ b/clang/test/Analysis/stack-addr-ps.cpp
@@ -1,4 +1,9 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify 
%s -Wno-undefined-bool-conversion
+// RUN: %clang_analyze_cc1 \
+// RUN:   -analyzer-checker=core,debug.ExprInspection,unix.Malloc \
+// RUN:   -verify %s \
+// RUN:   -Wno-undefined-bool-conversion
+// unix.Malloc is necessary to model __builtin_alloca,
+// which could trigger an "unexpected region" bug in StackAddrEscapeChecker.
 
 typedef __INTPTR_TYPE__ intptr_t;
 
@@ -846,3 +851,25 @@ void top(char **p) {
   foo(); // no-warning FIXME: p binding is reclaimed before the function end
 }
 } // namespace early_reclaim_dead_limitation
+
+using size_t = decltype(sizeof(int));
+void * malloc(size_t size);
+void free(void*);
+
+namespace alloca_region_pointer {
+void callee(char **pptr) {
+  char local;
+  *pptr = &local;
+}
+
+void top_alloca_no_crash() {
+  char **pptr = (char**)__builtin_alloca(sizeof(char*));
+  callee(pptr);
+}
+
+void top_malloc_no_crash_fn() {
+  char **pptr = (char**)malloc(sizeof(char*));
+  callee(pptr);
+  free(pptr);
+}
+} // namespace alloca_region_pointer

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


[clang] [analyzer][StackAddrEscapeChecker] Fix assert failure for alloca regions (PR #109655)

2024-09-23 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-static-analyzer-1

@llvm/pr-subscribers-clang

Author: Arseniy Zaostrovnykh (necto)


Changes

Fixes #107852

Make it explicit that the checker skips alloca regions to avoid the risc of 
producing false positives for code that has advnaced memory management.
StackAddrEscapeChecker already used this strategy when it comes to malloc'ed 
regions, so this change relaxes the assertion and explicitly silents the issues 
related to memory regions generated with alloca.

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


2 Files Affected:

- (modified) clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp (+4) 
- (modified) clang/test/Analysis/stack-addr-ps.cpp (+28-1) 


``diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
index d8c52941b19366..a76639bb86b208 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
@@ -337,6 +337,10 @@ static std::optional printReferrer(const 
MemRegion *Referrer) {
   // warn_bind_ref_member_to_parameter or
   // warn_init_ptr_member_to_parameter_addr
   return std::nullopt;
+} else if (isa(Referrer)) {
+  // Skip alloca() regions, they indicate advanced memory management
+  // and higher likelihood of CSA false positives.
+  return std::nullopt;
 } else {
   assert(false && "Unexpected referrer region type.");
   return std::nullopt;
diff --git a/clang/test/Analysis/stack-addr-ps.cpp 
b/clang/test/Analysis/stack-addr-ps.cpp
index 35f38fbbfbefdc..1f8b62824772e1 100644
--- a/clang/test/Analysis/stack-addr-ps.cpp
+++ b/clang/test/Analysis/stack-addr-ps.cpp
@@ -1,4 +1,9 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify 
%s -Wno-undefined-bool-conversion
+// RUN: %clang_analyze_cc1 \
+// RUN:   -analyzer-checker=core,debug.ExprInspection,unix.Malloc \
+// RUN:   -verify %s \
+// RUN:   -Wno-undefined-bool-conversion
+// unix.Malloc is necessary to model __builtin_alloca,
+// which could trigger an "unexpected region" bug in StackAddrEscapeChecker.
 
 typedef __INTPTR_TYPE__ intptr_t;
 
@@ -846,3 +851,25 @@ void top(char **p) {
   foo(); // no-warning FIXME: p binding is reclaimed before the function end
 }
 } // namespace early_reclaim_dead_limitation
+
+using size_t = decltype(sizeof(int));
+void * malloc(size_t size);
+void free(void*);
+
+namespace alloca_region_pointer {
+void callee(char **pptr) {
+  char local;
+  *pptr = &local;
+}
+
+void top_alloca_no_crash() {
+  char **pptr = (char**)__builtin_alloca(sizeof(char*));
+  callee(pptr);
+}
+
+void top_malloc_no_crash_fn() {
+  char **pptr = (char**)malloc(sizeof(char*));
+  callee(pptr);
+  free(pptr);
+}
+} // namespace alloca_region_pointer

``




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


[clang] [lldb] [AMDGPU] Specify width and align for all AMDGPU builtin types. NFC. (PR #109656)

2024-09-23 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Jay Foad (jayfoad)


Changes

This will be used in ASTContext::getTypeInfo which needs this
information for all builtin types, not just pointers.


---

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


25 Files Affected:

- (modified) clang/include/clang/AST/ASTContext.h (+2-1) 
- (modified) clang/include/clang/AST/Type.h (+1-1) 
- (modified) clang/include/clang/AST/TypeProperties.td (+1-1) 
- (modified) clang/include/clang/Basic/AMDGPUTypes.def (+3-3) 
- (modified) clang/include/clang/Serialization/ASTBitCodes.h (+1-1) 
- (modified) clang/lib/AST/ASTContext.cpp (+4-4) 
- (modified) clang/lib/AST/ASTImporter.cpp (+1-1) 
- (modified) clang/lib/AST/ExprConstant.cpp (+1-1) 
- (modified) clang/lib/AST/ItaniumMangle.cpp (+1-1) 
- (modified) clang/lib/AST/MicrosoftMangle.cpp (+1-1) 
- (modified) clang/lib/AST/NSAPI.cpp (+1-1) 
- (modified) clang/lib/AST/PrintfFormatString.cpp (+1-1) 
- (modified) clang/lib/AST/Type.cpp (+2-2) 
- (modified) clang/lib/AST/TypeLoc.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGDebugInfo.h (+2-1) 
- (modified) clang/lib/CodeGen/CodeGenTypes.cpp (+1-1) 
- (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+1-1) 
- (modified) clang/lib/Index/USRGeneration.cpp (+1-1) 
- (modified) clang/lib/Sema/Sema.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaExpr.cpp (+2-2) 
- (modified) clang/lib/Serialization/ASTCommon.cpp (+1-1) 
- (modified) clang/lib/Serialization/ASTReader.cpp (+1-1) 
- (modified) clang/tools/libclang/CIndex.cpp (+1-1) 
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+2-1) 


``diff
diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 1984310df0442e..f46e12a57d4c38 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1197,7 +1197,8 @@ class ASTContext : public RefCountedBase {
 #include "clang/Basic/RISCVVTypes.def"
 #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
 #include "clang/Basic/WebAssemblyReferenceTypes.def"
-#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
+#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align)   
\
+  CanQualType SingletonId;
 #include "clang/Basic/AMDGPUTypes.def"
 #define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
 #include "clang/Basic/HLSLIntangibleTypes.def"
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index dc87b84153e74a..cee4e68fe0dc6d 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -3050,7 +3050,7 @@ class BuiltinType : public Type {
 #define WASM_TYPE(Name, Id, SingletonId) Id,
 #include "clang/Basic/WebAssemblyReferenceTypes.def"
 // AMDGPU types
-#define AMDGPU_TYPE(Name, Id, SingletonId) Id,
+#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) Id,
 #include "clang/Basic/AMDGPUTypes.def"
 // HLSL intangible Types
 #define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) Id,
diff --git a/clang/include/clang/AST/TypeProperties.td 
b/clang/include/clang/AST/TypeProperties.td
index bb7bfa8cd0b76e..d05072607e949c 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -893,7 +893,7 @@ let Class = BuiltinType in {
   case BuiltinType::ID: return ctx.SINGLETON_ID;
 #include "clang/Basic/WebAssemblyReferenceTypes.def"
 
-#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \
+#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID, WIDTH, ALIGN) \
   case BuiltinType::ID: return ctx.SINGLETON_ID;
 #include "clang/Basic/AMDGPUTypes.def"
 
diff --git a/clang/include/clang/Basic/AMDGPUTypes.def 
b/clang/include/clang/Basic/AMDGPUTypes.def
index 7454d61f5dd516..e47e544fdc82c1 100644
--- a/clang/include/clang/Basic/AMDGPUTypes.def
+++ b/clang/include/clang/Basic/AMDGPUTypes.def
@@ -11,11 +11,11 @@
 
//===--===//
 
 #ifndef AMDGPU_OPAQUE_PTR_TYPE
-#define AMDGPU_OPAQUE_PTR_TYPE(Name, AS, Width, Align, Id, SingletonId) \
-  AMDGPU_TYPE(Name, Id, SingletonId)
+#define AMDGPU_OPAQUE_PTR_TYPE(Name, Id, SingletonId, Width, Align, AS) \
+  AMDGPU_TYPE(Name, Id, SingletonId, Width, Align)
 #endif
 
-AMDGPU_OPAQUE_PTR_TYPE("__amdgpu_buffer_rsrc_t", 8, 128, 128, 
AMDGPUBufferRsrc, AMDGPUBufferRsrcTy)
+AMDGPU_OPAQUE_PTR_TYPE("__amdgpu_buffer_rsrc_t", AMDGPUBufferRsrc, 
AMDGPUBufferRsrcTy, 128, 128, 8)
 
 #undef AMDGPU_TYPE
 #undef AMDGPU_OPAQUE_PTR_TYPE
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h 
b/clang/include/clang/Serialization/ASTBitCodes.h
index 4410df296d8efc..8c29f8c0ae5f55 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -1122,7 +1122,7 @@ enum PredefinedTypeIDs {
 #define WASM_TYPE(Name, Id, SingletonId) PREDEF_TYPE_

[clang] [lldb] [AMDGPU] Specify width and align for all AMDGPU builtin types. NFC. (PR #109656)

2024-09-23 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-modules
@llvm/pr-subscribers-debuginfo

@llvm/pr-subscribers-lldb

Author: Jay Foad (jayfoad)


Changes

This will be used in ASTContext::getTypeInfo which needs this
information for all builtin types, not just pointers.


---

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


25 Files Affected:

- (modified) clang/include/clang/AST/ASTContext.h (+2-1) 
- (modified) clang/include/clang/AST/Type.h (+1-1) 
- (modified) clang/include/clang/AST/TypeProperties.td (+1-1) 
- (modified) clang/include/clang/Basic/AMDGPUTypes.def (+3-3) 
- (modified) clang/include/clang/Serialization/ASTBitCodes.h (+1-1) 
- (modified) clang/lib/AST/ASTContext.cpp (+4-4) 
- (modified) clang/lib/AST/ASTImporter.cpp (+1-1) 
- (modified) clang/lib/AST/ExprConstant.cpp (+1-1) 
- (modified) clang/lib/AST/ItaniumMangle.cpp (+1-1) 
- (modified) clang/lib/AST/MicrosoftMangle.cpp (+1-1) 
- (modified) clang/lib/AST/NSAPI.cpp (+1-1) 
- (modified) clang/lib/AST/PrintfFormatString.cpp (+1-1) 
- (modified) clang/lib/AST/Type.cpp (+2-2) 
- (modified) clang/lib/AST/TypeLoc.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGDebugInfo.h (+2-1) 
- (modified) clang/lib/CodeGen/CodeGenTypes.cpp (+1-1) 
- (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+1-1) 
- (modified) clang/lib/Index/USRGeneration.cpp (+1-1) 
- (modified) clang/lib/Sema/Sema.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaExpr.cpp (+2-2) 
- (modified) clang/lib/Serialization/ASTCommon.cpp (+1-1) 
- (modified) clang/lib/Serialization/ASTReader.cpp (+1-1) 
- (modified) clang/tools/libclang/CIndex.cpp (+1-1) 
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+2-1) 


``diff
diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 1984310df0442e..f46e12a57d4c38 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1197,7 +1197,8 @@ class ASTContext : public RefCountedBase {
 #include "clang/Basic/RISCVVTypes.def"
 #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
 #include "clang/Basic/WebAssemblyReferenceTypes.def"
-#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
+#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align)   
\
+  CanQualType SingletonId;
 #include "clang/Basic/AMDGPUTypes.def"
 #define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
 #include "clang/Basic/HLSLIntangibleTypes.def"
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index dc87b84153e74a..cee4e68fe0dc6d 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -3050,7 +3050,7 @@ class BuiltinType : public Type {
 #define WASM_TYPE(Name, Id, SingletonId) Id,
 #include "clang/Basic/WebAssemblyReferenceTypes.def"
 // AMDGPU types
-#define AMDGPU_TYPE(Name, Id, SingletonId) Id,
+#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) Id,
 #include "clang/Basic/AMDGPUTypes.def"
 // HLSL intangible Types
 #define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) Id,
diff --git a/clang/include/clang/AST/TypeProperties.td 
b/clang/include/clang/AST/TypeProperties.td
index bb7bfa8cd0b76e..d05072607e949c 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -893,7 +893,7 @@ let Class = BuiltinType in {
   case BuiltinType::ID: return ctx.SINGLETON_ID;
 #include "clang/Basic/WebAssemblyReferenceTypes.def"
 
-#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \
+#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID, WIDTH, ALIGN) \
   case BuiltinType::ID: return ctx.SINGLETON_ID;
 #include "clang/Basic/AMDGPUTypes.def"
 
diff --git a/clang/include/clang/Basic/AMDGPUTypes.def 
b/clang/include/clang/Basic/AMDGPUTypes.def
index 7454d61f5dd516..e47e544fdc82c1 100644
--- a/clang/include/clang/Basic/AMDGPUTypes.def
+++ b/clang/include/clang/Basic/AMDGPUTypes.def
@@ -11,11 +11,11 @@
 
//===--===//
 
 #ifndef AMDGPU_OPAQUE_PTR_TYPE
-#define AMDGPU_OPAQUE_PTR_TYPE(Name, AS, Width, Align, Id, SingletonId) \
-  AMDGPU_TYPE(Name, Id, SingletonId)
+#define AMDGPU_OPAQUE_PTR_TYPE(Name, Id, SingletonId, Width, Align, AS) \
+  AMDGPU_TYPE(Name, Id, SingletonId, Width, Align)
 #endif
 
-AMDGPU_OPAQUE_PTR_TYPE("__amdgpu_buffer_rsrc_t", 8, 128, 128, 
AMDGPUBufferRsrc, AMDGPUBufferRsrcTy)
+AMDGPU_OPAQUE_PTR_TYPE("__amdgpu_buffer_rsrc_t", AMDGPUBufferRsrc, 
AMDGPUBufferRsrcTy, 128, 128, 8)
 
 #undef AMDGPU_TYPE
 #undef AMDGPU_OPAQUE_PTR_TYPE
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h 
b/clang/include/clang/Serialization/ASTBitCodes.h
index 4410df296d8efc..8c29f8c0ae5f55 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -1122,7 +1122,7 @@ enum PredefinedTypeIDs

[clang] [lldb] [AMDGPU] Specify width and align for all AMDGPU builtin types. NFC. (PR #109656)

2024-09-23 Thread Jay Foad via cfe-commits

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

This will be used in ASTContext::getTypeInfo which needs this
information for all builtin types, not just pointers.


>From 0ef4ea17a711a1ee95080bc1635ae9aa824df596 Mon Sep 17 00:00:00 2001
From: Jay Foad 
Date: Tue, 17 Sep 2024 15:06:41 +0100
Subject: [PATCH] [AMDGPU] Specify width and align for all AMDGPU builtin
 types. NFC.

This will be used in ASTContext::getTypeInfo which needs this
information for all builtin types, not just pointers.
---
 clang/include/clang/AST/ASTContext.h | 3 ++-
 clang/include/clang/AST/Type.h   | 2 +-
 clang/include/clang/AST/TypeProperties.td| 2 +-
 clang/include/clang/Basic/AMDGPUTypes.def| 6 +++---
 clang/include/clang/Serialization/ASTBitCodes.h  | 2 +-
 clang/lib/AST/ASTContext.cpp | 8 
 clang/lib/AST/ASTImporter.cpp| 2 +-
 clang/lib/AST/ExprConstant.cpp   | 2 +-
 clang/lib/AST/ItaniumMangle.cpp  | 2 +-
 clang/lib/AST/MicrosoftMangle.cpp| 2 +-
 clang/lib/AST/NSAPI.cpp  | 2 +-
 clang/lib/AST/PrintfFormatString.cpp | 2 +-
 clang/lib/AST/Type.cpp   | 4 ++--
 clang/lib/AST/TypeLoc.cpp| 2 +-
 clang/lib/CodeGen/CGDebugInfo.cpp| 2 +-
 clang/lib/CodeGen/CGDebugInfo.h  | 3 ++-
 clang/lib/CodeGen/CodeGenTypes.cpp   | 2 +-
 clang/lib/CodeGen/ItaniumCXXABI.cpp  | 2 +-
 clang/lib/Index/USRGeneration.cpp| 2 +-
 clang/lib/Sema/Sema.cpp  | 2 +-
 clang/lib/Sema/SemaExpr.cpp  | 4 ++--
 clang/lib/Serialization/ASTCommon.cpp| 2 +-
 clang/lib/Serialization/ASTReader.cpp| 2 +-
 clang/tools/libclang/CIndex.cpp  | 2 +-
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 3 ++-
 25 files changed, 35 insertions(+), 32 deletions(-)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 1984310df0442e..f46e12a57d4c38 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1197,7 +1197,8 @@ class ASTContext : public RefCountedBase {
 #include "clang/Basic/RISCVVTypes.def"
 #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
 #include "clang/Basic/WebAssemblyReferenceTypes.def"
-#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
+#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align)   
\
+  CanQualType SingletonId;
 #include "clang/Basic/AMDGPUTypes.def"
 #define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
 #include "clang/Basic/HLSLIntangibleTypes.def"
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index dc87b84153e74a..cee4e68fe0dc6d 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -3050,7 +3050,7 @@ class BuiltinType : public Type {
 #define WASM_TYPE(Name, Id, SingletonId) Id,
 #include "clang/Basic/WebAssemblyReferenceTypes.def"
 // AMDGPU types
-#define AMDGPU_TYPE(Name, Id, SingletonId) Id,
+#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) Id,
 #include "clang/Basic/AMDGPUTypes.def"
 // HLSL intangible Types
 #define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) Id,
diff --git a/clang/include/clang/AST/TypeProperties.td 
b/clang/include/clang/AST/TypeProperties.td
index bb7bfa8cd0b76e..d05072607e949c 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -893,7 +893,7 @@ let Class = BuiltinType in {
   case BuiltinType::ID: return ctx.SINGLETON_ID;
 #include "clang/Basic/WebAssemblyReferenceTypes.def"
 
-#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \
+#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID, WIDTH, ALIGN) \
   case BuiltinType::ID: return ctx.SINGLETON_ID;
 #include "clang/Basic/AMDGPUTypes.def"
 
diff --git a/clang/include/clang/Basic/AMDGPUTypes.def 
b/clang/include/clang/Basic/AMDGPUTypes.def
index 7454d61f5dd516..e47e544fdc82c1 100644
--- a/clang/include/clang/Basic/AMDGPUTypes.def
+++ b/clang/include/clang/Basic/AMDGPUTypes.def
@@ -11,11 +11,11 @@
 
//===--===//
 
 #ifndef AMDGPU_OPAQUE_PTR_TYPE
-#define AMDGPU_OPAQUE_PTR_TYPE(Name, AS, Width, Align, Id, SingletonId) \
-  AMDGPU_TYPE(Name, Id, SingletonId)
+#define AMDGPU_OPAQUE_PTR_TYPE(Name, Id, SingletonId, Width, Align, AS) \
+  AMDGPU_TYPE(Name, Id, SingletonId, Width, Align)
 #endif
 
-AMDGPU_OPAQUE_PTR_TYPE("__amdgpu_buffer_rsrc_t", 8, 128, 128, 
AMDGPUBufferRsrc, AMDGPUBufferRsrcTy)
+AMDGPU_OPAQUE_PTR_TYPE("__amdgpu_buffer

[clang] [lldb] [AMDGPU] Specify width and align for all AMDGPU builtin types. NFC. (PR #109656)

2024-09-23 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Jay Foad (jayfoad)


Changes

This will be used in ASTContext::getTypeInfo which needs this
information for all builtin types, not just pointers.


---

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


25 Files Affected:

- (modified) clang/include/clang/AST/ASTContext.h (+2-1) 
- (modified) clang/include/clang/AST/Type.h (+1-1) 
- (modified) clang/include/clang/AST/TypeProperties.td (+1-1) 
- (modified) clang/include/clang/Basic/AMDGPUTypes.def (+3-3) 
- (modified) clang/include/clang/Serialization/ASTBitCodes.h (+1-1) 
- (modified) clang/lib/AST/ASTContext.cpp (+4-4) 
- (modified) clang/lib/AST/ASTImporter.cpp (+1-1) 
- (modified) clang/lib/AST/ExprConstant.cpp (+1-1) 
- (modified) clang/lib/AST/ItaniumMangle.cpp (+1-1) 
- (modified) clang/lib/AST/MicrosoftMangle.cpp (+1-1) 
- (modified) clang/lib/AST/NSAPI.cpp (+1-1) 
- (modified) clang/lib/AST/PrintfFormatString.cpp (+1-1) 
- (modified) clang/lib/AST/Type.cpp (+2-2) 
- (modified) clang/lib/AST/TypeLoc.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGDebugInfo.h (+2-1) 
- (modified) clang/lib/CodeGen/CodeGenTypes.cpp (+1-1) 
- (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+1-1) 
- (modified) clang/lib/Index/USRGeneration.cpp (+1-1) 
- (modified) clang/lib/Sema/Sema.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaExpr.cpp (+2-2) 
- (modified) clang/lib/Serialization/ASTCommon.cpp (+1-1) 
- (modified) clang/lib/Serialization/ASTReader.cpp (+1-1) 
- (modified) clang/tools/libclang/CIndex.cpp (+1-1) 
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+2-1) 


``diff
diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 1984310df0442e..f46e12a57d4c38 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1197,7 +1197,8 @@ class ASTContext : public RefCountedBase {
 #include "clang/Basic/RISCVVTypes.def"
 #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
 #include "clang/Basic/WebAssemblyReferenceTypes.def"
-#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
+#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align)   
\
+  CanQualType SingletonId;
 #include "clang/Basic/AMDGPUTypes.def"
 #define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
 #include "clang/Basic/HLSLIntangibleTypes.def"
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index dc87b84153e74a..cee4e68fe0dc6d 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -3050,7 +3050,7 @@ class BuiltinType : public Type {
 #define WASM_TYPE(Name, Id, SingletonId) Id,
 #include "clang/Basic/WebAssemblyReferenceTypes.def"
 // AMDGPU types
-#define AMDGPU_TYPE(Name, Id, SingletonId) Id,
+#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) Id,
 #include "clang/Basic/AMDGPUTypes.def"
 // HLSL intangible Types
 #define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) Id,
diff --git a/clang/include/clang/AST/TypeProperties.td 
b/clang/include/clang/AST/TypeProperties.td
index bb7bfa8cd0b76e..d05072607e949c 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -893,7 +893,7 @@ let Class = BuiltinType in {
   case BuiltinType::ID: return ctx.SINGLETON_ID;
 #include "clang/Basic/WebAssemblyReferenceTypes.def"
 
-#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \
+#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID, WIDTH, ALIGN) \
   case BuiltinType::ID: return ctx.SINGLETON_ID;
 #include "clang/Basic/AMDGPUTypes.def"
 
diff --git a/clang/include/clang/Basic/AMDGPUTypes.def 
b/clang/include/clang/Basic/AMDGPUTypes.def
index 7454d61f5dd516..e47e544fdc82c1 100644
--- a/clang/include/clang/Basic/AMDGPUTypes.def
+++ b/clang/include/clang/Basic/AMDGPUTypes.def
@@ -11,11 +11,11 @@
 
//===--===//
 
 #ifndef AMDGPU_OPAQUE_PTR_TYPE
-#define AMDGPU_OPAQUE_PTR_TYPE(Name, AS, Width, Align, Id, SingletonId) \
-  AMDGPU_TYPE(Name, Id, SingletonId)
+#define AMDGPU_OPAQUE_PTR_TYPE(Name, Id, SingletonId, Width, Align, AS) \
+  AMDGPU_TYPE(Name, Id, SingletonId, Width, Align)
 #endif
 
-AMDGPU_OPAQUE_PTR_TYPE("__amdgpu_buffer_rsrc_t", 8, 128, 128, 
AMDGPUBufferRsrc, AMDGPUBufferRsrcTy)
+AMDGPU_OPAQUE_PTR_TYPE("__amdgpu_buffer_rsrc_t", AMDGPUBufferRsrc, 
AMDGPUBufferRsrcTy, 128, 128, 8)
 
 #undef AMDGPU_TYPE
 #undef AMDGPU_OPAQUE_PTR_TYPE
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h 
b/clang/include/clang/Serialization/ASTBitCodes.h
index 4410df296d8efc..8c29f8c0ae5f55 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -1122,7 +1122,7 @@ enum PredefinedTypeIDs {
 #define WASM_TYPE(Name, Id, SingletonId) PREDEF_TYPE_##Id##_I

[clang] [C++20][Modules] NFC Reworked handling of inline for functions defined in-class (PR #109470)

2024-09-23 Thread via cfe-commits

https://github.com/tomasz-kaminski-sonarsource edited 
https://github.com/llvm/llvm-project/pull/109470
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [C++20][Modules] NFC Reworked handling of inline for functions defined in class (PR #109470)

2024-09-23 Thread via cfe-commits

https://github.com/tomasz-kaminski-sonarsource edited 
https://github.com/llvm/llvm-project/pull/109470
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Apply the [[gsl::Owner]] or [[gsl::Pointer]] attributes to the STL template specialization declarations. (PR #109653)

2024-09-23 Thread Haojian Wu via cfe-commits

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

>From ea66fe54a0c820cb5671b0ee10a521da8d483714 Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Mon, 23 Sep 2024 13:50:39 +0200
Subject: [PATCH] [clang] Apply the [[gsl::Owner]] or [[gsl::Pointer]]
 attributes to STL explicit template specialization declarations.

---
 clang/docs/ReleaseNotes.rst |  3 +++
 clang/lib/Sema/SemaTemplate.cpp |  1 +
 .../test/SemaCXX/attr-gsl-owner-pointer-std.cpp | 17 +
 3 files changed, 21 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8f7772baafcdb1..b47e06cb0c5d68 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -273,6 +273,9 @@ Attribute Changes in Clang
   not change the behaviour of the compiler, as this was true for previous
   versions.
 
+- Fix a bug where clang doesn't automatically apply the ``[[gsl::Owner]]`` or
+  ``[[gsl::Pointer]]`` to STL explicit template specialization decls. 
(#GH109442)
+
 Improvements to Clang's diagnostics
 ---
 
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 92274cda15e0b7..99423b01114cc6 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -8631,6 +8631,7 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
 return SkipBody->Previous;
 
   Specialization->setInvalidDecl(Invalid);
+  inferGslOwnerPointerAttribute(Specialization);
   return Specialization;
 }
 
diff --git a/clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp 
b/clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp
index 352e1e473580a6..8fb4cc7621fedf 100644
--- a/clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp
+++ b/clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp
@@ -27,6 +27,11 @@ class vector {
 static_assert(sizeof(vector), "");   // Force instantiation.
 static_assert(sizeof(vector::iterator), ""); // Force instantiation.
 
+template <>
+class vector {};
+// CHECK: ClassTemplateSpecializationDecl {{.*}} vector
+// CHECK: OwnerAttr {{.*}}
+
 // If std::container::iterator is a using declaration, attributes are inferred
 // for the underlying class.
 template 
@@ -173,6 +178,18 @@ class reference_wrapper;
 class some_unknown_type;
 // CHECK: CXXRecordDecl {{.*}} some_unknown_type
 
+using size_t = unsigned;
+inline constexpr size_t dynamic_extent = -1;
+template 
+class span;
+// CHECK: CXXRecordDecl {{.*}} span
+// CHECK: PointerAttr {{.*}}
+
+
+template 
+struct span<_Tp, dynamic_extent> {};
+// CHECK: ClassTemplatePartialSpecializationDecl {{.*}} span
+// CHECK: PointerAttr {{.*}}
 } // namespace std
 
 namespace user {

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


[clang] [C++20][Modules] NFC Reworked handling of inline for functions defined in class (PR #109470)

2024-09-23 Thread via cfe-commits

https://github.com/tomasz-kaminski-sonarsource edited 
https://github.com/llvm/llvm-project/pull/109470
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Driver][AArch64] Add support for aarch64-amazon-linux triple (PR #109263)

2024-09-23 Thread Paul Walker via cfe-commits

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

Whilst I understand the rational for requesting an alternate solution, it feels 
unfair.  If the PR was to add a new OS or Vendor I'd have more sympathy but 
here we're talking about extending the existing OS-Vendor support to cover 
another target (i.e. x86_64-amazon-linux -> aarch64-amazon-linux) and so it 
seems fair to do so using the same method and maintain consistency.


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


[clang] f8f41bf - [clang] Apply the [[gsl::Owner]] or [[gsl::Pointer]] attributes to the STL template specialization declarations. (#109653)

2024-09-23 Thread via cfe-commits

Author: Haojian Wu
Date: 2024-09-23T14:59:30+02:00
New Revision: f8f41bf92c92ebc9b113a2a573d12880b86d5af3

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

LOG: [clang] Apply the [[gsl::Owner]] or [[gsl::Pointer]] attributes to the STL 
template specialization declarations. (#109653)

Fixes #109442

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaTemplate.cpp
clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8f7772baafcdb1..b47e06cb0c5d68 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -273,6 +273,9 @@ Attribute Changes in Clang
   not change the behaviour of the compiler, as this was true for previous
   versions.
 
+- Fix a bug where clang doesn't automatically apply the ``[[gsl::Owner]]`` or
+  ``[[gsl::Pointer]]`` to STL explicit template specialization decls. 
(#GH109442)
+
 Improvements to Clang's diagnostics
 ---
 

diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 92274cda15e0b7..99423b01114cc6 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -8631,6 +8631,7 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
 return SkipBody->Previous;
 
   Specialization->setInvalidDecl(Invalid);
+  inferGslOwnerPointerAttribute(Specialization);
   return Specialization;
 }
 

diff  --git a/clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp 
b/clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp
index 352e1e473580a6..8fb4cc7621fedf 100644
--- a/clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp
+++ b/clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp
@@ -27,6 +27,11 @@ class vector {
 static_assert(sizeof(vector), "");   // Force instantiation.
 static_assert(sizeof(vector::iterator), ""); // Force instantiation.
 
+template <>
+class vector {};
+// CHECK: ClassTemplateSpecializationDecl {{.*}} vector
+// CHECK: OwnerAttr {{.*}}
+
 // If std::container::iterator is a using declaration, attributes are inferred
 // for the underlying class.
 template 
@@ -173,6 +178,18 @@ class reference_wrapper;
 class some_unknown_type;
 // CHECK: CXXRecordDecl {{.*}} some_unknown_type
 
+using size_t = unsigned;
+inline constexpr size_t dynamic_extent = -1;
+template 
+class span;
+// CHECK: CXXRecordDecl {{.*}} span
+// CHECK: PointerAttr {{.*}}
+
+
+template 
+struct span<_Tp, dynamic_extent> {};
+// CHECK: ClassTemplatePartialSpecializationDecl {{.*}} span
+// CHECK: PointerAttr {{.*}}
 } // namespace std
 
 namespace user {



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


[clang] [clang] Apply the [[gsl::Owner]] or [[gsl::Pointer]] attributes to the STL template specialization declarations. (PR #109653)

2024-09-23 Thread Haojian Wu via cfe-commits

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


[clang] [analyzer][StackAddrEscapeChecker] Fix assert failure for alloca regions (PR #109655)

2024-09-23 Thread Donát Nagy via cfe-commits


@@ -1,4 +1,9 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify 
%s -Wno-undefined-bool-conversion
+// RUN: %clang_analyze_cc1 \
+// RUN:   -analyzer-checker=core,debug.ExprInspection,unix.Malloc \
+// RUN:   -verify %s \
+// RUN:   -Wno-undefined-bool-conversion
+// unix.Malloc is necessary to model __builtin_alloca,
+// which could trigger an "unexpected region" bug in StackAddrEscapeChecker.

NagyDonat wrote:

Malloc / etc. modeling should not be a dependency of `StackAddrEscapeChecker` 
(and  in particular the `unix.Malloc` part of `MallocChecker` cannot be a 
strong dependency of anything, because it can generate reports, while only 
modeling checkers may be dependencies of other checkers). 

I don't think that we __need__ a separate testcase to see that 
`StackAddrEscapeChecker` does not crash on `__builtin_alloca` when 
`unix.Malloc` is not enabled -- the reason for this crash was that 
`unix.Malloc` introduced an unusual region type (`AllocaRegion`) and without 
that modeling the return value of `__builtin_alloca` is just a generic conjured 
region which should be already covered by the many other testcases. However, 
I'm not opposed to adding that testcase if you would like to see it.

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


[clang] [Clang][Driver][AArch64] Add support for aarch64-amazon-linux triple (PR #109263)

2024-09-23 Thread Paul Walker via cfe-commits

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


[clang] [clang] Lifetime of locals must end before musttail call (PR #109255)

2024-09-23 Thread Haojian Wu via cfe-commits

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

Thanks, still looks good.

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


[clang] [RISCV][FMV] Support target_version (PR #99040)

2024-09-23 Thread Piyou Chen via cfe-commits

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


[clang] 0b0a37e - [clang] Lifetime of locals must end before musttail call (#109255)

2024-09-23 Thread via cfe-commits

Author: Oliver Stannard
Date: 2024-09-23T10:04:08+01:00
New Revision: 0b0a37e158bcf6d0667b4744b3d335f91578e0c9

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

LOG: [clang] Lifetime of locals must end before musttail call (#109255)

The lifetimes of local variables and function parameters must end before
the call to a [[clang::musttail]] function, instead of before the
return, because we will not have a stack frame to hold them when doing
the call.

This documents this limitation, and adds diagnostics to warn about some
code which is invalid because of it.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/CheckExprLifetime.cpp
clang/lib/Sema/CheckExprLifetime.h
clang/lib/Sema/SemaStmt.cpp
clang/test/SemaCXX/attr-musttail.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index da5205087fd821..8f7772baafcdb1 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -268,6 +268,11 @@ Attribute Changes in Clang
 - Introduced a new attribute ``[[clang::coro_await_elidable_argument]]`` on 
function parameters
   to propagate safe elide context to arguments if such function is also under 
a safe elide context.
 
+- The documentation of the ``[[clang::musttail]]`` attribute was updated to
+  note that the lifetimes of all local variables end before the call. This does
+  not change the behaviour of the compiler, as this was true for previous
+  versions.
+
 Improvements to Clang's diagnostics
 ---
 
@@ -324,6 +329,10 @@ Improvements to Clang's diagnostics
 
 - Don't emit bogus dangling diagnostics when ``[[gsl::Owner]]`` and 
`[[clang::lifetimebound]]` are used together (#GH108272).
 
+- The ``-Wreturn-stack-address`` warning now also warns about addresses of
+  local variables passed to function calls using the ``[[clang::musttail]]``
+  attribute.
+
 Improvements to Clang's time-trace
 --
 

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 8ef151b3f2fddb..f23a148e546fa3 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -637,6 +637,12 @@ return value must be trivially destructible. The calling 
convention of the
 caller and callee must match, and they must not be variadic functions or have
 old style K&R C function declarations.
 
+The lifetimes of all local variables and function parameters end immediately
+before the call to the function. This means that it is undefined behaviour to
+pass a pointer or reference to a local variable to the called function, which
+is not the case without the attribute. Clang will emit a warning in common
+cases where this happens.
+
 ``clang::musttail`` provides assurances that the tail call can be optimized on
 all targets, not just one.
   }];

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index ba813af960af6f..e4e04bff8b5120 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10101,11 +10101,15 @@ def err_lifetimebound_ctor_dtor : Error<
 // CHECK: returning address/reference of stack memory
 def warn_ret_stack_addr_ref : Warning<
   "%select{address of|reference to}0 stack memory associated with "
-  "%select{local variable|parameter|compound literal}2 %1 returned">,
+  "%select{local variable|parameter|compound literal}2 %1 "
+  "%select{returned|passed to musttail function}3">,
   InGroup;
 def warn_ret_local_temp_addr_ref : Warning<
   "returning %select{address of|reference to}0 local temporary object">,
   InGroup;
+def warn_musttail_local_temp_addr_ref : Warning<
+  "passing %select{address of|reference to}0 local temporary object to 
musttail function">,
+  InGroup;
 def err_ret_local_temp_ref : Error<
   "returning reference to local temporary object">;
 def warn_ret_addr_label : Warning<

diff  --git a/clang/lib/Sema/CheckExprLifetime.cpp 
b/clang/lib/Sema/CheckExprLifetime.cpp
index c98fbca849faba..e9e39c11ffbaab 100644
--- a/clang/lib/Sema/CheckExprLifetime.cpp
+++ b/clang/lib/Sema/CheckExprLifetime.cpp
@@ -33,6 +33,10 @@ enum LifetimeKind {
   /// the entity is a return object.
   LK_Return,
 
+  /// The lifetime of a temporary bound to this entity ends too soon, because
+  /// the entity passed to a musttail function call.
+  LK_MustTail,
+
   /// The lifetime of a temporary bound to this entity ends too soon, because
   /// the entity is the result of a statement expression.
   LK_StmtExprResult,
@@ -1150,6 +1154,7 @@ static void checkExprLifetimeImpl(Sema

[clang] [clang] Lifetime of locals must end before musttail call (PR #109255)

2024-09-23 Thread Oliver Stannard via cfe-commits

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


[clang] [llvm] [CMake] Preserve clang-prebolt (PR #109351)

2024-09-23 Thread Madhur Amilkanthwar via cfe-commits

madhur13490 wrote:

Here are CMAKE variables we use downstream. 
```
-DLLVM_ENABLE_PROJECTS=bolt;clang;openmp;lld




-DLLVM_ENABLE_RUNTIMES=compiler-rt  




-DLLVM_TARGETS_TO_BUILD=AArch64 




-DCLANG_DEFAULT_LINKER=lld  




-DCMAKE_BUILD_TYPE=Release  









-C ../clang/cmake/caches/BOLT-PGO.cmake 



  
-DBOOTSTRAP_LLVM_ENABLE_LLD=ON  




-DBOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_LLD=ON




-DBOOTSTRAP_CLANG_DEFAULT_LINKER=lld




-DBOOTSTRAP_BOOTSTRAP_CLANG_DEFAULT_LINKER=lld  




-DPGO_INSTRUMENT_LTO=Thin   




-DCLANG_BOOTSTRAP_PASSTHROUGH=CMAKE_INSTALL_PREFIX;LLVM_TARGETS_TO_BUILD;CMAKE_BUILD_TYPE;
  
 
```

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


[clang] [clang-repl] Simplify the value printing logic to enable out-of-process. (PR #107737)

2024-09-23 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev updated 
https://github.com/llvm/llvm-project/pull/107737

>From 2aa7527b52656d064c39aec94c9f1001ed10f7d8 Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Fri, 6 Sep 2024 09:52:36 +
Subject: [PATCH 1/5] [clang-repl] Simplify the value printing logic to enable
 out-of-process.

This patch improves the design of the IncrementalParser and Interpreter classes.
Now the incremental parser is only responsible for building the partial
translation unit declaration and the AST, while the Interpreter fills in the
lower level llvm::Module and other JIT-related infrastructure. Finally the
Interpreter class now orchestrates the AST and the LLVM IR with the
IncrementalParser and IncrementalExecutor classes.

The design improvement allows us to rework some of the logic that extracts an
interpreter value into the clang::Value object. The new implementation
simplifies use-cases which are used for out-of-process execution by allowing
interpreter to be inherited or customized with an clang::ASTConsumer.

This change will enable completing the pretty printing work which is in
llvm/llvm-project#84769
---
 .../clang/Frontend/MultiplexConsumer.h|   3 +-
 clang/include/clang/Interpreter/Interpreter.h |  53 +-
 clang/lib/Frontend/MultiplexConsumer.cpp  |   7 +
 clang/lib/Interpreter/CMakeLists.txt  |   1 +
 clang/lib/Interpreter/DeviceOffload.cpp   |  10 +-
 clang/lib/Interpreter/DeviceOffload.h |  14 +-
 clang/lib/Interpreter/IncrementalExecutor.cpp |   2 +-
 clang/lib/Interpreter/IncrementalParser.cpp   | 253 +--
 clang/lib/Interpreter/IncrementalParser.h |  45 +-
 clang/lib/Interpreter/Interpreter.cpp | 648 ++
 .../Interpreter/InterpreterValuePrinter.cpp   | 400 +++
 .../Interpreter/CodeCompletionTest.cpp|   2 +-
 .../Interpreter/InterpreterExtensionsTest.cpp |  64 +-
 13 files changed, 707 insertions(+), 795 deletions(-)
 create mode 100644 clang/lib/Interpreter/InterpreterValuePrinter.cpp

diff --git a/clang/include/clang/Frontend/MultiplexConsumer.h 
b/clang/include/clang/Frontend/MultiplexConsumer.h
index 3a7670d7a51aa6..b190750bb29fb8 100644
--- a/clang/include/clang/Frontend/MultiplexConsumer.h
+++ b/clang/include/clang/Frontend/MultiplexConsumer.h
@@ -53,6 +53,7 @@ class MultiplexConsumer : public SemaConsumer {
 public:
   // Takes ownership of the pointers in C.
   MultiplexConsumer(std::vector> C);
+  MultiplexConsumer(std::unique_ptr C);
   ~MultiplexConsumer() override;
 
   // ASTConsumer
@@ -80,7 +81,7 @@ class MultiplexConsumer : public SemaConsumer {
   void InitializeSema(Sema &S) override;
   void ForgetSema() override;
 
-private:
+protected:
   std::vector> Consumers; // Owns these.
   std::unique_ptr MutationListener;
   std::unique_ptr DeserializationListener;
diff --git a/clang/include/clang/Interpreter/Interpreter.h 
b/clang/include/clang/Interpreter/Interpreter.h
index 1234608bb58647..cbb1cfd4ab02a8 100644
--- a/clang/include/clang/Interpreter/Interpreter.h
+++ b/clang/include/clang/Interpreter/Interpreter.h
@@ -14,11 +14,9 @@
 #ifndef LLVM_CLANG_INTERPRETER_INTERPRETER_H
 #define LLVM_CLANG_INTERPRETER_INTERPRETER_H
 
-#include "clang/AST/Decl.h"
 #include "clang/AST/GlobalDecl.h"
 #include "clang/Interpreter/PartialTranslationUnit.h"
 #include "clang/Interpreter/Value.h"
-#include "clang/Sema/Ownership.h"
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ExecutionEngine/JITSymbol.h"
@@ -38,6 +36,9 @@ class ThreadSafeContext;
 namespace clang {
 
 class CompilerInstance;
+class CodeGenerator;
+class CXXRecordDecl;
+class Decl;
 class IncrementalExecutor;
 class IncrementalParser;
 
@@ -77,26 +78,27 @@ class IncrementalCompilerBuilder {
   llvm::StringRef CudaSDKPath;
 };
 
-/// Generate glue code between the Interpreter's built-in runtime and user 
code.
-class RuntimeInterfaceBuilder {
-public:
-  virtual ~RuntimeInterfaceBuilder() = default;
-
-  using TransformExprFunction = ExprResult(RuntimeInterfaceBuilder *Builder,
-   Expr *, ArrayRef);
-  virtual TransformExprFunction *getPrintValueTransformer() = 0;
-};
+class IncrementalAction;
+class InProcessPrintingASTConsumer;
 
 /// Provides top-level interfaces for incremental compilation and execution.
 class Interpreter {
+  friend class Value;
+  friend InProcessPrintingASTConsumer;
+
   std::unique_ptr TSCtx;
+  /// Long-lived, incremental parsing action.
+  std::unique_ptr Act;
   std::unique_ptr IncrParser;
   std::unique_ptr IncrExecutor;
-  std::unique_ptr RuntimeIB;
 
   // An optional parser for CUDA offloading
   std::unique_ptr DeviceParser;
 
+  /// List containing every information about every incrementally parsed piece
+  /// of code.
+  std::list PTUs;
+
   unsigned InitPTUSize = 0;
 
   // This member holds the last result of the value printing. It's a class
@@ -104,15 +106,15 @@ class Interpreter {
   // printing happens, it's in an invalid state.
   Value LastValue;
 
-  // Add

[clang] 898fd39 - [clang][bytecode] Check allocation size limit for operator new (#109590)

2024-09-23 Thread via cfe-commits

Author: Timm Baeder
Date: 2024-09-23T09:59:41+02:00
New Revision: 898fd396b836600ef857464941220d07894b859b

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

LOG: [clang][bytecode] Check allocation size limit for operator new (#109590)

Added: 


Modified: 
clang/lib/AST/ByteCode/InterpBuiltin.cpp
clang/lib/AST/ByteCode/InterpFrame.cpp
clang/test/AST/ByteCode/new-delete.cpp

Removed: 




diff  --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 51c77b7da1a655..523f5cb993dbc7 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1306,7 +1306,16 @@ static bool interp__builtin_operator_new(InterpState &S, 
CodePtr OpPC,
 return false;
   }
 
-  // FIXME: CheckArraySize for NumElems?
+  // NB: The same check we're using in CheckArraySize()
+  if (NumElems.getActiveBits() >
+  ConstantArrayType::getMaxSizeBits(S.getASTContext()) ||
+  NumElems.ugt(Descriptor::MaxArrayElemBytes / ElemSize.getQuantity())) {
+// FIXME: NoThrow check?
+const SourceInfo &Loc = S.Current->getSource(OpPC);
+S.FFDiag(Loc, diag::note_constexpr_new_too_large)
+<< NumElems.getZExtValue();
+return false;
+  }
 
   std::optional ElemT = S.getContext().classify(ElemType);
   DynamicAllocator &Allocator = S.getAllocator();

diff  --git a/clang/lib/AST/ByteCode/InterpFrame.cpp 
b/clang/lib/AST/ByteCode/InterpFrame.cpp
index 28e189bb339e62..7c877a70fe6b97 100644
--- a/clang/lib/AST/ByteCode/InterpFrame.cpp
+++ b/clang/lib/AST/ByteCode/InterpFrame.cpp
@@ -102,14 +102,26 @@ static void print(llvm::raw_ostream &OS, const T &V, 
ASTContext &ASTCtx,
   V.toAPValue(ASTCtx).printPretty(OS, ASTCtx, Ty);
 }
 
+static bool shouldSkipInBacktrace(const Function *F) {
+  if (F->isBuiltin())
+return true;
+  if (F->isLambdaStaticInvoker())
+return true;
+
+  const FunctionDecl *FD = F->getDecl();
+  if (FD->getDeclName().getCXXOverloadedOperator() == OO_New ||
+  FD->getDeclName().getCXXOverloadedOperator() == OO_Array_New)
+return true;
+  return false;
+}
+
 void InterpFrame::describe(llvm::raw_ostream &OS) const {
   // We create frames for builtin functions as well, but we can't reliably
   // diagnose them. The 'in call to' diagnostics for them add no value to the
   // user _and_ it doesn't generally work since the argument types don't always
   // match the function prototype. Just ignore them.
   // Similarly, for lambda static invokers, we would just print __invoke().
-  if (const auto *F = getFunction();
-  F && (F->isBuiltin() || F->isLambdaStaticInvoker()))
+  if (const auto *F = getFunction(); F && shouldSkipInBacktrace(F))
 return;
 
   const Expr *CallExpr = Caller->getExpr(getRetPC());

diff  --git a/clang/test/AST/ByteCode/new-delete.cpp 
b/clang/test/AST/ByteCode/new-delete.cpp
index 2ba1286b250dc6..6cefbba307215a 100644
--- a/clang/test/AST/ByteCode/new-delete.cpp
+++ b/clang/test/AST/ByteCode/new-delete.cpp
@@ -592,7 +592,8 @@ namespace std {
   using size_t = decltype(sizeof(0));
   template struct allocator {
 constexpr T *allocate(size_t N) {
-  return (T*)__builtin_operator_new(sizeof(T) * N); // both-note 
2{{allocation performed here}}
+  return (T*)__builtin_operator_new(sizeof(T) * N); // both-note 
2{{allocation performed here}} \
+// #alloc
 }
 constexpr void deallocate(void *p) {
   __builtin_operator_delete(p); // both-note 
2{{std::allocator<...>::deallocate' used to delete pointer to object allocated 
with 'new'}} \
@@ -731,6 +732,30 @@ namespace Limits {
 return n;
   }
   static_assert(dynarray(5, 0) == 'f');
+
+
+#if __LP64__
+  template 
+  struct S {
+  constexpr S(unsigned long long N)
+  : data(nullptr){
+  data = alloc.allocate(N); // both-note {{in call to 
'this->alloc.allocate(18446744073709551615)}}
+  }
+  constexpr T operator[](std::size_t i) const {
+return data[i];
+  }
+
+  constexpr ~S() {
+  alloc.deallocate(data);
+  }
+  std::allocator alloc;
+  T* data;
+  };
+
+  constexpr std::size_t s = S(~0UL)[42]; // both-error 
{{constexpr variable 's' must be initialized by a constant expression}} \
+  // both-note@#alloc 
{{cannot allocate array; evaluated array bound 2305843009213693951 is too 
large}} \
+  // both-note {{in call 
to}}
+#endif
 }
 
 #else



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


[clang] [clang][bytecode] Check allocation size limit for operator new (PR #109590)

2024-09-23 Thread Timm Baeder via cfe-commits

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


[clang] [llvm] [Clang][LLVM][AArch64] Add intrinsic for LUTI4 SME2 instruction (PR #97755)

2024-09-23 Thread via cfe-commits


@@ -350,3 +350,8 @@ void test_svdot_multi_za32_bad_lane(uint32_t slice_base, 
svuint16_t z_u16,
   svsudot_lane_za32_s8_vg1x2(slice_base, z_s8x2, z_u8, 4); // expected-error 
{{argument value 4 is outside the valid range [0, 3]}}
   svsudot_lane_za32_s8_vg1x4(slice_base, z_s8x4, z_u8, 4); // expected-error 
{{argument value 4 is outside the valid range [0, 3]}}
 }
+
+void test_luti4_zt_x4(svuint8x2_t op) __arm_streaming __arm_in("zt0") {
+  // Check Zt tile 0
+  svluti4_zt_u8_x4(1, op);  // expected-error {{argument value 1 is outside 
the valid range [0, 0]}}

CarolineConcatto wrote:

I believe the positive tests are already in the codegen 
sme2-intrinsics-write-zt.ll
test_luti4_zt_u8_x.
I will not add, because I dont see positive tests here too.

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


[clang] [llvm] [Clang][LLVM][AArch64] Add intrinsic for LUTI4 SME2 instruction (PR #97755)

2024-09-23 Thread via cfe-commits


@@ -5415,6 +5423,11 @@ void AArch64DAGToDAGISel::Select(SDNode *Node) {
 SelectMultiVectorLuti(Node, 2, Opc, 3);
   return;
 }
+case Intrinsic::aarch64_sme_luti4_zt_x4: {
+  // Does not have immediate but it has 2ZPR input
+  SelectMultiVectorLuti(Node, 4, AArch64::LUTI4_4ZZT2Z, 0, true);

CarolineConcatto wrote:

I create a SelectMultiVectorLutiLane and a SelectMultiVectorLuti.

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


[clang] [llvm] [Clang][LLVM][AArch64] Add intrinsic for LUTI4 SME2 instruction (PR #97755)

2024-09-23 Thread via cfe-commits


@@ -410,7 +410,7 @@ class AArch64DAGToDAGISel : public SelectionDAGISel {
   }
 
   void SelectMultiVectorLuti(SDNode *Node, unsigned NumOutVecs, unsigned Opc,
- uint32_t MaxImm);
+ uint32_t MaxImm, bool IsMultiVector = false);

CarolineConcatto wrote:

There are 2 functions now, one for lane and without. So this is not used 
anymore.

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


[clang] [Clang][Driver] Add option to provide path for multilib's YAML config file (PR #109640)

2024-09-23 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Lucas Duarte Prates (pratlucas)


Changes

Since the introduction of the use of a YAML file to configure the
selection of multilibs for baremetal, the path for that file has been
hardcoded into the clang driver code. This makes it difficult to provide
any alternative configurations for multilib and, by consequence, impacts
the tetability of any changes related to it - e.g. the existing multilib
YAML tests currently rely on creating fake toolchain directories to
inject their own configuration files.

This change introduces a new command line option to the clang driver,
`--multi-lib-config=`, to enable the use of a custom path to be used
when loading the multilib YAML config file. It also updates the existing
multilib YAML tests to use the new option.


---

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


9 Files Affected:

- (modified) clang/include/clang/Driver/Options.td (+3) 
- (modified) clang/lib/Driver/ToolChains/BareMetal.cpp (+7) 
- (added) clang/test/Driver/Inputs/multilib/empty.yaml (+8) 
- (modified) clang/test/Driver/baremetal-multilib-custom-error.yaml (+5-12) 
- (modified) clang/test/Driver/baremetal-multilib-exclusive-group.yaml (+6-14) 
- (modified) clang/test/Driver/baremetal-multilib-group-error.yaml (+1-9) 
- (modified) clang/test/Driver/baremetal-multilib-layered.yaml (+4-10) 
- (modified) clang/test/Driver/baremetal-multilib.yaml (+7-14) 
- (modified) clang/test/Driver/print-multi-selection-flags.c (+19-19) 


``diff
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 002f60350543d9..ac95acd1e854a3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5546,6 +5546,9 @@ def mthumb : Flag<["-"], "mthumb">, Group;
 def mtune_EQ : Joined<["-"], "mtune=">, Group,
   Visibility<[ClangOption, FlangOption]>,
   HelpText<"Only supported on AArch64, PowerPC, RISC-V, SPARC, SystemZ, and 
X86">;
+def multi_lib_config : Joined<["-", "--"], "multi-lib-config=">,
+  HelpText<"Path to the YAML configuration file to be used for multilib 
selection">,
+  MetaVarName<"">;
 def multi__module : Flag<["-"], "multi_module">;
 def multiply__defined__unused : Separate<["-"], "multiply_defined_unused">;
 def multiply__defined : Separate<["-"], "multiply_defined">;
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 8aed9ed6e18817..124acdd0a66a20 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -172,6 +172,13 @@ static bool isPPCBareMetal(const llvm::Triple &Triple) {
 static void findMultilibsFromYAML(const ToolChain &TC, const Driver &D,
   StringRef MultilibPath, const ArgList &Args,
   DetectedMultilibs &Result) {
+  if (Arg *ConfigFileArg = Args.getLastArg(options::OPT_multi_lib_config)) {
+MultilibPath = ConfigFileArg->getValue();
+if (!D.getVFS().exists(MultilibPath)) {
+  D.Diag(clang::diag::err_drv_no_such_file) << MultilibPath.str();
+  return;
+}
+  }
   llvm::ErrorOr> MB =
   D.getVFS().getBufferForFile(MultilibPath);
   if (!MB)
diff --git a/clang/test/Driver/Inputs/multilib/empty.yaml 
b/clang/test/Driver/Inputs/multilib/empty.yaml
new file mode 100644
index 00..82c476a13367cd
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib/empty.yaml
@@ -0,0 +1,8 @@
+
+MultilibVersion: 1.0
+
+Variants:
+
+Mappings:
+
+...
diff --git a/clang/test/Driver/baremetal-multilib-custom-error.yaml 
b/clang/test/Driver/baremetal-multilib-custom-error.yaml
index c006bb4072ce2f..151eece9f69954 100644
--- a/clang/test/Driver/baremetal-multilib-custom-error.yaml
+++ b/clang/test/Driver/baremetal-multilib-custom-error.yaml
@@ -1,35 +1,28 @@
 # REQUIRES: shell
 # UNSUPPORTED: system-windows
 
-# RUN: rm -rf %t
-# RUN: mkdir -p %t/bin
-# RUN: mkdir -p %t/lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/lib
-# RUN: touch 
%t/lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/lib/libclang_rt.builtins.a
-# RUN: ln -s %clang %t/bin/clang
-# RUN: ln -s %s %t/lib/clang-runtimes/multilib.yaml
-
-# RUN: %t/bin/clang -no-canonical-prefixes -print-multi-directory 2>&1 \
+# RUN: %clang --multi-lib-config=%s -no-canonical-prefixes 
-print-multi-directory 2>&1 \
 # RUN: --target=thumbv8m.main-none-eabi -march=armv8.1m.main --sysroot= \
 # RUN:   | FileCheck 
--check-prefix=CHECK-PRINT-MULTI-DIRECTORY-NOMVE-SOFTFLOAT %s
 # CHECK-PRINT-MULTI-DIRECTORY-NOMVE-SOFTFLOAT: nomve-softfloat
 
-# RUN: not %t/bin/clang -no-canonical-prefixes -print-multi-directory 2>&1 \
+# RUN: not %clang --multi-lib-config=%s -no-canonical-prefixes 
-print-multi-directory 2>&1 \
 # RUN: --target=thumbv8m.main-none-eabi -march=armv8.1m.main+mve 
--sysroot= \
 # RUN:   | FileCheck --check-prefix=CHECK-ERROR %s
 # CHE

[clang] [Clang][Driver] Add option to provide path for multilib's YAML config file (PR #109640)

2024-09-23 Thread Lucas Duarte Prates via cfe-commits

https://github.com/pratlucas created 
https://github.com/llvm/llvm-project/pull/109640

Since the introduction of the use of a YAML file to configure the
selection of multilibs for baremetal, the path for that file has been
hardcoded into the clang driver code. This makes it difficult to provide
any alternative configurations for multilib and, by consequence, impacts
the tetability of any changes related to it - e.g. the existing multilib
YAML tests currently rely on creating fake toolchain directories to
inject their own configuration files.

This change introduces a new command line option to the clang driver,
`--multi-lib-config=`, to enable the use of a custom path to be used
when loading the multilib YAML config file. It also updates the existing
multilib YAML tests to use the new option.


>From 45a02861ec0a8e50a57a733118e037cdd0bbafbc Mon Sep 17 00:00:00 2001
From: Lucas Prates 
Date: Mon, 23 Sep 2024 09:25:20 +0100
Subject: [PATCH] [Clang][Driver] Add option to provide path for multilib's
 YAML config file

Since the introduction of the use of a YAML file to configure the
selection of multilibs for baremetal, the path for that file has been
hardcoded into the clang driver code. This makes it difficult to provide
any alternative configurations for multilib and, by consequence, impacts
the tetability of any changes related to it - e.g. the existing multilib
YAML tests currently rely on creating fake toolchain directories to
inject their own configuration files.

This change introduces a new command line option to the clang driver,
`--multi-lib-config=`, to enable the use of a custom path to be used
when loading the multilib YAML config file. It also updates the existing
multilib YAML tests to use the new option.
---
 clang/include/clang/Driver/Options.td |  3 ++
 clang/lib/Driver/ToolChains/BareMetal.cpp |  7 
 clang/test/Driver/Inputs/multilib/empty.yaml  |  8 
 .../baremetal-multilib-custom-error.yaml  | 17 +++--
 .../baremetal-multilib-exclusive-group.yaml   | 20 +++---
 .../baremetal-multilib-group-error.yaml   | 10 +
 .../Driver/baremetal-multilib-layered.yaml| 14 ++-
 clang/test/Driver/baremetal-multilib.yaml | 21 --
 .../test/Driver/print-multi-selection-flags.c | 38 +--
 9 files changed, 60 insertions(+), 78 deletions(-)
 create mode 100644 clang/test/Driver/Inputs/multilib/empty.yaml

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 002f60350543d9..ac95acd1e854a3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5546,6 +5546,9 @@ def mthumb : Flag<["-"], "mthumb">, Group;
 def mtune_EQ : Joined<["-"], "mtune=">, Group,
   Visibility<[ClangOption, FlangOption]>,
   HelpText<"Only supported on AArch64, PowerPC, RISC-V, SPARC, SystemZ, and 
X86">;
+def multi_lib_config : Joined<["-", "--"], "multi-lib-config=">,
+  HelpText<"Path to the YAML configuration file to be used for multilib 
selection">,
+  MetaVarName<"">;
 def multi__module : Flag<["-"], "multi_module">;
 def multiply__defined__unused : Separate<["-"], "multiply_defined_unused">;
 def multiply__defined : Separate<["-"], "multiply_defined">;
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 8aed9ed6e18817..124acdd0a66a20 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -172,6 +172,13 @@ static bool isPPCBareMetal(const llvm::Triple &Triple) {
 static void findMultilibsFromYAML(const ToolChain &TC, const Driver &D,
   StringRef MultilibPath, const ArgList &Args,
   DetectedMultilibs &Result) {
+  if (Arg *ConfigFileArg = Args.getLastArg(options::OPT_multi_lib_config)) {
+MultilibPath = ConfigFileArg->getValue();
+if (!D.getVFS().exists(MultilibPath)) {
+  D.Diag(clang::diag::err_drv_no_such_file) << MultilibPath.str();
+  return;
+}
+  }
   llvm::ErrorOr> MB =
   D.getVFS().getBufferForFile(MultilibPath);
   if (!MB)
diff --git a/clang/test/Driver/Inputs/multilib/empty.yaml 
b/clang/test/Driver/Inputs/multilib/empty.yaml
new file mode 100644
index 00..82c476a13367cd
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib/empty.yaml
@@ -0,0 +1,8 @@
+
+MultilibVersion: 1.0
+
+Variants:
+
+Mappings:
+
+...
diff --git a/clang/test/Driver/baremetal-multilib-custom-error.yaml 
b/clang/test/Driver/baremetal-multilib-custom-error.yaml
index c006bb4072ce2f..151eece9f69954 100644
--- a/clang/test/Driver/baremetal-multilib-custom-error.yaml
+++ b/clang/test/Driver/baremetal-multilib-custom-error.yaml
@@ -1,35 +1,28 @@
 # REQUIRES: shell
 # UNSUPPORTED: system-windows
 
-# RUN: rm -rf %t
-# RUN: mkdir -p %t/bin
-# RUN: mkdir -p %t/lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/lib
-# RUN: touch 
%t/lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/lib/libclang_

[clang] [compiler-rt] [llvm] [PGO] Initialize GOV Writeout and Reset Functions in the Runtime on AIX (PR #108570)

2024-09-23 Thread Rainer Orth via cfe-commits

rorth wrote:

I've now tested the patch on both `sparcv9-sun-solaris2.11` and 
`amd64-pc-solaris2.11`: no failures.

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


[clang] [llvm] [AArch64] Implement intrinsics for SME2 FSCALE (PR #100128)

2024-09-23 Thread via cfe-commits

https://github.com/Lukacma updated 
https://github.com/llvm/llvm-project/pull/100128

>From ea280c4177aa64c29a921ea40c95fc7024ce24ed Mon Sep 17 00:00:00 2001
From: Marian Lukac 
Date: Tue, 23 Jul 2024 14:11:49 +
Subject: [PATCH 1/2] [AArch64] Implement intrinsics for SME2 FSCALE

---
 clang/include/clang/Basic/arm_sve.td  |  10 +
 .../acle_sme2_fp8_scale.c | 452 ++
 llvm/include/llvm/IR/IntrinsicsAArch64.td |  25 +
 .../Target/AArch64/AArch64ISelDAGToDAG.cpp|  28 ++
 .../CodeGen/AArch64/sme2-intrinsics-fscale.ll | 186 +++
 5 files changed, 701 insertions(+)
 create mode 100644 
clang/test/CodeGen/aarch64-fp8-intrinsics/acle_sme2_fp8_scale.c
 create mode 100644 llvm/test/CodeGen/AArch64/sme2-intrinsics-fscale.ll

diff --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index 94c093d8911562..2fb93e091aa5c1 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -2377,6 +2377,16 @@ let SVETargetGuard = InvalidMode, SMETargetGuard = 
"sme2" in {
   def SVUUNPK_X4 : SInst<"svunpk_{d}[_{3}_x4]", "42.h", "UsUiUl", MergeNone, 
"aarch64_sve_uunpk_x4", [IsStreaming], []>;
 }
 
+//
+// Multi-vector scaling
+//
+let  SVETargetGuard = InvalidMode, SMETargetGuard = "sme2,fp8" in {
+  def FSCALE_SINGLE_X2 : Inst<"svscale[_single_{d}_x2]", "22x", "fhd", 
MergeNone, "aarch64_sme_fp8_scale_single_x2", [IsStreaming],[]>;
+  def FSCALE_SINGLE_X4 : Inst<"svscale[_single_{d}_x4]", "44x", "fhd", 
MergeNone, "aarch64_sme_fp8_scale_single_x4", [IsStreaming],[]>;
+  def FSCALE_X2 : Inst<"svscale[_{d}_x2]", "222.x", "fhd", MergeNone, 
"aarch64_sme_fp8_scale_x2", [IsStreaming],[]>;
+  def FSCALE_X4 : Inst<"svscale[_{d}_x4]", "444.x", "fhd", MergeNone, 
"aarch64_sme_fp8_scale_x4", [IsStreaming],[]>;
+}
+
 let SVETargetGuard = "sve2p1", SMETargetGuard = "sme2" in {
 // == BFloat16 multiply-subtract ==
   def SVBFMLSLB : SInst<"svbfmlslb[_{d}]", "dd$$", "f", MergeNone, 
"aarch64_sve_bfmlslb", [IsOverloadNone, VerifyRuntimeMode], []>;
diff --git a/clang/test/CodeGen/aarch64-fp8-intrinsics/acle_sme2_fp8_scale.c 
b/clang/test/CodeGen/aarch64-fp8-intrinsics/acle_sme2_fp8_scale.c
new file mode 100644
index 00..b733e772ba3075
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-fp8-intrinsics/acle_sme2_fp8_scale.c
@@ -0,0 +1,452 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme 
-target-feature +sme2 -target-feature +fp8 -disable-O0-optnone -Werror -Wall 
-emit-llvm -o - %s | opt -S -passes=mem2reg,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme 
-target-feature +sme2 -target-feature +fp8 -disable-O0-optnone -Werror -Wall 
-emit-llvm -o - -x c++ %s | opt -S -passes=mem2reg,tailcallelim | FileCheck %s 
-check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sme -target-feature +sme2 -target-feature +fp8 
-disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S 
-passes=mem2reg,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sme -target-feature +sme2 -target-feature +fp8 
-disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S 
-passes=mem2reg,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme 
-target-feature +sme2 -target-feature +fp8 -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) A1
+#else
+#define SVE_ACLE_FUNC(A1,A2) A1##A2
+#endif
+
+
+// Single x2
+// CHECK-LABEL: @test_svscale_single_f16_x2(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.vector.extract.nxv8f16.nxv16f16( [[OP1:%.*]], i64 0)
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  
@llvm.vector.extract.nxv8f16.nxv16f16( [[OP1]], i64 8)
+// CHECK-NEXT:[[TMP2:%.*]] = tail call { ,  } @llvm.aarch64.sme.fp8.scale.single.x2.nxv8f16( 
[[TMP0]],  [[TMP1]],  [[OP2:%.*]])
+// CHECK-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP2]], 0
+// CHECK-NEXT:[[TMP4:%.*]] = tail call  
@llvm.vector.insert.nxv16f16.nxv8f16( poison,  [[TMP3]], i64 0)
+// CHECK-NEXT:[[TMP5:%.*]] = extractvalue { ,  } [[TMP2]], 1
+// CHECK-NEXT:[[TMP6:%.*]] = tail call  
@llvm.vector.insert.nxv16f16.nxv8f16( [[TMP4]],  [[TMP5]], i64 8)
+// CHECK-NEXT:ret  [[TMP6]]
+//
+// CPP-CHECK-LABEL: 
@_Z26test_svscale_single_f16_x213svfloat16x2_tu11__SVInt16_t(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.vector.extract.nxv8f16.nxv16f16( [[OP1:%.*]], i64 0)
+// CPP-CHECK-NEXT:[[TMP1:%.*]] = tail call  
@llvm.vector.extract.nxv8f16.nx

[clang-tools-extra] Add clang-tidy external examples (PR #106675)

2024-09-23 Thread via cfe-commits

MichelleCDjunaidi wrote:

Well, the documentation builds now thanks to @HerrCai0907. Does it look fine 
@SimplyDanny @5chmidti ?

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


[clang] [C++20][Modules] Restore inliness of constexpr/consteval functions defined in-class (PR #109470)

2024-09-23 Thread via cfe-commits

tomasz-kaminski-sonarsource wrote:

I tested this on 19.0.1 and missed the fact that it was fixed on main by 
https://github.com/llvm/llvm-project/commit/74ac96ae1a81c7ecc0e27ff6f45309cff1f2df97.
I will rework this in NFC comment, that would add tests.

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


[clang] [llvm] [Coroutines] Change `llvm.coro.noop` to accept `llvm_anyptr_ty` instead (PR #102096)

2024-09-23 Thread Joseph Huber via cfe-commits

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


[clang] [Clang][HIP] Warn when __AMDGCN_WAVEFRONT_SIZE is used in host code without relying on target-dependent overload resolution (PR #109663)

2024-09-23 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Fabian Ritter (ritter-x2a)


Changes

This is a proposal for an alternative to PR #91478 that would make PRs 
#93546 and #103031 unnecessary. Please let me know if this one 
is preferrable over PRs #91478 and #103031.

The `__AMDGCN_WAVEFRONT_SIZE` and `__AMDGCN_WAVEFRONT_SIZE__` macros in HIP can 
only provide meaningful values during device compilation. They are currently 
usable in host code, but only contain the default value of 64, independent of 
the target device(s).

This patch checks for numeric literals in clearly identifiable host code if 
they are the result of expanding the wavefront-size macros and issues a 
diagnostic if that's the case.

The alternative PR, #91478, relied on constexpr functions with host and 
device overloads (where the host overload is marked as deprecated) to diagnose 
uses of these macros in host code. A problem with this approach are uses of the 
macros outside of function bodies, e.g., in template arguments of return types, 
or default template arguments of functions. In these cases, calls to functions 
with target overloads are resolved to the host variant during host compilation 
and to the device variant during device compilation - independently of the 
target of the function they belong to. Therefore, using the wavefront size 
macros in such cases leads to diagnostics during host compilation with #91478, even if they are only associated to a device function.

PR #93546 is a proposal to suppress these spurious diagnostics. PR 
#103031 is a proposal to change the behavior of target-dependent 
overload resolution outside of function bodies to use the target attributes 
that occur before the overloaded call to select the overload candidate.

In contrast to #91478, this PR will not diagnose uses of the 
wavefront-size macros outside of function bodies or initializers of global host 
variables.

Implements SWDEV-449015.

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


5 Files Affected:

- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+2) 
- (modified) clang/include/clang/Sema/SemaCUDA.h (+4) 
- (modified) clang/lib/Sema/SemaCUDA.cpp (+39) 
- (modified) clang/lib/Sema/SemaExpr.cpp (+3) 
- (added) clang/test/Driver/hip-wavefront-size-host-diagnostics.hip (+109) 


``diff
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e4e04bff8b5120..557d2803021f60 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9109,6 +9109,8 @@ def warn_offload_incompatible_redeclare : Warning<
   "new declaration is %select{__device__|__global__|__host__|__host__ 
__device__}0 function, "
   "old declaration is %select{__device__|__global__|__host__|__host__ 
__device__}1 function">,
   InGroup>, DefaultIgnore;
+def warn_ref_device_macro_on_host : Warning<
+  "device-specific macro %0 is not available in a 
%select{__device__|__global__|__host__|__host__ __device__}1 context">, 
InGroup>;
 
 def err_cuda_device_builtin_surftex_cls_template : Error<
 "illegal device builtin %select{surface|texture}0 reference "
diff --git a/clang/include/clang/Sema/SemaCUDA.h 
b/clang/include/clang/Sema/SemaCUDA.h
index 71f05e88fb539c..80b8dc24664b68 100644
--- a/clang/include/clang/Sema/SemaCUDA.h
+++ b/clang/include/clang/Sema/SemaCUDA.h
@@ -263,6 +263,10 @@ class SemaCUDA : public SemaBase {
   // for __constant__ and __device__ variables.
   void checkAllowedInitializer(VarDecl *VD);
 
+  /// Check if the token is part of a macro that is used outside of its allowed
+  /// compilation mode.
+  void checkTargetMacroUse(const Token &Tok);
+
   /// Check whether NewFD is a valid overload for CUDA. Emits
   /// diagnostics and invalidates NewFD if not.
   void checkTargetOverload(FunctionDecl *NewFD, const LookupResult &Previous);
diff --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp
index fbb3de4b3e4165..b09319bbd894d4 100644
--- a/clang/lib/Sema/SemaCUDA.cpp
+++ b/clang/lib/Sema/SemaCUDA.cpp
@@ -703,6 +703,45 @@ void SemaCUDA::checkAllowedInitializer(VarDecl *VD) {
   }
 }
 
+void SemaCUDA::checkTargetMacroUse(const Token &Tok) {
+  assert(SemaRef.LangOpts.HIP);
+
+  // Currently, we check only for the AMDGCN_WAVEFRONT_SIZE macros, which 
should
+  // only be used in device compilation.
+  if (SemaRef.LangOpts.CUDAIsDevice)
+return;
+
+  auto *FD = SemaRef.getCurFunctionDecl(/*AllowLambda=*/true);
+  // If we are not in a FunctionDecl and we have no other meaningful way of
+  // determining the compilation mode, avoid potentially spurious warnings.
+  if (!FD && SemaRef.CUDA().CurCUDATargetCtx.Kind == SemaCUDA::CTCK_Unknown)
+return;
+
+  auto Target = SemaRef.CUDA().IdentifyTarget(FD);
+  if (Target != CUDAFunctionTarget::HostDevice &&
+  Target != CUDAFunctionTarget::Host)
+return;
+
+  const auto &Loc = Tok.getLocation();
+  if (!Loc.isMa

[clang] [Clang][HIP] Target-dependent overload resolution in declarators and specifiers (PR #103031)

2024-09-23 Thread Fabian Ritter via cfe-commits


@@ -0,0 +1,703 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only 
-verify=expected,onhost %s
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fsyntax-only -fcuda-is-device 
-verify=expected,ondevice %s
+
+
+// Tests to ensure that functions with host and device overloads in that are
+// called outside of function bodies and variable initializers, e.g., in
+// template arguments are resolved with respect to the declaration to which 
they
+// belong.
+
+// Opaque types used for tests:
+struct DeviceTy {};
+struct HostTy {};
+struct HostDeviceTy {};
+struct TemplateTy {};
+
+struct TrueTy { static const bool value = true; };
+struct FalseTy { static const bool value = false; };
+
+// Select one of two types based on a boolean condition.
+template  struct select_type {};
+template  struct select_type { typedef T 
type; };
+template  struct select_type { typedef F 
type; };
+
+template  struct check : public select_type { };
+
+// Check if two types are the same.
+template struct is_same : public FalseTy { };
+template struct is_same : public TrueTy { };
+
+// A static assertion that fails at compile time if the expression E does not
+// have type T.
+#define ASSERT_HAS_TYPE(E, T) static_assert(is_same::value);
+
+
+// is_on_device() is true when called in a device context and false if called 
in a host context.
+__attribute__((host)) constexpr bool is_on_device(void) { return false; }
+__attribute__((device)) constexpr bool is_on_device(void) { return true; }
+
+
+// this type depends on whether it occurs in host or device code
+#define targetdep_t select_type::type
+
+// Defines and typedefs with different values in host and device compilation.
+#ifdef __CUDA_ARCH__
+#define CurrentTarget DEVICE
+typedef DeviceTy CurrentTargetTy;
+typedef DeviceTy TemplateIfHostTy;
+#else
+#define CurrentTarget HOST
+typedef HostTy CurrentTargetTy;
+typedef TemplateTy TemplateIfHostTy;
+#endif
+
+
+
+// targetdep_t in function declarations should depend on the target of the
+// declared function.
+__attribute__((device)) targetdep_t decl_ret_early_device(void);
+ASSERT_HAS_TYPE(decl_ret_early_device(), DeviceTy)
+
+__attribute__((host)) targetdep_t decl_ret_early_host(void);
+ASSERT_HAS_TYPE(decl_ret_early_host(), HostTy)
+
+__attribute__((host,device)) targetdep_t decl_ret_early_host_device(void);
+ASSERT_HAS_TYPE(decl_ret_early_host_device(), CurrentTargetTy)
+
+// If the function target is specified too late and can therefore not be
+// considered for overload resolution in targetdep_t, warn.
+targetdep_t __attribute__((device)) decl_ret_late_device(void); // 
expected-warning {{target attribute has been ignored for overload resolution}}
+ASSERT_HAS_TYPE(decl_ret_late_device(), HostTy)
+
+// No warning necessary if the ignored attribute doesn't change the result.
+targetdep_t __attribute__((host)) decl_ret_late_host(void);
+ASSERT_HAS_TYPE(decl_ret_late_host(), HostTy)
+
+targetdep_t __attribute__((host,device)) decl_ret_late_host_device(void); // 
expected-warning {{target attribute has been ignored for overload resolution}}
+ASSERT_HAS_TYPE(decl_ret_late_host_device(), HostTy)
+
+// An odd way of writing this, but it's possible.
+__attribute__((device)) targetdep_t __attribute__((host)) 
decl_ret_early_device_late_host(void); // expected-warning {{target attribute 
has been ignored for overload resolution}}
+ASSERT_HAS_TYPE(decl_ret_early_device_late_host(), DeviceTy)
+
+
+// The same for function definitions and parameter types:
+__attribute__((device)) targetdep_t ret_early_device(targetdep_t x) {
+  ASSERT_HAS_TYPE(ret_early_device({}), DeviceTy)
+  ASSERT_HAS_TYPE(x, DeviceTy)
+  return {};
+}
+
+__attribute__((host)) targetdep_t ret_early_host(targetdep_t x) {
+  ASSERT_HAS_TYPE(ret_early_host({}), HostTy)
+  ASSERT_HAS_TYPE(x, HostTy)
+  return {};
+}
+
+__attribute__((host, device)) targetdep_t ret_early_hostdevice(targetdep_t x) {
+  ASSERT_HAS_TYPE(ret_early_hostdevice({}), CurrentTargetTy)
+  ASSERT_HAS_TYPE(x, CurrentTargetTy)
+  return {};
+}
+
+// The parameter is still after the attribute, so it needs no warning.
+targetdep_t __attribute__((device)) // expected-warning {{target attribute has 
been ignored for overload resolution}}
+ret_late_device(targetdep_t x) {
+  ASSERT_HAS_TYPE(ret_late_device({}), HostTy)
+  ASSERT_HAS_TYPE(x, DeviceTy)
+  return {};
+}
+
+targetdep_t __attribute__((host, device)) // expected-warning {{target 
attribute has been ignored for overload resolution}}
+ret_late_hostdevice(targetdep_t x) {
+  ASSERT_HAS_TYPE(ret_late_hostdevice({}), HostTy)
+  ASSERT_HAS_TYPE(x, CurrentTargetTy)
+  return {};
+}
+
+targetdep_t __attribute__((host)) ret_late_host(targetdep_t x) {
+  ASSERT_HAS_TYPE(ret_late_host({}), HostTy)
+  ASSERT_HAS_TYPE(x, HostTy)
+  return {};
+}
+
+__attribute__((device)) targetdep_t __attribute__((host)) // expected-warning 
{{target attribute has been ignored for overload resolution}}
+ret_early_device_late_host(targetdep_t x) 

[clang] [Clang][HIP] Warn when __AMDGCN_WAVEFRONT_SIZE is used in host code without relying on target-dependent overload resolution (PR #109663)

2024-09-23 Thread Fabian Ritter via cfe-commits

https://github.com/ritter-x2a created 
https://github.com/llvm/llvm-project/pull/109663

This is a proposal for an alternative to PR #91478 that would make PRs #93546 
and #103031 unnecessary. Please let me know if this one is preferrable over PRs 
#91478 and #103031.

The `__AMDGCN_WAVEFRONT_SIZE` and `__AMDGCN_WAVEFRONT_SIZE__` macros in HIP can 
only provide meaningful values during device compilation. They are currently 
usable in host code, but only contain the default value of 64, independent of 
the target device(s).

This patch checks for numeric literals in clearly identifiable host code if 
they are the result of expanding the wavefront-size macros and issues a 
diagnostic if that's the case.

The alternative PR, #91478, relied on constexpr functions with host and device 
overloads (where the host overload is marked as deprecated) to diagnose uses of 
these macros in host code. A problem with this approach are uses of the macros 
outside of function bodies, e.g., in template arguments of return types, or 
default template arguments of functions. In these cases, calls to functions 
with target overloads are resolved to the host variant during host compilation 
and to the device variant during device compilation - independently of the 
target of the function they belong to. Therefore, using the wavefront size 
macros in such cases leads to diagnostics during host compilation with #91478, 
even if they are only associated to a device function.

PR #93546 is a proposal to suppress these spurious diagnostics. PR #103031 is a 
proposal to change the behavior of target-dependent overload resolution outside 
of function bodies to use the target attributes that occur before the 
overloaded call to select the overload candidate.

In contrast to #91478, this PR will not diagnose uses of the wavefront-size 
macros outside of function bodies or initializers of global host variables.

Implements SWDEV-449015.

>From 33d853eaa12431fe4dce3a69407d4ad25173ea2f Mon Sep 17 00:00:00 2001
From: Fabian Ritter 
Date: Mon, 23 Sep 2024 08:54:07 -0400
Subject: [PATCH] [Clang][HIP] Warn when __AMDGCN_WAVEFRONT_SIZE is used in
 host code without relying on target-dependent overload resolution

The __AMDGCN_WAVEFRONT_SIZE and __AMDGCN_WAVEFRONT_SIZE__ macros in HIP can
only provide meaningful values during device compilation. They are currently
usable in host code, but only contain the default value of 64, independent of
the target device(s).

This patch checks for numeric literals in clearly identifiable host code if
they are the result of expanding the wavefront-size macros and issues a
diagnostic if that's the case.

A alternative PR, #91478, relied on constexpr functions with host and device
overloads (where the host overload is marked as deprecated) to diagnose uses of
these macros in host code. A problem with this approach are uses of the macros
outside of function bodies, e.g., in template arguments of return types, or
default template arguments of functions. In these cases, calls to functions
with target overloads are resolved to the host variant during host compilation
and to the device variant during device compilation - independently of the
target of the function they belong to. Therefore, using the wavefront size
macros in such cases leads to diagnostics during host compilation with #91478,
even if they are only associated to a device function.

PR #93546 is a proposal to suppress these spurious diagnostics. PR #103031 is a
proposal to change the behavior of target-dependent overload resolution outside
of function bodies to use the target attributes that occur before the
overloaded call to select the overload candidate.

In contrast to #91478, this PR will not diagnose uses of the wavefront-size
macros outside of function bodies or initializers of global host variables.

Implements SWDEV-449015.
---
 .../clang/Basic/DiagnosticSemaKinds.td|   2 +
 clang/include/clang/Sema/SemaCUDA.h   |   4 +
 clang/lib/Sema/SemaCUDA.cpp   |  39 +++
 clang/lib/Sema/SemaExpr.cpp   |   3 +
 .../hip-wavefront-size-host-diagnostics.hip   | 109 ++
 5 files changed, 157 insertions(+)
 create mode 100644 clang/test/Driver/hip-wavefront-size-host-diagnostics.hip

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e4e04bff8b5120..557d2803021f60 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9109,6 +9109,8 @@ def warn_offload_incompatible_redeclare : Warning<
   "new declaration is %select{__device__|__global__|__host__|__host__ 
__device__}0 function, "
   "old declaration is %select{__device__|__global__|__host__|__host__ 
__device__}1 function">,
   InGroup>, DefaultIgnore;
+def warn_ref_device_macro_on_host : Warning<
+  "device-specific macro %0 is not available in a 
%select{__device__|__global__|__host__|__host__ __device__}1 

[clang] [AST] Avoid repeated hash lookups (NFC) (PR #109603)

2024-09-23 Thread Erich Keane via cfe-commits

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


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


[clang] [clang] Ignore inline namespace for `hasName` (PR #109147)

2024-09-23 Thread Erich Keane via cfe-commits

https://github.com/erichkeane commented:

I have no problem with the code here, but don't know enough about ASTMatchers 
to be able to review this for 'well justified'. Do we have someone besides 
Aaron who does?

Also, it needs a release note I think for the matcher change.

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


[clang] [analyzer][StackAddrEscapeChecker] Fix assert failure for alloca regions (PR #109655)

2024-09-23 Thread Arseniy Zaostrovnykh via cfe-commits

https://github.com/necto updated 
https://github.com/llvm/llvm-project/pull/109655

>From b69749ab1854b0c12a69821c35bff1b866d6f307 Mon Sep 17 00:00:00 2001
From: Arseniy Zaostrovnykh 
Date: Mon, 23 Sep 2024 14:21:31 +0200
Subject: [PATCH 1/3] [analyzer][StackAddrEscapeChecker] Fix assert failure for
 alloca regions

Fixes #107852

Make it explicit that the checker skips alloca regions to avoid the risc
of producing false positives for code that has advnaced memory
management.
StackAddrEscapeChecker already used this strategy when it comes to
malloc'ed regions, so this change relaxes the assertion and explicitly
silents the issues related to memory regions generated with alloca.
---
 .../Checkers/StackAddrEscapeChecker.cpp   |  4 +++
 clang/test/Analysis/stack-addr-ps.cpp | 29 ++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
index d8c52941b19366..a76639bb86b208 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
@@ -337,6 +337,10 @@ static std::optional printReferrer(const 
MemRegion *Referrer) {
   // warn_bind_ref_member_to_parameter or
   // warn_init_ptr_member_to_parameter_addr
   return std::nullopt;
+} else if (isa(Referrer)) {
+  // Skip alloca() regions, they indicate advanced memory management
+  // and higher likelihood of CSA false positives.
+  return std::nullopt;
 } else {
   assert(false && "Unexpected referrer region type.");
   return std::nullopt;
diff --git a/clang/test/Analysis/stack-addr-ps.cpp 
b/clang/test/Analysis/stack-addr-ps.cpp
index 35f38fbbfbefdc..1f8b62824772e1 100644
--- a/clang/test/Analysis/stack-addr-ps.cpp
+++ b/clang/test/Analysis/stack-addr-ps.cpp
@@ -1,4 +1,9 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify 
%s -Wno-undefined-bool-conversion
+// RUN: %clang_analyze_cc1 \
+// RUN:   -analyzer-checker=core,debug.ExprInspection,unix.Malloc \
+// RUN:   -verify %s \
+// RUN:   -Wno-undefined-bool-conversion
+// unix.Malloc is necessary to model __builtin_alloca,
+// which could trigger an "unexpected region" bug in StackAddrEscapeChecker.
 
 typedef __INTPTR_TYPE__ intptr_t;
 
@@ -846,3 +851,25 @@ void top(char **p) {
   foo(); // no-warning FIXME: p binding is reclaimed before the function end
 }
 } // namespace early_reclaim_dead_limitation
+
+using size_t = decltype(sizeof(int));
+void * malloc(size_t size);
+void free(void*);
+
+namespace alloca_region_pointer {
+void callee(char **pptr) {
+  char local;
+  *pptr = &local;
+}
+
+void top_alloca_no_crash() {
+  char **pptr = (char**)__builtin_alloca(sizeof(char*));
+  callee(pptr);
+}
+
+void top_malloc_no_crash_fn() {
+  char **pptr = (char**)malloc(sizeof(char*));
+  callee(pptr);
+  free(pptr);
+}
+} // namespace alloca_region_pointer

>From b2ed9f98f1a025413c2efb5230b704cf0cebb7e9 Mon Sep 17 00:00:00 2001
From: Arseniy Zaostrovnykh 
Date: Mon, 23 Sep 2024 15:39:11 +0200
Subject: [PATCH 2/3] Address review feedback: add another lit run without
 malloc checker

---
 clang/test/Analysis/stack-addr-ps.cpp | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/clang/test/Analysis/stack-addr-ps.cpp 
b/clang/test/Analysis/stack-addr-ps.cpp
index 1f8b62824772e1..2f75cdaf51bd8c 100644
--- a/clang/test/Analysis/stack-addr-ps.cpp
+++ b/clang/test/Analysis/stack-addr-ps.cpp
@@ -1,4 +1,8 @@
 // RUN: %clang_analyze_cc1 \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -verify %s \
+// RUN:   -Wno-undefined-bool-conversion
+// RUN: %clang_analyze_cc1 \
 // RUN:   -analyzer-checker=core,debug.ExprInspection,unix.Malloc \
 // RUN:   -verify %s \
 // RUN:   -Wno-undefined-bool-conversion
@@ -860,9 +864,9 @@ namespace alloca_region_pointer {
 void callee(char **pptr) {
   char local;
   *pptr = &local;
-}
+} // no crash
 
-void top_alloca_no_crash() {
+void top_alloca_no_crash_fn() {
   char **pptr = (char**)__builtin_alloca(sizeof(char*));
   callee(pptr);
 }

>From 9d0ab4e3dc446cc29f1a20c5e32277d0633aff0b Mon Sep 17 00:00:00 2001
From: Arseniy Zaostrovnykh 
Date: Mon, 23 Sep 2024 15:40:10 +0200
Subject: [PATCH 3/3] Move malloc and free definitions up in the file

---
 clang/test/Analysis/stack-addr-ps.cpp | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/test/Analysis/stack-addr-ps.cpp 
b/clang/test/Analysis/stack-addr-ps.cpp
index 2f75cdaf51bd8c..73e9dbeca460f6 100644
--- a/clang/test/Analysis/stack-addr-ps.cpp
+++ b/clang/test/Analysis/stack-addr-ps.cpp
@@ -14,6 +14,10 @@ typedef __INTPTR_TYPE__ intptr_t;
 template 
 void clang_analyzer_dump(T x);
 
+using size_t = decltype(sizeof(int));
+void * malloc(size_t size);
+void free(void*);
+
 const int& g() {
   int s;
   return s; // expected-warning{{Address of stack memory associa

[clang] [analyzer][StackAddrEscapeChecker] Fix assert failure for alloca regions (PR #109655)

2024-09-23 Thread Arseniy Zaostrovnykh via cfe-commits

https://github.com/necto updated 
https://github.com/llvm/llvm-project/pull/109655

>From b69749ab1854b0c12a69821c35bff1b866d6f307 Mon Sep 17 00:00:00 2001
From: Arseniy Zaostrovnykh 
Date: Mon, 23 Sep 2024 14:21:31 +0200
Subject: [PATCH 1/2] [analyzer][StackAddrEscapeChecker] Fix assert failure for
 alloca regions

Fixes #107852

Make it explicit that the checker skips alloca regions to avoid the risc
of producing false positives for code that has advnaced memory
management.
StackAddrEscapeChecker already used this strategy when it comes to
malloc'ed regions, so this change relaxes the assertion and explicitly
silents the issues related to memory regions generated with alloca.
---
 .../Checkers/StackAddrEscapeChecker.cpp   |  4 +++
 clang/test/Analysis/stack-addr-ps.cpp | 29 ++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
index d8c52941b19366..a76639bb86b208 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
@@ -337,6 +337,10 @@ static std::optional printReferrer(const 
MemRegion *Referrer) {
   // warn_bind_ref_member_to_parameter or
   // warn_init_ptr_member_to_parameter_addr
   return std::nullopt;
+} else if (isa(Referrer)) {
+  // Skip alloca() regions, they indicate advanced memory management
+  // and higher likelihood of CSA false positives.
+  return std::nullopt;
 } else {
   assert(false && "Unexpected referrer region type.");
   return std::nullopt;
diff --git a/clang/test/Analysis/stack-addr-ps.cpp 
b/clang/test/Analysis/stack-addr-ps.cpp
index 35f38fbbfbefdc..1f8b62824772e1 100644
--- a/clang/test/Analysis/stack-addr-ps.cpp
+++ b/clang/test/Analysis/stack-addr-ps.cpp
@@ -1,4 +1,9 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify 
%s -Wno-undefined-bool-conversion
+// RUN: %clang_analyze_cc1 \
+// RUN:   -analyzer-checker=core,debug.ExprInspection,unix.Malloc \
+// RUN:   -verify %s \
+// RUN:   -Wno-undefined-bool-conversion
+// unix.Malloc is necessary to model __builtin_alloca,
+// which could trigger an "unexpected region" bug in StackAddrEscapeChecker.
 
 typedef __INTPTR_TYPE__ intptr_t;
 
@@ -846,3 +851,25 @@ void top(char **p) {
   foo(); // no-warning FIXME: p binding is reclaimed before the function end
 }
 } // namespace early_reclaim_dead_limitation
+
+using size_t = decltype(sizeof(int));
+void * malloc(size_t size);
+void free(void*);
+
+namespace alloca_region_pointer {
+void callee(char **pptr) {
+  char local;
+  *pptr = &local;
+}
+
+void top_alloca_no_crash() {
+  char **pptr = (char**)__builtin_alloca(sizeof(char*));
+  callee(pptr);
+}
+
+void top_malloc_no_crash_fn() {
+  char **pptr = (char**)malloc(sizeof(char*));
+  callee(pptr);
+  free(pptr);
+}
+} // namespace alloca_region_pointer

>From b2ed9f98f1a025413c2efb5230b704cf0cebb7e9 Mon Sep 17 00:00:00 2001
From: Arseniy Zaostrovnykh 
Date: Mon, 23 Sep 2024 15:39:11 +0200
Subject: [PATCH 2/2] Address review feedback: add another lit run without
 malloc checker

---
 clang/test/Analysis/stack-addr-ps.cpp | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/clang/test/Analysis/stack-addr-ps.cpp 
b/clang/test/Analysis/stack-addr-ps.cpp
index 1f8b62824772e1..2f75cdaf51bd8c 100644
--- a/clang/test/Analysis/stack-addr-ps.cpp
+++ b/clang/test/Analysis/stack-addr-ps.cpp
@@ -1,4 +1,8 @@
 // RUN: %clang_analyze_cc1 \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -verify %s \
+// RUN:   -Wno-undefined-bool-conversion
+// RUN: %clang_analyze_cc1 \
 // RUN:   -analyzer-checker=core,debug.ExprInspection,unix.Malloc \
 // RUN:   -verify %s \
 // RUN:   -Wno-undefined-bool-conversion
@@ -860,9 +864,9 @@ namespace alloca_region_pointer {
 void callee(char **pptr) {
   char local;
   *pptr = &local;
-}
+} // no crash
 
-void top_alloca_no_crash() {
+void top_alloca_no_crash_fn() {
   char **pptr = (char**)__builtin_alloca(sizeof(char*));
   callee(pptr);
 }

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


[clang] [analyzer][StackAddrEscapeChecker] Fix assert failure for alloca regions (PR #109655)

2024-09-23 Thread Arseniy Zaostrovnykh via cfe-commits


@@ -846,3 +851,25 @@ void top(char **p) {
   foo(); // no-warning FIXME: p binding is reclaimed before the function end
 }
 } // namespace early_reclaim_dead_limitation
+
+using size_t = decltype(sizeof(int));
+void * malloc(size_t size);
+void free(void*);

necto wrote:

Moved 9d0ab4e

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


[clang] [analyzer][StackAddrEscapeChecker] Fix assert failure for alloca regions (PR #109655)

2024-09-23 Thread Arseniy Zaostrovnykh via cfe-commits


@@ -1,4 +1,9 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify 
%s -Wno-undefined-bool-conversion
+// RUN: %clang_analyze_cc1 \
+// RUN:   -analyzer-checker=core,debug.ExprInspection,unix.Malloc \
+// RUN:   -verify %s \
+// RUN:   -Wno-undefined-bool-conversion
+// unix.Malloc is necessary to model __builtin_alloca,
+// which could trigger an "unexpected region" bug in StackAddrEscapeChecker.

necto wrote:

I added a run without malloc checker to demonstrate that there is no dependency 
see b2ed9f9

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


[clang] ff9f1a6 - [Rewrite] Avoid repeated hash lookups (NFC) (#109605)

2024-09-23 Thread via cfe-commits

Author: Kazu Hirata
Date: 2024-09-23T06:42:46-07:00
New Revision: ff9f1a6ea2a0031387d23ce510d43edd81a18a1e

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

LOG: [Rewrite] Avoid repeated hash lookups (NFC) (#109605)

Added: 


Modified: 
clang/lib/Frontend/Rewrite/RewriteObjC.cpp

Removed: 




diff  --git a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp 
b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
index 180a0125023ee7..ac5baf72a65c90 100644
--- a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
+++ b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
@@ -4358,21 +4358,21 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
 for (unsigned i = 0; i < InnerBlockDeclRefs.size(); i++) {
   DeclRefExpr *Exp = InnerBlockDeclRefs[i];
   ValueDecl *VD = Exp->getDecl();
-  if (!VD->hasAttr() && !BlockByCopyDeclsPtrSet.count(VD)) {
+  if (!VD->hasAttr() &&
+  BlockByCopyDeclsPtrSet.insert(VD).second) {
 // We need to save the copied-in variables in nested
 // blocks because it is needed at the end for some of the API
 // generations. See SynthesizeBlockLiterals routine.
 InnerDeclRefs.push_back(Exp);
 countOfInnerDecls++;
 BlockDeclRefs.push_back(Exp);
-BlockByCopyDeclsPtrSet.insert(VD);
 BlockByCopyDecls.push_back(VD);
   }
-  if (VD->hasAttr() && !BlockByRefDeclsPtrSet.count(VD)) {
+  if (VD->hasAttr() &&
+  BlockByRefDeclsPtrSet.insert(VD).second) {
 InnerDeclRefs.push_back(Exp);
 countOfInnerDecls++;
 BlockDeclRefs.push_back(Exp);
-BlockByRefDeclsPtrSet.insert(VD);
 BlockByRefDecls.push_back(VD);
   }
 }



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


[clang] [Rewrite] Avoid repeated hash lookups (NFC) (PR #109605)

2024-09-23 Thread Kazu Hirata via cfe-commits

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


[clang] [Rewrite] Avoid repeated hash lookups (NFC) (PR #109605)

2024-09-23 Thread Kazu Hirata via cfe-commits

kazutakahirata wrote:

> LGTM, but it would probably make sense to make BlockByCopyDecls a SetVector, 
> instead of having separate vector and set.
> 
> Edit: Also worth noting that this pattern also exists here: 
> https://github.com/llvm/llvm-project/blob/50ce6d0114f8abd4b5580d2c277525eebdf25874/clang/lib/Frontend/Rewrite/RewriteObjC.cpp#L3556C42-L3556C61

Ack.  There are quite a few places within LLVM where we see 
`Map.try_emplace(Key, Vector.size())`.  I bet many of those can be converted to 
`MapVector`.

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


[clang] [llvm] [CMake] Preserve clang-prebolt (PR #109351)

2024-09-23 Thread Amir Ayupov via cfe-commits

aaupov wrote:

> This commit is breaking LTO-PGO-BOLT build while optimizing clang with BOLT. 
> 
> 
> 
> ```
> 
> [3064/3065] Merging BOLT fdata
> 
> Using legacy profile format.
> 
> Profile from 2 files merged.
> 
> [3064/3065] Optimizing Clang with BOLT
> 
> BOLT-INFO: shared object or position-independent executable detected
> 
> BOLT-INFO: Target architecture: aarch64
> 
> BOLT-INFO: BOLT version: 51d1d03b17bb8bf66b6422c4482d8d615ab53409
> 
> BOLT-INFO: first alloc address is 0x0
> 
> BOLT-INFO: enabling relocation mode
> 
> BOLT-INFO: pre-processing profile using branch profile reader
> 
> BOLT-WARNING: 1 collisions detected while hashing binary objects. Use -v=1 to 
> see the list.
> 
> BOLT-INFO: number of removed linker-inserted veneers: 0
> 
> BOLT-INFO: 11906 out of 212101 functions in the binary (5.6%) have non-empty 
> execution profile
> 
> BOLT-INFO: 272 functions with profile could not be optimized
> 
> BOLT-INFO: profile for 1 objects was ignored
> 
> BOLT-INFO: removed 1 empty block
> 
> BOLT-INFO: basic block reordering modified layout of 4273 functions (35.89% 
> of profiled, 2.01% of total)
> 
> BOLT-INFO: UCE removed 1 blocks and 4 bytes of code
> 
> BOLT-INFO: 68 Functions were reordered by LoopInversionPass
> 
> :0: error: fixup value out of range
> 
> :0: error: fixup value out of range
> 
> :0: error: fixup value out of range
> 
> :0: error: fixup value out of range
> 
> :0: error: fixup value out of range
> 
> :0: error: fixup value out of range
> 
> :0: error: fixup value out of range
> 
> :0: error: fixup value out of range
> 
> ```
> 
> 
> 
> More information on LTO-PGO-BOLT can be found on 
> https://llvm.org/docs/AdvancedBuilds.html

This change was tested on a buildbot: 
https://lab.llvm.org/buildbot/#/builders/113/builds/2934

Can you please try cleaning the build directory?

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


[clang] d6a6e25 - [AST] Avoid repeated hash lookups (NFC) (#109603)

2024-09-23 Thread via cfe-commits

Author: Kazu Hirata
Date: 2024-09-23T06:45:59-07:00
New Revision: d6a6e25c5158be8a1b820aedf067fce394f7a313

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

LOG: [AST] Avoid repeated hash lookups (NFC) (#109603)

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 8bd5abf2bf9643..fd8aa8de79b49f 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -12587,8 +12587,7 @@ void ASTContext::forEachMultiversionedFunctionVersion(
FD->getDeclContext()->getRedeclContext()->lookup(FD->getDeclName())) {
 FunctionDecl *CurFD = CurDecl->getAsFunction()->getMostRecentDecl();
 if (CurFD && hasSameType(CurFD->getType(), FD->getType()) &&
-!SeenDecls.contains(CurFD)) {
-  SeenDecls.insert(CurFD);
+SeenDecls.insert(CurFD).second) {
   Pred(CurFD);
 }
   }



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


[clang] [AST] Avoid repeated hash lookups (NFC) (PR #109603)

2024-09-23 Thread Kazu Hirata via cfe-commits

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


[clang] [SystemZ][z/OS] fix ppc-xmmintrin.c on z/OS (PR #109676)

2024-09-23 Thread Abhina Sree via cfe-commits

https://github.com/abhina-sree approved this pull request.

LGTM

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


[clang] [flang] [clang][flang] Support -time in both clang and flang (PR #109165)

2024-09-23 Thread Tarun Prabhu via cfe-commits

https://github.com/tarunprabhu updated 
https://github.com/llvm/llvm-project/pull/109165

>From 9bb43511fc688501730eeff0bec882d05d286278 Mon Sep 17 00:00:00 2001
From: Tarun Prabhu 
Date: Wed, 18 Sep 2024 09:49:26 -0600
Subject: [PATCH 1/2] [clang][flang] Support -time in both clang and flang

The -time option prints timing information for the subcommands (compiler,
linker) in a format similar to that used by gcc/gfortran (we use more digits
of precision).

This partially addresses requests from #89888
---
 clang/include/clang/Driver/Options.td |  1 +
 clang/lib/Driver/Compilation.cpp  | 21 +
 clang/lib/Driver/Driver.cpp   |  3 +++
 clang/test/Driver/time.c  | 24 
 flang/test/Driver/time.f90| 22 ++
 5 files changed, 71 insertions(+)
 create mode 100644 clang/test/Driver/time.c
 create mode 100644 flang/test/Driver/time.f90

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index aa3ae92fb6ae78..eecd4ac5d94413 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5844,6 +5844,7 @@ def print_enabled_extensions : Flag<["-", "--"], 
"print-enabled-extensions">,
 def : Flag<["-"], "mcpu=help">, Alias;
 def : Flag<["-"], "mtune=help">, Alias;
 def time : Flag<["-"], "time">,
+  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
   HelpText<"Time individual commands">;
 def traditional_cpp : Flag<["-", "--"], "traditional-cpp">,
   Visibility<[ClangOption, CC1Option]>,
diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp
index ad077d5bbfa69a..aadaa236246a27 100644
--- a/clang/lib/Driver/Compilation.cpp
+++ b/clang/lib/Driver/Compilation.cpp
@@ -21,6 +21,9 @@
 #include "llvm/Option/OptSpecifier.h"
 #include "llvm/Option/Option.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Format.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Timer.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Triple.h"
 #include 
@@ -194,11 +197,29 @@ int Compilation::ExecuteCommand(const Command &C,
   if (LogOnly)
 return 0;
 
+  // We don't use any timers or llvm::TimeGroup's because those are tied into
+  // the global static timer list which, in principle, could be cleared without
+  // us knowing about it.
+  llvm::TimeRecord StartTime;
+  if (getArgs().hasArg(options::OPT_time)) {
+StartTime = llvm::TimeRecord::getCurrentTime(true);
+  }
+
   std::string Error;
   bool ExecutionFailed;
   int Res = C.Execute(Redirects, &Error, &ExecutionFailed);
   if (PostCallback)
 PostCallback(C, Res);
+
+  if (getArgs().hasArg(options::OPT_time)) {
+llvm::TimeRecord Time = llvm::TimeRecord::getCurrentTime(false);
+Time -= StartTime;
+llvm::StringRef Name = llvm::sys::path::filename(C.getExecutable());
+llvm::errs() << "# " << Name << " "
+ << llvm::format("%0.5f", Time.getUserTime()) << " "
+ << llvm::format("%0.5f", Time.getSystemTime()) << "\n";
+  }
+
   if (!Error.empty()) {
 assert(Res && "Error string set with 0 result code!");
 getDriver().Diag(diag::err_drv_command_failure) << Error;
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index efe398dd531da7..c8b45e9be5328b 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1289,6 +1289,9 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
   // Ignore -pipe.
   Args.ClaimAllArgs(options::OPT_pipe);
 
+  // Ignore -time.
+  Args.ClaimAllArgs(options::OPT_time);
+
   // Extract -ccc args.
   //
   // FIXME: We need to figure out where this behavior should live. Most of it
diff --git a/clang/test/Driver/time.c b/clang/test/Driver/time.c
new file mode 100644
index 00..1e19f29ab76a32
--- /dev/null
+++ b/clang/test/Driver/time.c
@@ -0,0 +1,24 @@
+// The -time option prints timing information for the various subcommands in a
+// format similar to that used by gcc. When compiling and linking, this will
+// include the time to call clang-${LLVM_VERSION_MAJOR} and the linker. Since
+// the name of the linker could vary across platforms, and name of the compiler
+// could be something different, just check that whatever is printed to stderr
+// looks like timing information.
+
+// RUN: %clang -time -c -O3 -o /dev/null %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=COMPILE-ONLY
+// RUN: %clang -time -S -emit-llvm -O3 -o /dev/null %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=COMPILE-ONLY
+// RUN: %clang -time -S -O3 -o /dev/null %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=COMPILE-ONLY
+// RUN: %clang -time -O3 -o /dev/null %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=COMPILE-AND-LINK
+
+// COMPILE-ONLY: # {{.+}} {{[0-9]+(.[0-9]+)?}} {{[0-9]+(.[0-9]+)?}}
+
+// COMPILE-AND-LINK: # {{.+}} {{[0-9]+(.[0-9]+)?}} {{[0-9]+(.[0-9]+)?}}
+// COMPILE-AND-LINK: # {{.+}} {{[0-9]+(.[0

[clang] [flang] [clang][flang] Support -time in both clang and flang (PR #109165)

2024-09-23 Thread Tarun Prabhu via cfe-commits

https://github.com/tarunprabhu updated 
https://github.com/llvm/llvm-project/pull/109165

>From 9bb43511fc688501730eeff0bec882d05d286278 Mon Sep 17 00:00:00 2001
From: Tarun Prabhu 
Date: Wed, 18 Sep 2024 09:49:26 -0600
Subject: [PATCH 1/4] [clang][flang] Support -time in both clang and flang

The -time option prints timing information for the subcommands (compiler,
linker) in a format similar to that used by gcc/gfortran (we use more digits
of precision).

This partially addresses requests from #89888
---
 clang/include/clang/Driver/Options.td |  1 +
 clang/lib/Driver/Compilation.cpp  | 21 +
 clang/lib/Driver/Driver.cpp   |  3 +++
 clang/test/Driver/time.c  | 24 
 flang/test/Driver/time.f90| 22 ++
 5 files changed, 71 insertions(+)
 create mode 100644 clang/test/Driver/time.c
 create mode 100644 flang/test/Driver/time.f90

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index aa3ae92fb6ae78..eecd4ac5d94413 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5844,6 +5844,7 @@ def print_enabled_extensions : Flag<["-", "--"], 
"print-enabled-extensions">,
 def : Flag<["-"], "mcpu=help">, Alias;
 def : Flag<["-"], "mtune=help">, Alias;
 def time : Flag<["-"], "time">,
+  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
   HelpText<"Time individual commands">;
 def traditional_cpp : Flag<["-", "--"], "traditional-cpp">,
   Visibility<[ClangOption, CC1Option]>,
diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp
index ad077d5bbfa69a..aadaa236246a27 100644
--- a/clang/lib/Driver/Compilation.cpp
+++ b/clang/lib/Driver/Compilation.cpp
@@ -21,6 +21,9 @@
 #include "llvm/Option/OptSpecifier.h"
 #include "llvm/Option/Option.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Format.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Timer.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Triple.h"
 #include 
@@ -194,11 +197,29 @@ int Compilation::ExecuteCommand(const Command &C,
   if (LogOnly)
 return 0;
 
+  // We don't use any timers or llvm::TimeGroup's because those are tied into
+  // the global static timer list which, in principle, could be cleared without
+  // us knowing about it.
+  llvm::TimeRecord StartTime;
+  if (getArgs().hasArg(options::OPT_time)) {
+StartTime = llvm::TimeRecord::getCurrentTime(true);
+  }
+
   std::string Error;
   bool ExecutionFailed;
   int Res = C.Execute(Redirects, &Error, &ExecutionFailed);
   if (PostCallback)
 PostCallback(C, Res);
+
+  if (getArgs().hasArg(options::OPT_time)) {
+llvm::TimeRecord Time = llvm::TimeRecord::getCurrentTime(false);
+Time -= StartTime;
+llvm::StringRef Name = llvm::sys::path::filename(C.getExecutable());
+llvm::errs() << "# " << Name << " "
+ << llvm::format("%0.5f", Time.getUserTime()) << " "
+ << llvm::format("%0.5f", Time.getSystemTime()) << "\n";
+  }
+
   if (!Error.empty()) {
 assert(Res && "Error string set with 0 result code!");
 getDriver().Diag(diag::err_drv_command_failure) << Error;
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index efe398dd531da7..c8b45e9be5328b 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1289,6 +1289,9 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
   // Ignore -pipe.
   Args.ClaimAllArgs(options::OPT_pipe);
 
+  // Ignore -time.
+  Args.ClaimAllArgs(options::OPT_time);
+
   // Extract -ccc args.
   //
   // FIXME: We need to figure out where this behavior should live. Most of it
diff --git a/clang/test/Driver/time.c b/clang/test/Driver/time.c
new file mode 100644
index 00..1e19f29ab76a32
--- /dev/null
+++ b/clang/test/Driver/time.c
@@ -0,0 +1,24 @@
+// The -time option prints timing information for the various subcommands in a
+// format similar to that used by gcc. When compiling and linking, this will
+// include the time to call clang-${LLVM_VERSION_MAJOR} and the linker. Since
+// the name of the linker could vary across platforms, and name of the compiler
+// could be something different, just check that whatever is printed to stderr
+// looks like timing information.
+
+// RUN: %clang -time -c -O3 -o /dev/null %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=COMPILE-ONLY
+// RUN: %clang -time -S -emit-llvm -O3 -o /dev/null %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=COMPILE-ONLY
+// RUN: %clang -time -S -O3 -o /dev/null %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=COMPILE-ONLY
+// RUN: %clang -time -O3 -o /dev/null %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=COMPILE-AND-LINK
+
+// COMPILE-ONLY: # {{.+}} {{[0-9]+(.[0-9]+)?}} {{[0-9]+(.[0-9]+)?}}
+
+// COMPILE-AND-LINK: # {{.+}} {{[0-9]+(.[0-9]+)?}} {{[0-9]+(.[0-9]+)?}}
+// COMPILE-AND-LINK: # {{.+}} {{[0-9]+(.[0

[clang] [flang] [clang][flang] Support -time in both clang and flang (PR #109165)

2024-09-23 Thread Tarun Prabhu via cfe-commits

https://github.com/tarunprabhu updated 
https://github.com/llvm/llvm-project/pull/109165

>From 9bb43511fc688501730eeff0bec882d05d286278 Mon Sep 17 00:00:00 2001
From: Tarun Prabhu 
Date: Wed, 18 Sep 2024 09:49:26 -0600
Subject: [PATCH 1/3] [clang][flang] Support -time in both clang and flang

The -time option prints timing information for the subcommands (compiler,
linker) in a format similar to that used by gcc/gfortran (we use more digits
of precision).

This partially addresses requests from #89888
---
 clang/include/clang/Driver/Options.td |  1 +
 clang/lib/Driver/Compilation.cpp  | 21 +
 clang/lib/Driver/Driver.cpp   |  3 +++
 clang/test/Driver/time.c  | 24 
 flang/test/Driver/time.f90| 22 ++
 5 files changed, 71 insertions(+)
 create mode 100644 clang/test/Driver/time.c
 create mode 100644 flang/test/Driver/time.f90

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index aa3ae92fb6ae78..eecd4ac5d94413 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5844,6 +5844,7 @@ def print_enabled_extensions : Flag<["-", "--"], 
"print-enabled-extensions">,
 def : Flag<["-"], "mcpu=help">, Alias;
 def : Flag<["-"], "mtune=help">, Alias;
 def time : Flag<["-"], "time">,
+  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
   HelpText<"Time individual commands">;
 def traditional_cpp : Flag<["-", "--"], "traditional-cpp">,
   Visibility<[ClangOption, CC1Option]>,
diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp
index ad077d5bbfa69a..aadaa236246a27 100644
--- a/clang/lib/Driver/Compilation.cpp
+++ b/clang/lib/Driver/Compilation.cpp
@@ -21,6 +21,9 @@
 #include "llvm/Option/OptSpecifier.h"
 #include "llvm/Option/Option.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Format.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Timer.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Triple.h"
 #include 
@@ -194,11 +197,29 @@ int Compilation::ExecuteCommand(const Command &C,
   if (LogOnly)
 return 0;
 
+  // We don't use any timers or llvm::TimeGroup's because those are tied into
+  // the global static timer list which, in principle, could be cleared without
+  // us knowing about it.
+  llvm::TimeRecord StartTime;
+  if (getArgs().hasArg(options::OPT_time)) {
+StartTime = llvm::TimeRecord::getCurrentTime(true);
+  }
+
   std::string Error;
   bool ExecutionFailed;
   int Res = C.Execute(Redirects, &Error, &ExecutionFailed);
   if (PostCallback)
 PostCallback(C, Res);
+
+  if (getArgs().hasArg(options::OPT_time)) {
+llvm::TimeRecord Time = llvm::TimeRecord::getCurrentTime(false);
+Time -= StartTime;
+llvm::StringRef Name = llvm::sys::path::filename(C.getExecutable());
+llvm::errs() << "# " << Name << " "
+ << llvm::format("%0.5f", Time.getUserTime()) << " "
+ << llvm::format("%0.5f", Time.getSystemTime()) << "\n";
+  }
+
   if (!Error.empty()) {
 assert(Res && "Error string set with 0 result code!");
 getDriver().Diag(diag::err_drv_command_failure) << Error;
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index efe398dd531da7..c8b45e9be5328b 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1289,6 +1289,9 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
   // Ignore -pipe.
   Args.ClaimAllArgs(options::OPT_pipe);
 
+  // Ignore -time.
+  Args.ClaimAllArgs(options::OPT_time);
+
   // Extract -ccc args.
   //
   // FIXME: We need to figure out where this behavior should live. Most of it
diff --git a/clang/test/Driver/time.c b/clang/test/Driver/time.c
new file mode 100644
index 00..1e19f29ab76a32
--- /dev/null
+++ b/clang/test/Driver/time.c
@@ -0,0 +1,24 @@
+// The -time option prints timing information for the various subcommands in a
+// format similar to that used by gcc. When compiling and linking, this will
+// include the time to call clang-${LLVM_VERSION_MAJOR} and the linker. Since
+// the name of the linker could vary across platforms, and name of the compiler
+// could be something different, just check that whatever is printed to stderr
+// looks like timing information.
+
+// RUN: %clang -time -c -O3 -o /dev/null %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=COMPILE-ONLY
+// RUN: %clang -time -S -emit-llvm -O3 -o /dev/null %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=COMPILE-ONLY
+// RUN: %clang -time -S -O3 -o /dev/null %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=COMPILE-ONLY
+// RUN: %clang -time -O3 -o /dev/null %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=COMPILE-AND-LINK
+
+// COMPILE-ONLY: # {{.+}} {{[0-9]+(.[0-9]+)?}} {{[0-9]+(.[0-9]+)?}}
+
+// COMPILE-AND-LINK: # {{.+}} {{[0-9]+(.[0-9]+)?}} {{[0-9]+(.[0-9]+)?}}
+// COMPILE-AND-LINK: # {{.+}} {{[0-9]+(.[0

[clang] [flang] [clang][flang] Support -time in both clang and flang (PR #109165)

2024-09-23 Thread Tarun Prabhu via cfe-commits


@@ -0,0 +1,24 @@
+// The -time option prints timing information for the various subcommands in a
+// format similar to that used by gcc. When compiling and linking, this will
+// include the time to call clang-${LLVM_VERSION_MAJOR} and the linker. Since
+// the name of the linker could vary across platforms, and name of the compiler
+// could be something different, just check that whatever is printed to stderr
+// looks like timing information.
+
+// RUN: %clang -time -c -O3 -o /dev/null %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=COMPILE-ONLY
+// RUN: %clang -time -S -emit-llvm -O3 -o /dev/null %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=COMPILE-ONLY
+// RUN: %clang -time -S -O3 -o /dev/null %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=COMPILE-ONLY
+// RUN: %clang -time -O3 -o /dev/null %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=COMPILE-AND-LINK
+
+// COMPILE-ONLY: # {{.+}} {{[0-9]+(.[0-9]+)?}} {{[0-9]+(.[0-9]+)?}}

tarunprabhu wrote:

Nice catch. Thanks. Fixed.

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


[clang] [llvm] [Clang][LLVM][AArch64] Add intrinsic for MOVT SME2 instruction (PR #97602)

2024-09-23 Thread via cfe-commits

https://github.com/CarolineConcatto updated 
https://github.com/llvm/llvm-project/pull/97602

>From 70d1ec0e1c1bd896cf753510a8452325b086430e Mon Sep 17 00:00:00 2001
From: Caroline Concatto 
Date: Wed, 3 Jul 2024 15:55:45 +
Subject: [PATCH 1/6] [Clang][LLVM][AArch64] Add intrinsic for MOVT SME2
 instruction

This patch adds these intrinsics:

  // Variants are also available for:
  // [_s8], [_u16], [_s16], [_u32], [_s32], [_u64], [_s64]
  // [_bf16], [_f16], [_f32], [_f64]
  void svwrite_lane_zt[_u8](uint64_t zt0, svuint8_t zt, uint64_t idx) 
__arm_streaming __arm_inout("zt0");
  void svwrite_zt[_u8](uint64_t zt0, svuint8_t zt) __arm_streaming 
__arm_inout("zt0");

according to PR#324[1]
[1]https://github.com/ARM-software/acle/pull/324
---
 clang/include/clang/Basic/arm_sme.td  |   5 +
 .../acle_sme2_write_lane_zt.c | 401 ++
 .../aarch64-sme2-intrinsics/acle_sme2_imm.cpp |  10 +-
 llvm/include/llvm/IR/IntrinsicsAArch64.td |   9 +
 .../Target/AArch64/AArch64ISelLowering.cpp|   2 +
 .../lib/Target/AArch64/AArch64SMEInstrInfo.td |   2 +-
 llvm/lib/Target/AArch64/SMEInstrFormats.td|  42 +-
 .../AArch64/sme2-intrinsics-read-zt.ll| 162 +++
 8 files changed, 630 insertions(+), 3 deletions(-)
 create mode 100644 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write_lane_zt.c
 create mode 100644 llvm/test/CodeGen/AArch64/sme2-intrinsics-read-zt.ll

diff --git a/clang/include/clang/Basic/arm_sme.td 
b/clang/include/clang/Basic/arm_sme.td
index ce8908f566f2fd..ff68e536e99b09 100644
--- a/clang/include/clang/Basic/arm_sme.td
+++ b/clang/include/clang/Basic/arm_sme.td
@@ -817,4 +817,9 @@ multiclass ZAReadzArray{
 
 defm SVREADZ_VG2 :  ZAReadzArray<"2">;
 defm SVREADZ_VG4 :  ZAReadzArray<"4">;
+
+let SMETargetGuard = "sme2,sme-lutv2" in {
+  def SVWRITE_LANE_ZT : SInst<"svwrite_lane_zt[_{d}]", "vidi", 
"cUcsUsiUilUlfhdb", MergeNone, "aarch64_sme_write_lane_zt", [IsStreaming, 
IsInOutZT0], [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_3>]>;
+  def SVWRITE_ZT : SInst<"svwrite_zt[_{d}]", "vid", "cUcsUsiUilUlfhdb", 
MergeNone, "aarch64_sme_write_zt", [IsStreaming, IsInOutZT0], [ImmCheck<0, 
ImmCheck0_0>]>;
+}
 } // let SVETargetGuard = InvalidMode
diff --git 
a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write_lane_zt.c 
b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write_lane_zt.c
new file mode 100644
index 00..9bdc3481953a21
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write_lane_zt.c
@@ -0,0 +1,401 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// RUN: %clang_cc1  -triple aarch64-none-linux-gnu -target-feature +bf16 
-target-feature +sme -target-feature +sme2 -target-feature +sme-lutv2 -O2 
-Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -x c++  -triple aarch64-none-linux-gnu -target-feature 
+bf16 -target-feature +sme -target-feature +sme2 -target-feature  +sme-lutv2  
-O2 -Werror -Wall -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-CXX
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS   -triple aarch64-none-linux-gnu 
-target-feature +bf16 -target-feature +sme -target-feature +sme2 
-target-feature  +sme-lutv2  -O2 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -x c++  -triple 
aarch64-none-linux-gnu -target-feature +bf16 -target-feature +sme 
-target-feature +sme2 -target-feature +sme-lutv2 -O2 -Werror -Wall -emit-llvm 
-o - %s | FileCheck %s -check-prefix CHECK-CXX
+
+// RUN: %clang_cc1  -triple aarch64-none-linux-gnu -target-feature +bf16 
-target-feature +sme -target-feature +sme2 -target-feature +sme-lutv2 -O2 -S 
-Werror -Wall -o /dev/null %s
+// REQUIRES: aarch64-registered-target
+
+#ifdef SVE_OVERLOADED_FORMS
+#define SVE_ACLE_FUNC(A1,A2_UNUSED) A1
+#else
+#define SVE_ACLE_FUNC(A1,A2) A1##A2
+#endif
+
+#include 
+
+// CHECK-LABEL: define dso_local void @test_write_lane_zt_u8_1(
+// CHECK-SAME:  [[V:%.*]]) local_unnamed_addr 
#[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.write.lane.zt.nxv16i8(i32 
0,  [[V]], i32 1)
+// CHECK-NEXT:ret void
+//
+// CHECK-CXX-LABEL: define dso_local void 
@_Z23test_write_lane_zt_u8_1u11__SVUint8_t(
+// CHECK-CXX-SAME:  [[V:%.*]]) local_unnamed_addr 
#[[ATTR0:[0-9]+]] {
+// CHECK-CXX-NEXT:  [[ENTRY:.*:]]
+// CHECK-CXX-NEXT:tail call void 
@llvm.aarch64.sme.write.lane.zt.nxv16i8(i32 0,  [[V]], i32 1)
+// CHECK-CXX-NEXT:ret void
+//
+void test_write_lane_zt_u8_1(svuint8_t v) __arm_streaming __arm_inout("zt0") {
+  SVE_ACLE_FUNC(svwrite_lane_zt, _u8)(0, v, 1);
+}
+
+// CHECK-LABEL: define dso_local void @test_write_lane_zt_s8_2(
+// CHECK-SAME:  [[V:%.*]]) local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.write.lane.zt.nxv16i8(i32 
0,  [[V]], i32 2)
+// CHECK-NEXT:ret void
+//
+// CHECK-CXX-LAB

[clang] [llvm] [Clang][LLVM][AArch64] Add intrinsic for MOVT SME2 instruction (PR #97602)

2024-09-23 Thread via cfe-commits

https://github.com/CarolineConcatto updated 
https://github.com/llvm/llvm-project/pull/97602

>From 70d1ec0e1c1bd896cf753510a8452325b086430e Mon Sep 17 00:00:00 2001
From: Caroline Concatto 
Date: Wed, 3 Jul 2024 15:55:45 +
Subject: [PATCH 1/7] [Clang][LLVM][AArch64] Add intrinsic for MOVT SME2
 instruction

This patch adds these intrinsics:

  // Variants are also available for:
  // [_s8], [_u16], [_s16], [_u32], [_s32], [_u64], [_s64]
  // [_bf16], [_f16], [_f32], [_f64]
  void svwrite_lane_zt[_u8](uint64_t zt0, svuint8_t zt, uint64_t idx) 
__arm_streaming __arm_inout("zt0");
  void svwrite_zt[_u8](uint64_t zt0, svuint8_t zt) __arm_streaming 
__arm_inout("zt0");

according to PR#324[1]
[1]https://github.com/ARM-software/acle/pull/324
---
 clang/include/clang/Basic/arm_sme.td  |   5 +
 .../acle_sme2_write_lane_zt.c | 401 ++
 .../aarch64-sme2-intrinsics/acle_sme2_imm.cpp |  10 +-
 llvm/include/llvm/IR/IntrinsicsAArch64.td |   9 +
 .../Target/AArch64/AArch64ISelLowering.cpp|   2 +
 .../lib/Target/AArch64/AArch64SMEInstrInfo.td |   2 +-
 llvm/lib/Target/AArch64/SMEInstrFormats.td|  42 +-
 .../AArch64/sme2-intrinsics-read-zt.ll| 162 +++
 8 files changed, 630 insertions(+), 3 deletions(-)
 create mode 100644 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write_lane_zt.c
 create mode 100644 llvm/test/CodeGen/AArch64/sme2-intrinsics-read-zt.ll

diff --git a/clang/include/clang/Basic/arm_sme.td 
b/clang/include/clang/Basic/arm_sme.td
index ce8908f566f2fd..ff68e536e99b09 100644
--- a/clang/include/clang/Basic/arm_sme.td
+++ b/clang/include/clang/Basic/arm_sme.td
@@ -817,4 +817,9 @@ multiclass ZAReadzArray{
 
 defm SVREADZ_VG2 :  ZAReadzArray<"2">;
 defm SVREADZ_VG4 :  ZAReadzArray<"4">;
+
+let SMETargetGuard = "sme2,sme-lutv2" in {
+  def SVWRITE_LANE_ZT : SInst<"svwrite_lane_zt[_{d}]", "vidi", 
"cUcsUsiUilUlfhdb", MergeNone, "aarch64_sme_write_lane_zt", [IsStreaming, 
IsInOutZT0], [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_3>]>;
+  def SVWRITE_ZT : SInst<"svwrite_zt[_{d}]", "vid", "cUcsUsiUilUlfhdb", 
MergeNone, "aarch64_sme_write_zt", [IsStreaming, IsInOutZT0], [ImmCheck<0, 
ImmCheck0_0>]>;
+}
 } // let SVETargetGuard = InvalidMode
diff --git 
a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write_lane_zt.c 
b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write_lane_zt.c
new file mode 100644
index 00..9bdc3481953a21
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write_lane_zt.c
@@ -0,0 +1,401 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// RUN: %clang_cc1  -triple aarch64-none-linux-gnu -target-feature +bf16 
-target-feature +sme -target-feature +sme2 -target-feature +sme-lutv2 -O2 
-Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -x c++  -triple aarch64-none-linux-gnu -target-feature 
+bf16 -target-feature +sme -target-feature +sme2 -target-feature  +sme-lutv2  
-O2 -Werror -Wall -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-CXX
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS   -triple aarch64-none-linux-gnu 
-target-feature +bf16 -target-feature +sme -target-feature +sme2 
-target-feature  +sme-lutv2  -O2 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -x c++  -triple 
aarch64-none-linux-gnu -target-feature +bf16 -target-feature +sme 
-target-feature +sme2 -target-feature +sme-lutv2 -O2 -Werror -Wall -emit-llvm 
-o - %s | FileCheck %s -check-prefix CHECK-CXX
+
+// RUN: %clang_cc1  -triple aarch64-none-linux-gnu -target-feature +bf16 
-target-feature +sme -target-feature +sme2 -target-feature +sme-lutv2 -O2 -S 
-Werror -Wall -o /dev/null %s
+// REQUIRES: aarch64-registered-target
+
+#ifdef SVE_OVERLOADED_FORMS
+#define SVE_ACLE_FUNC(A1,A2_UNUSED) A1
+#else
+#define SVE_ACLE_FUNC(A1,A2) A1##A2
+#endif
+
+#include 
+
+// CHECK-LABEL: define dso_local void @test_write_lane_zt_u8_1(
+// CHECK-SAME:  [[V:%.*]]) local_unnamed_addr 
#[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.write.lane.zt.nxv16i8(i32 
0,  [[V]], i32 1)
+// CHECK-NEXT:ret void
+//
+// CHECK-CXX-LABEL: define dso_local void 
@_Z23test_write_lane_zt_u8_1u11__SVUint8_t(
+// CHECK-CXX-SAME:  [[V:%.*]]) local_unnamed_addr 
#[[ATTR0:[0-9]+]] {
+// CHECK-CXX-NEXT:  [[ENTRY:.*:]]
+// CHECK-CXX-NEXT:tail call void 
@llvm.aarch64.sme.write.lane.zt.nxv16i8(i32 0,  [[V]], i32 1)
+// CHECK-CXX-NEXT:ret void
+//
+void test_write_lane_zt_u8_1(svuint8_t v) __arm_streaming __arm_inout("zt0") {
+  SVE_ACLE_FUNC(svwrite_lane_zt, _u8)(0, v, 1);
+}
+
+// CHECK-LABEL: define dso_local void @test_write_lane_zt_s8_2(
+// CHECK-SAME:  [[V:%.*]]) local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.write.lane.zt.nxv16i8(i32 
0,  [[V]], i32 2)
+// CHECK-NEXT:ret void
+//
+// CHECK-CXX-LAB

[clang] [llvm] [NVPTX] Remove nvvm.bitcast.* intrinsics (PR #107936)

2024-09-23 Thread Alex MacLean via cfe-commits


@@ -599,14 +599,6 @@ TARGET_BUILTIN(__nvvm_e4m3x2_to_f16x2_rn_relu, "V2hs", "", 
AND(SM_89,PTX81))
 TARGET_BUILTIN(__nvvm_e5m2x2_to_f16x2_rn, "V2hs", "", AND(SM_89,PTX81))
 TARGET_BUILTIN(__nvvm_e5m2x2_to_f16x2_rn_relu, "V2hs", "", AND(SM_89,PTX81))
 
-// Bitcast

AlexMaclean wrote:

Thanks! I've just confirmed these do not work in nvcc.

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


[clang] [Clang][Sema] Refactor collection of multi-level template argument lists (PR #106585)

2024-09-23 Thread Krystian Stasiowski via cfe-commits

sdkrystian wrote:

I've manually reduced the standalone reproducer to the following:
```cpp
template
struct A
{
template
static constexpr bool f();
};

template<>
template
constexpr bool A<0>::f()
{
return A<1>::f();
}

template<>
template
constexpr bool A<1>::f()
{
return true;
}

template
constexpr bool g()
{
return A::template f(); // note: undefined function 'f' cannot 
be used in a constant expression
}

template bool g<0>();

static_assert(g<1>()); // error: static assertion expression is not an integral 
constant expression
```
The error does not occur if the explicit instantiation definition (i.e. 
`template bool g<0>()`) is removed. I'm looking into it.

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


[clang] Add support for aligning BlockComments in declarations (PR #109497)

2024-09-23 Thread via cfe-commits

https://github.com/JessehMSFT updated 
https://github.com/llvm/llvm-project/pull/109497

>From 38333491868dfad9c84719d9dd8fd872a2aa7584 Mon Sep 17 00:00:00 2001
From: Jesse Harvey 
Date: Fri, 20 Sep 2024 16:40:35 -0700
Subject: [PATCH 1/2] Add support for aligning BlockComments in declarations

---
 clang/include/clang/Format/Format.h| 25 +++-
 clang/lib/Format/Format.cpp| 22 ---
 clang/lib/Format/WhitespaceManager.cpp | 11 +++-
 clang/unittests/Format/ConfigParseTest.cpp | 73 +++---
 clang/unittests/Format/FormatTest.cpp  | 49 ++-
 5 files changed, 134 insertions(+), 46 deletions(-)

diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index d8b62c7652a0f6..f7b6bfffd61314 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -260,12 +260,35 @@ struct FormatStyle {
 ///   bbb >>= 2;
 /// \endcode
 bool PadOperators;
+/// Only for ``AlignConsecutiveDeclarations``.  Whether block comments
+/// are aligned in declarations.
+/// \code
+///   true:
+///   someLongFunction(int/*a*/,
+///bool   b,
+///const std::string& c)
+///
+///   const bool ret = someLongFunction(4/*a*/,
+/// true /*b*/,
+/// str  /*c*/);
+///
+///   false:
+///   someLongFunction(int /*a*/,
+///bool b,
+///const std::string& c)
+///
+///   const bool ret = someLongFunction(4 /*a*/,
+/// true /*b*/,
+/// str /*c*/);
+/// \endcode
+bool AlignBlockComments;
 bool operator==(const AlignConsecutiveStyle &R) const {
   return Enabled == R.Enabled && AcrossEmptyLines == R.AcrossEmptyLines &&
  AcrossComments == R.AcrossComments &&
  AlignCompound == R.AlignCompound &&
  AlignFunctionPointers == R.AlignFunctionPointers &&
- PadOperators == R.PadOperators;
+ PadOperators == R.PadOperators &&
+ AlignBlockComments == R.AlignBlockComments;
 }
 bool operator!=(const AlignConsecutiveStyle &R) const {
   return !(*this == R);
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index d2463b892fbb96..ab8eadd0171aa6 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -48,39 +48,46 @@ template <> struct 
MappingTraits {
 FormatStyle::AlignConsecutiveStyle(
 {/*Enabled=*/false, /*AcrossEmptyLines=*/false,
  /*AcrossComments=*/false, /*AlignCompound=*/false,
- /*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
+ /*AlignFunctionPointers=*/false, /*PadOperators=*/true,
+ /*AlignBlockComments=*/false}));
 IO.enumCase(Value, "Consecutive",
 FormatStyle::AlignConsecutiveStyle(
 {/*Enabled=*/true, /*AcrossEmptyLines=*/false,
  /*AcrossComments=*/false, /*AlignCompound=*/false,
- /*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
+ /*AlignFunctionPointers=*/false, /*PadOperators=*/true,
+ /*AlignBlockComments=*/false}));
 IO.enumCase(Value, "AcrossEmptyLines",
 FormatStyle::AlignConsecutiveStyle(
 {/*Enabled=*/true, /*AcrossEmptyLines=*/true,
  /*AcrossComments=*/false, /*AlignCompound=*/false,
- /*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
+ /*AlignFunctionPointers=*/false, /*PadOperators=*/true,
+ /*AlignBlockComments=*/false}));
 IO.enumCase(Value, "AcrossComments",
 FormatStyle::AlignConsecutiveStyle(
 {/*Enabled=*/true, /*AcrossEmptyLines=*/false,
  /*AcrossComments=*/true, /*AlignCompound=*/false,
- /*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
+ /*AlignFunctionPointers=*/false, /*PadOperators=*/true,
+ /*AlignBlockComments=*/false}));
 IO.enumCase(Value, "AcrossEmptyLinesAndComments",
 FormatStyle::AlignConsecutiveStyle(
 {/*Enabled=*/true, /*AcrossEmptyLines=*/true,
  /*AcrossComments=*/true, /*AlignCompound=*/false,
- /*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
+ /*AlignFunctionPointers=*/false, /*PadOperators=*/true,
+ /*AlignBlockComments=*/false}));
 
 // For backward compatibility.
 IO.enumCase(Value, "true",
 FormatStyle::AlignConsecutiveStyle(

[clang] [llvm] [clang] Add "debug_transparent" attribute (PR #109490)

2024-09-23 Thread Michael Buch via cfe-commits


@@ -109,6 +110,21 @@ static bool IsArtificial(VarDecl const *VD) {
   cast(VD->getDeclContext())->isImplicit());
 }
 
+static bool usesDebugTransparent(const Decl *D, const CodeGenModule &CGM) {
+  if (!D)
+return false;
+
+  if (auto *attr = D->getAttr()) {

Michael137 wrote:

```suggestion
  if (D->hasAttr()) {
```

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


[clang] [llvm] [clang] Add "debug_transparent" attribute (PR #109490)

2024-09-23 Thread Michael Buch via cfe-commits


@@ -109,6 +110,21 @@ static bool IsArtificial(VarDecl const *VD) {
   cast(VD->getDeclContext())->isImplicit());
 }
 
+static bool usesDebugTransparent(const Decl *D, const CodeGenModule &CGM) {
+  if (!D)
+return false;
+
+  if (auto *attr = D->getAttr()) {
+auto opts = CGM.getCodeGenOpts();
+if (opts.DwarfVersion == 0) {
+  auto &diags = CGM.getDiags();
+  diags.Report(attr->getLocation(), diag::warn_debug_transparent_ignored);

Michael137 wrote:

Nit:
```suggestion
  CGM.getDiags().Report(attr->getLocation(), 
diag::warn_debug_transparent_ignored);
```

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


[clang] [llvm] [clang] Add "debug_transparent" attribute (PR #109490)

2024-09-23 Thread Michael Buch via cfe-commits


@@ -109,6 +110,21 @@ static bool IsArtificial(VarDecl const *VD) {
   cast(VD->getDeclContext())->isImplicit());
 }
 
+static bool usesDebugTransparent(const Decl *D, const CodeGenModule &CGM) {
+  if (!D)
+return false;
+
+  if (auto *attr = D->getAttr()) {

Michael137 wrote:

Might also be worth inverting this condition and preferring early-return style.

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


[clang] [Clang] Add explicit visibility symbol macros (PR #108276)

2024-09-23 Thread Saleem Abdulrasool via cfe-commits


@@ -0,0 +1,69 @@
+//===-- clang/Support/Compiler.h - Compiler abstraction support -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file defines explicit visibility macros used to export symbols from
+// clang-cpp
+//
+//===--===//
+
+#ifndef CLANG_SUPPORT_COMPILER_H
+#define CLANG_SUPPORT_COMPILER_H
+
+#include "llvm/Support/Compiler.h"
+
+/// CLANG_ABI is the main export/visibility macro to mark something as
+/// explicitly exported when clang is built as a shared library with everything
+/// else that is unannotated will have internal visibility.
+///
+/// CLANG_EXPORT_TEMPLATE is used on explicit template instantiations in source
+/// files that were declared extern in a header. This macro is only set as a
+/// compiler export attribute on windows, on other platforms it does nothing.
+///
+/// CLANG_TEMPLATE_ABI is for annotating extern template declarations in 
headers
+/// for both functions and classes. On windows its turned in to dllimport for
+/// library consumers, for other platforms its a default visibility attribute.
+#ifndef CLANG_ABI_GENERATING_ANNOTATIONS
+// Marker to add to classes or functions in public headers that should not have
+// export macros added to them by the clang tool
+#define CLANG_ABI_NOT_EXPORTED
+#if defined(LLVM_BUILD_LLVM_DYLIB) || defined(LLVM_BUILD_SHARED_LIBS)

compnerd wrote:

I don't know about this - we could be building LLVM dynamically and clang 
statically. I don't think that we should use the same macros for clang.

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


[clang] [Clang] Add explicit visibility symbol macros (PR #108276)

2024-09-23 Thread Saleem Abdulrasool via cfe-commits


@@ -0,0 +1,69 @@
+//===-- clang/Support/Compiler.h - Compiler abstraction support -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file defines explicit visibility macros used to export symbols from
+// clang-cpp
+//
+//===--===//
+
+#ifndef CLANG_SUPPORT_COMPILER_H
+#define CLANG_SUPPORT_COMPILER_H
+
+#include "llvm/Support/Compiler.h"
+
+/// CLANG_ABI is the main export/visibility macro to mark something as
+/// explicitly exported when clang is built as a shared library with everything
+/// else that is unannotated will have internal visibility.
+///
+/// CLANG_EXPORT_TEMPLATE is used on explicit template instantiations in source
+/// files that were declared extern in a header. This macro is only set as a
+/// compiler export attribute on windows, on other platforms it does nothing.
+///
+/// CLANG_TEMPLATE_ABI is for annotating extern template declarations in 
headers
+/// for both functions and classes. On windows its turned in to dllimport for
+/// library consumers, for other platforms its a default visibility attribute.
+#ifndef CLANG_ABI_GENERATING_ANNOTATIONS
+// Marker to add to classes or functions in public headers that should not have
+// export macros added to them by the clang tool
+#define CLANG_ABI_NOT_EXPORTED
+#if defined(LLVM_BUILD_LLVM_DYLIB) || defined(LLVM_BUILD_SHARED_LIBS)
+// Some libraries like those for tablegen are linked in to tools that used
+// in the build so can't depend on the llvm shared library. If export macros
+// were left enabled when building these we would get duplicate or
+// missing symbol linker errors on windows.
+#if defined(CLANG_BUILD_STATIC)
+#define CLANG_ABI
+#define CLANG_TEMPLATE_ABI
+#define CLANG_EXPORT_TEMPLATE
+#elif defined(_WIN32) && !defined(__MINGW32__)
+#if defined(CLANG_EXPORTS)
+#define CLANG_ABI __declspec(dllexport)
+#define CLANG_TEMPLATE_ABI
+#define CLANG_EXPORT_TEMPLATE __declspec(dllexport)
+#else
+#define CLANG_ABI __declspec(dllimport)
+#define CLANG_TEMPLATE_ABI __declspec(dllimport)
+#define CLANG_EXPORT_TEMPLATE
+#endif
+#elif defined(__ELF__) || defined(__MINGW32__) || defined(_AIX)
+#define CLANG_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
+#define CLANG_TEMPLATE_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
+#define CLANG_EXPORT_TEMPLATE
+#elif defined(__MACH__) || defined(__WASM__)
+#define CLANG_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
+#define CLANG_TEMPLATE_ABI
+#define CLANG_EXPORT_TEMPLATE
+#endif
+#else
+#define CLANG_ABI
+#define CLANG_TEMPLATE_ABI
+#define CLANG_EXPORT_TEMPLATE
+#endif
+#endif

compnerd wrote:

The lack of indentation makes this very difficult to read. There are too many 
branches between the static and dynamic builds, and the various differences in 
the annotations.

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


[clang] [llvm] [clang] Add "debug_transparent" attribute (PR #109490)

2024-09-23 Thread Michael Buch via cfe-commits

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


[clang] [Clang] Add explicit visibility symbol macros (PR #108276)

2024-09-23 Thread Saleem Abdulrasool via cfe-commits


@@ -7,6 +7,7 @@
 # 
//======//
 
 set(LLVM_LINK_COMPONENTS Support)
-add_clang_tool(nvptx-arch NVPTXArch.cpp)
+add_clang_tool(nvptx-arch DISABLE_CLANG_LINK_DYLIB

compnerd wrote:

Likewise

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


[clang] [Clang] Add explicit visibility symbol macros (PR #108276)

2024-09-23 Thread Saleem Abdulrasool via cfe-commits


@@ -8,6 +8,7 @@
 
 set(LLVM_LINK_COMPONENTS Support)
 
-add_clang_tool(amdgpu-arch AMDGPUArch.cpp AMDGPUArchByHSA.cpp 
AMDGPUArchByHIP.cpp)
+add_clang_tool(amdgpu-arch DISABLE_CLANG_LINK_DYLIB

compnerd wrote:

Why is this not allowed? Can we add a note about this?

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


[clang] [Clang] Add explicit visibility symbol macros (PR #108276)

2024-09-23 Thread Saleem Abdulrasool via cfe-commits


@@ -26,7 +26,7 @@ if(NOT CLANG_BUILT_STANDALONE)
   set(tablegen_deps intrinsics_gen LinkerWrapperOpts)
 endif()
 
-add_clang_tool(clang-linker-wrapper
+add_clang_tool(clang-linker-wrapper DISABLE_CLANG_LINK_DYLIB

compnerd wrote:

Similar

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


[clang] [llvm] [clang] Add "debug_transparent" attribute (PR #109490)

2024-09-23 Thread Michael Buch via cfe-commits


@@ -4160,6 +4178,8 @@ llvm::DISubprogram 
*CGDebugInfo::getFunctionFwdDeclOrStub(GlobalDecl GD,
   if (Stub) {
 Flags |= getCallSiteRelatedAttrs();
 SPFlags |= llvm::DISubprogram::SPFlagDefinition;
+if (usesDebugTransparent(FD, CGM))

Michael137 wrote:

Do we really need this?

AFAICT, the stub is only generated when we do 
`EmitInlinedInheritingCXXConstructorCall`. Those inheriting constructors don't 
support the `debug_transparent` attribute anyway. I think it would be 
sufficient to just add a test that ensures we do the right thing for inlined 
functions.

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


[clang] [llvm] [clang] Add "debug_transparent" attribute (PR #109490)

2024-09-23 Thread Michael Buch via cfe-commits


@@ -109,6 +110,21 @@ static bool IsArtificial(VarDecl const *VD) {
   cast(VD->getDeclContext())->isImplicit());
 }
 
+static bool usesDebugTransparent(const Decl *D, const CodeGenModule &CGM) {
+  if (!D)
+return false;
+
+  if (auto *attr = D->getAttr()) {
+auto opts = CGM.getCodeGenOpts();
+if (opts.DwarfVersion == 0) {

Michael137 wrote:

Nit:
```suggestion
if (CGM.getCodeGenOpts().DwarfVersion == 0) {
```

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


  1   2   3   4   5   >