[clang] [llvm] Remove mmx 3dnow (PR #96246)

2024-06-21 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang commented:

This is much like what we have removed for KNL intrinsics/instructions., so 
general LGTM. But I'd like Simon to sign off given I'm not familar with 3DNOW 
instructions.

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


[clang] [Clang][AArch64] Expose compatible SVE intrinsics with only +sme (PR #95787)

2024-06-21 Thread Sander de Smalen via cfe-commits

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


[clang] ae41232 - [clang][Interp] Fix Descriptor::getElemQualType() for complex/vectors

2024-06-21 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-06-21T09:34:18+02:00
New Revision: ae41232191ec73b5ee96e5f21df99a42ca25d626

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

LOG: [clang][Interp] Fix Descriptor::getElemQualType() for complex/vectors

We handle them like arrays but still need to differentiate between
array/vector/complex types when dealing with QualTypes.

Added: 


Modified: 
clang/lib/AST/Interp/Descriptor.cpp
clang/test/AST/Interp/vectors.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/Descriptor.cpp 
b/clang/lib/AST/Interp/Descriptor.cpp
index d20ab1340c890..fcb778f7aeab0 100644
--- a/clang/lib/AST/Interp/Descriptor.cpp
+++ b/clang/lib/AST/Interp/Descriptor.cpp
@@ -359,8 +359,14 @@ QualType Descriptor::getType() const {
 
 QualType Descriptor::getElemQualType() const {
   assert(isArray());
-  const auto *AT = cast(getType());
-  return AT->getElementType();
+  QualType T = getType();
+  if (const auto *AT = T->getAsArrayTypeUnsafe())
+return AT->getElementType();
+  if (const auto *CT = T->getAs())
+return CT->getElementType();
+  if (const auto *CT = T->getAs())
+return CT->getElementType();
+  llvm_unreachable("Array that's not an array/complex/vector type?");
 }
 
 SourceLocation Descriptor::getLocation() const {

diff  --git a/clang/test/AST/Interp/vectors.cpp 
b/clang/test/AST/Interp/vectors.cpp
index 61c400b57b3f8..6991a348b07a9 100644
--- a/clang/test/AST/Interp/vectors.cpp
+++ b/clang/test/AST/Interp/vectors.cpp
@@ -81,3 +81,13 @@ namespace VectorElementExpr {
   static_assert(twoElts.x == 22, ""); // ref-error {{not an integral constant 
expression}}
   static_assert(twoElts.y == 33, ""); // ref-error {{not an integral constant 
expression}}
 }
+
+namespace Temporaries {
+  typedef __attribute__((vector_size(16))) int vi4a;
+  typedef __attribute__((ext_vector_type(4))) int vi4b;
+  struct S {
+vi4a v;
+vi4b w;
+  };
+  int &&s = S().w[1];
+}



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


[clang] 0adecfb - [clang][test] Enable a commented-out test (#96195)

2024-06-21 Thread via cfe-commits

Author: Timm Baeder
Date: 2024-06-21T09:35:25+02:00
New Revision: 0adecfbc393e86def951bca3516593a0a58ca7d0

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

LOG: [clang][test] Enable a commented-out test (#96195)

This doesn't seem to crash anymore.

Added: 


Modified: 
clang/test/CodeGenCXX/temporaries.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/temporaries.cpp 
b/clang/test/CodeGenCXX/temporaries.cpp
index 186f4934873fa..f992ce206c581 100644
--- a/clang/test/CodeGenCXX/temporaries.cpp
+++ b/clang/test/CodeGenCXX/temporaries.cpp
@@ -683,8 +683,7 @@ namespace Vector {
   // CHECK: store i32 {{.*}}, ptr @_ZGRN6Vector1sE_
   // CHECK: store ptr @_ZGRN6Vector1sE_, ptr @_ZN6Vector1sE,
   int &&s = S().w[1];
-  // FIXME PR16204: The following code leads to an assertion in Sema.
-  //int &&s = S().w.y;
+  int &&ss = S().w.y;
 }
 
 namespace ImplicitTemporaryCleanup {



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


[clang] [clang][test] Enable a commented-out test (PR #96195)

2024-06-21 Thread Timm Baeder via cfe-commits

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


[clang] [llvm] [RISCV] Add riscv_atomic.h and Zawrs/Zalrsc builtins (PR #94578)

2024-06-21 Thread Pengcheng Wang via cfe-commits

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


[clang] [Clang] Clarify diagnostic notes for implicitly generated deduction guides (PR #96084)

2024-06-21 Thread Haojian Wu via cfe-commits

hokein wrote:


Thanks for the patch! +1 on the idea of printing deduction guides in 
diagnostics. This improves the experience for both users and compiler 
developers. This is https://github.com/llvm/llvm-project/issues/92393 :)

> Perhaps an approach more similar to what we display for ambiguous cast paths 
> would be better, i.e., listing each implicit deduction guide we tried in a 
> single note.
>
> Thanks for suggesting a better approach. However, implementing this would 
> require significant changes to our diagnostic logic for overloads. We 
> currently explain the reasons for deduction failure in subsequent notes, with 
> around 16 different kinds of deduction failures, each with its own diagnostic 
> message. Given this complexity, I don't think it's necessary (or feasible) to 
> special-case CTAD guides for each note.

In my opinion, including the deduction guide in the existing note (e.g., 
`candidate template "template S()-> S" ignored: ...`) is clearer 
and more concise. It seems that the current implementation in clang assumes all 
template candidates are written in the source code, which isn't true for the 
CTAD case. We could extend it to work for not-explicitly-written-in-source-code 
case. 
Although we have 19 `candidate template ignored` notes, they are mostly 
localized in `SemaOverload.cpp`. Extending them is possible but would require 
some work.

However, I don't feel strongly about this, and am also fine with the current 
implementation, as it has already improved the experience.





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


[clang] [Clang] Clarify diagnostic notes for implicitly generated deduction guides (PR #96084)

2024-06-21 Thread Haojian Wu via cfe-commits


@@ -12114,6 +12115,35 @@ static void NoteFunctionCandidate(Sema &S, 
OverloadCandidate *Cand,
 return;
   }
 
+  // If this is an implicit deduction guide against an implicitly defined
+  // constructor, add a note for it. Neither these deduction guides nor their
+  // corresponding constructors are explicitly spelled in the source code,
+  // and simply producing a deduction failure note around the heading of the
+  // enclosing RecordDecl would be confusing.
+  //
+  // We prefer adding such notes at the end of the last deduction failure
+  // reason because duplicate code snippets appearing in the diagnostic
+  // would likely become noisy.
+  auto _ = llvm::make_scope_exit([&] {
+auto *DG = dyn_cast(Fn);
+if (!DG || !DG->isImplicit() || DG->getCorrespondingConstructor())

hokein wrote:

(I assume we always print using-alias deduction guides)

Note that checking the implicit guides is not sufficient for using-alias 
deduction guides. Those synthesized from the explicitly written deduction guide 
will retain the explicit bit (to ensure correct function overload resolution).


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


[clang] [Clang] Clarify diagnostic notes for implicitly generated deduction guides (PR #96084)

2024-06-21 Thread Haojian Wu via cfe-commits


@@ -12114,6 +12115,35 @@ static void NoteFunctionCandidate(Sema &S, 
OverloadCandidate *Cand,
 return;
   }
 
+  // If this is an implicit deduction guide against an implicitly defined
+  // constructor, add a note for it. Neither these deduction guides nor their
+  // corresponding constructors are explicitly spelled in the source code,

hokein wrote:

Any reason to filter out the "explicit constructor" case? We still synthesize a 
deduction guide from a constructor, and they are not identical, e.g. its 
template parameters is a combination of template parameters of the class and 
template parameters of the corresponding constructor. I think it is useful to 
print them as well.

I think a simple model here would be that we always print synthesized deduction 
guides (this covers the using-alias case.)

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


[clang-tools-extra] [clang-tidy] Clarify diagnostics of bugprone-sizeof-expression (PR #95550)

2024-06-21 Thread Donát Nagy via cfe-commits


@@ -342,31 +342,33 @@ void SizeofExpressionCheck::check(const 
MatchFinder::MatchResult &Result) {
 
 if (DenominatorSize > CharUnits::Zero() &&
 !NumeratorSize.isMultipleOf(DenominatorSize)) {
-  diag(E->getOperatorLoc(), "suspicious usage of 
'sizeof(...)/sizeof(...)';"
+  diag(E->getOperatorLoc(), "suspicious usage of 
'sizeof(...)/sizeof(...)':"
 " numerator is not a multiple of denominator")
   << E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange();
 } else if (ElementSize > CharUnits::Zero() &&
DenominatorSize > CharUnits::Zero() &&
ElementSize != DenominatorSize) {
-  diag(E->getOperatorLoc(), "suspicious usage of 
'sizeof(...)/sizeof(...)';"
-" numerator is not a multiple of denominator")
+  diag(E->getOperatorLoc(),
+   "suspicious usage of 'sizeof(array)/sizeof(...)':"

NagyDonat wrote:

It would be slightly better in isolation, but all the other diagnostics look 
like e.g. `suspicious usage of 'sizeof(..., ...)'` or `suspicious usage of 
'sizeof(this)'; did you mean 'sizeof(*this)'` so for the sake of consistency 
I'd like to leave this aspect of the messages unchanged.

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


[clang] [llvm] [RISCV] Add riscv_atomic.h and Zawrs builtins (PR #96283)

2024-06-21 Thread Pengcheng Wang via cfe-commits

https://github.com/wangpc-pp created 
https://github.com/llvm/llvm-project/pull/96283

`riscv_atomic.h` contains all builtins for atomics.

Currently, we suppoprt builtins for Zawrs extension.

Doc: https://github.com/riscv-non-isa/riscv-c-api-doc/pull/79


>From 4b597ebf69de59d62e5587a27cedf2b12e831763 Mon Sep 17 00:00:00 2001
From: Wang Pengcheng 
Date: Fri, 21 Jun 2024 16:09:13 +0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6-beta.1
---
 clang/include/clang/Basic/BuiltinsRISCV.td|  8 
 clang/lib/CodeGen/CGBuiltin.cpp   |  8 
 clang/lib/Headers/CMakeLists.txt  |  1 +
 clang/lib/Headers/riscv_atomic.h  | 18 
 .../CodeGen/RISCV/atomics-intrinsics/zawrs.c  | 42 +++
 llvm/include/llvm/IR/IntrinsicsRISCV.td   | 10 +
 llvm/lib/Target/RISCV/RISCVInstrInfoZa.td |  5 ++-
 llvm/test/CodeGen/RISCV/zawrs-intrinsic.ll| 33 +++
 8 files changed, 124 insertions(+), 1 deletion(-)
 create mode 100644 clang/lib/Headers/riscv_atomic.h
 create mode 100644 clang/test/CodeGen/RISCV/atomics-intrinsics/zawrs.c
 create mode 100644 llvm/test/CodeGen/RISCV/zawrs-intrinsic.ll

diff --git a/clang/include/clang/Basic/BuiltinsRISCV.td 
b/clang/include/clang/Basic/BuiltinsRISCV.td
index 4cc89a8a9d8af..429f1356aa5fd 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.td
+++ b/clang/include/clang/Basic/BuiltinsRISCV.td
@@ -146,3 +146,11 @@ let Features = "zihintntl", Attributes = 
[CustomTypeChecking] in {
 def ntl_load : RISCVBuiltin<"void(...)">;
 def ntl_store : RISCVBuiltin<"void(...)">;
 } // Features = "zihintntl", Attributes = [CustomTypeChecking]
+
+//===--===//
+// Zawrs extension.
+//===--===//
+let Features = "zawrs" in {
+def wrs_nto : RISCVBuiltin<"void()">;
+def wrs_sto : RISCVBuiltin<"void()">;
+} // Features = "zawrs"
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 2516ed4508242..1e130cad6d00d 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -21834,6 +21834,14 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
 ID = Intrinsic::riscv_sm3p1;
 break;
 
+  // Zawrs
+  case RISCV::BI__builtin_riscv_wrs_nto:
+ID = Intrinsic::riscv_wrs_nto;
+break;
+  case RISCV::BI__builtin_riscv_wrs_sto:
+ID = Intrinsic::riscv_wrs_sto;
+break;
+
   // Zihintntl
   case RISCV::BI__builtin_riscv_ntl_load: {
 llvm::Type *ResTy = ConvertType(E->getType());
diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index 89fa0ecd45eb4..f8f430e6921cb 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -118,6 +118,7 @@ set(ppc_htm_files
   )
 
 set(riscv_files
+  riscv_atomic.h
   riscv_bitmanip.h
   riscv_crypto.h
   riscv_ntlh.h
diff --git a/clang/lib/Headers/riscv_atomic.h b/clang/lib/Headers/riscv_atomic.h
new file mode 100644
index 0..4c548bdfa8253
--- /dev/null
+++ b/clang/lib/Headers/riscv_atomic.h
@@ -0,0 +1,18 @@
+/*=== riscv_atomic.h - RISC-V atomic intrinsics ===
+ *
+ * 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
+ *
+ *===---===
+ */
+
+#ifndef __RISCV_ATOMIC_H
+#define __RISCV_ATOMIC_H
+
+#ifdef __riscv_zawrs
+#define __riscv_wrs_nto __builtin_riscv_wrs_nto
+#define __riscv_wrs_sto __builtin_riscv_wrs_sto
+#endif
+
+#endif
diff --git a/clang/test/CodeGen/RISCV/atomics-intrinsics/zawrs.c 
b/clang/test/CodeGen/RISCV/atomics-intrinsics/zawrs.c
new file mode 100644
index 0..e3d4899244ca4
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/atomics-intrinsics/zawrs.c
@@ -0,0 +1,42 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv32 -target-feature +zawrs -disable-O0-optnone \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefixes=CHECK-RV32 %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zawrs -disable-O0-optnone \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV32-LABEL: define dso_local void @zawrs_nto
+// CHECK-RV32-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:call void @llvm.riscv.wrs.nto()
+// CHECK-RV32-NEXT:ret void
+//
+// CHECK-RV64-LABEL: define dso_local void @zawrs_nto
+// CHECK-RV64-SAME

[clang] [llvm] [RISCV] Add riscv_atomic.h and Zawrs builtins (PR #96283)

2024-06-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Pengcheng Wang (wangpc-pp)


Changes

`riscv_atomic.h` contains all builtins for atomics.

Currently, we suppoprt builtins for Zawrs extension.

Doc: https://github.com/riscv-non-isa/riscv-c-api-doc/pull/79


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


8 Files Affected:

- (modified) clang/include/clang/Basic/BuiltinsRISCV.td (+8) 
- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+8) 
- (modified) clang/lib/Headers/CMakeLists.txt (+1) 
- (added) clang/lib/Headers/riscv_atomic.h (+18) 
- (added) clang/test/CodeGen/RISCV/atomics-intrinsics/zawrs.c (+42) 
- (modified) llvm/include/llvm/IR/IntrinsicsRISCV.td (+10) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoZa.td (+4-1) 
- (added) llvm/test/CodeGen/RISCV/zawrs-intrinsic.ll (+33) 


``diff
diff --git a/clang/include/clang/Basic/BuiltinsRISCV.td 
b/clang/include/clang/Basic/BuiltinsRISCV.td
index 4cc89a8a9d8af..429f1356aa5fd 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.td
+++ b/clang/include/clang/Basic/BuiltinsRISCV.td
@@ -146,3 +146,11 @@ let Features = "zihintntl", Attributes = 
[CustomTypeChecking] in {
 def ntl_load : RISCVBuiltin<"void(...)">;
 def ntl_store : RISCVBuiltin<"void(...)">;
 } // Features = "zihintntl", Attributes = [CustomTypeChecking]
+
+//===--===//
+// Zawrs extension.
+//===--===//
+let Features = "zawrs" in {
+def wrs_nto : RISCVBuiltin<"void()">;
+def wrs_sto : RISCVBuiltin<"void()">;
+} // Features = "zawrs"
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 2516ed4508242..1e130cad6d00d 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -21834,6 +21834,14 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
 ID = Intrinsic::riscv_sm3p1;
 break;
 
+  // Zawrs
+  case RISCV::BI__builtin_riscv_wrs_nto:
+ID = Intrinsic::riscv_wrs_nto;
+break;
+  case RISCV::BI__builtin_riscv_wrs_sto:
+ID = Intrinsic::riscv_wrs_sto;
+break;
+
   // Zihintntl
   case RISCV::BI__builtin_riscv_ntl_load: {
 llvm::Type *ResTy = ConvertType(E->getType());
diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index 89fa0ecd45eb4..f8f430e6921cb 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -118,6 +118,7 @@ set(ppc_htm_files
   )
 
 set(riscv_files
+  riscv_atomic.h
   riscv_bitmanip.h
   riscv_crypto.h
   riscv_ntlh.h
diff --git a/clang/lib/Headers/riscv_atomic.h b/clang/lib/Headers/riscv_atomic.h
new file mode 100644
index 0..4c548bdfa8253
--- /dev/null
+++ b/clang/lib/Headers/riscv_atomic.h
@@ -0,0 +1,18 @@
+/*=== riscv_atomic.h - RISC-V atomic intrinsics ===
+ *
+ * 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
+ *
+ *===---===
+ */
+
+#ifndef __RISCV_ATOMIC_H
+#define __RISCV_ATOMIC_H
+
+#ifdef __riscv_zawrs
+#define __riscv_wrs_nto __builtin_riscv_wrs_nto
+#define __riscv_wrs_sto __builtin_riscv_wrs_sto
+#endif
+
+#endif
diff --git a/clang/test/CodeGen/RISCV/atomics-intrinsics/zawrs.c 
b/clang/test/CodeGen/RISCV/atomics-intrinsics/zawrs.c
new file mode 100644
index 0..e3d4899244ca4
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/atomics-intrinsics/zawrs.c
@@ -0,0 +1,42 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv32 -target-feature +zawrs -disable-O0-optnone \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefixes=CHECK-RV32 %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zawrs -disable-O0-optnone \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV32-LABEL: define dso_local void @zawrs_nto
+// CHECK-RV32-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:call void @llvm.riscv.wrs.nto()
+// CHECK-RV32-NEXT:ret void
+//
+// CHECK-RV64-LABEL: define dso_local void @zawrs_nto
+// CHECK-RV64-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:call void @llvm.riscv.wrs.nto()
+// CHECK-RV64-NEXT:ret void
+//
+void zawrs_nto() {
+  __riscv_wrs_nto();
+}
+
+// CHECK-RV32-LABEL: define dso_local void @zawrs_sto
+// CHECK-RV32-SAME: () #[[ATTR0]] {
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:call void @llvm.riscv.wrs.sto()
+// CHECK-RV32-NEXT:ret void
+//
+// CHECK-RV64-LABEL: define dso_local void @zawrs_sto
+// CHECK-RV64-SAME: () #[[ATTR0]] {
+// 

[clang] [clang] Change style of superseded issues on C++ DR status page (PR #96051)

2024-06-21 Thread via cfe-commits

h-vetinari wrote:

I was wondering for a while along similar lines, if NAD ("not a defect") 
shouldn't get a downgraded colour as well. A "No" to  NAD is certainly less 
relevant than an actual defect report, isn't it?

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


[clang] [flang] [mlir] [flang] Add basic -mtune support (PR #95043)

2024-06-21 Thread Christian Ulmann via cfe-commits

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

The MLIR side looks good to me % one remaining nit comment. Thanks for 
addressing the comments.

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


[clang] [flang] [mlir] [flang] Add basic -mtune support (PR #95043)

2024-06-21 Thread Christian Ulmann via cfe-commits

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


[clang] [flang] [mlir] [flang] Add basic -mtune support (PR #95043)

2024-06-21 Thread Christian Ulmann via cfe-commits


@@ -0,0 +1,9 @@
+; RUN: mlir-translate -import-llvm -split-input-file %s | FileCheck %s
+
+; CHECK-LABEL: llvm.func @tune_cpu()
+; CHECK-SAME: tune_cpu = "pentium4"

Dinistro wrote:

Given that we are both not entirely sure what happens, it might be sensible to 
check for that, just to be sure 🙂 

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


[clang] Enable ASAN in amdgpu toolchain for OpenCL (PR #96262)

2024-06-21 Thread Matt Arsenault via cfe-commits

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


[clang] Enable ASAN in amdgpu toolchain for OpenCL (PR #96262)

2024-06-21 Thread Matt Arsenault via cfe-commits

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


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


[clang] Enable ASAN in amdgpu toolchain for OpenCL (PR #96262)

2024-06-21 Thread Matt Arsenault via cfe-commits


@@ -169,6 +180,11 @@
 // COMMON-UNSAFE-MATH-SAME: "-mlink-builtin-bitcode" 
"{{.*}}/amdgcn/bitcode/oclc_finite_only_off.bc"
 // COMMON-UNSAFE-MATH-SAME: "-mlink-builtin-bitcode" 
"{{.*}}/amdgcn/bitcode/oclc_correctly_rounded_sqrt_off.bc"
 
+// ASAN-SAME: "-fsanitize=address"
+
+// NOASAN-NOT: "-fsanitize=address"
+// NOASAN-NOT: amdgcn/bitcode/asanrtl.bc

arsenm wrote:

Usual gripe about fragility of negative tests 

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


[clang] b635d69 - [NFC] Fix laod -> load typos. NFC

2024-06-21 Thread David Green via cfe-commits

Author: David Green
Date: 2024-06-21T09:26:44+01:00
New Revision: b635d690ed1e3fbebab9dee1b157fa380d3e9eba

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

LOG: [NFC] Fix laod -> load typos. NFC

Added: 


Modified: 
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaHLSL/ScalarOverloadResolution.hlsl
clang/test/SemaHLSL/VectorElementOverloadResolution.hlsl
llvm/lib/Target/AMDGPU/AMDGPUPostLegalizerCombiner.cpp
llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
llvm/test/CodeGen/AArch64/speculation-hardening-loads.ll
llvm/test/CodeGen/X86/load-partial-dot-product.ll
llvm/test/tools/yaml2obj/COFF/load-config.yaml

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index d38700d56e4ff..c1189e6935dc9 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -16111,7 +16111,7 @@ ExprResult Sema::BuildCXXConstructExpr(
 CXXConstructionKind ConstructKind, SourceRange ParenRange) {
   if (auto *Shadow = dyn_cast(FoundDecl)) {
 Constructor = findInheritingConstructor(ConstructLoc, Constructor, Shadow);
-// The only way to get here is if we did overlaod resolution to find the
+// The only way to get here is if we did overload resolution to find the
 // shadow decl, so we don't need to worry about re-checking the trailing
 // requires clause.
 if (DiagnoseUseOfOverloadedDecl(Constructor, ConstructLoc))

diff  --git a/clang/test/SemaHLSL/ScalarOverloadResolution.hlsl 
b/clang/test/SemaHLSL/ScalarOverloadResolution.hlsl
index 41702ef175320..d1a47af228e24 100644
--- a/clang/test/SemaHLSL/ScalarOverloadResolution.hlsl
+++ b/clang/test/SemaHLSL/ScalarOverloadResolution.hlsl
@@ -72,7 +72,7 @@ void Case1(half H, float F, double D) {
   HalfFloatDouble(D);
 }
 
-// Case 2: A function declared with double and float overlaods.
+// Case 2: A function declared with double and float overloads.
 //   (a) When called with half, it will resolve to float because float is lower
 //   ranked than double.
 //   (b) When called with float it will resolve to float because float is an

diff  --git a/clang/test/SemaHLSL/VectorElementOverloadResolution.hlsl 
b/clang/test/SemaHLSL/VectorElementOverloadResolution.hlsl
index 12575084ead2b..bbf8d3b5e102c 100644
--- a/clang/test/SemaHLSL/VectorElementOverloadResolution.hlsl
+++ b/clang/test/SemaHLSL/VectorElementOverloadResolution.hlsl
@@ -71,7 +71,7 @@ void Case1(half2 H, float2 F, double2 D) {
   HalfFloatDouble(D);
 }
 
-// Case 2: A function declared with double and float overlaods.
+// Case 2: A function declared with double and float overloads.
 //   (a) When called with half, it will resolve to float because float is lower
 //   ranked than double.
 //   (b) When called with float it will resolve to float because float is an

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUPostLegalizerCombiner.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUPostLegalizerCombiner.cpp
index 46d44704af5a7..cfe9f33efc91b 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUPostLegalizerCombiner.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUPostLegalizerCombiner.cpp
@@ -100,7 +100,7 @@ class AMDGPUPostLegalizerCombinerImpl : public Combiner {
   bool matchRemoveFcanonicalize(MachineInstr &MI, Register &Reg) const;
 
   // Combine unsigned buffer load and signed extension instructions to generate
-  // signed buffer laod instructions.
+  // signed buffer load instructions.
   bool matchCombineSignExtendInReg(
   MachineInstr &MI, std::pair &MatchInfo) const;
   void applyCombineSignExtendInReg(

diff  --git a/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp 
b/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
index 471c7ca4d7356..4e515e05c842a 100644
--- a/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
+++ b/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
@@ -57,7 +57,7 @@
 //
 // base = gep a, 0, x, y
 // load base
-// laod base + 1  * sizeof(float)
+// load base + 1  * sizeof(float)
 // load base + 32 * sizeof(float)
 // load base + 33 * sizeof(float)
 //

diff  --git a/llvm/test/CodeGen/AArch64/speculation-hardening-loads.ll 
b/llvm/test/CodeGen/AArch64/speculation-hardening-loads.ll
index 03b41db2291a2..6a95859c7692d 100644
--- a/llvm/test/CodeGen/AArch64/speculation-hardening-loads.ll
+++ b/llvm/test/CodeGen/AArch64/speculation-hardening-loads.ll
@@ -22,7 +22,7 @@ define double @ld_double(ptr %p) speculative_load_hardening {
 entry:
   %0 = load double, ptr %p, align 8
   ret double %0
-; Checking that the address laoded from is masked for a floating point load.
+; Checking that the address loaded from is masked for a floating point load.
 ; CHECK-LABEL: ld_double
 ; CHECK:  cmp sp, #0
 ; CHECK-NEXT: csetm x16, ne
@@ -43,7 +43,7 @@ entry:
   

[clang] Clang: Support minimumnum and maximumnum intrinsics (PR #96281)

2024-06-21 Thread Nikolas Klauser via cfe-commits


@@ -3636,6 +3648,22 @@ def Fmin : FPMathTemplate, LibBuiltin<"math.h"> {
   let OnlyBuiltinPrefixedAliasIsConstexpr = 1;
 }
 
+def FmaximumNum : FPMathTemplate, LibBuiltin<"math.h"> {

philnik777 wrote:

Why is this a libbuiltin? IIUC this is only supposed to be an intrinsic, never 
alibrary function.

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


[clang] d59a4ca - [RISCV] Add Syntacore SCR3 processor definition (#95953)

2024-06-21 Thread via cfe-commits

Author: Anton Sidorenko
Date: 2024-06-21T11:40:10+03:00
New Revision: d59a4cac5fe6c05da0e9088aad8f94c207423c36

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

LOG: [RISCV] Add Syntacore SCR3 processor definition (#95953)

Syntacore SCR3 is a microcontroller-class processor core. Overview:
https://syntacore.com/products/scr3
This PR introduces two CPUs:
  * 'syntacore-scr3-rv32' which is rv32imc
  * 'syntacore-scr3-rv64' which is rv64imac

-

Co-authored-by: Dmitrii Petrov 

Added: 


Modified: 
clang/test/Driver/riscv-cpus.c
clang/test/Misc/target-invalid-cpu-note.c
llvm/docs/ReleaseNotes.rst
llvm/lib/Target/RISCV/RISCVProcessors.td

Removed: 




diff  --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index 41c257bc559ed..26bcda6468dd2 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -358,3 +358,26 @@
 
 // RUN: not %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv32 
-march=rv64i | FileCheck -check-prefix=MISMATCH-ARCH %s
 // MISMATCH-ARCH: cpu 'generic-rv32' does not support rv64
+
+// RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=syntacore-scr3-rv32 | 
FileCheck -check-prefix=MCPU-SYNTACORE-SCR3-RV32 %s
+// MCPU-SYNTACORE-SCR3-RV32: "-target-cpu" "syntacore-scr3-rv32"
+// MCPU-SYNTACORE-SCR3-RV32-SAME: "-target-feature" "+m"
+// MCPU-SYNTACORE-SCR3-RV32-SAME: "-target-feature" "+c"
+// MCPU-SYNTACORE-SCR3-RV32-SAME: "-target-feature" "+zicsr"
+// MCPU-SYNTACORE-SCR3-RV32-SAME: "-target-feature" "+zifencei"
+// MCPU-SYNTACORE-SCR3-RV32-SAME: "-target-abi" "ilp32"
+
+// RUN: %clang --target=riscv32 -### -c %s 2>&1 -mtune=syntacore-scr3-rv32 | 
FileCheck -check-prefix=MTUNE-SYNTACORE-SCR3-RV32 %s
+// MTUNE-SYNTACORE-SCR3-RV32: "-tune-cpu" "syntacore-scr3-rv32"
+
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=syntacore-scr3-rv64 | 
FileCheck -check-prefix=MCPU-SYNTACORE-SCR3-RV64 %s
+// MCPU-SYNTACORE-SCR3-RV64: "-target-cpu" "syntacore-scr3-rv64"
+// MCPU-SYNTACORE-SCR3-RV64-SAME: "-target-feature" "+m"
+// MCPU-SYNTACORE-SCR3-RV64-SAME: "-target-feature" "+a"
+// MCPU-SYNTACORE-SCR3-RV64-SAME: "-target-feature" "+c"
+// MCPU-SYNTACORE-SCR3-RV64-SAME: "-target-feature" "+zicsr"
+// MCPU-SYNTACORE-SCR3-RV64-SAME: "-target-feature" "+zifencei"
+// MCPU-SYNTACORE-SCR3-RV64-SAME: "-target-abi" "lp64"
+
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=syntacore-scr3-rv64 | 
FileCheck -check-prefix=MTUNE-SYNTACORE-SCR3-RV64 %s
+// MTUNE-SYNTACORE-SCR3-RV64: "-tune-cpu" "syntacore-scr3-rv64"

diff  --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 59d3aaa122dbe..1a9063ee5a257 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -81,16 +81,16 @@
 
 // RUN: not %clang_cc1 -triple riscv32 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV32
 // RISCV32: error: unknown target CPU 'not-a-cpu'
-// RISCV32-NEXT: note: valid target CPU values are: generic-rv32, rocket-rv32, 
sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, sifive-e76, 
syntacore-scr1-base, syntacore-scr1-max{{$}}
+// RISCV32-NEXT: note: valid target CPU values are: generic-rv32, rocket-rv32, 
sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, sifive-e76, 
syntacore-scr1-base, syntacore-scr1-max, syntacore-scr3-rv32{{$}}
 
 // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV64
 // RISCV64: error: unknown target CPU 'not-a-cpu'
-// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-p450, sifive-p670, sifive-s21, sifive-s51, sifive-s54, sifive-s76, 
sifive-u54, sifive-u74, sifive-x280, spacemit-x60, veyron-v1, 
xiangshan-nanhu{{$}}
+// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-p450, sifive-p670, sifive-s21, sifive-s51, sifive-s54, sifive-s76, 
sifive-u54, sifive-u74, sifive-x280, spacemit-x60, syntacore-scr3-rv64, 
veyron-v1, xiangshan-nanhu{{$}}
 
 // RUN: not %clang_cc1 -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV32
 // TUNE-RISCV32: error: unknown target CPU 'not-a-cpu'
-// TUNE-RISCV32-NEXT: note: valid target CPU values are: generic-rv32, 
rocket-rv32, sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, 
sifive-e76, syntacore-scr1-base, syntacore-scr1-max, generic, rocket, 
sifive-7-series{{$}}
+// TUNE-RISCV32-NEXT: note: valid target CPU values are: generic-rv32, 
rocket-rv32, sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, 
sifive-e76, syntacore-scr1-base, syntacore-scr1-max, syntacore-scr3-rv32, 
generic, rocket, sifive-7-series{{$}}
 
 // RUN: not %

[clang] [llvm] [RISCV] Add Syntacore SCR3 processor definition (PR #95953)

2024-06-21 Thread Anton Sidorenko via cfe-commits

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


[clang-tools-extra] Enforce SL.con.3: Add check to replace operator[] with at() [Cont.] (PR #95220)

2024-06-21 Thread Paul Heidekrüger via cfe-commits

https://github.com/PBHDK updated https://github.com/llvm/llvm-project/pull/95220

From 37292995de0c5aa87408586749795a97468d4725 Mon Sep 17 00:00:00 2001
From: Sebastian Wolf 
Date: Wed, 17 Apr 2024 16:16:35 +0200
Subject: [PATCH 01/18] Enforce SL.con.3: Add check to replace operator[] with
 at() on std containers

---
 .../AvoidBoundsErrorsCheck.cpp| 81 +++
 .../AvoidBoundsErrorsCheck.h  | 32 
 .../cppcoreguidelines/CMakeLists.txt  |  1 +
 .../CppCoreGuidelinesTidyModule.cpp   |  3 +
 clang-tools-extra/docs/ReleaseNotes.rst   |  5 ++
 .../cppcoreguidelines/avoid-bounds-errors.rst | 20 +
 .../docs/clang-tidy/checks/list.rst   |  1 +
 .../cppcoreguidelines/avoid-bounds-errors.cpp | 66 +++
 8 files changed, 209 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-bounds-errors.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-bounds-errors.cpp

diff --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.cpp 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.cpp
new file mode 100644
index 0..524c21b5bdb81
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.cpp
@@ -0,0 +1,81 @@
+//===--- AvoidBoundsErrorsCheck.cpp - clang-tidy 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "AvoidBoundsErrorsCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+#include 
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::cppcoreguidelines {
+
+bool isApplicable(const QualType &Type) {
+  const auto TypeStr = Type.getAsString();
+  bool Result = false;
+  // Only check for containers in the std namespace
+  if (TypeStr.find("std::vector") != std::string::npos) {
+Result = true;
+  }
+  if (TypeStr.find("std::array") != std::string::npos) {
+Result = true;
+  }
+  if (TypeStr.find("std::deque") != std::string::npos) {
+Result = true;
+  }
+  if (TypeStr.find("std::map") != std::string::npos) {
+Result = true;
+  }
+  if (TypeStr.find("std::unordered_map") != std::string::npos) {
+Result = true;
+  }
+  if (TypeStr.find("std::flat_map") != std::string::npos) {
+Result = true;
+  }
+  // TODO Add std::span with C++26
+  return Result;
+}
+
+void AvoidBoundsErrorsCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  callExpr(callee(cxxMethodDecl(hasName("operator[]")).bind("f")))
+  .bind("x"),
+  this);
+}
+
+void AvoidBoundsErrorsCheck::check(const MatchFinder::MatchResult &Result) {
+  const ASTContext &Context = *Result.Context;
+  const SourceManager &Source = Context.getSourceManager();
+  const auto *MatchedExpr = Result.Nodes.getNodeAs("x");
+  const auto *MatchedFunction = Result.Nodes.getNodeAs("f");
+  const auto Type = MatchedFunction->getThisType();
+  if (!isApplicable(Type)) {
+return;
+  }
+
+  // Get original code.
+  const SourceLocation b(MatchedExpr->getBeginLoc());
+  const SourceLocation e(MatchedExpr->getEndLoc());
+  const std::string OriginalCode =
+  Lexer::getSourceText(CharSourceRange::getTokenRange(b, e), Source,
+   getLangOpts())
+  .str();
+  const auto Range = SourceRange(b, e);
+
+  // Build replacement.
+  std::string NewCode = OriginalCode;
+  const auto BeginOpen = NewCode.find("[");
+  NewCode.replace(BeginOpen, 1, ".at(");
+  const auto BeginClose = NewCode.find("]");
+  NewCode.replace(BeginClose, 1, ")");
+
+  diag(MatchedExpr->getBeginLoc(), "Do not use operator[], use at() instead.")
+  << FixItHint::CreateReplacement(Range, NewCode);
+}
+
+} // namespace clang::tidy::cppcoreguidelines
diff --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.h 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.h
new file mode 100644
index 0..f915729cd7bbe
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.h
@@ -0,0 +1,32 @@
+//===--- AvoidBoundsErrorsCheck.h - clang-tidy --*- 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
+//
+//===--===//
+
+#ifndef 
LLV

[clang-tools-extra] Enforce SL.con.3: Add check to replace operator[] with at() [Cont.] (PR #95220)

2024-06-21 Thread Paul Heidekrüger via cfe-commits

https://github.com/PBHDK updated https://github.com/llvm/llvm-project/pull/95220

From 37292995de0c5aa87408586749795a97468d4725 Mon Sep 17 00:00:00 2001
From: Sebastian Wolf 
Date: Wed, 17 Apr 2024 16:16:35 +0200
Subject: [PATCH 01/19] Enforce SL.con.3: Add check to replace operator[] with
 at() on std containers

---
 .../AvoidBoundsErrorsCheck.cpp| 81 +++
 .../AvoidBoundsErrorsCheck.h  | 32 
 .../cppcoreguidelines/CMakeLists.txt  |  1 +
 .../CppCoreGuidelinesTidyModule.cpp   |  3 +
 clang-tools-extra/docs/ReleaseNotes.rst   |  5 ++
 .../cppcoreguidelines/avoid-bounds-errors.rst | 20 +
 .../docs/clang-tidy/checks/list.rst   |  1 +
 .../cppcoreguidelines/avoid-bounds-errors.cpp | 66 +++
 8 files changed, 209 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-bounds-errors.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-bounds-errors.cpp

diff --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.cpp 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.cpp
new file mode 100644
index 0..524c21b5bdb81
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.cpp
@@ -0,0 +1,81 @@
+//===--- AvoidBoundsErrorsCheck.cpp - clang-tidy 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "AvoidBoundsErrorsCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+#include 
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::cppcoreguidelines {
+
+bool isApplicable(const QualType &Type) {
+  const auto TypeStr = Type.getAsString();
+  bool Result = false;
+  // Only check for containers in the std namespace
+  if (TypeStr.find("std::vector") != std::string::npos) {
+Result = true;
+  }
+  if (TypeStr.find("std::array") != std::string::npos) {
+Result = true;
+  }
+  if (TypeStr.find("std::deque") != std::string::npos) {
+Result = true;
+  }
+  if (TypeStr.find("std::map") != std::string::npos) {
+Result = true;
+  }
+  if (TypeStr.find("std::unordered_map") != std::string::npos) {
+Result = true;
+  }
+  if (TypeStr.find("std::flat_map") != std::string::npos) {
+Result = true;
+  }
+  // TODO Add std::span with C++26
+  return Result;
+}
+
+void AvoidBoundsErrorsCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  callExpr(callee(cxxMethodDecl(hasName("operator[]")).bind("f")))
+  .bind("x"),
+  this);
+}
+
+void AvoidBoundsErrorsCheck::check(const MatchFinder::MatchResult &Result) {
+  const ASTContext &Context = *Result.Context;
+  const SourceManager &Source = Context.getSourceManager();
+  const auto *MatchedExpr = Result.Nodes.getNodeAs("x");
+  const auto *MatchedFunction = Result.Nodes.getNodeAs("f");
+  const auto Type = MatchedFunction->getThisType();
+  if (!isApplicable(Type)) {
+return;
+  }
+
+  // Get original code.
+  const SourceLocation b(MatchedExpr->getBeginLoc());
+  const SourceLocation e(MatchedExpr->getEndLoc());
+  const std::string OriginalCode =
+  Lexer::getSourceText(CharSourceRange::getTokenRange(b, e), Source,
+   getLangOpts())
+  .str();
+  const auto Range = SourceRange(b, e);
+
+  // Build replacement.
+  std::string NewCode = OriginalCode;
+  const auto BeginOpen = NewCode.find("[");
+  NewCode.replace(BeginOpen, 1, ".at(");
+  const auto BeginClose = NewCode.find("]");
+  NewCode.replace(BeginClose, 1, ")");
+
+  diag(MatchedExpr->getBeginLoc(), "Do not use operator[], use at() instead.")
+  << FixItHint::CreateReplacement(Range, NewCode);
+}
+
+} // namespace clang::tidy::cppcoreguidelines
diff --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.h 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.h
new file mode 100644
index 0..f915729cd7bbe
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.h
@@ -0,0 +1,32 @@
+//===--- AvoidBoundsErrorsCheck.h - clang-tidy --*- 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
+//
+//===--===//
+
+#ifndef 
LLV

[clang] a078416 - [AArch64] Fix up failing test that should have been caught by precommit

2024-06-21 Thread Sander de Smalen via cfe-commits

Author: Sander de Smalen
Date: 2024-06-21T08:54:18Z
New Revision: a078416a8594a5981367d9096e2181abe7811c5f

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

LOG: [AArch64] Fix up failing test that should have been caught by precommit

Not sure why Github precommit tests didn't show this. Do they not build
for all targets?

Added: 


Modified: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create2-bfloat.c

Removed: 




diff  --git 
a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create2-bfloat.c 
b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create2-bfloat.c
index afff231b7740b..abcb48fb8fa1a 100644
--- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create2-bfloat.c
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create2-bfloat.c
@@ -4,8 +4,8 @@
 // RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64 -target-feature 
+sve -target-feature +bf16 -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 -fclang-abi-compat=latest -DSVE_OVERLOADED_FORMS -triple 
aarch64 -target-feature +sve -target-feature +bf16 -disable-O0-optnone -Werror 
-Wall -emit-llvm -o - %s | opt -S -passes=mem2reg,tailcallelim | FileCheck %s
 // RUN: %clang_cc1 -fclang-abi-compat=latest -DSVE_OVERLOADED_FORMS -triple 
aarch64 -target-feature +sve -target-feature +bf16 -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 -fclang-abi-compat=latest -triple aarch64 -target-feature 
+b16 -target-feature +sve -target-feature +sme -S -disable-O0-optnone -Werror 
-Wall -o /dev/null %s
-// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64 -target-feature 
+b16 -target-feature +sme -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
+// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64 -target-feature 
+bf16 -target-feature +sve -target-feature +sme -S -disable-O0-optnone -Werror 
-Wall -o /dev/null %s
+// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64 -target-feature 
+bf16 -target-feature +sme -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
 
 #include 
 



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


[clang-tools-extra] Enforce SL.con.3: Add check to replace operator[] with at() [Cont.] (PR #95220)

2024-06-21 Thread Paul Heidekrüger via cfe-commits

https://github.com/PBHDK updated https://github.com/llvm/llvm-project/pull/95220

From 37292995de0c5aa87408586749795a97468d4725 Mon Sep 17 00:00:00 2001
From: Sebastian Wolf 
Date: Wed, 17 Apr 2024 16:16:35 +0200
Subject: [PATCH 01/21] Enforce SL.con.3: Add check to replace operator[] with
 at() on std containers

---
 .../AvoidBoundsErrorsCheck.cpp| 81 +++
 .../AvoidBoundsErrorsCheck.h  | 32 
 .../cppcoreguidelines/CMakeLists.txt  |  1 +
 .../CppCoreGuidelinesTidyModule.cpp   |  3 +
 clang-tools-extra/docs/ReleaseNotes.rst   |  5 ++
 .../cppcoreguidelines/avoid-bounds-errors.rst | 20 +
 .../docs/clang-tidy/checks/list.rst   |  1 +
 .../cppcoreguidelines/avoid-bounds-errors.cpp | 66 +++
 8 files changed, 209 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-bounds-errors.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-bounds-errors.cpp

diff --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.cpp 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.cpp
new file mode 100644
index 0..524c21b5bdb81
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.cpp
@@ -0,0 +1,81 @@
+//===--- AvoidBoundsErrorsCheck.cpp - clang-tidy 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "AvoidBoundsErrorsCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+#include 
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::cppcoreguidelines {
+
+bool isApplicable(const QualType &Type) {
+  const auto TypeStr = Type.getAsString();
+  bool Result = false;
+  // Only check for containers in the std namespace
+  if (TypeStr.find("std::vector") != std::string::npos) {
+Result = true;
+  }
+  if (TypeStr.find("std::array") != std::string::npos) {
+Result = true;
+  }
+  if (TypeStr.find("std::deque") != std::string::npos) {
+Result = true;
+  }
+  if (TypeStr.find("std::map") != std::string::npos) {
+Result = true;
+  }
+  if (TypeStr.find("std::unordered_map") != std::string::npos) {
+Result = true;
+  }
+  if (TypeStr.find("std::flat_map") != std::string::npos) {
+Result = true;
+  }
+  // TODO Add std::span with C++26
+  return Result;
+}
+
+void AvoidBoundsErrorsCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  callExpr(callee(cxxMethodDecl(hasName("operator[]")).bind("f")))
+  .bind("x"),
+  this);
+}
+
+void AvoidBoundsErrorsCheck::check(const MatchFinder::MatchResult &Result) {
+  const ASTContext &Context = *Result.Context;
+  const SourceManager &Source = Context.getSourceManager();
+  const auto *MatchedExpr = Result.Nodes.getNodeAs("x");
+  const auto *MatchedFunction = Result.Nodes.getNodeAs("f");
+  const auto Type = MatchedFunction->getThisType();
+  if (!isApplicable(Type)) {
+return;
+  }
+
+  // Get original code.
+  const SourceLocation b(MatchedExpr->getBeginLoc());
+  const SourceLocation e(MatchedExpr->getEndLoc());
+  const std::string OriginalCode =
+  Lexer::getSourceText(CharSourceRange::getTokenRange(b, e), Source,
+   getLangOpts())
+  .str();
+  const auto Range = SourceRange(b, e);
+
+  // Build replacement.
+  std::string NewCode = OriginalCode;
+  const auto BeginOpen = NewCode.find("[");
+  NewCode.replace(BeginOpen, 1, ".at(");
+  const auto BeginClose = NewCode.find("]");
+  NewCode.replace(BeginClose, 1, ")");
+
+  diag(MatchedExpr->getBeginLoc(), "Do not use operator[], use at() instead.")
+  << FixItHint::CreateReplacement(Range, NewCode);
+}
+
+} // namespace clang::tidy::cppcoreguidelines
diff --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.h 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.h
new file mode 100644
index 0..f915729cd7bbe
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.h
@@ -0,0 +1,32 @@
+//===--- AvoidBoundsErrorsCheck.h - clang-tidy --*- 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
+//
+//===--===//
+
+#ifndef 
LLV

[clang-tools-extra] Enforce SL.con.3: Add check to replace operator[] with at() [Cont.] (PR #95220)

2024-06-21 Thread Paul Heidekrüger via cfe-commits


@@ -0,0 +1,40 @@
+//===--- PreferAtOverSubscriptOperatorCheck.h - clang-tidy --*- C++ 
-*-===//
+//===--- PreferMemberInitializerCheck.h - clang-tidy *- 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
+//
+//===--===//
+
+#ifndef 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PREFERATOVERSUBSCRIPTOPERATORCHECK_H
+#define 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PREFERATOVERSUBSCRIPTOPERATORCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang::tidy::cppcoreguidelines {
+
+/// Enforce CPP core guidelines SL.con.3

PBHDK wrote:

> Maybe we can just replace the Doxygen comment above with what's in the 
> release notes + check description right now:
> > Flags the unsafe `operator[]` and suggests replacing it with `at()`.
> 
> What do you think?

@5chmidti just giving this a polite bump in case it got lost 🙂

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


[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)

2024-06-21 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm commented:

I'm wondering if we should really have all the different typed variants, and if 
this should be the name. I guess

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


[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)

2024-06-21 Thread Matt Arsenault via cfe-commits


@@ -149,6 +149,19 @@ BUILTIN(__builtin_amdgcn_mqsad_pk_u16_u8, "WUiWUiUiWUi", 
"nc")
 BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", "nc")
 
 BUILTIN(__builtin_amdgcn_make_buffer_rsrc, "Qbv*sii", "nc")
+BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_i8, "vcQbiiIi", "n")

arsenm wrote:

Probably should drop the _ptr part of the name. This was more of a legacy issue 
in the intrinsic case, since the resource-as-vector case already took the name.

Also not sure if we should follow the naming convention of the instruction 
instead (probably the gfx12 one?).

Also should document these somewhere 

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


[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)

2024-06-21 Thread Matt Arsenault via cfe-commits

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


[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)

2024-06-21 Thread Matt Arsenault via cfe-commits


@@ -626,6 +626,18 @@ static Value *emitQuaternaryBuiltin(CodeGenFunction &CGF, 
const CallExpr *E,
   return CGF.Builder.CreateCall(F, {Src0, Src1, Src2, Src3});
 }
 
+static Value *emitQuinaryBuiltin(CodeGenFunction &CGF, const CallExpr *E,

arsenm wrote:

The name is a bit misleading. It's more like a unary builtin with a single 
mangling type 

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


[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)

2024-06-21 Thread via cfe-commits

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

>From d5caa1a22c90c7d3b1fd995c3ae980f02e4c14c9 Mon Sep 17 00:00:00 2001
From: Marian Lukac 
Date: Wed, 12 Jun 2024 11:13:48 +
Subject: [PATCH 1/5] fix for mve

---
 clang/lib/Sema/SemaType.cpp| 18 --
 clang/test/Sema/arm-vector-types-support.c | 11 ++-
 clang/test/SemaCUDA/neon-attrs.cu  | 22 --
 clang/utils/TableGen/NeonEmitter.cpp   |  5 -
 4 files changed, 14 insertions(+), 42 deletions(-)
 delete mode 100644 clang/test/SemaCUDA/neon-attrs.cu

diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 441fdcca0758f..9c0d043725dde 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8086,23 +8086,21 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, 
const ParsedAttr &Attr,
 
   // Target must have NEON (or MVE, whose vectors are similar enough
   // not to need a separate attribute)
-  if (!(S.Context.getTargetInfo().hasFeature("neon") ||
-S.Context.getTargetInfo().hasFeature("mve") ||
-S.Context.getTargetInfo().hasFeature("sve") ||
-S.Context.getTargetInfo().hasFeature("sme") ||
+  if (!(S.Context.getTargetInfo().hasFeature("mve") ||
 IsTargetCUDAAndHostARM) &&
-  VecKind == VectorKind::Neon) {
+  VecKind == VectorKind::Neon && 
+  S.Context.getTargetInfo().getTriple().isArmMClass()) {
 S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
-<< Attr << "'neon', 'mve', 'sve' or 'sme'";
+<< Attr << "'mve'";
 Attr.setInvalid();
 return;
   }
-  if (!(S.Context.getTargetInfo().hasFeature("neon") ||
-S.Context.getTargetInfo().hasFeature("mve") ||
+  if (!(S.Context.getTargetInfo().hasFeature("mve") ||
 IsTargetCUDAAndHostARM) &&
-  VecKind == VectorKind::NeonPoly) {
+  VecKind == VectorKind::NeonPoly &&
+  S.Context.getTargetInfo().getTriple().isArmMClass()) {
 S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
-<< Attr << "'neon' or 'mve'";
+<< Attr << "'mve'";
 Attr.setInvalid();
 return;
   }
diff --git a/clang/test/Sema/arm-vector-types-support.c 
b/clang/test/Sema/arm-vector-types-support.c
index ed5f5ba175a94..e648d791a2687 100644
--- a/clang/test/Sema/arm-vector-types-support.c
+++ b/clang/test/Sema/arm-vector-types-support.c
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify
-// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify
-// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi 
aapcs-soft -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple armv8.1m.main -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify=sve-type
+// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi 
aapcs-soft -fsyntax-only -verify=sve-type
 
-typedef __attribute__((neon_vector_type(2))) int int32x2_t; // 
expected-error{{'neon_vector_type' attribute is not supported on targets 
missing 'neon', 'mve', 'sve' or 'sme'; specify an appropriate -march= or 
-mcpu=}}
-typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // 
expected-error{{'neon_polyvector_type' attribute is not supported on targets 
missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}}
+typedef __attribute__((neon_vector_type(2))) int int32x2_t; // 
expected-error{{'neon_vector_type' attribute is not supported on targets 
missing 'mve'; specify an appropriate -march= or -mcpu=}}
+typedef __attribute__((neon_polyvector_type(16))) unsigned char poly8x16_t; // 
expected-error{{'neon_polyvector_type' attribute is not supported on targets 
missing 'mve'; specify an appropriate -march= or -mcpu=}}
 typedef __attribute__((arm_sve_vector_bits(256))) void nosveflag; // 
expected-error{{'arm_sve_vector_bits' attribute is not supported on targets 
missing 'sve'; specify an appropriate -march= or -mcpu=}}
+  // 
sve-type-error@-1{{'arm_sve_vector_bits' attribute is not supported on targets 
missing 'sve'; specify an appropriate -march= or -mcpu=}}
diff --git a/clang/test/SemaCUDA/neon-attrs.cu 
b/clang/test/SemaCUDA/neon-attrs.cu
deleted file mode 100644
index 129056741ac9a..0
--- a/clang/test/SemaCUDA/neon-attrs.cu
+++ /dev/null
@@ -1,22 +0,0 @@
-// CPU-side compilation on ARM with neon enabled (no errors expected).
-// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -aux-triple 
nvptx64 -x cuda -fsyntax-only -verify=quiet %s
-
-// CPU-side compilation on ARM with neon disabled.
-// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature -neon -aux-triple 
nvptx64 -x cuda -fsyntax-only -verify %s
-
-// GPU-side compilation on ARM (no errors expected).
-// RUN: %clang_cc1 -triple nvptx64 -aux-triple arm64-linux-gnu 
-fcuda-is-device -x cuda -fsyntax-only -verify=quiet %s
-
-// Regular C++ compilation on ARM with

[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)

2024-06-21 Thread via cfe-commits


@@ -8086,23 +8086,21 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, 
const ParsedAttr &Attr,
 
   // Target must have NEON (or MVE, whose vectors are similar enough
   // not to need a separate attribute)
-  if (!(S.Context.getTargetInfo().hasFeature("neon") ||
-S.Context.getTargetInfo().hasFeature("mve") ||
-S.Context.getTargetInfo().hasFeature("sve") ||
-S.Context.getTargetInfo().hasFeature("sme") ||
+  if (!(S.Context.getTargetInfo().hasFeature("mve") ||
 IsTargetCUDAAndHostARM) &&

Lukacma wrote:

Ah now I understand. What you are trying to see that for mve there is no reason 
to check for GPUs as they will never be target for this extension?

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


[clang] [Clang] Clarify diagnostic notes for implicitly generated deduction guides (PR #96084)

2024-06-21 Thread Younan Zhang via cfe-commits


@@ -12114,6 +12115,35 @@ static void NoteFunctionCandidate(Sema &S, 
OverloadCandidate *Cand,
 return;
   }
 
+  // If this is an implicit deduction guide against an implicitly defined
+  // constructor, add a note for it. Neither these deduction guides nor their
+  // corresponding constructors are explicitly spelled in the source code,

zyn0217 wrote:

Yeah, we would have a deduction guide with combined template parameters; 
however, my concern is that we already have sufficient code contexts in the 
snippets of a diagnostic for users to understand the error. For example,
```cpp
template  struct Outer {
template  struct Inner {
template 
Inner(U, V, V) {}
};
};

Outer::Inner i(42, "hello");
```
https://clang.godbolt.org/z/1bEfqrrMv

we currently have a note followed by a code snippet:
```
:4:2: note: candidate function template not viable: requires 3 
arguments, but 2 were provided
4 | Inner(U, V, V) {}
  | ^ ~~~
```
although we don't have the synthesized template parameters presented, I think 
(subjectively) this is probably already legible.

> (this covers the using-alias case.)

With the filter currently in place, I have seen a bunch of additional notes 
following the using-alias cases. However, I'm not sure I have handled them all.

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


[clang] [Clang] Clarify diagnostic notes for implicitly generated deduction guides (PR #96084)

2024-06-21 Thread Younan Zhang via cfe-commits


@@ -12114,6 +12115,35 @@ static void NoteFunctionCandidate(Sema &S, 
OverloadCandidate *Cand,
 return;
   }
 
+  // If this is an implicit deduction guide against an implicitly defined
+  // constructor, add a note for it. Neither these deduction guides nor their
+  // corresponding constructors are explicitly spelled in the source code,

zyn0217 wrote:

But I'm not opposed to removing the filter and emitting all the candidates like 
what GCC does, anyway.

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


[clang] aed9891 - [clang] Cover CWG issues about `export template` (#94876)

2024-06-21 Thread via cfe-commits

Author: Vlad Serebrennikov
Date: 2024-06-21T13:49:04+04:00
New Revision: aed989157ddcdaaf3fea295c449f23dffe327ae5

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

LOG: [clang] Cover CWG issues about `export template` (#94876)

This PR covers the following Core issues:
[CWG204](https://cplusplus.github.io/CWG/issues/204.html) "Exported
class templates"
[CWG323](https://cplusplus.github.io/CWG/issues/323.html) "Where must
`export` appear?"
[CWG335](https://cplusplus.github.io/CWG/issues/335.html) "Allowing
`export` on template members of nontemplate classes"
[CWG820](https://cplusplus.github.io/CWG/issues/820.html) "Deprecation
of `export`"

I believe the list above is entirety of Core issues that are dedicated
solely to `export template`.

I believe we have two main points of view here, which command what this
PR should do:
1. (easy) Removal of `export template` was done as a defect report in
CWG820, and the rest are effectively superseded by it, because we apply
defect reports retroactively.
2. (harder) Those Core issues are testable individually, so we should
test them for the behavior Core wanted at the time.

This PR implements the first option, making our C++ DR status page
greener.
I think I can be persuaded to go with the second option, if reviewers
have strong preference for it.

Added: 


Modified: 
clang/test/CXX/drs/cwg2xx.cpp
clang/test/CXX/drs/cwg3xx.cpp
clang/test/CXX/drs/cwg8xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/test/CXX/drs/cwg2xx.cpp b/clang/test/CXX/drs/cwg2xx.cpp
index 99916dea9a912..926cb19596026 100644
--- a/clang/test/CXX/drs/cwg2xx.cpp
+++ b/clang/test/CXX/drs/cwg2xx.cpp
@@ -41,7 +41,7 @@ namespace cwg202 { // cwg202: 3.1
   template struct X;
 }
 
-// FIXME (export) cwg204: no
+// cwg204: sup 820
 
 namespace cwg206 { // cwg206: yes
   struct S; // #cwg206-S

diff  --git a/clang/test/CXX/drs/cwg3xx.cpp b/clang/test/CXX/drs/cwg3xx.cpp
index 94227dc031c6a..a10ed95941ba4 100644
--- a/clang/test/CXX/drs/cwg3xx.cpp
+++ b/clang/test/CXX/drs/cwg3xx.cpp
@@ -377,7 +377,7 @@ namespace cwg322 { // cwg322: 2.8
   int &s = a;
 }
 
-// cwg323: no
+// cwg323: sup 820
 
 namespace cwg324 { // cwg324: 3.6
   struct S { int n : 1; } s; // #cwg324-n
@@ -587,7 +587,7 @@ namespace cwg334 { // cwg334: yes
   template void f();
 }
 
-// cwg335: no
+// cwg335: sup 820
 
 namespace cwg336 { // cwg336: yes
   namespace Pre {

diff  --git a/clang/test/CXX/drs/cwg8xx.cpp b/clang/test/CXX/drs/cwg8xx.cpp
index eba601300584d..c8cbdfcee3f4d 100644
--- a/clang/test/CXX/drs/cwg8xx.cpp
+++ b/clang/test/CXX/drs/cwg8xx.cpp
@@ -1,14 +1,19 @@
-// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s 
-verify=expected -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98-17 -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors
 
-#if __cplusplus == 199711L
-// expected-no-diagnostics
-#endif
+namespace cwg820 { // cwg820: 2.7
+exp

[clang] [clang] Cover CWG issues about `export template` (PR #94876)

2024-06-21 Thread Vlad Serebrennikov via cfe-commits

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


[clang] bc4d50f - [clang] Implement CWG2877 "Type-only lookup for using-enum-declarator" (#95399)

2024-06-21 Thread via cfe-commits

Author: Vlad Serebrennikov
Date: 2024-06-21T13:49:43+04:00
New Revision: bc4d50f02ded9eea287daccf2b4a39ae5d30abd0

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

LOG: [clang] Implement CWG2877 "Type-only lookup for using-enum-declarator" 
(#95399)

This patch implements 2024-05-31 resolution of a tentatively ready issue
[CWG2877](https://cplusplus.github.io/CWG/issues/2877.html) "Type-only
lookup for using-enum-declarator", which supersedes earlier
[CWG2621](https://cplusplus.github.io/CWG/issues/2621.html) "Kind of
lookup for `using enum` declarations".

Now we perform type-only lookup (not to be confused with type-only
context) for `elaborated-enum-declarator`. This is the same kind of
lookup that elaborated type specifiers and base specifiers undergo.

I also found out (and fixed) that one of our existing tests claimed that
a dependent type can be used in `elaborated-enum-declarator`, but that's
not the case:
> The
[using-enum-declarator](http://eel.is/c++draft/enum.udecl#nt:using-enum-declarator)
shall designate a non-dependent type with a reachable
[enum-specifier](http://eel.is/c++draft/dcl.enum#nt:enum-specifier)[.](http://eel.is/c++draft/enum.udecl#1.sentence-2)

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/CXX/drs/cwg26xx.cpp
clang/test/CXX/drs/cwg28xx.cpp
clang/test/SemaCXX/cxx20-using-enum.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 88969a0131038..455c34bce0684 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -287,6 +287,9 @@ Resolutions to C++ Defect Reports
 - P0522 implementation is enabled by default in all language versions, and
   provisional wording for CWG2398 is implemented.
 
+- Clang now performs type-only lookup for the name in ``using enum`` 
declaration.
+  (`CWG2877: Type-only lookup for using-enum-declarator 
`_).
+
 - Clang now requires a template argument list after a template keyword.
   (`CWG96: Syntactic disambiguation using the template keyword 
`_).
 

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 95a732bcba618..e43e5f465361d 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -4031,8 +4031,8 @@ class Sema final : public SemaBase {
   const ParsedAttributesView &AttrList);
   Decl *ActOnUsingEnumDeclaration(Scope *CurScope, AccessSpecifier AS,
   SourceLocation UsingLoc,
-  SourceLocation EnumLoc,
-  SourceLocation IdentLoc, IdentifierInfo &II,
+  SourceLocation EnumLoc, SourceRange TyLoc,
+  const IdentifierInfo &II, ParsedType Ty,
   CXXScopeSpec *SS = nullptr);
   Decl *ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS,
   MultiTemplateParamsArg TemplateParams,

diff  --git a/clang/lib/Parse/ParseDeclCXX.cpp 
b/clang/lib/Parse/ParseDeclCXX.cpp
index d02548f6441f9..5e3ee5f0579aa 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -692,7 +692,7 @@ bool Parser::ParseUsingDeclarator(DeclaratorContext Context,
 /// using-enum-declaration: [C++20, dcl.enum]
 ///   'using' elaborated-enum-specifier ;
 ///   The terminal name of the elaborated-enum-specifier undergoes
-///   ordinary lookup
+///   type-only lookup
 ///
 /// elaborated-enum-specifier:
 ///   'enum' nested-name-specifier[opt] identifier
@@ -724,7 +724,7 @@ Parser::DeclGroupPtrTy Parser::ParseUsingDeclaration(
/*ObectHasErrors=*/false,
/*EnteringConttext=*/false,
/*MayBePseudoDestructor=*/nullptr,
-   /*IsTypename=*/false,
+   /*IsTypename=*/true,
/*IdentifierInfo=*/nullptr,
/*OnlyNamespace=*/false,
/*InUsingDeclaration=*/true)) {
@@ -738,16 +738,49 @@ Parser::DeclGroupPtrTy Parser::ParseUsingDeclaration(
   return nullptr;
 }
 
-if (!Tok.is(tok::identifier)) {
+Decl *UED = nullptr;
+
+// FIXME: identifier and annot_template_id handling is very similar to
+// ParseBaseTypeSpecifier. It should be factored out into a function.
+

[clang] [clang] Implement CWG2877 "Type-only lookup for using-enum-declarator" (PR #95399)

2024-06-21 Thread Vlad Serebrennikov via cfe-commits

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


[clang] [llvm] security check cookie execute only when needed (PR #95904)

2024-06-21 Thread via cfe-commits

mahesh-attarde wrote:

> @efriedma-quic do you have any more comments?

ping @efriedma-quic 

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


[clang] 2b5d1fb - [clang] Add test for CWG2811 "Clarify "use" of main" (#96168)

2024-06-21 Thread via cfe-commits

Author: Vlad Serebrennikov
Date: 2024-06-21T13:50:03+04:00
New Revision: 2b5d1fb889fca7287858db0791bfecc1465f23e1

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

LOG: [clang] Add test for CWG2811 "Clarify "use" of main" (#96168)

This patch covers
[CWG2811](https://cplusplus.github.io/CWG/issues/2811.html) "Clarify
"use" of main", basically adding a test for `-Wmain`, focusing on usages
of `main` in unevaluated contexts.

To my understanding, the diagnostic message is based on the wording, so
I updated it based on the new wording. I also replaces "ISO C++
requires" with a phrasing that explicitly says "extension".

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/test/CXX/basic/basic.start/basic.start.init/p3.cpp
clang/test/CXX/drs/cwg28xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 9bf55acbac011..25a87078a5709 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -973,7 +973,7 @@ def err_main_global_variable :
 def warn_main_redefined : Warning<"variable named 'main' with external linkage 
"
 "has undefined behavior">, InGroup;
 def ext_main_used : Extension<
-  "ISO C++ does not allow 'main' to be used by a program">, InGroup;
+"referring to 'main' within an expression is a Clang extension">, 
InGroup;
 
 /// parser diagnostics
 def ext_no_declarators : ExtWarn<"declaration does not declare anything">,

diff  --git a/clang/test/CXX/basic/basic.start/basic.start.init/p3.cpp 
b/clang/test/CXX/basic/basic.start/basic.start.init/p3.cpp
index 506232ebacc4c..6614003fb93dd 100644
--- a/clang/test/CXX/basic/basic.start/basic.start.init/p3.cpp
+++ b/clang/test/CXX/basic/basic.start/basic.start.init/p3.cpp
@@ -16,9 +16,9 @@ int main(int argc, char **argv)
   = delete; // expected-error {{'main' is not allowed to be deleted}}
 #else
 {
-  int (*pmain)(int, char**) = &main; // expected-error {{ISO C++ does not 
allow 'main' to be used by a program}}
+  int (*pmain)(int, char**) = &main; // expected-error {{referring to 'main' 
within an expression is a Clang extension}}
 
   if (argc)
-main(0, 0); // expected-error {{ISO C++ does not allow 'main' to be used 
by a program}}
+main(0, 0); // expected-error {{referring to 'main' within an expression 
is a Clang extension}}
 }
 #endif

diff  --git a/clang/test/CXX/drs/cwg28xx.cpp b/clang/test/CXX/drs/cwg28xx.cpp
index 67aa34484fe8b..c77bd433d8e21 100644
--- a/clang/test/CXX/drs/cwg28xx.cpp
+++ b/clang/test/CXX/drs/cwg28xx.cpp
@@ -6,6 +6,30 @@
 // RUN: %clang_cc1 -std=c++23 -pedantic-errors 
-verify=expected,since-cxx20,since-cxx23 %s
 // RUN: %clang_cc1 -std=c++2c -pedantic-errors 
-verify=expected,since-cxx20,since-cxx23,since-cxx26 %s
 
+
+int main() {} // required for cwg2811
+
+namespace cwg2811 { // cwg2811: 3.5
+#if __cplusplus >= 201103L
+void f() {
+  (void)[&] {
+using T = decltype(main);
+// expected-error@-1 {{referring to 'main' within an expression is a Clang 
extension}}
+  };
+  using T2 = decltype(main);
+  // expected-error@-1 {{referring to 'main' within an expression is a Clang 
extension}}
+}
+
+using T = decltype(main);
+// expected-error@-1 {{referring to 'main' within an expression is a Clang 
extension}}
+
+int main();
+
+using U = decltype(main);
+using U2 = decltype(&main);
+#endif
+} // namespace cwg2811
+
 namespace cwg2819 { // cwg2819: 19 tentatively ready 2023-12-01
 #if __cpp_constexpr >= 202306L
   constexpr void* p = nullptr;

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 7474a4f65585b..937f67981e296 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -16682,7 +16682,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/2811.html";>2811
 DR
 Clarify "use" of main
-Unknown
+Clang 3.5
   
   
 https://cplusplus.github.io/CWG/issues/2812.html";>2812



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


[clang] [clang] Add test for CWG2811 "Clarify "use" of main" (PR #96168)

2024-06-21 Thread Vlad Serebrennikov via cfe-commits

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


[clang] d4d95ee - [Serialization] Register identifiers in ahead and don't emit predefined decls

2024-06-21 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2024-06-21T17:50:30+08:00
New Revision: d4d95ee65159db1ea1a8c4159cfdaf8b81097897

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

LOG: [Serialization] Register identifiers in ahead and don't emit predefined 
decls

See the added test for the motivation example. In that example, we add a
new function declaration in `a.cppm` and this is not used in the reduced
BMI of `b.cppm`. We expect that the change won't affect the BMI of
`b.cppm`. But it is the not the case.

There are 2 reason for unexpected result:
1. We would register the interesting identifiers in a pretty late phase.
   This may cause some some predefined identifier ID change due to we
   insert other identifiers during emitting decls and types.
2. In `GenerateNameLookup`, we would generate information for predefined
   decls. This may not be intended. Since every predefined decl doesn't
   belong to any module.

And this patch solves the first issue by registering the identifiers in
the very early posititon to make sure the ID won't get affected by the
process to emit decls and types. And we solve the second question by
filtering predefined decls simply.

Added: 
clang/test/Modules/no-transitive-identifier-change-2.cppm

Modified: 
clang/include/clang/Serialization/ASTWriter.h
clang/lib/Serialization/ASTWriter.cpp
clang/test/Modules/decl-params-determinisim.m

Removed: 




diff  --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index ce79c75dc2911..71a7c28047e31 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -228,6 +228,11 @@ class ASTWriter : public ASTDeserializationListener,
   /// unit, while 0 is reserved for NULL.
   llvm::DenseMap DeclIDs;
 
+  /// Set of predefined decls. This is a helper data to determine if a decl
+  /// is predefined. It should be more clear and safer to query the set
+  /// instead of comparing the result of `getDeclID()` or `GetDeclRef()`.
+  llvm::SmallPtrSet PredefinedDecls;
+
   /// Offset of each declaration in the bitstream, indexed by
   /// the declaration's ID.
   std::vector DeclOffsets;
@@ -563,8 +568,6 @@ class ASTWriter : public ASTDeserializationListener,
   void WriteType(QualType T);
 
   bool isLookupResultExternal(StoredDeclsList &Result, DeclContext *DC);
-  bool isLookupResultEntirelyExternalOrUnreachable(StoredDeclsList &Result,
-   DeclContext *DC);
 
   void GenerateNameLookupTable(const DeclContext *DC,
llvm::SmallVectorImpl &LookupTable);
@@ -844,6 +847,8 @@ class ASTWriter : public ASTDeserializationListener,
   bool hasChain() const { return Chain; }
   ASTReader *getChain() const { return Chain; }
 
+  bool isWritingModule() const { return WritingModule; }
+
   bool isWritingStdCXXNamedModules() const {
 return WritingModule && WritingModule->isNamedModule();
   }
@@ -852,6 +857,10 @@ class ASTWriter : public ASTDeserializationListener,
 
   bool getDoneWritingDeclsAndTypes() const { return DoneWritingDeclsAndTypes; }
 
+  bool isDeclPredefined(const Decl *D) const {
+return PredefinedDecls.count(D);
+  }
+
   void handleVTable(CXXRecordDecl *RD);
 
 private:

diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index e00bacfd940b9..e6a58dcc61e3f 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -3728,6 +3728,29 @@ static NamedDecl *getDeclForLocalLookup(const 
LangOptions &LangOpts,
 
 namespace {
 
+bool IsInterestingIdentifier(const IdentifierInfo *II, uint64_t MacroOffset,
+ bool IsModule, bool IsCPlusPlus) {
+  bool NeedDecls = !IsModule || !IsCPlusPlus;
+
+  bool IsInteresting =
+  II->getNotableIdentifierID() != tok::NotableIdentifierKind::not_notable 
||
+  II->getBuiltinID() != Builtin::ID::NotBuiltin ||
+  II->getObjCKeywordID() != tok::ObjCKeywordKind::objc_not_keyword;
+  if (MacroOffset || II->isPoisoned() || (!IsModule && IsInteresting) ||
+  II->hasRevertedTokenIDToIdentifier() ||
+  (NeedDecls && II->getFETokenInfo()))
+return true;
+
+  return false;
+}
+
+bool IsInterestingNonMacroIdentifier(const IdentifierInfo *II,
+ ASTWriter &Writer) {
+  bool IsModule = Writer.isWritingModule();
+  bool IsCPlusPlus = Writer.getLangOpts().CPlusPlus;
+  return IsInterestingIdentifier(II, /*MacroOffset=*/0, IsModule, IsCPlusPlus);
+}
+
 class ASTIdentifierTableTrait {
   ASTWriter &Writer;
   Preprocessor &PP;
@@ -3741,17 +3764,8 @@ class ASTIdentifierTableTrait {
   /// doesn't check whether the name has macros defined; use 
PublicMacroIterator
   

[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)

2024-06-21 Thread Shilei Tian via cfe-commits


@@ -626,6 +626,18 @@ static Value *emitQuaternaryBuiltin(CodeGenFunction &CGF, 
const CallExpr *E,
   return CGF.Builder.CreateCall(F, {Src0, Src1, Src2, Src3});
 }
 
+static Value *emitQuinaryBuiltin(CodeGenFunction &CGF, const CallExpr *E,

shiltian wrote:

If we look at existing `emitXXXBuiltin` (ignore quaternary one which was added 
by me), it looks like `XXX` means the number of arguments we have for the 
builtin, and all of them just have single mangling.
I think a better unified function signature might be `template  
void emitBuiltinWithSingleMangling` but it is out of the scope. I can do it in 
a separate patch.

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


[clang] [llvm] Remove mmx 3dnow (PR #96246)

2024-06-21 Thread Simon Pilgrim via cfe-commits

RKSimon wrote:

I'd prefer we rip off ALL the 3dnow/mmx bandaid in one big series of patches - 
and not split across the 19.X/20.X releases. 

So can we get all the mmx patches done in time for the 19.0 branch?

Also, this "might" have bigger impact than the KNL changes - should we announce 
the plan in 19.X and do it for 20.X?

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


[clang] [clang][AArch64][FMV] Stop emitting alias to ifunc. (PR #96221)

2024-06-21 Thread Alexandros Lamprineas via cfe-commits

https://github.com/labrinea updated 
https://github.com/llvm/llvm-project/pull/96221

>From 4b884669236cae2d5ac42a95517d9ce57060a494 Mon Sep 17 00:00:00 2001
From: Alexandros Lamprineas 
Date: Thu, 20 Jun 2024 17:40:44 +0100
Subject: [PATCH 1/2] [clang][AArch64][FMV] Stop emitting alias to ifunc.

Long story short the interaction of two optimizations happening in
GlobalOpt results in a crash. For more details look at the issue
https://github.com/llvm/llvm-project/issues/96197. I will be
fixing this in GlobalOpt but it is a conservative solution since
it won't allow us to optimize resolvers which return a pointer
to a function whose definition is in another TU when compiling
without LTO:

__attribute__((target_version("simd"))) void bar(void);
__attribute__((target_version("default"))) void bar(void);
int foo() { bar(); }
---
 clang/lib/CodeGen/CodeGenModule.cpp  |  4 ++--
 .../CodeGen/aarch64-mixed-target-attributes.c|  3 ---
 clang/test/CodeGen/attr-target-clones-aarch64.c  | 16 
 clang/test/CodeGen/attr-target-version.c | 13 -
 .../CodeGenCXX/attr-target-clones-aarch64.cpp|  4 
 clang/test/CodeGenCXX/attr-target-version.cpp|  6 --
 clang/test/CodeGenCXX/fmv-namespace.cpp  |  2 --
 7 files changed, 2 insertions(+), 46 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index dd4a665ebc78b..76534475e88f7 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4259,8 +4259,8 @@ void CodeGenModule::emitMultiVersionFunctions() {
 llvm::Constant *ResolverConstant = GetOrCreateMultiVersionResolver(GD);
 if (auto *IFunc = dyn_cast(ResolverConstant)) {
   ResolverConstant = IFunc->getResolver();
-  if (FD->isTargetClonesMultiVersion() ||
-  FD->isTargetVersionMultiVersion()) {
+  if (FD->isTargetClonesMultiVersion() &&
+  !getTarget().getTriple().isAArch64()) {
 std::string MangledName = getMangledNameImpl(
 *this, GD, FD, /*OmitMultiVersionMangling=*/true);
 if (!GetGlobalValue(MangledName + ".ifunc")) {
diff --git a/clang/test/CodeGen/aarch64-mixed-target-attributes.c 
b/clang/test/CodeGen/aarch64-mixed-target-attributes.c
index 6aa747d4cb461..3c047fec6ceed 100644
--- a/clang/test/CodeGen/aarch64-mixed-target-attributes.c
+++ b/clang/test/CodeGen/aarch64-mixed-target-attributes.c
@@ -30,9 +30,6 @@ __attribute__((target_version("jscvt"))) int 
default_def_with_version_decls(void
 
 //.
 // CHECK: @__aarch64_cpu_features = external dso_local global { i64 }
-// CHECK: @explicit_default.ifunc = weak_odr alias i32 (), ptr 
@explicit_default
-// CHECK: @implicit_default.ifunc = weak_odr alias i32 (), ptr 
@implicit_default
-// CHECK: @default_def_with_version_decls.ifunc = weak_odr alias i32 (), ptr 
@default_def_with_version_decls
 // CHECK: @explicit_default = weak_odr ifunc i32 (), ptr 
@explicit_default.resolver
 // CHECK: @implicit_default = weak_odr ifunc i32 (), ptr 
@implicit_default.resolver
 // CHECK: @default_def_with_version_decls = weak_odr ifunc i32 (), ptr 
@default_def_with_version_decls.resolver
diff --git a/clang/test/CodeGen/attr-target-clones-aarch64.c 
b/clang/test/CodeGen/attr-target-clones-aarch64.c
index ad6079a91fcd5..60f9c7f1fc24e 100644
--- a/clang/test/CodeGen/attr-target-clones-aarch64.c
+++ b/clang/test/CodeGen/attr-target-clones-aarch64.c
@@ -27,14 +27,6 @@ inline int __attribute__((target_clones("fp16", 
"sve2-bitperm+fcma", "default"))
 
 //.
 // CHECK: @__aarch64_cpu_features = external dso_local global { i64 }
-// CHECK: @ftc.ifunc = weak_odr alias i32 (), ptr @ftc
-// CHECK: @ftc_def.ifunc = weak_odr alias i32 (), ptr @ftc_def
-// CHECK: @ftc_dup1.ifunc = weak_odr alias i32 (), ptr @ftc_dup1
-// CHECK: @ftc_dup2.ifunc = weak_odr alias i32 (), ptr @ftc_dup2
-// CHECK: @ftc_dup3.ifunc = weak_odr alias i32 (), ptr @ftc_dup3
-// CHECK: @ftc_inline2.ifunc = weak_odr alias i32 (), ptr @ftc_inline2
-// CHECK: @ftc_inline1.ifunc = weak_odr alias i32 (), ptr @ftc_inline1
-// CHECK: @ftc_inline3.ifunc = weak_odr alias i32 (), ptr @ftc_inline3
 // CHECK: @ftc = weak_odr ifunc i32 (), ptr @ftc.resolver
 // CHECK: @ftc_def = weak_odr ifunc i32 (), ptr @ftc_def.resolver
 // CHECK: @ftc_dup1 = weak_odr ifunc i32 (), ptr @ftc_dup1.resolver
@@ -45,14 +37,6 @@ inline int __attribute__((target_clones("fp16", 
"sve2-bitperm+fcma", "default"))
 // CHECK: @ftc_inline3 = weak_odr ifunc i32 (), ptr @ftc_inline3.resolver
 //.
 // CHECK-MTE-BTI: @__aarch64_cpu_features = external dso_local global { i64 }
-// CHECK-MTE-BTI: @ftc.ifunc = weak_odr alias i32 (), ptr @ftc
-// CHECK-MTE-BTI: @ftc_def.ifunc = weak_odr alias i32 (), ptr @ftc_def
-// CHECK-MTE-BTI: @ftc_dup1.ifunc = weak_odr alias i32 (), ptr @ftc_dup1
-// CHECK-MTE-BTI: @ftc_dup2.ifunc = weak_odr alias i32 (), ptr @ftc_dup2
-// CHECK-MTE-BTI: @ftc_dup3.ifunc = weak_odr alias i32 (), ptr @ftc_dup3
-// CHECK-MTE-BTI: @ftc_in

[clang] [SourceManager] Expose max usage of source location space as a Statistic (PR #96292)

2024-06-21 Thread Ilya Biryukov via cfe-commits

https://github.com/ilya-biryukov created 
https://github.com/llvm/llvm-project/pull/96292

We have been running into source location exhaustion recently and want to use 
the statistics to monitor the usage in various files to be able to anticipate 
where the next problem will happen.

I picked `Statistic` because it can be written into a structured JSON file and 
is easier to consume by further automation.

This commit does not change any existing per-source-manager metrics exposed via 
`SourceManager::PrintStats()`. This does create some redundancy, but I also 
expect to be non-controversial because it aligns with the intended use of 
`Statistic`.

>From ded4cdee02b56b0284b5e44fd24de6e07c57e6bf Mon Sep 17 00:00:00 2001
From: Ilya Biryukov 
Date: Tue, 11 Jun 2024 19:07:07 +0200
Subject: [PATCH] [SourceManager] Expose max usage of source location space as
 a Statistic

We have been running into source location exhaustion recently and want
to use the statistics to monitor the usage in various files to be able
to anticipate where the next problem will happen.

I picked `Statistic` because it can be written into a structured JSON
file and is easier to consume by further automation.

This commit does not change any existing per-source-manager metrics
exposed via `SourceManager::PrintStats()`. This does create some
redundancy, but I also expect to be non-controversial because it aligns
with the intended use of `Statistic`.
---
 clang/include/clang/Basic/SourceManager.h |  1 +
 clang/lib/Basic/SourceManager.cpp | 16 
 2 files changed, 17 insertions(+)

diff --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index d2e2e914327f2..d3ccc7ef81c07 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -1981,6 +1981,7 @@ class SourceManager : public 
RefCountedBase {
  SourceLocation SpellLoc,
  SourceLocation ExpansionLoc,
  unsigned ExpansionLength) const;
+  void updateSlocUsageStats() const;
 };
 
 /// Comparison function object.
diff --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index f0af1a3e3a38b..e430e8974ff5c 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -20,6 +20,7 @@
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/Allocator.h"
@@ -46,6 +47,12 @@ using namespace clang;
 using namespace SrcMgr;
 using llvm::MemoryBuffer;
 
+#define DEBUG_TYPE "source-manager"
+
+STATISTIC(
+MaxUsedSLocBytes,
+"Maximum number of bytes used by source locations (both loaded and 
local)");
+
 
//===--===//
 // SourceManager Helper Classes
 
//===--===//
@@ -466,6 +473,7 @@ SourceManager::AllocateLoadedSLocEntries(unsigned 
NumSLocEntries,
   SLocEntryLoaded.resize(LoadedSLocEntryTable.size());
   SLocEntryOffsetLoaded.resize(LoadedSLocEntryTable.size());
   CurrentLoadedOffset -= TotalSize;
+  updateSlocUsageStats();
   int BaseID = -int(LoadedSLocEntryTable.size()) - 1;
   LoadedSLocEntryAllocBegin.push_back(FileID::get(BaseID));
   return std::make_pair(BaseID, CurrentLoadedOffset);
@@ -619,6 +627,7 @@ FileID SourceManager::createFileIDImpl(ContentCache &File, 
StringRef Filename,
   // We do a +1 here because we want a SourceLocation that means "the end of 
the
   // file", e.g. for the "no newline at the end of the file" diagnostic.
   NextLocalOffset += FileSize + 1;
+  updateSlocUsageStats();
 
   // Set LastFileIDLookup to the newly created file.  The next getFileID call 
is
   // almost guaranteed to be from that file.
@@ -679,6 +688,7 @@ SourceManager::createExpansionLocImpl(const ExpansionInfo 
&Info,
   }
   // See createFileID for that +1.
   NextLocalOffset += Length + 1;
+  updateSlocUsageStats();
   return SourceLocation::getMacroLoc(NextLocalOffset - (Length + 1));
 }
 
@@ -1843,6 +1853,12 @@ void SourceManager::associateFileChunkWithMacroArgExp(
   MacroArgsCache[EndOffs] = EndOffsMappedLoc;
 }
 
+void SourceManager::updateSlocUsageStats() const {
+  SourceLocation::UIntTy UsedBytes =
+  NextLocalOffset + (MaxLoadedOffset - CurrentLoadedOffset);
+  MaxUsedSLocBytes.updateMax(UsedBytes);
+}
+
 /// If \arg Loc points inside a function macro argument, the returned
 /// location will be the macro location in which the argument was expanded.
 /// If a macro argument is used multiple times, the expanded location will

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


[clang] [SourceManager] Expose max usage of source location space as a Statistic (PR #96292)

2024-06-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Ilya Biryukov (ilya-biryukov)


Changes

We have been running into source location exhaustion recently and want to use 
the statistics to monitor the usage in various files to be able to anticipate 
where the next problem will happen.

I picked `Statistic` because it can be written into a structured JSON file and 
is easier to consume by further automation.

This commit does not change any existing per-source-manager metrics exposed via 
`SourceManager::PrintStats()`. This does create some redundancy, but I also 
expect to be non-controversial because it aligns with the intended use of 
`Statistic`.

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


2 Files Affected:

- (modified) clang/include/clang/Basic/SourceManager.h (+1) 
- (modified) clang/lib/Basic/SourceManager.cpp (+16) 


``diff
diff --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index d2e2e914327f2..d3ccc7ef81c07 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -1981,6 +1981,7 @@ class SourceManager : public 
RefCountedBase {
  SourceLocation SpellLoc,
  SourceLocation ExpansionLoc,
  unsigned ExpansionLength) const;
+  void updateSlocUsageStats() const;
 };
 
 /// Comparison function object.
diff --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index f0af1a3e3a38b..e430e8974ff5c 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -20,6 +20,7 @@
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/Allocator.h"
@@ -46,6 +47,12 @@ using namespace clang;
 using namespace SrcMgr;
 using llvm::MemoryBuffer;
 
+#define DEBUG_TYPE "source-manager"
+
+STATISTIC(
+MaxUsedSLocBytes,
+"Maximum number of bytes used by source locations (both loaded and 
local)");
+
 
//===--===//
 // SourceManager Helper Classes
 
//===--===//
@@ -466,6 +473,7 @@ SourceManager::AllocateLoadedSLocEntries(unsigned 
NumSLocEntries,
   SLocEntryLoaded.resize(LoadedSLocEntryTable.size());
   SLocEntryOffsetLoaded.resize(LoadedSLocEntryTable.size());
   CurrentLoadedOffset -= TotalSize;
+  updateSlocUsageStats();
   int BaseID = -int(LoadedSLocEntryTable.size()) - 1;
   LoadedSLocEntryAllocBegin.push_back(FileID::get(BaseID));
   return std::make_pair(BaseID, CurrentLoadedOffset);
@@ -619,6 +627,7 @@ FileID SourceManager::createFileIDImpl(ContentCache &File, 
StringRef Filename,
   // We do a +1 here because we want a SourceLocation that means "the end of 
the
   // file", e.g. for the "no newline at the end of the file" diagnostic.
   NextLocalOffset += FileSize + 1;
+  updateSlocUsageStats();
 
   // Set LastFileIDLookup to the newly created file.  The next getFileID call 
is
   // almost guaranteed to be from that file.
@@ -679,6 +688,7 @@ SourceManager::createExpansionLocImpl(const ExpansionInfo 
&Info,
   }
   // See createFileID for that +1.
   NextLocalOffset += Length + 1;
+  updateSlocUsageStats();
   return SourceLocation::getMacroLoc(NextLocalOffset - (Length + 1));
 }
 
@@ -1843,6 +1853,12 @@ void SourceManager::associateFileChunkWithMacroArgExp(
   MacroArgsCache[EndOffs] = EndOffsMappedLoc;
 }
 
+void SourceManager::updateSlocUsageStats() const {
+  SourceLocation::UIntTy UsedBytes =
+  NextLocalOffset + (MaxLoadedOffset - CurrentLoadedOffset);
+  MaxUsedSLocBytes.updateMax(UsedBytes);
+}
+
 /// If \arg Loc points inside a function macro argument, the returned
 /// location will be the macro location in which the argument was expanded.
 /// If a macro argument is used multiple times, the expanded location will

``




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


[clang] [SourceManager] Expose max usage of source location space as a Statistic (PR #96292)

2024-06-21 Thread Ilya Biryukov via cfe-commits

ilya-biryukov wrote:

cc @aeubanks @jyknight 

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


[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)

2024-06-21 Thread Shilei Tian via cfe-commits


@@ -149,6 +149,19 @@ BUILTIN(__builtin_amdgcn_mqsad_pk_u16_u8, "WUiWUiUiWUi", 
"nc")
 BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", "nc")
 
 BUILTIN(__builtin_amdgcn_make_buffer_rsrc, "Qbv*sii", "nc")
+BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_i8, "vcQbiiIi", "n")

shiltian wrote:

> Probably should drop the _ptr part of the name. This was more of a legacy 
> issue in the intrinsic case, since the resource-as-vector case already took 
> the name.

Sure, can do.

> Also not sure if we should follow the naming convention of the instruction 
> instead (probably the gfx12 one?).

you mean things like `buffer_store_b8`? In this way, we don't need to 
differentiate types, just bit size.

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


[clang] [llvm] Remove mmx 3dnow (PR #96246)

2024-06-21 Thread Simon Pilgrim via cfe-commits


@@ -7,151 +7,16 @@
  *===---===
  */
 
+// 3dNow intrinsics are no longer supported, and this header remains only as a
+// stub for users who were including it to get to _m_prefetch or
+// _m_prefetchw. Such uses should prefer x86intrin.h.

RKSimon wrote:

How best can we add a deprecation warning to builds for people who are doing 
this?

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


[clang] [llvm] Remove mmx 3dnow (PR #96246)

2024-06-21 Thread Simon Pilgrim via cfe-commits


@@ -1825,32 +1818,32 @@ def : ProcModel;
-def : Proc<"k6-2", [FeatureX87, FeatureCX8, Feature3DNow],
+def : Proc<"k6-2", [FeatureX87, FeatureCX8],

RKSimon wrote:

These still need FeatureMMX and SSEPrefetch (or a similar flag)

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


[clang] [clang][analyzer] Improve documentation of checker 'cplusplus.Move' (NFC) (PR #96295)

2024-06-21 Thread Balázs Kéri via cfe-commits

https://github.com/balazske created 
https://github.com/llvm/llvm-project/pull/96295

None

From 0c57ad1ca36a841dff700eb98f878475e0243b88 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= 
Date: Fri, 21 Jun 2024 12:13:02 +0200
Subject: [PATCH] [clang][analyzer] Improve documentation of checker
 'cplusplus.Move' (NFC)

---
 clang/docs/analyzer/checkers.rst  | 39 +--
 .../clang/StaticAnalyzer/Checkers/Checkers.td | 21 +++---
 2 files changed, 40 insertions(+), 20 deletions(-)

diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index b8d5f372bdf61..445f434e1e6ce 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -420,21 +420,52 @@ around, such as ``std::string_view``.
 
 cplusplus.Move (C++)
 
-Method calls on a moved-from object and copying a moved-from object will be 
reported.
-
+Find use-after-move bugs in C++. This includes method calls on moved-from
+objects, assignment of a moved-from object, and repeated move of a moved-from
+object.
 
 .. code-block:: cpp
 
-  struct A {
+ struct A {
void foo() {}
  };
 
- void f() {
+ void f1() {
A a;
A b = std::move(a); // note: 'a' became 'moved-from' here
a.foo();// warn: method call on a 'moved-from' object 'a'
  }
 
+ void f2() {
+   A a;
+   A b = std::move(a);
+   A c(std::move(a)); // warn: move of an already moved-from object
+ }
+
+ void f3() {
+   A a;
+   A b = std::move(a);
+   b = a; // warn: copy of moved-from object
+ }
+
+The checker option ``WarnOn`` controls on what objects the use-after-move is
+checked. The most strict value is ``KnownsOnly``, in this mode only objects are
+checked whose type is known to be move-unsafe. These include most STL objects
+(but excluding move-safe ones) and smart pointers. With option value
+``KnownsAndLocals`` local variables (of any type) are additionally checked. The
+idea behind this is that local variables are usually not tempting to be re-used
+so an use after move is more likely a bug than with member variables. With
+option value ``All`` any use-after move condition is checked on all kinds of
+variables, excluding global variables and known move-safe cases. Default value
+is ``KnownsAndLocals``.
+
+Call of methods named ``empty()`` or ``isEmpty()`` are allowed on moved-from
+objects because these methods are considered as move-safe. Functions called
+``reset()``, ``destroy()``, ``clear()``, ``assign``, ``resize``,  ``shrink`` 
are
+treated as state-reset functions and are allowed on moved-from objects, these
+make the object valid again. This applies to any type of object (not only STL
+ones).
+
 .. _cplusplus-NewDelete:
 
 cplusplus.NewDelete (C++)
diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 429c334a0b24b..6e224a4e098ad 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -686,22 +686,11 @@ def MoveChecker: Checker<"Move">,
   CheckerOptions<[
 CmdLineOption
   ]>,

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


[clang] [clang][AArch64][FMV] Stop emitting alias to ifunc. (PR #96221)

2024-06-21 Thread Alexandros Lamprineas via cfe-commits

https://github.com/labrinea updated 
https://github.com/llvm/llvm-project/pull/96221

>From 4b884669236cae2d5ac42a95517d9ce57060a494 Mon Sep 17 00:00:00 2001
From: Alexandros Lamprineas 
Date: Thu, 20 Jun 2024 17:40:44 +0100
Subject: [PATCH 1/2] [clang][AArch64][FMV] Stop emitting alias to ifunc.

Long story short the interaction of two optimizations happening in
GlobalOpt results in a crash. For more details look at the issue
https://github.com/llvm/llvm-project/issues/96197. I will be
fixing this in GlobalOpt but it is a conservative solution since
it won't allow us to optimize resolvers which return a pointer
to a function whose definition is in another TU when compiling
without LTO:

__attribute__((target_version("simd"))) void bar(void);
__attribute__((target_version("default"))) void bar(void);
int foo() { bar(); }
---
 clang/lib/CodeGen/CodeGenModule.cpp  |  4 ++--
 .../CodeGen/aarch64-mixed-target-attributes.c|  3 ---
 clang/test/CodeGen/attr-target-clones-aarch64.c  | 16 
 clang/test/CodeGen/attr-target-version.c | 13 -
 .../CodeGenCXX/attr-target-clones-aarch64.cpp|  4 
 clang/test/CodeGenCXX/attr-target-version.cpp|  6 --
 clang/test/CodeGenCXX/fmv-namespace.cpp  |  2 --
 7 files changed, 2 insertions(+), 46 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index dd4a665ebc78b..76534475e88f7 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4259,8 +4259,8 @@ void CodeGenModule::emitMultiVersionFunctions() {
 llvm::Constant *ResolverConstant = GetOrCreateMultiVersionResolver(GD);
 if (auto *IFunc = dyn_cast(ResolverConstant)) {
   ResolverConstant = IFunc->getResolver();
-  if (FD->isTargetClonesMultiVersion() ||
-  FD->isTargetVersionMultiVersion()) {
+  if (FD->isTargetClonesMultiVersion() &&
+  !getTarget().getTriple().isAArch64()) {
 std::string MangledName = getMangledNameImpl(
 *this, GD, FD, /*OmitMultiVersionMangling=*/true);
 if (!GetGlobalValue(MangledName + ".ifunc")) {
diff --git a/clang/test/CodeGen/aarch64-mixed-target-attributes.c 
b/clang/test/CodeGen/aarch64-mixed-target-attributes.c
index 6aa747d4cb461..3c047fec6ceed 100644
--- a/clang/test/CodeGen/aarch64-mixed-target-attributes.c
+++ b/clang/test/CodeGen/aarch64-mixed-target-attributes.c
@@ -30,9 +30,6 @@ __attribute__((target_version("jscvt"))) int 
default_def_with_version_decls(void
 
 //.
 // CHECK: @__aarch64_cpu_features = external dso_local global { i64 }
-// CHECK: @explicit_default.ifunc = weak_odr alias i32 (), ptr 
@explicit_default
-// CHECK: @implicit_default.ifunc = weak_odr alias i32 (), ptr 
@implicit_default
-// CHECK: @default_def_with_version_decls.ifunc = weak_odr alias i32 (), ptr 
@default_def_with_version_decls
 // CHECK: @explicit_default = weak_odr ifunc i32 (), ptr 
@explicit_default.resolver
 // CHECK: @implicit_default = weak_odr ifunc i32 (), ptr 
@implicit_default.resolver
 // CHECK: @default_def_with_version_decls = weak_odr ifunc i32 (), ptr 
@default_def_with_version_decls.resolver
diff --git a/clang/test/CodeGen/attr-target-clones-aarch64.c 
b/clang/test/CodeGen/attr-target-clones-aarch64.c
index ad6079a91fcd5..60f9c7f1fc24e 100644
--- a/clang/test/CodeGen/attr-target-clones-aarch64.c
+++ b/clang/test/CodeGen/attr-target-clones-aarch64.c
@@ -27,14 +27,6 @@ inline int __attribute__((target_clones("fp16", 
"sve2-bitperm+fcma", "default"))
 
 //.
 // CHECK: @__aarch64_cpu_features = external dso_local global { i64 }
-// CHECK: @ftc.ifunc = weak_odr alias i32 (), ptr @ftc
-// CHECK: @ftc_def.ifunc = weak_odr alias i32 (), ptr @ftc_def
-// CHECK: @ftc_dup1.ifunc = weak_odr alias i32 (), ptr @ftc_dup1
-// CHECK: @ftc_dup2.ifunc = weak_odr alias i32 (), ptr @ftc_dup2
-// CHECK: @ftc_dup3.ifunc = weak_odr alias i32 (), ptr @ftc_dup3
-// CHECK: @ftc_inline2.ifunc = weak_odr alias i32 (), ptr @ftc_inline2
-// CHECK: @ftc_inline1.ifunc = weak_odr alias i32 (), ptr @ftc_inline1
-// CHECK: @ftc_inline3.ifunc = weak_odr alias i32 (), ptr @ftc_inline3
 // CHECK: @ftc = weak_odr ifunc i32 (), ptr @ftc.resolver
 // CHECK: @ftc_def = weak_odr ifunc i32 (), ptr @ftc_def.resolver
 // CHECK: @ftc_dup1 = weak_odr ifunc i32 (), ptr @ftc_dup1.resolver
@@ -45,14 +37,6 @@ inline int __attribute__((target_clones("fp16", 
"sve2-bitperm+fcma", "default"))
 // CHECK: @ftc_inline3 = weak_odr ifunc i32 (), ptr @ftc_inline3.resolver
 //.
 // CHECK-MTE-BTI: @__aarch64_cpu_features = external dso_local global { i64 }
-// CHECK-MTE-BTI: @ftc.ifunc = weak_odr alias i32 (), ptr @ftc
-// CHECK-MTE-BTI: @ftc_def.ifunc = weak_odr alias i32 (), ptr @ftc_def
-// CHECK-MTE-BTI: @ftc_dup1.ifunc = weak_odr alias i32 (), ptr @ftc_dup1
-// CHECK-MTE-BTI: @ftc_dup2.ifunc = weak_odr alias i32 (), ptr @ftc_dup2
-// CHECK-MTE-BTI: @ftc_dup3.ifunc = weak_odr alias i32 (), ptr @ftc_dup3
-// CHECK-MTE-BTI: @ftc_in

[clang] [clang][analyzer] Improve documentation of checker 'cplusplus.Move' (NFC) (PR #96295)

2024-06-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Balázs Kéri (balazske)


Changes



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


2 Files Affected:

- (modified) clang/docs/analyzer/checkers.rst (+35-4) 
- (modified) clang/include/clang/StaticAnalyzer/Checkers/Checkers.td (+5-16) 


``diff
diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index b8d5f372bdf61..445f434e1e6ce 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -420,21 +420,52 @@ around, such as ``std::string_view``.
 
 cplusplus.Move (C++)
 
-Method calls on a moved-from object and copying a moved-from object will be 
reported.
-
+Find use-after-move bugs in C++. This includes method calls on moved-from
+objects, assignment of a moved-from object, and repeated move of a moved-from
+object.
 
 .. code-block:: cpp
 
-  struct A {
+ struct A {
void foo() {}
  };
 
- void f() {
+ void f1() {
A a;
A b = std::move(a); // note: 'a' became 'moved-from' here
a.foo();// warn: method call on a 'moved-from' object 'a'
  }
 
+ void f2() {
+   A a;
+   A b = std::move(a);
+   A c(std::move(a)); // warn: move of an already moved-from object
+ }
+
+ void f3() {
+   A a;
+   A b = std::move(a);
+   b = a; // warn: copy of moved-from object
+ }
+
+The checker option ``WarnOn`` controls on what objects the use-after-move is
+checked. The most strict value is ``KnownsOnly``, in this mode only objects are
+checked whose type is known to be move-unsafe. These include most STL objects
+(but excluding move-safe ones) and smart pointers. With option value
+``KnownsAndLocals`` local variables (of any type) are additionally checked. The
+idea behind this is that local variables are usually not tempting to be re-used
+so an use after move is more likely a bug than with member variables. With
+option value ``All`` any use-after move condition is checked on all kinds of
+variables, excluding global variables and known move-safe cases. Default value
+is ``KnownsAndLocals``.
+
+Call of methods named ``empty()`` or ``isEmpty()`` are allowed on moved-from
+objects because these methods are considered as move-safe. Functions called
+``reset()``, ``destroy()``, ``clear()``, ``assign``, ``resize``,  ``shrink`` 
are
+treated as state-reset functions and are allowed on moved-from objects, these
+make the object valid again. This applies to any type of object (not only STL
+ones).
+
 .. _cplusplus-NewDelete:
 
 cplusplus.NewDelete (C++)
diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 429c334a0b24b..6e224a4e098ad 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -686,22 +686,11 @@ def MoveChecker: Checker<"Move">,
   CheckerOptions<[
 CmdLineOption
   ]>,

``




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


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-06-21 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

@nikic thanks. Please also revert 
https://github.com/llvm/llvm-project/commit/225d8fc8eb24fb797154c1ef6dcbe5ba033142da

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


[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)

2024-06-21 Thread Matt Arsenault via cfe-commits


@@ -149,6 +149,19 @@ BUILTIN(__builtin_amdgcn_mqsad_pk_u16_u8, "WUiWUiUiWUi", 
"nc")
 BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", "nc")
 
 BUILTIN(__builtin_amdgcn_make_buffer_rsrc, "Qbv*sii", "nc")
+BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_i8, "vcQbiiIi", "n")

arsenm wrote:

Yes. Pre-gfx12 it was _byte, _short, _dword, _dwordxN. But that also means you 
need casts and we drop the FP and 16-element versions so I don't know which way 
is best. Ideally we would just use the elementwise intrinsic approach but that 
won't work for loads 

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


[clang] [clang][ASTImporter] Fix possible crash "given incorrect InsertPos for specialization". (PR #89887)

2024-06-21 Thread Balázs Kéri via cfe-commits

balazske wrote:

I have not enough resources to create a reproducer and it is not trivial, so I 
would merge this change now.

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


[clang] 0290a0e - [clang][ASTImporter] Fix possible crash "given incorrect InsertPos for specialization". (#89887)

2024-06-21 Thread via cfe-commits

Author: Balázs Kéri
Date: 2024-06-21T12:51:43+02:00
New Revision: 0290a0e64f0d235e0e6b38283f9a389c7ab977dc

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

LOG: [clang][ASTImporter] Fix possible crash "given incorrect InsertPos for 
specialization". (#89887)

In some situations a new `VarTemplateSpecializationDecl` (for the same
template) can be added during import of another one. The "insert
position" that is used to insert the current object into the list of
specializations is stored at start of the import and is used later. If
the list changes before the insertion the position is not valid any
more.

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 1b67feaae8874..4e1b3a5a94de7 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -6565,6 +6565,11 @@ ExpectedDecl 
ASTNodeImporter::VisitVarTemplateSpecializationDecl(
   return D2;
   }
 
+  // Update InsertPos, because preceding import calls may have invalidated
+  // it by adding new specializations.
+  if (!VarTemplate->findSpecialization(TemplateArgs, InsertPos))
+VarTemplate->AddSpecialization(D2, InsertPos);
+
   QualType T;
   if (Error Err = importInto(T, D->getType()))
 return std::move(Err);
@@ -6603,8 +6608,6 @@ ExpectedDecl 
ASTNodeImporter::VisitVarTemplateSpecializationDecl(
   if (FoundSpecialization)
 D2->setPreviousDecl(FoundSpecialization->getMostRecentDecl());
 
-  VarTemplate->AddSpecialization(D2, InsertPos);
-
   addDeclToContexts(D, D2);
 
   // Import the rest of the chain. I.e. import all subsequent declarations.



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


[clang] [clang][ASTImporter] Fix possible crash "given incorrect InsertPos for specialization". (PR #89887)

2024-06-21 Thread Balázs Kéri via cfe-commits

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


[clang] [clang][analyzer] Improve documentation of checker 'cplusplus.Move' (NFC) (PR #96295)

2024-06-21 Thread Donát Nagy via cfe-commits

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


[clang] [clang][analyzer] Improve documentation of checker 'cplusplus.Move' (NFC) (PR #96295)

2024-06-21 Thread Donát Nagy via cfe-commits


@@ -420,21 +420,52 @@ around, such as ``std::string_view``.
 
 cplusplus.Move (C++)
 
-Method calls on a moved-from object and copying a moved-from object will be 
reported.
-
+Find use-after-move bugs in C++. This includes method calls on moved-from
+objects, assignment of a moved-from object, and repeated move of a moved-from
+object.
 
 .. code-block:: cpp
 
-  struct A {
+ struct A {
void foo() {}
  };
 
- void f() {
+ void f1() {
A a;
A b = std::move(a); // note: 'a' became 'moved-from' here
a.foo();// warn: method call on a 'moved-from' object 'a'
  }
 
+ void f2() {
+   A a;
+   A b = std::move(a);
+   A c(std::move(a)); // warn: move of an already moved-from object
+ }
+
+ void f3() {
+   A a;
+   A b = std::move(a);
+   b = a; // warn: copy of moved-from object
+ }
+
+The checker option ``WarnOn`` controls on what objects the use-after-move is
+checked. The most strict value is ``KnownsOnly``, in this mode only objects are
+checked whose type is known to be move-unsafe. These include most STL objects
+(but excluding move-safe ones) and smart pointers. With option value
+``KnownsAndLocals`` local variables (of any type) are additionally checked. The
+idea behind this is that local variables are usually not tempting to be re-used
+so an use after move is more likely a bug than with member variables. With
+option value ``All`` any use-after move condition is checked on all kinds of
+variables, excluding global variables and known move-safe cases. Default value
+is ``KnownsAndLocals``.

NagyDonat wrote:

```suggestion
The checker option ``WarnOn`` controls on what objects the use-after-move is
checked.
* The most strict value is ``KnownsOnly``, in this mode only objects are
  checked whose type is known to be move-unsafe. These include most STL objects
  (but excluding move-safe ones) and smart pointers.
* With option value ``KnownsAndLocals`` local variables (of any type) are
  additionally checked. The idea behind this is that local variables are
  usually not tempting to be re-used so an use after move is more likely a bug
  than with member variables.
* With option value ``All`` any use-after move condition is checked on all
  kinds of variables, excluding global variables and known move-safe cases.
Default value is ``KnownsAndLocals``.
```
This paragraph was very long, re-flow it into a bullet point list.

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


[clang] [clang][analyzer] Improve documentation of checker 'cplusplus.Move' (NFC) (PR #96295)

2024-06-21 Thread Donát Nagy via cfe-commits

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

LGTM, thanks for updating the docs!

I only have one minor inline remark about formatting.

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


[clang] [clang][analyzer] Improve documentation of checker 'cplusplus.Move' (NFC) (PR #96295)

2024-06-21 Thread Donát Nagy via cfe-commits

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


[clang] c7c6361 - [clang][Interp] Don't try to decay non-pointers to pointers

2024-06-21 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-06-21T13:15:35+02:00
New Revision: c7c636189adc45251be2b7cc53b6b047e1ac3536

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

LOG: [clang][Interp] Don't try to decay non-pointers to pointers

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2-0x.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 034e479ff3a32..edc2ec8e50952 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -4250,7 +4250,7 @@ bool ByteCodeExprGen::visitDeclRef(const 
ValueDecl *D, const Expr *E) {
 if (E->getType()->isVoidType())
   return true;
 // Convert the dummy pointer to another pointer type if we have to.
-if (PrimType PT = classifyPrim(E); PT != PT_Ptr) {
+if (PrimType PT = classifyPrim(E); PT != PT_Ptr && isPtrType(PT)) {
   if (!this->emitDecayPtr(PT_Ptr, PT, E))
 return false;
 }

diff  --git 
a/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2-0x.cpp 
b/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2-0x.cpp
index 11dd5194192be..a63ffa92d726a 100644
--- a/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2-0x.cpp
+++ b/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2-0x.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -verify %s
+// RUN: %clang_cc1 -std=c++11 -verify %s 
-fexperimental-new-constant-interpreter
 
 template struct S; // expected-note 3{{here}}
 



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


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-06-21 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

@nikic Thanks. I submit an RFC now
https://discourse.llvm.org/t/rfc-fix-llvm-min-f-and-llvm-max-f-intrinsics/79735

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


[clang] [clang-format] Annotate r_paren before braced list as TT_CastRParen (PR #96271)

2024-06-21 Thread via cfe-commits

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

LGTM

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


[clang] [Clang] skip alignment checks on incomplete types to avoid an assertion failure while parsing lambda used as default argument (PR #94542)

2024-06-21 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> @AaronBallman Thank you for your feedback. Do you think this needs to be 
> reviewed by someone else? I can't add reviewers myself :)

Nope, it's ready to land; sorry for not asking earlier, do you need me to 
commit this on your behalf?

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


[clang] [clang-format][NFC] Add CMake target clang-format-check-format (PR #95873)

2024-06-21 Thread via cfe-commits

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

nice!

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


[clang] [clang-tools-extra] Reland [clang][Sema, Lex, Parse] Preprocessor embed in C and C++ (PR #95802)

2024-06-21 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

Thank you both for collaborating to get that solved!

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


[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)

2024-06-21 Thread Shilei Tian via cfe-commits


@@ -149,6 +149,19 @@ BUILTIN(__builtin_amdgcn_mqsad_pk_u16_u8, "WUiWUiUiWUi", 
"nc")
 BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", "nc")
 
 BUILTIN(__builtin_amdgcn_make_buffer_rsrc, "Qbv*sii", "nc")
+BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_i8, "vcQbiiIi", "n")

shiltian wrote:

The current variants don't have v16 version anyway. I think it might be more 
reasonable to provide the actual low level thingy to users and they need to 
take care of types, since we never know what kind of types there will be.

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


[libcxx] [libcxxabi] [libunwind] [libc++] Fix deployment target Lit features (PR #94791)

2024-06-21 Thread Louis Dionne via cfe-commits

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


[clang] [Clang] skip alignment checks on incomplete types to avoid an assertion failure while parsing lambda used as default argument (PR #94542)

2024-06-21 Thread Oleksandr T. via cfe-commits

a-tarasyuk wrote:

@AaronBallman Yes, I do. I don't have access to merge…

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


[clang] 9b50a88 - [Clang] skip alignment checks on incomplete types to avoid an assertion failure while parsing lambda used as default argument (#94542)

2024-06-21 Thread via cfe-commits

Author: Oleksandr T
Date: 2024-06-21T08:18:14-04:00
New Revision: 9b50a88853cc5df4fcdcb56a2ea57f5db4b1978b

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

LOG: [Clang] skip alignment checks on incomplete types to avoid an assertion 
failure while parsing lambda used as default argument (#94542)

Fixes #93512

Added: 
clang/test/SemaCXX/lambda-as-default-parameter.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaStmt.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 455c34bce0684..7ac0fa0141b47 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -912,7 +912,8 @@ Bug Fixes to C++ Support
   between the addresses of two labels (a GNU extension) to a pointer within a 
constant expression. (#GH95366).
 - Fix immediate escalation bugs in the presence of dependent call arguments. 
(#GH94935)
 - Clang now diagnoses explicit specializations with storage class specifiers 
in all contexts.
-
+- Fix an assertion failure caused by parsing a lambda used as a default 
argument for the value of a
+  forward-declared class. (#GH93512).
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 411e9af26f2b7..1bb86385333ef 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3355,7 +3355,7 @@ Sema::NamedReturnInfo Sema::getNamedReturnInfo(const 
VarDecl *VD) {
 
   // Variables with higher required alignment than their type's ABI
   // alignment cannot use NRVO.
-  if (!VD->hasDependentAlignment() &&
+  if (!VD->hasDependentAlignment() && !VDType->isIncompleteType() &&
   Context.getDeclAlign(VD) > Context.getTypeAlignInChars(VDType))
 Info.S = NamedReturnInfo::MoveEligible;
 

diff  --git a/clang/test/SemaCXX/lambda-as-default-parameter.cpp 
b/clang/test/SemaCXX/lambda-as-default-parameter.cpp
new file mode 100644
index 0..1f07a7f5644b7
--- /dev/null
+++ b/clang/test/SemaCXX/lambda-as-default-parameter.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct a; // expected-note {{forward declaration of 'a'}} \
+ expected-note {{forward declaration of 'a'}}
+void b(a c = [] { return c; }); // expected-error {{initialization of 
incomplete type 'a'}} \
+   expected-error {{variable has incomplete 
type 'a'}}



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


[clang] [Clang] skip alignment checks on incomplete types to avoid an assertion failure while parsing lambda used as default argument (PR #94542)

2024-06-21 Thread Aaron Ballman via cfe-commits

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


[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)

2024-06-21 Thread via cfe-commits


@@ -8077,32 +8077,21 @@ static bool verifyValidIntegerConstantExpr(Sema &S, 
const ParsedAttr &Attr,
 /// match one of the standard Neon vector types.
 static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr,
  Sema &S, VectorKind VecKind) {
-  bool IsTargetCUDAAndHostARM = false;
-  if (S.getLangOpts().CUDAIsDevice) {
-const TargetInfo *AuxTI = S.getASTContext().getAuxTargetInfo();
-IsTargetCUDAAndHostARM =
-AuxTI && (AuxTI->getTriple().isAArch64() || 
AuxTI->getTriple().isARM());
-  }
-
   // Target must have NEON (or MVE, whose vectors are similar enough
   // not to need a separate attribute)
-  if (!(S.Context.getTargetInfo().hasFeature("neon") ||
-S.Context.getTargetInfo().hasFeature("mve") ||
-S.Context.getTargetInfo().hasFeature("sve") ||
-S.Context.getTargetInfo().hasFeature("sme") ||
-IsTargetCUDAAndHostARM) &&
-  VecKind == VectorKind::Neon) {
-S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
-<< Attr << "'neon', 'mve', 'sve' or 'sme'";
+  if (!S.Context.getTargetInfo().hasFeature("mve") &&
+  VecKind == VectorKind::Neon &&
+  S.Context.getTargetInfo().getTriple().isArmMClass()) {
+S.Diag(Attr.getLoc(), diag::err_attribute_unsupported_m_profile)
+<< Attr << "'mve'";
 Attr.setInvalid();
 return;
   }
-  if (!(S.Context.getTargetInfo().hasFeature("neon") ||
-S.Context.getTargetInfo().hasFeature("mve") ||
-IsTargetCUDAAndHostARM) &&
-  VecKind == VectorKind::NeonPoly) {
-S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
-<< Attr << "'neon' or 'mve'";
+  if (!S.Context.getTargetInfo().hasFeature("mve") &&
+  VecKind == VectorKind::NeonPoly &&

CarolineConcatto wrote:

Wha happens if we have the original test(git show ed2d497291f0de330), but 
without the neon check:
  if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM)){


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


[clang] [llvm] [openmp] [Clang][OpenMP] Add reverse directive (PR #92916)

2024-06-21 Thread Michael Kruse via cfe-commits

Meinersbur wrote:

#92916 has been accepted, but waiting for this PR.

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


[clang] 138ea7d - Revert "[ubsan] Display correct runtime messages for negative _BitInt" (#96239)

2024-06-21 Thread via cfe-commits

Author: earnol
Date: 2024-06-21T08:33:46-04:00
New Revision: 138ea7d1fb82c2525da8dcc2f8ea73eae7b25f25

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

LOG: Revert "[ubsan] Display correct runtime messages for negative _BitInt" 
(#96239)

Reverts llvm/llvm-project#93612 due to the issues with ppc64le platform.

Added: 


Modified: 
clang/lib/CodeGen/CGExpr.cpp
compiler-rt/lib/ubsan/ubsan_value.cpp
compiler-rt/lib/ubsan/ubsan_value.h

Removed: 
compiler-rt/test/ubsan/TestCases/Integer/bit-int-pass.c
compiler-rt/test/ubsan/TestCases/Integer/bit-int.c



diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 55b2b4337fab8..3dfe5e09c778d 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -41,7 +41,6 @@
 #include "llvm/IR/MatrixBuilder.h"
 #include "llvm/Passes/OptimizationLevel.h"
 #include "llvm/Support/ConvertUTF.h"
-#include "llvm/Support/Endian.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/SaveAndRestore.h"
@@ -65,22 +64,6 @@ static llvm::cl::opt ClSanitizeGuardChecks(
 "ubsan-guard-checks", llvm::cl::Optional,
 llvm::cl::desc("Guard UBSAN checks with `llvm.allow.ubsan.check()`."));
 
-//======//
-//Defines for metadata
-//======//
-
-// Those values are crucial to be the SAME as in ubsan runtime library.
-enum VariableTypeDescriptorKind : uint16_t {
-  /// An integer type.
-  TK_Integer = 0x,
-  /// A floating-point type.
-  TK_Float = 0x0001,
-  /// An _BitInt(N) type.
-  TK_BitInt = 0x0002,
-  /// Any other type. The value representation is unspecified.
-  TK_Unknown = 0x
-};
-
 //======//
 //Miscellaneous Helper Methods
 //======//
@@ -3315,40 +3298,22 @@ LValue CodeGenFunction::EmitPredefinedLValue(const 
PredefinedExpr *E) {
 ///   { i16 TypeKind, i16 TypeInfo }
 /// \endcode
 ///
-/// followed by an array of i8 containing the type name with extra information
-/// for BitInt. TypeKind is TK_Integer(0) for an integer, TK_Float(1) for a
-/// floating point value, TK_BitInt(2) for BitInt and TK_Unknown(0x) for
-/// anything else.
+/// followed by an array of i8 containing the type name. TypeKind is 0 for an
+/// integer, 1 for a floating point value, and -1 for anything else.
 llvm::Constant *CodeGenFunction::EmitCheckTypeDescriptor(QualType T) {
   // Only emit each type's descriptor once.
   if (llvm::Constant *C = CGM.getTypeDescriptorFromMap(T))
 return C;
 
-  uint16_t TypeKind = TK_Unknown;
+  uint16_t TypeKind = -1;
   uint16_t TypeInfo = 0;
-  bool IsBitInt = false;
 
   if (T->isIntegerType()) {
-TypeKind = TK_Integer;
+TypeKind = 0;
 TypeInfo = (llvm::Log2_32(getContext().getTypeSize(T)) << 1) |
(T->isSignedIntegerType() ? 1 : 0);
-// Follow suggestion from https://github.com/llvm/llvm-project/issues/64100
-// So we can write the exact amount of bits in TypeName after '\0'
-// making it .'\0'.<32-bit width>.
-if (T->isSignedIntegerType() && T->getAs()) {
-  // Do a sanity checks as we are using 32-bit type to store bit length.
-  assert((getContext().getTypeSize(T) > 0) &&
- " non positive amount of bits in __BitInt type");
-  assert((getContext().getTypeSize(T) <= 0x) &&
- " too many bits in __BitInt type");
-
-  // Redefine TypeKind with the actual __BitInt type if we have signed
-  // BitInt.
-  TypeKind = TK_BitInt;
-  IsBitInt = true;
-}
   } else if (T->isFloatingType()) {
-TypeKind = TK_Float;
+TypeKind = 1;
 TypeInfo = getContext().getTypeSize(T);
   }
 
@@ -3359,20 +3324,6 @@ llvm::Constant 
*CodeGenFunction::EmitCheckTypeDescriptor(QualType T) {
   DiagnosticsEngine::ak_qualtype, (intptr_t)T.getAsOpaquePtr(), 
StringRef(),
   StringRef(), std::nullopt, Buffer, std::nullopt);
 
-  if (IsBitInt) {
-// The Structure is: 0 to end the string, 32 bit unsigned integer in target
-// endianness, zero.
-char S[6] = {'\0', '\0', '\0', '\0', '\0', '\0'};
-const auto *EIT = T->castAs();
-uint32_t Bits = EIT->getNumBits();
-llvm::support::endian::write32(S + 1, Bits,
-   getTarget().isBigEndian()
-   ? llvm::endianness::big
-   : llvm::endianness::little);
-StringRef str = StringRef(S, sizeof(S) / sizeof(decltype(S[0])));
-Buffer.append(str);
-  }
-
   llvm:

[clang] [compiler-rt] Revert "[ubsan] Display correct runtime messages for negative _BitInt" (PR #96239)

2024-06-21 Thread via cfe-commits

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


[clang] [compiler-rt] [ubsan] Display correct runtime messages for negative _BitInt (PR #96240)

2024-06-21 Thread via cfe-commits


@@ -0,0 +1,174 @@
+// RUN: %clang -Wno-constant-conversion -Wno-array-bounds 
-Wno-division-by-zero -Wno-shift-negative-value -Wno-shift-count-negative 
-Wno-int-to-pointer-cast -O0 
-fsanitize=alignment,array-bounds,bool,float-cast-overflow,implicit-integer-sign-change,implicit-signed-integer-truncation,implicit-unsigned-integer-truncation,integer-divide-by-zero,nonnull-attribute,null,nullability-arg,nullability-assign,nullability-return,pointer-overflow,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,unsigned-integer-overflow,unsigned-shift-base,vla-bound
 %s -o %t1 && %run %t1 2>&1 | FileCheck %s --check-prefix=RUNTIME
+// RUN: %clang -Wno-constant-conversion -Wno-array-bounds 
-Wno-division-by-zero -Wno-shift-negative-value -Wno-shift-count-negative 
-Wno-int-to-pointer-cast 
-fsanitize=array-bounds,enum,float-cast-overflow,integer-divide-by-zero,implicit-unsigned-integer-truncation,implicit-signed-integer-truncation,implicit-integer-sign-change,unsigned-integer-overflow,signed-integer-overflow,shift-base,shift-exponent
 -O0 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=IR

earnol wrote:

Duplication looks really ugly. Is there is a way to run IR test and runtime 
test on the same code?

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


[clang] [compiler-rt] [ubsan] Display correct runtime messages for negative _BitInt (PR #96240)

2024-06-21 Thread via cfe-commits

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


[clang] [compiler-rt] [ubsan] Display correct runtime messages for negative _BitInt (PR #96240)

2024-06-21 Thread via cfe-commits


@@ -0,0 +1,174 @@
+// RUN: %clang -Wno-constant-conversion -Wno-array-bounds 
-Wno-division-by-zero -Wno-shift-negative-value -Wno-shift-count-negative 
-Wno-int-to-pointer-cast -O0 
-fsanitize=alignment,array-bounds,bool,float-cast-overflow,implicit-integer-sign-change,implicit-signed-integer-truncation,implicit-unsigned-integer-truncation,integer-divide-by-zero,nonnull-attribute,null,nullability-arg,nullability-assign,nullability-return,pointer-overflow,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,unsigned-integer-overflow,unsigned-shift-base,vla-bound
 %s -o %t1 && %run %t1 2>&1 | FileCheck %s --check-prefix=RUNTIME
+// RUN: %clang -Wno-constant-conversion -Wno-array-bounds 
-Wno-division-by-zero -Wno-shift-negative-value -Wno-shift-count-negative 
-Wno-int-to-pointer-cast 
-fsanitize=array-bounds,enum,float-cast-overflow,integer-divide-by-zero,implicit-unsigned-integer-truncation,implicit-signed-integer-truncation,implicit-integer-sign-change,unsigned-integer-overflow,signed-integer-overflow,shift-base,shift-exponent
 -O0 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=IR
+
+#include 
+#include 
+
+uint32_t float_divide_by_zero() {
+  float f = 1.0f / 0.0f;
+  // IR: constant { i16, i16, [8 x i8] } { i16 1, i16 32, [8 x i8] 
c"'float'\00" }
+  _BitInt(37) r = (_BitInt(37))f;
+  // RUNTIME: {{.*}}bit-int.c:[[@LINE-1]]:19: runtime error: inf is outside 
the range of representable values of type
+  // IR: constant { i16, i16, [20 x i8] } { i16 2, i16 13, [20 x i8] 
c"'_BitInt(37)'\00%\00\00\00\00\00" }
+  return r;
+}
+
+uint32_t integer_divide_by_zero() __attribute__((no_sanitize("memory"))) {
+  _BitInt(37) x = 1 / 0;
+  // RUNTIME: {{.*}}bit-int.c:[[@LINE-1]]:21: runtime error: division by zero

earnol wrote:

Accepted.

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


[clang] [clang] Allow class with anonymous union member to be const-default-constructible even if a union member has a default member initializer (#95854) (PR #96301)

2024-06-21 Thread Rajveer Singh Bharadwaj via cfe-commits

https://github.com/Rajveer100 created 
https://github.com/llvm/llvm-project/pull/96301

Resolves #95854

-- As per https://eel.is/c++draft/dcl.init#general-8.3

>From c8f2496e91d58c8704911665e1bf1dd7dfbb1d2e Mon Sep 17 00:00:00 2001
From: Rajveer 
Date: Fri, 21 Jun 2024 18:26:36 +0530
Subject: [PATCH] [clang] Allow class with anonymous union member to be
 const-default-constructible even if a union member has a default member
 initializer (#95854)

Resolves #95854

-- As per https://eel.is/c++draft/dcl.init#general-8.3
---
 clang/include/clang/AST/DeclCXX.h |  3 ++-
 clang/test/Sema/debug-95854.cpp   | 11 +++
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/Sema/debug-95854.cpp

diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index fb52ac804849d..1d1083a5d6205 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1392,7 +1392,8 @@ class CXXRecordDecl : public RecordDecl {
   bool allowConstDefaultInit() const {
 return !data().HasUninitializedFields ||
!(data().HasDefaultedDefaultConstructor ||
- needsImplicitDefaultConstructor());
+ needsImplicitDefaultConstructor()) ||
+   hasInClassInitializer();
   }
 
   /// Determine whether this class has a destructor which has no
diff --git a/clang/test/Sema/debug-95854.cpp b/clang/test/Sema/debug-95854.cpp
new file mode 100644
index 0..1fb976558650d
--- /dev/null
+++ b/clang/test/Sema/debug-95854.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s
+//
+// expected-no-diagnostics
+
+struct A {
+  union {
+int n = 0;
+int m;
+  };
+};
+const A a;

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


[clang] [clang] Allow class with anonymous union member to be const-default-constructible even if a union member has a default member initializer (#95854) (PR #96301)

2024-06-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Rajveer Singh Bharadwaj (Rajveer100)


Changes

Resolves #95854

-- As per https://eel.is/c++draft/dcl.init#general-8.3

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


2 Files Affected:

- (modified) clang/include/clang/AST/DeclCXX.h (+2-1) 
- (added) clang/test/Sema/debug-95854.cpp (+11) 


``diff
diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index fb52ac804849d..1d1083a5d6205 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1392,7 +1392,8 @@ class CXXRecordDecl : public RecordDecl {
   bool allowConstDefaultInit() const {
 return !data().HasUninitializedFields ||
!(data().HasDefaultedDefaultConstructor ||
- needsImplicitDefaultConstructor());
+ needsImplicitDefaultConstructor()) ||
+   hasInClassInitializer();
   }
 
   /// Determine whether this class has a destructor which has no
diff --git a/clang/test/Sema/debug-95854.cpp b/clang/test/Sema/debug-95854.cpp
new file mode 100644
index 0..1fb976558650d
--- /dev/null
+++ b/clang/test/Sema/debug-95854.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s
+//
+// expected-no-diagnostics
+
+struct A {
+  union {
+int n = 0;
+int m;
+  };
+};
+const A a;

``




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


[clang] [clang] Allow class with anonymous union member to be const-default-constructible even if a union member has a default member initializer (#95854) (PR #96301)

2024-06-21 Thread Rajveer Singh Bharadwaj via cfe-commits

Rajveer100 wrote:

@zygoloid 

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


[clang] Clang: Support minimumnum and maximumnum intrinsics (PR #96281)

2024-06-21 Thread YunQiang Su via cfe-commits


@@ -3636,6 +3648,22 @@ def Fmin : FPMathTemplate, LibBuiltin<"math.h"> {
   let OnlyBuiltinPrefixedAliasIsConstexpr = 1;
 }
 
+def FmaximumNum : FPMathTemplate, LibBuiltin<"math.h"> {

wzssyqa wrote:

Oh, newer libc does have this function: 
https://www.gnu.org/software/libc/manual/html_node/Misc-FP-Arithmetic.html

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


[clang-tools-extra] 48ef912 - [VFS] Avoid include (NFC)

2024-06-21 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2024-06-21T15:17:41+02:00
New Revision: 48ef912e2b32798b704af242e551a7090102c750

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

LOG: [VFS] Avoid  include (NFC)

Directly use a vector instead of wrapping it in a stack, like we
do in most places.

Added: 


Modified: 
clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp
clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/clangd/Selection.h
clang/lib/Sema/SemaAPINotes.cpp
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
clang/unittests/Support/TimeProfilerTest.cpp
lldb/include/lldb/Target/StackFrameRecognizer.h
llvm/include/llvm/Support/VirtualFileSystem.h
llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
llvm/lib/Support/VirtualFileSystem.cpp
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp 
b/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
index fafb029e7de1b..04ca006143503 100644
--- a/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
@@ -9,6 +9,7 @@
 #include "RedundantStrcatCallsCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include 
 
 using namespace clang::ast_matchers;
 

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp
index a64c9b2905ca1..01276af6c7d8f 100644
--- a/clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp
@@ -12,6 +12,7 @@
 #include "clang/Lex/MacroArgs.h"
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
+#include 
 
 namespace clang::tidy::bugprone {
 

diff  --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index 5bec7966a9c3a..85c80eb482efb 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

diff  --git a/clang-tools-extra/clangd/Selection.h 
b/clang-tools-extra/clangd/Selection.h
index f80ee83c4b94c..cb40c6d403487 100644
--- a/clang-tools-extra/clangd/Selection.h
+++ b/clang-tools-extra/clangd/Selection.h
@@ -45,6 +45,7 @@
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/SmallVector.h"
+#include 
 
 namespace clang {
 namespace clangd {

diff  --git a/clang/lib/Sema/SemaAPINotes.cpp b/clang/lib/Sema/SemaAPINotes.cpp
index bc1628f5b7163..d535cb35cfbc8 100644
--- a/clang/lib/Sema/SemaAPINotes.cpp
+++ b/clang/lib/Sema/SemaAPINotes.cpp
@@ -18,6 +18,7 @@
 #include "clang/Sema/SemaInternal.h"
 #include "clang/Sema/SemaObjC.h"
 #include "clang/Sema/SemaSwift.h"
+#include 
 
 using namespace clang;
 

diff  --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp 
b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index 487a3bd16b674..4ff4f7de425ca 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -59,6 +59,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 

diff  --git a/clang/unittests/Support/TimeProfilerTest.cpp 
b/clang/unittests/Support/TimeProfilerTest.cpp
index 97fdbb7232b13..5f3950ff033f1 100644
--- a/clang/unittests/Support/TimeProfilerTest.cpp
+++ b/clang/unittests/Support/TimeProfilerTest.cpp
@@ -12,6 +12,7 @@
 
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/TimeProfiler.h"
+#include 
 
 #include "gtest/gtest.h"
 

diff  --git a/lldb/include/lldb/Target/StackFrameRecognizer.h 
b/lldb/include/lldb/Target/StackFrameRecognizer.h
index 5e8e12b2a4e96..e9ac2750192ef 100644
--- a/lldb/include/lldb/Target/StackFrameRecognizer.h
+++ b/lldb/include/lldb/Target/StackFrameRecognizer.h
@@ -17,6 +17,7 @@
 #include "lldb/lldb-private-forward.h"
 #include "lldb/lldb-public.h"
 
+#include 
 #include 
 #include 
 

diff  --git a/llvm/include/llvm/Support/VirtualFileSystem.h 
b/llvm/include/llvm/Support/VirtualFileSystem.h
index a1e38de74dfcc..f7cfcd4058e72 100644
--- a/llvm/include/llvm/Support/VirtualFileSystem.h
+++ b/llvm/include/llvm/Support/VirtualFileSystem.h
@@ -31,7 +31,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -219,7 +218,7 @@ namespace detail {
 
 /// Keeps state for the recursive_directory_iter

[libunwind] [llvm] [runtimes] remove workaround for old CMake when setting `--unwindlib=none` (PR #93429)

2024-06-21 Thread Louis Dionne via cfe-commits

ldionne wrote:

I looked into it and I don't quite understand. We should definitely be building 
with `-fno-exceptions` in that configuration (and I can see that in the logs), 
so I don't understand why we have things like:

```
| ld.lld: error: undefined symbol: __cxa_begin_catch
| >>> referenced by cxa_handlers.cpp:63 
(/home/tcwg-buildbot/worker/linaro-aarch64-libcxx-02/llvm-project/libcxx-ci/build/armv7m-picolibc-no-exceptions/../../libcxxabi/src/cxa_handlers.cpp:63)
| >>>   cxa_handlers.cpp.obj:(std::__terminate(void (*)())) in 
archive 
/home/tcwg-buildbot/worker/linaro-aarch64-libcxx-02/llvm-project/libcxx-ci/build/armv7m-picolibc-no-exceptions/lib/libc++abi.a
```

There should not be references to these functions since we're building without 
exceptions.

Pinging the bot owner @mplatings 

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


[clang] [compiler-rt] [libcxx] [libunwind] [llvm] [openmp] [cmake] switch to CMake's native `check_{compiler,linker}_flag` (PR #96171)

2024-06-21 Thread Louis Dionne via cfe-commits

ldionne wrote:

Yeah I think this is a great cleanup, I think we just need to fix the CI issues.

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


[clang] 30299b8 - [CommandLine] Avoid ManagedStatic.h include (NFC)

2024-06-21 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2024-06-21T15:45:17+02:00
New Revision: 30299b87171cbad2dacb8b1ec0e75801785f16d9

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

LOG: [CommandLine] Avoid ManagedStatic.h include (NFC)

The two variables using ManagedStatic that are exported by this
header are not actually used anywhere -- they are used through
SubCommand::getTopLevel() and SubCommand::getAll() instead.
Drop the extern declarations and the include.

Added: 


Modified: 
clang/lib/Frontend/PrecompiledPreamble.cpp
lldb/utils/TableGen/LLDBTableGen.cpp
llvm/include/llvm/Support/CommandLine.h
llvm/lib/Support/CommandLine.cpp
llvm/lib/Support/RandomNumberGenerator.cpp
llvm/lib/Support/TypeSize.cpp

Removed: 




diff  --git a/clang/lib/Frontend/PrecompiledPreamble.cpp 
b/clang/lib/Frontend/PrecompiledPreamble.cpp
index fdf05c3613c95..cab5838fceb24 100644
--- a/clang/lib/Frontend/PrecompiledPreamble.cpp
+++ b/clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -28,6 +28,7 @@
 #include "llvm/Config/llvm-config.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/VirtualFileSystem.h"

diff  --git a/lldb/utils/TableGen/LLDBTableGen.cpp 
b/lldb/utils/TableGen/LLDBTableGen.cpp
index c63ca76c0d48f..bbd3f3d6c66c4 100644
--- a/lldb/utils/TableGen/LLDBTableGen.cpp
+++ b/lldb/utils/TableGen/LLDBTableGen.cpp
@@ -12,6 +12,7 @@
 
 #include "LLDBTableGenBackends.h" // Declares all backends.
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/TableGen/Error.h"

diff  --git a/llvm/include/llvm/Support/CommandLine.h 
b/llvm/include/llvm/Support/CommandLine.h
index b035209406b68..5d60bb64bbb20 100644
--- a/llvm/include/llvm/Support/CommandLine.h
+++ b/llvm/include/llvm/Support/CommandLine.h
@@ -28,7 +28,6 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/StringSaver.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -237,12 +236,6 @@ class SubCommand {
   Option *ConsumeAfterOpt = nullptr; // The ConsumeAfter option if it exists.
 };
 
-// A special subcommand representing no subcommand
-extern ManagedStatic TopLevelSubCommand;
-
-// A special subcommand that can be used to put an option into all subcommands.
-extern ManagedStatic AllSubCommands;
-
 class SubCommandGroup {
   SmallVector Subs;
 

diff  --git a/llvm/lib/Support/CommandLine.cpp 
b/llvm/lib/Support/CommandLine.cpp
index 8a00d4798f33d..6dc0c86cea894 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -455,10 +455,10 @@ void OptionCategory::registerCategory() {
 // initialization because it is referenced from cl::opt constructors, which run
 // dynamically in an arbitrary order.
 LLVM_REQUIRE_CONSTANT_INITIALIZATION
-ManagedStatic llvm::cl::TopLevelSubCommand;
+static ManagedStatic TopLevelSubCommand;
 
 // A special subcommand that can be used to put an option into all subcommands.
-ManagedStatic llvm::cl::AllSubCommands;
+static ManagedStatic AllSubCommands;
 
 SubCommand &SubCommand::getTopLevel() { return *TopLevelSubCommand; }
 

diff  --git a/llvm/lib/Support/RandomNumberGenerator.cpp 
b/llvm/lib/Support/RandomNumberGenerator.cpp
index 12fe109dbc2b5..2959fc2bfed17 100644
--- a/llvm/lib/Support/RandomNumberGenerator.cpp
+++ b/llvm/lib/Support/RandomNumberGenerator.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/raw_ostream.h"
 #ifdef _WIN32
 #include "llvm/Support/Windows/WindowsSupport.h"

diff  --git a/llvm/lib/Support/TypeSize.cpp b/llvm/lib/Support/TypeSize.cpp
index 8bed9b29cba55..43346b81cd676 100644
--- a/llvm/lib/Support/TypeSize.cpp
+++ b/llvm/lib/Support/TypeSize.cpp
@@ -8,6 +8,7 @@
 
 #include "llvm/Support/TypeSize.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/WithColor.h"
 
 #include "DebugOptions.h"



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


[clang] [clang] Lower _BitInt(129+) to a different type in LLVM IR (PR #91364)

2024-06-21 Thread Mariya Podchishchaeva via cfe-commits


@@ -2012,26 +2015,27 @@ llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address 
Addr, bool Volatile,
 }
 
 llvm::Value *CodeGenFunction::EmitToMemory(llvm::Value *Value, QualType Ty) {
-  // Bool has a different representation in memory than in registers.
-  if (hasBooleanRepresentation(Ty)) {
-// This should really always be an i1, but sometimes it's already
-// an i8, and it's awkward to track those cases down.
-if (Value->getType()->isIntegerTy(1))
-  return Builder.CreateZExt(Value, ConvertTypeForMem(Ty), "frombool");
-assert(Value->getType()->isIntegerTy(getContext().getTypeSize(Ty)) &&
-   "wrong value rep of bool");
+  if (hasBooleanRepresentation(Ty) ||
+  (Ty->isBitIntType() && Value->getType()->isIntegerTy())) {

Fznamznon wrote:

I see, fixed now.

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


[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)

2024-06-21 Thread Matt Arsenault via cfe-commits


@@ -149,6 +149,19 @@ BUILTIN(__builtin_amdgcn_mqsad_pk_u16_u8, "WUiWUiUiWUi", 
"nc")
 BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", "nc")
 
 BUILTIN(__builtin_amdgcn_make_buffer_rsrc, "Qbv*sii", "nc")
+BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_i8, "vcQbiiIi", "n")

arsenm wrote:

Plus we can always write the instcombine to fold the bitcast into the intrinsic 
signature 

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


[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce Realtime Sanitizer (RTSan) backend (PR #92460)

2024-06-21 Thread Chris Apple via cfe-commits

cjappl wrote:

Pinging reviewers, after we had more conversations on the overall structure and 
usefulness of RTSan, and it was approved. 

@zygoloid @vitalybuka @MaskRay 

Details of the aforementioned discussion are around here in the discourse 
thread:
https://discourse.llvm.org/t/rfc-nolock-and-noalloc-attributes/76837/82

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


[clang] [lld] [llvm] [RISCV] Make M imply Zmmul (PR #95070)

2024-06-21 Thread Philip Reames via cfe-commits

preames wrote:

Given the concern about breaking configurations w/no-integrated-as and older 
binutils, can someone summarize here which versions of binutils are known to 
work/not work after this change?  This will likely become the key search result 
for such breakage, and having it well documented for users seems critical.  

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


[libunwind] db8c7e0 - [libc++] Fix deployment target Lit features (#94791)

2024-06-21 Thread via cfe-commits

Author: Louis Dionne
Date: 2024-06-21T10:31:22-04:00
New Revision: db8c7e004a8acf74f40e0f7bc60066f26d43ccd9

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

LOG: [libc++] Fix deployment target Lit features (#94791)

We were not making any distinction between e.g. the "Apple-flavored"
libc++ built from trunk and the system-provided standard library on
Apple platforms. For example, any test that would be XFAILed on a
back-deployment target would unexpectedly pass when run on that
deployment target against the tip of trunk Apple-flavored libc++. In
reality, that test would be expected to pass because we're running
against the latest libc++, even if it is Apple-flavored.

To solve this issue, we introduce a new feature that describes whether
the Standard Library in use is the one provided by the system by
default, and that notion is different from the underlying standard
library flavor. We also refactor the existing Lit features to make a
distinction between availability markup and the library we're running
against at runtime, which otherwise limit the flexibility of what we can
express in the test suite. Finally, we refactor some of the
back-deployment versions that were incorrect (such as thinking that LLVM
10 was introduced in macOS 11, when in reality macOS 11 was synced with
LLVM 11).

Fixes #82107

Added: 


Modified: 
libcxx/include/__configuration/availability.h
libcxx/lib/abi/CHANGELOG.TXT
libcxx/test/configs/apple-libc++-backdeployment.cfg.in
libcxx/test/libcxx/atomics/atomics.syn/wait.pass.cpp

libcxx/test/libcxx/input.output/iostreams.base/ios.base/ios.base.cons/dtor.uninitialized.pass.cpp
libcxx/test/libcxx/language.support/cxa_deleted_virtual.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.capacity/PR53170.pass.cpp

libcxx/test/libcxx/strings/basic.string/string.capacity/allocation_size.pass.cpp

libcxx/test/libcxx/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp

libcxx/test/libcxx/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp

libcxx/test/libcxx/thread/thread.threads/thread.thread.this/sleep_for.signals.pass.cpp
libcxx/test/std/depr/depr.c.headers/stdlib_h.aligned_alloc.compile.pass.cpp

libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp

libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp

libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/refresh.pass.cpp

libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp

libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp

libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp

libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_file/copy_file.pass.cpp

libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp

libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directory/create_directory.pass.cpp

libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directory/create_directory_with_attributes.pass.cpp

libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.file_size/file_size.pass.cpp

libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp

libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.remove_all/toctou.pass.cpp

libcxx/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/bool.pass.cpp

libcxx/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/double.pass.cpp

libcxx/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/float.pass.cpp

libcxx/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/int.pass.cpp

libcxx/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long.pass.cpp

libcxx/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_double.pass.cpp

libcxx/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_long.pass.cpp

libcxx/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp

libcxx/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/short.pass.cpp

libcxx/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/u

[libcxx] [libcxxabi] [libunwind] [libc++] Fix deployment target Lit features (PR #94791)

2024-06-21 Thread Louis Dionne via cfe-commits

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


[libunwind] [llvm] [runtimes] remove workaround for old CMake when setting `--unwindlib=none` (PR #93429)

2024-06-21 Thread David Spickett via cfe-commits

DavidSpickett wrote:

Linaro will look into this.

Reproducing the build is quite easy if you do want to look yourselves in the 
meantime:
```
$ ./libcxx/utils/ci/run-buildbot 
armv7m-picolibc-no-exceptions
```
You'll need a recent `qemu-system-arm` installed to run the tests, I have 8.1.3 
locally. Picolib is downloaded and built for you by the script.

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


[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)

2024-06-21 Thread via cfe-commits


@@ -8077,32 +8077,21 @@ static bool verifyValidIntegerConstantExpr(Sema &S, 
const ParsedAttr &Attr,
 /// match one of the standard Neon vector types.
 static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr,
  Sema &S, VectorKind VecKind) {
-  bool IsTargetCUDAAndHostARM = false;
-  if (S.getLangOpts().CUDAIsDevice) {
-const TargetInfo *AuxTI = S.getASTContext().getAuxTargetInfo();
-IsTargetCUDAAndHostARM =
-AuxTI && (AuxTI->getTriple().isAArch64() || 
AuxTI->getTriple().isARM());
-  }
-
   // Target must have NEON (or MVE, whose vectors are similar enough
   // not to need a separate attribute)
-  if (!(S.Context.getTargetInfo().hasFeature("neon") ||
-S.Context.getTargetInfo().hasFeature("mve") ||
-S.Context.getTargetInfo().hasFeature("sve") ||
-S.Context.getTargetInfo().hasFeature("sme") ||
-IsTargetCUDAAndHostARM) &&
-  VecKind == VectorKind::Neon) {
-S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
-<< Attr << "'neon', 'mve', 'sve' or 'sme'";
+  if (!S.Context.getTargetInfo().hasFeature("mve") &&
+  VecKind == VectorKind::Neon &&
+  S.Context.getTargetInfo().getTriple().isArmMClass()) {
+S.Diag(Attr.getLoc(), diag::err_attribute_unsupported_m_profile)
+<< Attr << "'mve'";
 Attr.setInvalid();
 return;
   }
-  if (!(S.Context.getTargetInfo().hasFeature("neon") ||
-S.Context.getTargetInfo().hasFeature("mve") ||
-IsTargetCUDAAndHostARM) &&
-  VecKind == VectorKind::NeonPoly) {
-S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
-<< Attr << "'neon' or 'mve'";
+  if (!S.Context.getTargetInfo().hasFeature("mve") &&
+  VecKind == VectorKind::NeonPoly &&

Lukacma wrote:

No that wouldn't work as we would still get missing attribute error on aarch64 
targets, as they don't have mve enabled.

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


[clang] [clang][analyzer] Improve documentation of checker 'cplusplus.Move' (NFC) (PR #96295)

2024-06-21 Thread Balázs Kéri via cfe-commits

https://github.com/balazske updated 
https://github.com/llvm/llvm-project/pull/96295

From 0c57ad1ca36a841dff700eb98f878475e0243b88 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= 
Date: Fri, 21 Jun 2024 12:13:02 +0200
Subject: [PATCH 1/2] [clang][analyzer] Improve documentation of checker
 'cplusplus.Move' (NFC)

---
 clang/docs/analyzer/checkers.rst  | 39 +--
 .../clang/StaticAnalyzer/Checkers/Checkers.td | 21 +++---
 2 files changed, 40 insertions(+), 20 deletions(-)

diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index b8d5f372bdf61..445f434e1e6ce 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -420,21 +420,52 @@ around, such as ``std::string_view``.
 
 cplusplus.Move (C++)
 
-Method calls on a moved-from object and copying a moved-from object will be 
reported.
-
+Find use-after-move bugs in C++. This includes method calls on moved-from
+objects, assignment of a moved-from object, and repeated move of a moved-from
+object.
 
 .. code-block:: cpp
 
-  struct A {
+ struct A {
void foo() {}
  };
 
- void f() {
+ void f1() {
A a;
A b = std::move(a); // note: 'a' became 'moved-from' here
a.foo();// warn: method call on a 'moved-from' object 'a'
  }
 
+ void f2() {
+   A a;
+   A b = std::move(a);
+   A c(std::move(a)); // warn: move of an already moved-from object
+ }
+
+ void f3() {
+   A a;
+   A b = std::move(a);
+   b = a; // warn: copy of moved-from object
+ }
+
+The checker option ``WarnOn`` controls on what objects the use-after-move is
+checked. The most strict value is ``KnownsOnly``, in this mode only objects are
+checked whose type is known to be move-unsafe. These include most STL objects
+(but excluding move-safe ones) and smart pointers. With option value
+``KnownsAndLocals`` local variables (of any type) are additionally checked. The
+idea behind this is that local variables are usually not tempting to be re-used
+so an use after move is more likely a bug than with member variables. With
+option value ``All`` any use-after move condition is checked on all kinds of
+variables, excluding global variables and known move-safe cases. Default value
+is ``KnownsAndLocals``.
+
+Call of methods named ``empty()`` or ``isEmpty()`` are allowed on moved-from
+objects because these methods are considered as move-safe. Functions called
+``reset()``, ``destroy()``, ``clear()``, ``assign``, ``resize``,  ``shrink`` 
are
+treated as state-reset functions and are allowed on moved-from objects, these
+make the object valid again. This applies to any type of object (not only STL
+ones).
+
 .. _cplusplus-NewDelete:
 
 cplusplus.NewDelete (C++)
diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 429c334a0b24b..6e224a4e098ad 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -686,22 +686,11 @@ def MoveChecker: Checker<"Move">,
   CheckerOptions<[
 CmdLineOption
   ]>,

From 866655581a1e1f0779542737a3f9d427a8d067b6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= 
Date: Fri, 21 Jun 2024 16:35:09 +0200
Subject: [PATCH 2/2] using bullet point list for option values

---
 clang/docs/analyzer/checkers.rst | 26 +++---
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 445f434e1e6ce..42c097d973d53 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -449,17 +449,21 @@ object.
  }
 
 The checker option ``WarnOn`` controls on what objects the use-after-move is
-checked. The most strict value is ``KnownsOnly``, in this mode only objects are
-checked whose type is known to be move-unsafe. These include most STL objects
-(but excluding move-safe ones) and smart pointers. With option value
-``KnownsAndLocals`` local variables (of any type) are additionally checked. The
-idea behind this is that local variables are usually not tempting to be re-used
-so an use after move is more likely a bug than with member variables. With
-option value ``All`` any use-after move condition is checked on all kinds of
-variables, excluding global variables and known move-safe cases. Default value
-is ``KnownsAndLocals``.
-
-Call of methods named ``empty()`` or ``isEmpty()`` are allowed on moved-from
+checked:
+
+* The most strict value is ``KnownsOnly``, in this mode only objects are
+  checked whose type is known to be move-unsafe. These include most STL objects
+  (but excluding move-safe ones) and smart pointers.
+* With option value ``KnownsAndLocals`` local variables (of any type) are
+  additionally checked. The idea behind this is that local variables are
+  usually not tempting to be re-used so an use after move is more likely a bug
+  than with

  1   2   3   >