[clang] [Clang] Fix template arguments collection for out-of-line declarations (PR #147463)

2025-07-07 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/147463

We were using the lexical DC as the starting point of template argument 
collection when comparing declarations. This caused an issue that template 
arguments from out-of-line declarations are ignored when substituting into the 
constraints, which in turn led to expression mismatching.

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


>From 3c715992afad34fb541be5242f2583f2d223f683 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Tue, 8 Jul 2025 13:32:07 +0800
Subject: [PATCH] [Clang] Fix template arguments collection for out-of-line
 declarations

We were using the lexical DC as the starting point of template argument
collection when comparing declarations. This caused an issue that
template arguments from out-of-line declarations are ignored when
substituting into the constraints, which in turn led to expression
mismatching.
---
 clang/docs/ReleaseNotes.rst   |  1 +
 clang/lib/Sema/SemaConcept.cpp|  2 +-
 .../SemaTemplate/concepts-out-of-line-def.cpp | 25 +++
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 96477ef6ddc9a..ef1f2a7f42355 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -857,6 +857,7 @@ Bug Fixes to C++ Support
 - Clang now correctly parses arbitrary order of ``[[]]``, ``__attribute__`` 
and ``alignas`` attributes for declarations (#GH133107)
 - Fixed a crash when forming an invalid function type in a dependent context. 
(#GH138657) (#GH115725) (#GH68852)
 - Fixed a function declaration mismatch that caused inconsistencies between 
concepts and variable template declarations. (#GH139476)
+- Fixed an out-of-line declaration mismatch involving nested template 
parameters. (#GH145521)
 - Clang no longer segfaults when there is a configuration mismatch between 
modules and their users (http://crbug.com/400353616).
 - Fix an incorrect deduction when calling an explicit object member function 
template through an overload set address.
 - Fixed bug in constant evaluation that would allow using the value of a
diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 1594b4423e4d2..19d6eb1513095 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -898,7 +898,7 @@ static const Expr 
*SubstituteConstraintExpressionWithoutSatisfaction(
 Sema &S, const Sema::TemplateCompareNewDeclInfo &DeclInfo,
 const Expr *ConstrExpr) {
   MultiLevelTemplateArgumentList MLTAL = S.getTemplateInstantiationArgs(
-  DeclInfo.getDecl(), DeclInfo.getLexicalDeclContext(), /*Final=*/false,
+  DeclInfo.getDecl(), DeclInfo.getDeclContext(), /*Final=*/false,
   /*Innermost=*/std::nullopt,
   /*RelativeToPrimary=*/true,
   /*Pattern=*/nullptr, /*ForConstraintInstantiation=*/true,
diff --git a/clang/test/SemaTemplate/concepts-out-of-line-def.cpp 
b/clang/test/SemaTemplate/concepts-out-of-line-def.cpp
index bf505dec0ca14..9811b18f4301b 100644
--- a/clang/test/SemaTemplate/concepts-out-of-line-def.cpp
+++ b/clang/test/SemaTemplate/concepts-out-of-line-def.cpp
@@ -868,3 +868,28 @@ template  requires moo::baa
 void moo::caw() {}
 
 }
+
+namespace GH145521 {
+
+template 
+concept is_valid = true;
+
+template
+class Nesting
+{
+public:
+template requires is_valid
+class Inner;
+
+template requires is_valid
+friend class Inner2;
+};
+
+template
+template requires is_valid
+class Nesting::Inner {};
+
+template requires is_valid
+class Inner2 {};
+
+}

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


[clang] [llvm] [NFC][PowerPC] Add test case for lockdown of vector compare greater than support for Zero vector comparisons (PR #147246)

2025-07-07 Thread via cfe-commits

Himadhith wrote:

- The assertions for this file `clang/test/CodeGen/PowerPC/check-zero-vector.c` 
are auto-generated. 
- But for the file `llvm/test/CodeGen/PowerPC/check-zero-vectors.ll`, the 
generated assertions were very long, I have limited them to the important code 
blocks. Also changed the register numbers to regular expression, as I had 
issues of register numbers being changed over different runs.

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


[clang] [clang-tools-extra] [clang] Extend SourceLocation to 64 bits. (PR #147292)

2025-07-07 Thread Haojian Wu via cfe-commits


@@ -43,17 +46,24 @@ namespace clang {
 // Macro locations have the top bit set, we rotate by one so it is the low bit.
 class SourceLocationEncoding {
   using UIntTy = SourceLocation::UIntTy;
-  constexpr static unsigned UIntBits = CHAR_BIT * sizeof(UIntTy);
 
   static UIntTy encodeRaw(UIntTy Raw) {
-return (Raw << 1) | (Raw >> (UIntBits - 1));
+return ((Raw & llvm::maskTrailingOnes(SourceLocation::Bits - 1))
+<< 1) |
+   (Raw >> (SourceLocation::Bits - 1));
   }
   static UIntTy decodeRaw(UIntTy Raw) {
-return (Raw >> 1) | (Raw << (UIntBits - 1));
+return (Raw >> 1) | ((Raw & 1) << (SourceLocation::Bits - 1));
   }
 
 public:
   using RawLocEncoding = uint64_t;
+  // 16 bits should be sufficient to store the module file index.
+  constexpr static unsigned ModuleFileIndexBits = 16;

hokein wrote:

This reflects the "only the lower 16 bits of A are used to store the module 
file index" comment.

I’m fine with using 20 bits for the module file index (which would still leave 
us with 4 spare bits that could potentially be used for the offset). However, 
I’d prefer to make that change in a follow-up patch to keep this one as minimal 
as possible.


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


[clang] [clang] Improve constexpr-unknown diagnostics. (PR #146288)

2025-07-07 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `fuchsia-x86_64-linux` 
running on `fuchsia-debian-64-us-central1-a-1` while building `clang` at step 4 
"annotate".

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


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

```
Step 4 (annotate) failure: 'python 
../llvm-zorg/zorg/buildbot/builders/annotated/fuchsia-linux.py ...' (failure)
...
[247/2515] Building CXX object 
libc/src/strings/CMakeFiles/libc.src.strings.strncasecmp.dir/strncasecmp.cpp.obj
[248/2515] Generating header complex.h from 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/runtimes/../libc/include/complex.yaml
[249/2515] Generating header fenv.h from 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/runtimes/../libc/include/fenv.yaml
[250/2515] Generating header ctype.h from 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/runtimes/../libc/include/ctype.yaml
[251/2515] Building CXX object 
libc/src/string/CMakeFiles/libc.src.string.strstr.dir/strstr.cpp.obj
[252/2515] Building CXX object 
libc/src/compiler/generic/CMakeFiles/libc.src.compiler.generic.__stack_chk_fail.dir/__stack_chk_fail.cpp.obj
[253/2515] Building CXX object 
libc/src/errno/CMakeFiles/libc.src.errno.errno.dir/libc_errno.cpp.obj
[254/2515] Generating header wchar.h from 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/runtimes/../libc/include/wchar.yaml
[255/2515] Building CXX object 
libc/src/string/CMakeFiles/libc.src.string.strcasestr.dir/strcasestr.cpp.obj
[256/2515] Building CXX object 
libc/src/strings/CMakeFiles/libc.src.strings.bcopy.dir/bcopy.cpp.obj
FAILED: libc/src/strings/CMakeFiles/libc.src.strings.bcopy.dir/bcopy.cpp.obj 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-k3zfrmw4/./bin/clang++ 
--target=armv7em-none-eabi -DLIBC_NAMESPACE=__llvm_libc_21_0_0_git 
-I/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc -isystem 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-k3zfrmw4/include/armv7em-unknown-none-eabi
 --target=armv7em-none-eabi -Wno-atomic-alignment "-Dvfprintf(stream, format, 
vlist)=vprintf(format, vlist)" "-Dfprintf(stream, format, ...)=printf(format)" 
-D_LIBCPP_PRINT=1 -mthumb -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -ffunction-sections 
-fdata-sections 
-ffile-prefix-map=/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-k3zfrmw4/runtimes/runtimes-armv7em-none-eabi-bins=../../../../llvm-project
 -ffile-prefix-map=/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/= 
-no-canonical-prefixes -Os -DNDEBUG --target=armv7em-none-eabi 
-DLIBC_QSORT_IMPL=LIBC_QSORT_HEAP_SORT -DLIBC_TYPES_TIME_T_IS_32_BIT 
-DLIBC_ADD_NULL_CHECKS "-DLIBC_MATH=(LIBC_MATH_SKIP_ACCURATE_PASS | 
LIBC_MATH_SMALL_TABLES)" -DLIBC_ERRNO_MODE=LIBC_ERRNO_MODE_EXTERNAL -fpie 
-ffreestanding -DLIBC_FULL_BUILD -nostdlibinc -ffixed-point -fno-builtin 
-fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables 
-fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern 
-fno-omit-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion 
-Wdeprecated -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic 
-Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof 
-Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety 
-Wglobal-constructors -DLIBC_COPT_PUBLIC_PACKAGING -MD -MT 
libc/src/strings/CMakeFiles/libc.src.strings.bcopy.dir/bcopy.cpp.obj -MF 
libc/src/strings/CMakeFiles/libc.src.strings.bcopy.dir/bcopy.cpp.obj.d -o 
libc/src/strings/CMakeFiles/libc.src.strings.bcopy.dir/bcopy.cpp.obj -c 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/strings/bcopy.cpp
In file included from 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/strings/bcopy.cpp:12:
In file included from 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/string/memory_utils/inline_memmove.h:38:
In file included from 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/string/memory_utils/generic/byte_per_byte.h:17:
In file included from 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/string/memory_utils/utils.h:15:
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:43:13:
 error: unknown type name 'uint8_t'
   43 | LIBC_INLINE uint8_t
  | ^
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:44:48:
 error: use of undeclared identifier 'uint8_t'
   44 | Endian<__ORDER_LITTLE_ENDIAN__>::to_big_endian(uint8_t v) {
  |^~~
/var/l

[clang] [clang-tools-extra] [clang] Extend SourceLocation to 64 bits. (PR #147292)

2025-07-07 Thread Chuanqi Xu via cfe-commits


@@ -43,17 +46,24 @@ namespace clang {
 // Macro locations have the top bit set, we rotate by one so it is the low bit.
 class SourceLocationEncoding {
   using UIntTy = SourceLocation::UIntTy;
-  constexpr static unsigned UIntBits = CHAR_BIT * sizeof(UIntTy);
 
   static UIntTy encodeRaw(UIntTy Raw) {
-return (Raw << 1) | (Raw >> (UIntBits - 1));
+return ((Raw & llvm::maskTrailingOnes(SourceLocation::Bits - 1))
+<< 1) |
+   (Raw >> (SourceLocation::Bits - 1));
   }
   static UIntTy decodeRaw(UIntTy Raw) {
-return (Raw >> 1) | (Raw << (UIntBits - 1));
+return (Raw >> 1) | ((Raw & 1) << (SourceLocation::Bits - 1));
   }
 
 public:
   using RawLocEncoding = uint64_t;
+  // 16 bits should be sufficient to store the module file index.
+  constexpr static unsigned ModuleFileIndexBits = 16;

ChuanqiXu9 wrote:

SGTM

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


[clang] [RISCV] Correct type lowering of struct of fixed-vector array in VLS (PR #147173)

2025-07-07 Thread Craig Topper via cfe-commits

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

LGTM

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


[clang] 4c98da2 - [clang][bytecode] Create a temporary for discarded CXXBindTemporaryExprs (#147303)

2025-07-07 Thread via cfe-commits

Author: Timm Baeder
Date: 2025-07-08T06:00:52+02:00
New Revision: 4c98da2cadfb23f6d4070db9136d8dc0a379bcc1

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

LOG: [clang][bytecode] Create a temporary for discarded CXXBindTemporaryExprs 
(#147303)

So we run the destructor.

Added: 


Modified: 
clang/lib/AST/ByteCode/Compiler.cpp
clang/lib/AST/ByteCode/Context.cpp
clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index d1c93e4694667..51c234d0d0471 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -2886,7 +2886,20 @@ bool Compiler::VisitMaterializeTemporaryExpr(
 template 
 bool Compiler::VisitCXXBindTemporaryExpr(
 const CXXBindTemporaryExpr *E) {
-  return this->delegate(E->getSubExpr());
+  const Expr *SubExpr = E->getSubExpr();
+
+  if (Initializing)
+return this->delegate(SubExpr);
+
+  // Make sure we create a temporary even if we're discarding, since that will
+  // make sure we will also call the destructor.
+
+  if (!this->visit(SubExpr))
+return false;
+
+  if (DiscardResult)
+return this->emitPopPtr(E);
+  return true;
 }
 
 template 

diff  --git a/clang/lib/AST/ByteCode/Context.cpp 
b/clang/lib/AST/ByteCode/Context.cpp
index 971eb7fd58876..a629ff9569428 100644
--- a/clang/lib/AST/ByteCode/Context.cpp
+++ b/clang/lib/AST/ByteCode/Context.cpp
@@ -67,7 +67,8 @@ bool Context::evaluateAsRValue(State &Parent, const Expr *E, 
APValue &Result) {
   }
 
   if (!Recursing) {
-assert(Stk.empty());
+// We *can* actually get here with a non-empty stack, since
+// things like InterpState::noteSideEffect() exist.
 C.cleanup();
 #ifndef NDEBUG
 // Make sure we don't rely on some value being still alive in

diff  --git a/clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp 
b/clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp
index c5d5427170394..86bed5f14441e 100644
--- a/clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp
+++ b/clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp
@@ -3,6 +3,11 @@
 // RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s "-DNEW=::operator new" 
"-DDELETE=::operator delete"
 // RUN: %clang_cc1 -std=c++2c -verify=expected,cxx26 %s "-DNEW=::operator new" 
"-DDELETE=::operator delete"
 
+// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s 
-DNEW=__builtin_operator_new -DDELETE=__builtin_operator_delete
+// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s "-DNEW=operator new" 
"-DDELETE=operator delete"
+// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s "-DNEW=::operator new" 
"-DDELETE=::operator delete"
+// RUN: %clang_cc1 -std=c++2c -verify=expected,cxx26 %s "-DNEW=::operator new" 
"-DDELETE=::operator delete"
+
 constexpr bool alloc_from_user_code() {
   void *p = NEW(sizeof(int)); // expected-note {{cannot allocate untyped 
memory in a constant expression; use 'std::allocator::allocate'}}
   DELETE(p);



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


[clang] [clang][bytecode] Create a temporary for discarded CXXBindTemporaryExprs (PR #147303)

2025-07-07 Thread Timm Baeder via cfe-commits

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


[clang] [libcxx] [clang] Fix -Wuninitialized for values passed by const pointers (PR #147221)

2025-07-07 Thread Igor Kudrin via cfe-commits

https://github.com/igorkudrin updated 
https://github.com/llvm/llvm-project/pull/147221

>From f1e26fed6c5023ba59990112ec4a77b024247e4b Mon Sep 17 00:00:00 2001
From: Igor Kudrin 
Date: Fri, 4 Jul 2025 23:55:41 -0700
Subject: [PATCH 1/3] [clang] Fix -Wuninitialized for values passed by const
 pointers

This enables producing a "variable is uninitialized" warning when a
value is passed to a pointer-to-const argument:

```
void foo(const int *);
void test() {
  int *v;
  foo(v);
}
```

Fixes #37460
---
 clang/lib/Analysis/UninitializedValues.cpp | 13 +
 clang/test/SemaCXX/uninitialized.cpp   |  8 ++--
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/clang/lib/Analysis/UninitializedValues.cpp 
b/clang/lib/Analysis/UninitializedValues.cpp
index b2a68b6c39a7e..540838f89f20c 100644
--- a/clang/lib/Analysis/UninitializedValues.cpp
+++ b/clang/lib/Analysis/UninitializedValues.cpp
@@ -438,13 +438,10 @@ void ClassifyRefs::VisitCallExpr(CallExpr *CE) {
 return;
   }
   bool isTrivialBody = hasTrivialBody(CE);
-  // If a value is passed by const pointer to a function,
-  // we should not assume that it is initialized by the call, and we
-  // conservatively do not assume that it is used.
-  // If a value is passed by const reference to a function,
-  // it should already be initialized.
-  for (CallExpr::arg_iterator I = CE->arg_begin(), E = CE->arg_end();
-   I != E; ++I) {
+  // A value passed by const pointer or reference to a function should already
+  // be initialized.
+  for (CallExpr::arg_iterator I = CE->arg_begin(), E = CE->arg_end(); I != E;
+   ++I) {
 if ((*I)->isGLValue()) {
   if ((*I)->getType().isConstQualified())
 classify((*I), isTrivialBody ? Ignore : ConstRefUse);
@@ -453,7 +450,7 @@ void ClassifyRefs::VisitCallExpr(CallExpr *CE) {
   const auto *UO = dyn_cast(Ex);
   if (UO && UO->getOpcode() == UO_AddrOf)
 Ex = UO->getSubExpr();
-  classify(Ex, Ignore);
+  classify(Ex, Use);
 }
   }
 }
diff --git a/clang/test/SemaCXX/uninitialized.cpp 
b/clang/test/SemaCXX/uninitialized.cpp
index c7b987e2172e6..4a944ba830bc3 100644
--- a/clang/test/SemaCXX/uninitialized.cpp
+++ b/clang/test/SemaCXX/uninitialized.cpp
@@ -162,12 +162,16 @@ void test_const_ptr() {
   int a;
   int b;  // expected-note {{initialize the variable 'b' to silence this 
warning}}
   foo(&a);
-  bar(&b);
-  b = a + b; // expected-warning {{variable 'b' is uninitialized when used 
here}}
+  bar(&b); // expected-warning {{variable 'b' is uninitialized when used here}}
+  b = a + b;
   int *ptr;  //expected-note {{initialize the variable 'ptr' to silence this 
warning}}
   const int *ptr2;
   foo(ptr); // expected-warning {{variable 'ptr' is uninitialized when used 
here}}
   foobar(&ptr2);
+  int *ptr3; // expected-note {{initialize the variable 'ptr3' to silence this 
warning}}
+  const int *ptr4; // expected-note {{initialize the variable 'ptr4' to 
silence this warning}}
+  bar(ptr3); // expected-warning {{variable 'ptr3' is uninitialized when used 
here}}
+  bar(ptr4); // expected-warning {{variable 'ptr4' is uninitialized when used 
here}}
 }
 }
 

>From d63b5dc783cfb9388515c3c9e7a736005e289b34 Mon Sep 17 00:00:00 2001
From: Igor Kudrin 
Date: Sun, 6 Jul 2025 18:41:48 -0700
Subject: [PATCH 2/3] fixup! libcxx tests

---
 .../ostream.inserters.arithmetic/pointer.pass.cpp | 4 ++--
 .../ostream.inserters.arithmetic/pointer.volatile.pass.cpp| 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git 
a/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp
 
b/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp
index 61fd0a804ecd3..f15f1b96b4b27 100644
--- 
a/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp
+++ 
b/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp
@@ -62,14 +62,14 @@ int main(int, char**)
 {
 testbuf sb1;
 std::ostream os1(&sb1);
-int n1;
+int n1 = 0;
 os1 << &n1;
 assert(os1.good());
 std::string s1(sb1.str());
 
 testbuf sb2;
 std::ostream os2(&sb2);
-int n2;
+int n2 = 0;
 os2 << &n2;
 assert(os2.good());
 std::string s2(sb2.str());
diff --git 
a/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.volatile.pass.cpp
 
b/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.volatile.pass.cpp
index 69d84f640d54e..6a1cde15a69bd 100644
--- 
a/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.volatile.pass.cpp
+++ 
b/libcxx/te

[libclc] [libclc] Declare workitem built-ins in clc, move ptx-nvidiacl workitem built-ins into clc (PR #144333)

2025-07-07 Thread Matt Arsenault via cfe-commits


@@ -0,0 +1,22 @@
+//===--===//
+//
+// 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 
+
+_CLC_DEF _CLC_OVERLOAD size_t __clc_get_global_size(uint dim) {
+  switch (dim) {
+  case 0:
+return __builtin_amdgcn_grid_size_x();
+  case 1:
+return __builtin_amdgcn_grid_size_y();
+  case 2:
+return __builtin_amdgcn_grid_size_z();
+  default:
+return 1;

arsenm wrote:

Ok, that's the spec then and it should follow 

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


[clang] [NFC] [C++] [Modules] Mark P2788 as implemented and add test (PR #147138)

2025-07-07 Thread Chuanqi Xu via cfe-commits

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


[clang] [llvm] [AMDGPU] Add support for `v_tanh_bf16` on gfx1250 (PR #147425)

2025-07-07 Thread Matt Arsenault via cfe-commits


@@ -13658,6 +13658,7 @@ bool SITargetLowering::isCanonicalized(Register Reg, 
const MachineFunction &MF,
 case Intrinsic::amdgcn_frexp_mant:
 case Intrinsic::amdgcn_fdot2:
 case Intrinsic::amdgcn_trig_preop:
+case Intrinsic::amdgcn_tanh:

arsenm wrote:

I don't follow, this shouldn't be hard to test? e.g. 
fcanonicalize-elimination.ll, you should just need a canonicalize call after 
these which should fold out 

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


[clang] 84be785 - [NFC] [C++] [Modules] Mark P1811 as implemented and add test (#146993)

2025-07-07 Thread via cfe-commits

Author: Ashwin Kishin Banwari
Date: 2025-07-08T09:54:33+08:00
New Revision: 84be78524de7d06943570854cbf31537c8f45199

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

LOG: [NFC] [C++] [Modules] Mark P1811 as implemented and add test (#146993)

This is already implemented. See godbolt:
https://godbolt.org/z/7x3arqj3G

Added: 
clang/test/SemaCXX/P1811.cpp

Modified: 
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/test/SemaCXX/P1811.cpp b/clang/test/SemaCXX/P1811.cpp
new file mode 100644
index 0..329110a2ce4dd
--- /dev/null
+++ b/clang/test/SemaCXX/P1811.cpp
@@ -0,0 +1,41 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+
+// RUN: %clang_cc1 -std=c++20 -verify -emit-module-interface %t/mod.cpp -o 
%t/mod.pcm
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify -fmodule-file=M=%t/mod.pcm 
%t/main1.cpp
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify -fmodule-file=M=%t/mod.pcm 
%t/main2.cpp
+
+//--- mod.cpp
+// expected-no-diagnostics
+module;
+#include "A.h"
+export module M;
+export A f() {return A{};}
+
+//--- A.h
+// expected-no-diagnostics
+#ifndef X
+#define X
+
+struct A{};
+
+#endif
+
+//--- main1.cpp
+// expected-no-diagnostics
+#include "A.h"
+import M;
+
+extern "C++" int main() {
+  A a;
+}
+
+//--- main2.cpp
+// expected-no-diagnostics
+import M;
+#include "A.h"
+
+extern "C++" int main() {
+  A a;
+}

diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 831f79f7cf17a..4b149db9ecdf1 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -911,7 +911,7 @@ C++20 implementation status
   
   
 https://wg21.link/p1811r0";>P1811R0
-No
+Clang 17
   
   
 https://wg21.link/p1703r1";>P1703R1



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


[clang] [NFC] [C++] [Modules] Mark P1811 as implemented and add test (PR #146993)

2025-07-07 Thread Chuanqi Xu via cfe-commits

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


[clang] [clang-tools-extra] [clang] Extend SourceLocation to 64 bits. (PR #147292)

2025-07-07 Thread Chuanqi Xu via cfe-commits

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


[clang] [Clang][Sema] Avoid duplicate diagnostics for incomplete types in nested name specifier (C++20+) (PR #147036)

2025-07-07 Thread Shafik Yaghmour via cfe-commits

shafik wrote:

> Why doesn't C++20 below suffer from the issue?
> 
> I think it's a waste to add a Sema scope object just for diagnostic issues. 
> It's more like that there's an underlying issue that would be otherwise 
> hidden by the patch. Can you explore?

Thank you for this PR but I agree this does not sound like the right approach 
and it looks like we have another candidate path in the pipeline already.

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


[clang] e427bd5 - [NFC] [C++] [Modules] Mark P2615 as implemented and add test (#147135)

2025-07-07 Thread via cfe-commits

Author: Ashwin Kishin Banwari
Date: 2025-07-08T10:00:55+08:00
New Revision: e427bd55a852eff2b7fed97941642be121557dca

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

LOG: [NFC] [C++] [Modules] Mark P2615 as implemented and add test (#147135)

This is already implemented. See godbolt:
https://godbolt.org/z/1ra4Ka8od

Added: 
clang/test/SemaCXX/P2615.cpp

Modified: 
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/test/SemaCXX/P2615.cpp b/clang/test/SemaCXX/P2615.cpp
new file mode 100644
index 0..fed177c21bc79
--- /dev/null
+++ b/clang/test/SemaCXX/P2615.cpp
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+
+// RUN: %clang_cc1 -std=c++20 -verify -fsyntax-only %t/A.cpp
+
+//--- A.cpp
+// expected-no-diagnostics
+export module A;
+export namespace N {int x = 42;}
+export using namespace N;

diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 4b149db9ecdf1..bd25862f8d277 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -943,7 +943,7 @@ C++20 implementation status
   

 https://wg21.link/P2615R1";>P2615R1 (DR)
-No
+Clang 17
   

 https://wg21.link/P2788R0";>P2788R0 (DR)



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


[clang] [NFC] [C++] [Modules] Mark P2615 as implemented and add test (PR #147135)

2025-07-07 Thread Chuanqi Xu via cfe-commits

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


[clang] 48ff068 - [NFC] [C++] [Modules] Mark P2788 as implemented and add test (#147138)

2025-07-07 Thread via cfe-commits

Author: Ashwin Kishin Banwari
Date: 2025-07-08T10:01:08+08:00
New Revision: 48ff068c525922e8323982795c69bbfbe49fea1e

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

LOG: [NFC] [C++] [Modules] Mark P2788 as implemented and add test (#147138)

This is already implemented.

Added: 
clang/test/SemaCXX/P2788.cpp

Modified: 
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/test/SemaCXX/P2788.cpp b/clang/test/SemaCXX/P2788.cpp
new file mode 100644
index 0..a9184e1521e8e
--- /dev/null
+++ b/clang/test/SemaCXX/P2788.cpp
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+
+// RUN: %clang_cc1 -std=c++20 -verify -emit-module-interface %t/B.cpp -o 
%t/B.pcm
+// RUN: %clang_cc1 -std=c++20 -verify -emit-module-interface %t/A.cpp 
-fmodule-file=A:B=%t/B.pcm -o %t/A.pcm
+
+//--- A.cpp
+// expected-no-diagnostics
+export module A;
+import :B;
+export int x = dimensions + 1;
+
+//--- B.cpp
+// expected-no-diagnostics
+export module A:B;
+const int dimensions=3;

diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index bd25862f8d277..56b6dd06a57f8 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -947,7 +947,7 @@ C++20 implementation status
   

 https://wg21.link/P2788R0";>P2788R0 (DR)
-No
+Clang 17
   
 
   Coroutines



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


[clang] [LifetimeSafety] Introduce intra-procedural analysis in Clang (PR #142313)

2025-07-07 Thread Utkarsh Saxena via cfe-commits

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


[clang-tools-extra] [clang-tidy] Make `bugprone-unhandled-self-assignment` check more general (PR #147066)

2025-07-07 Thread Andrey Karlov via cfe-commits

https://github.com/negativ updated 
https://github.com/llvm/llvm-project/pull/147066

>From 950b6dce92eb2a831e7bd7e7ba44b3e8cc354dd4 Mon Sep 17 00:00:00 2001
From: Andrey Karlov 
Date: Fri, 4 Jul 2025 17:13:20 +0300
Subject: [PATCH 1/5] Checking that some kind of constructor is called and
 followed by a `swap`

---
 .../bugprone/UnhandledSelfAssignmentCheck.cpp | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git 
a/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
index 1f432c4ccc5f0..8307e744a434c 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
@@ -68,7 +68,23 @@ void 
UnhandledSelfAssignmentCheck::registerMatchers(MatchFinder *Finder) {
   const auto HasNoNestedSelfAssign =
   
cxxMethodDecl(unless(hasDescendant(cxxMemberCallExpr(callee(cxxMethodDecl(
   hasName("operator="), ofClass(equalsBoundNode("class";
-
+  
+  // Checking that some kind of constructor is called and followed by a `swap`:
+  // T& operator=(const T& other) {
+  //T tmp{this->internal_data(), some, other, args};
+  //swap(tmp);
+  //return *this;
+  // }
+  const auto HasCopyAndSwap = cxxMethodDecl(
+  ofClass(cxxRecordDecl(unless(hasAncestor(classTemplateDecl(),
+  hasDescendant(
+  stmt(hasDescendant(
+   varDecl(hasType(cxxRecordDecl(equalsBoundNode("class"
+   .bind("tmp_var")),
+   hasDescendant(callExpr(callee(functionDecl(hasName("swap"))),
+  hasAnyArgument(declRefExpr(to(varDecl(
+  equalsBoundNode("tmp_var"));
+
   DeclarationMatcher AdditionalMatcher = cxxMethodDecl();
   if (WarnOnlyIfThisHasSuspiciousField) {
 // Matcher for standard smart pointers.
@@ -94,6 +110,7 @@ void 
UnhandledSelfAssignmentCheck::registerMatchers(MatchFinder *Finder) {
HasReferenceParam, HasNoSelfCheck,
unless(HasNonTemplateSelfCopy),
unless(HasTemplateSelfCopy),
+   unless(HasCopyAndSwap),
HasNoNestedSelfAssign, AdditionalMatcher)
  .bind("copyAssignmentOperator"),
  this);

>From 0cd33ec49693cfc6f5a72b72a9c50ba868634221 Mon Sep 17 00:00:00 2001
From: Andrey Karlov 
Date: Fri, 4 Jul 2025 17:19:02 +0300
Subject: [PATCH 2/5] Tests

---
 .../bugprone/unhandled-self-assignment.cpp| 90 +++
 1 file changed, 90 insertions(+)

diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-self-assignment.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-self-assignment.cpp
index 8610393449f97..f2f61062f883f 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-self-assignment.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-self-assignment.cpp
@@ -28,6 +28,13 @@ template 
 class auto_ptr {
 };
 
+namespace pmr {
+template 
+class allocator {};
+}
+
+struct allocator_arg_t {} allocator_arg;
+
 } // namespace std
 
 void assert(int expression){};
@@ -540,6 +547,89 @@ class NotACopyAssignmentOperator {
   Uy *getUy() const { return Ptr2; }
 };
 
+// Support "extended" copy/move constructors
+class AllocatorAwareClass {
+  // pointer member to trigger bugprone-unhandled-self-assignment
+  void *foo = nullptr;
+
+  public:
+using allocator_type = std::pmr::allocator<>;
+
+AllocatorAwareClass(const AllocatorAwareClass& other) {
+}
+
+AllocatorAwareClass(const AllocatorAwareClass& other, const 
allocator_type& alloc) {
+}
+
+AllocatorAwareClass& operator=(const AllocatorAwareClass& other) {
+AllocatorAwareClass tmp(other, get_allocator());
+swap(tmp);
+return *this;
+}
+
+void swap(AllocatorAwareClass& other) noexcept {
+}
+
+allocator_type get_allocator() const {
+return allocator_type();
+}
+};
+
+// Support "extended" copy/move constructors + std::swap
+class AllocatorAwareClassStdSwap {
+  // pointer member to trigger bugprone-unhandled-self-assignment
+  void *foo = nullptr;
+
+  public:
+using allocator_type = std::pmr::allocator<>;
+
+AllocatorAwareClassStdSwap(const AllocatorAwareClassStdSwap& other) {
+}
+
+AllocatorAwareClassStdSwap(const AllocatorAwareClassStdSwap& other, const 
allocator_type& alloc) {
+}
+
+AllocatorAwareClassStdSwap& operator=(const AllocatorAwareClassStdSwap& 
other) {
+using std::swap;
+
+AllocatorAwareClassStdSwap tmp(other, get_allocator());
+swap(*this, tmp);
+return *this;
+}
+
+allocator_type get_allocator() const {
+re

[libclc] [NFC][libclc] Fix typo in OpenCL header math/sincos.h (PR #147244)

2025-07-07 Thread Tim Gymnich via cfe-commits

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


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


[clang] [llvm] [HIPSTDPAR] Add support for globals (PR #146813)

2025-07-07 Thread Juan Manuel Martinez Caamaño via cfe-commits


@@ -114,24 +115,221 @@ static inline void clearModule(Module &M) { // TODO: 
simplify.
 eraseFromModule(*M.ifuncs().begin());
 }
 
+static inline SmallVector>
+collectIndirectableUses(GlobalVariable *G) {
+  // We are interested only in use chains that end in an Instruction.
+  SmallVector> Uses;
+
+  SmallVector> Tmp(G->use_begin(), G->use_end());
+  while (!Tmp.empty()) {
+Use &U = Tmp.back();
+Tmp.pop_back();
+if (isa(U.getUser()))
+  Uses.emplace_back(U);
+else
+  transform(U.getUser()->uses(), std::back_inserter(Tmp),
+[](auto &&U) { return std::ref(U); });
+  }
+
+  return Uses;
+}
+
+static inline GlobalVariable *getGlobalForName(GlobalVariable *G) {
+  // Create an anonymous global which stores the variable's name, which will be
+  // used by the HIPSTDPAR runtime to look up the program-wide symbol.
+  LLVMContext &Ctx = G->getContext();
+  auto *CDS = ConstantDataArray::getString(Ctx, G->getName());
+
+  GlobalVariable *N = G->getParent()->getOrInsertGlobal("", CDS->getType());
+  N->setInitializer(CDS);
+  N->setLinkage(GlobalValue::LinkageTypes::PrivateLinkage);
+  N->setConstant(true);
+
+  return N;
+}
+
+static inline GlobalVariable *getIndirectionGlobal(Module *M) {
+  // Create an anonymous global which stores a pointer to a pointer, which will
+  // be externally initialised by the HIPSTDPAR runtime with the address of the
+  // program-wide symbol.
+  Type *PtrTy = PointerType::get(
+  M->getContext(), M->getDataLayout().getDefaultGlobalsAddressSpace());
+  GlobalVariable *NewG = M->getOrInsertGlobal("", PtrTy);
+
+  NewG->setInitializer(PoisonValue::get(NewG->getValueType()));
+  NewG->setLinkage(GlobalValue::LinkageTypes::PrivateLinkage);
+  NewG->setConstant(true);
+  NewG->setExternallyInitialized(true);
+
+  return NewG;
+}
+
+static inline Constant *
+appendIndirectedGlobal(const GlobalVariable *IndirectionTable,
+   SmallVector &SymbolIndirections,
+   GlobalVariable *ToIndirect) {
+  Module *M = ToIndirect->getParent();
+
+  auto *InitTy = cast(IndirectionTable->getValueType());
+  auto *SymbolListTy = cast(InitTy->getStructElementType(2));
+  Type *NameTy = SymbolListTy->getElementType(0);
+  Type *IndirectTy = SymbolListTy->getElementType(1);
+
+  Constant *NameG = getGlobalForName(ToIndirect);
+  Constant *IndirectG = getIndirectionGlobal(M);
+  Constant *Entry = ConstantStruct::get(
+  SymbolListTy, {ConstantExpr::getAddrSpaceCast(NameG, NameTy),
+ ConstantExpr::getAddrSpaceCast(IndirectG, IndirectTy)});
+  SymbolIndirections.push_back(Entry);
+
+  return IndirectG;
+}
+
+static void fillIndirectionTable(GlobalVariable *IndirectionTable,
+ SmallVector Indirections) {
+  Module *M = IndirectionTable->getParent();
+  size_t SymCnt = Indirections.size();
+
+  auto *InitTy = cast(IndirectionTable->getValueType());
+  Type *SymbolListTy = InitTy->getStructElementType(1);
+  auto *SymbolTy = cast(InitTy->getStructElementType(2));
+
+  Constant *Count = ConstantInt::get(InitTy->getStructElementType(0), SymCnt);
+  M->removeGlobalVariable(IndirectionTable);
+  GlobalVariable *Symbols =
+  M->getOrInsertGlobal("", ArrayType::get(SymbolTy, SymCnt));
+  Symbols->setLinkage(GlobalValue::LinkageTypes::PrivateLinkage);
+  Symbols->setInitializer(
+  ConstantArray::get(ArrayType::get(SymbolTy, SymCnt), {Indirections}));
+  Symbols->setConstant(true);
+
+  Constant *ASCSymbols = ConstantExpr::getAddrSpaceCast(Symbols, SymbolListTy);
+  Constant *Init = ConstantStruct::get(
+  InitTy, {Count, ASCSymbols, PoisonValue::get(SymbolTy)});
+  M->insertGlobalVariable(IndirectionTable);
+  IndirectionTable->setInitializer(Init);
+}
+
+static void replaceWithIndirectUse(const Use &U, const GlobalVariable *G,
+   Constant *IndirectedG) {
+  auto *I = cast(U.getUser());
+
+  IRBuilder<> Builder(I);
+  Value *Op = I->getOperand(U.getOperandNo());
+
+  // We walk back up the use chain, which could be an arbitrarily long sequence
+  // of constexpr AS casts, ptr-to-int and GEP instructions, until we reach the
+  // indirected global.
+  while (auto *CE = dyn_cast(Op)) {
+assert((CE->getOpcode() == Instruction::GetElementPtr ||
+CE->getOpcode() == Instruction::AddrSpaceCast ||
+CE->getOpcode() == Instruction::PtrToInt) &&
+   "Only GEP, ASCAST or PTRTOINT constant uses supported!");
+
+Instruction *NewI = Builder.Insert(CE->getAsInstruction());
+I->replaceUsesOfWith(Op, NewI);
+I = NewI;
+Op = I->getOperand(0);
+Builder.SetInsertPoint(I);
+  }
+
+  assert(Op == G && "Must reach indirected global!");
+
+  Builder.GetInsertPoint()->setOperand(
+  0, Builder.CreateLoad(G->getType(), IndirectedG));
+}
+
+static inline bool isValidIndirectionTable(GlobalVariable *IndirectionTable) {
+  std::string W;
+  raw_string_ostream OS(W);
+
+  Type *Ty = Indirec

[clang] [llvm] [HIPSTDPAR] Add support for globals (PR #146813)

2025-07-07 Thread Juan Manuel Martinez Caamaño via cfe-commits


@@ -114,24 +115,221 @@ static inline void clearModule(Module &M) { // TODO: 
simplify.
 eraseFromModule(*M.ifuncs().begin());
 }
 
+static inline SmallVector>
+collectIndirectableUses(GlobalVariable *G) {
+  // We are interested only in use chains that end in an Instruction.
+  SmallVector> Uses;
+
+  SmallVector> Tmp(G->use_begin(), G->use_end());
+  while (!Tmp.empty()) {
+Use &U = Tmp.back();
+Tmp.pop_back();

jmmartinez wrote:

```suggestion
Use &U = Tmp.pop_back_val();
```

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


[clang] [llvm] [HIPSTDPAR] Add support for globals (PR #146813)

2025-07-07 Thread Juan Manuel Martinez Caamaño via cfe-commits


@@ -114,24 +115,221 @@ static inline void clearModule(Module &M) { // TODO: 
simplify.
 eraseFromModule(*M.ifuncs().begin());
 }
 
+static inline SmallVector>
+collectIndirectableUses(GlobalVariable *G) {
+  // We are interested only in use chains that end in an Instruction.
+  SmallVector> Uses;
+
+  SmallVector> Tmp(G->use_begin(), G->use_end());
+  while (!Tmp.empty()) {
+Use &U = Tmp.back();
+Tmp.pop_back();
+if (isa(U.getUser()))
+  Uses.emplace_back(U);
+else
+  transform(U.getUser()->uses(), std::back_inserter(Tmp),
+[](auto &&U) { return std::ref(U); });
+  }
+
+  return Uses;
+}
+
+static inline GlobalVariable *getGlobalForName(GlobalVariable *G) {
+  // Create an anonymous global which stores the variable's name, which will be
+  // used by the HIPSTDPAR runtime to look up the program-wide symbol.
+  LLVMContext &Ctx = G->getContext();
+  auto *CDS = ConstantDataArray::getString(Ctx, G->getName());
+
+  GlobalVariable *N = G->getParent()->getOrInsertGlobal("", CDS->getType());
+  N->setInitializer(CDS);
+  N->setLinkage(GlobalValue::LinkageTypes::PrivateLinkage);
+  N->setConstant(true);
+
+  return N;
+}
+
+static inline GlobalVariable *getIndirectionGlobal(Module *M) {
+  // Create an anonymous global which stores a pointer to a pointer, which will
+  // be externally initialised by the HIPSTDPAR runtime with the address of the
+  // program-wide symbol.
+  Type *PtrTy = PointerType::get(
+  M->getContext(), M->getDataLayout().getDefaultGlobalsAddressSpace());
+  GlobalVariable *NewG = M->getOrInsertGlobal("", PtrTy);
+
+  NewG->setInitializer(PoisonValue::get(NewG->getValueType()));
+  NewG->setLinkage(GlobalValue::LinkageTypes::PrivateLinkage);
+  NewG->setConstant(true);
+  NewG->setExternallyInitialized(true);
+
+  return NewG;
+}
+
+static inline Constant *
+appendIndirectedGlobal(const GlobalVariable *IndirectionTable,
+   SmallVector &SymbolIndirections,
+   GlobalVariable *ToIndirect) {
+  Module *M = ToIndirect->getParent();
+
+  auto *InitTy = cast(IndirectionTable->getValueType());
+  auto *SymbolListTy = cast(InitTy->getStructElementType(2));
+  Type *NameTy = SymbolListTy->getElementType(0);
+  Type *IndirectTy = SymbolListTy->getElementType(1);
+
+  Constant *NameG = getGlobalForName(ToIndirect);
+  Constant *IndirectG = getIndirectionGlobal(M);
+  Constant *Entry = ConstantStruct::get(
+  SymbolListTy, {ConstantExpr::getAddrSpaceCast(NameG, NameTy),
+ ConstantExpr::getAddrSpaceCast(IndirectG, IndirectTy)});
+  SymbolIndirections.push_back(Entry);
+
+  return IndirectG;
+}
+
+static void fillIndirectionTable(GlobalVariable *IndirectionTable,
+ SmallVector Indirections) {
+  Module *M = IndirectionTable->getParent();
+  size_t SymCnt = Indirections.size();
+
+  auto *InitTy = cast(IndirectionTable->getValueType());
+  Type *SymbolListTy = InitTy->getStructElementType(1);
+  auto *SymbolTy = cast(InitTy->getStructElementType(2));
+
+  Constant *Count = ConstantInt::get(InitTy->getStructElementType(0), SymCnt);
+  M->removeGlobalVariable(IndirectionTable);
+  GlobalVariable *Symbols =
+  M->getOrInsertGlobal("", ArrayType::get(SymbolTy, SymCnt));
+  Symbols->setLinkage(GlobalValue::LinkageTypes::PrivateLinkage);
+  Symbols->setInitializer(
+  ConstantArray::get(ArrayType::get(SymbolTy, SymCnt), {Indirections}));
+  Symbols->setConstant(true);
+
+  Constant *ASCSymbols = ConstantExpr::getAddrSpaceCast(Symbols, SymbolListTy);
+  Constant *Init = ConstantStruct::get(
+  InitTy, {Count, ASCSymbols, PoisonValue::get(SymbolTy)});
+  M->insertGlobalVariable(IndirectionTable);
+  IndirectionTable->setInitializer(Init);
+}
+
+static void replaceWithIndirectUse(const Use &U, const GlobalVariable *G,
+   Constant *IndirectedG) {
+  auto *I = cast(U.getUser());
+
+  IRBuilder<> Builder(I);
+  Value *Op = I->getOperand(U.getOperandNo());
+
+  // We walk back up the use chain, which could be an arbitrarily long sequence
+  // of constexpr AS casts, ptr-to-int and GEP instructions, until we reach the
+  // indirected global.
+  while (auto *CE = dyn_cast(Op)) {
+assert((CE->getOpcode() == Instruction::GetElementPtr ||
+CE->getOpcode() == Instruction::AddrSpaceCast ||
+CE->getOpcode() == Instruction::PtrToInt) &&
+   "Only GEP, ASCAST or PTRTOINT constant uses supported!");
+
+Instruction *NewI = Builder.Insert(CE->getAsInstruction());
+I->replaceUsesOfWith(Op, NewI);
+I = NewI;
+Op = I->getOperand(0);
+Builder.SetInsertPoint(I);
+  }
+
+  assert(Op == G && "Must reach indirected global!");
+
+  Builder.GetInsertPoint()->setOperand(

jmmartinez wrote:

Isn't this the same as `I->setOperand(0, ...)` ?

Is it possible that there is no cast/gep/ptrtoint and only some other kind of 
user? Something where the operand is not at the 

[clang] [llvm] [HIPSTDPAR] Add support for globals (PR #146813)

2025-07-07 Thread Juan Manuel Martinez Caamaño via cfe-commits


@@ -114,24 +115,221 @@ static inline void clearModule(Module &M) { // TODO: 
simplify.
 eraseFromModule(*M.ifuncs().begin());
 }
 
+static inline SmallVector>
+collectIndirectableUses(GlobalVariable *G) {
+  // We are interested only in use chains that end in an Instruction.
+  SmallVector> Uses;
+
+  SmallVector> Tmp(G->use_begin(), G->use_end());

jmmartinez wrote:

nitpick: Can we rename `Tmp` as `Stack`?

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


[clang] [llvm] [HIPSTDPAR] Add support for globals (PR #146813)

2025-07-07 Thread Juan Manuel Martinez Caamaño via cfe-commits


@@ -114,24 +115,221 @@ static inline void clearModule(Module &M) { // TODO: 
simplify.
 eraseFromModule(*M.ifuncs().begin());
 }
 
+static inline SmallVector>
+collectIndirectableUses(GlobalVariable *G) {
+  // We are interested only in use chains that end in an Instruction.
+  SmallVector> Uses;
+
+  SmallVector> Tmp(G->use_begin(), G->use_end());
+  while (!Tmp.empty()) {
+Use &U = Tmp.back();
+Tmp.pop_back();
+if (isa(U.getUser()))
+  Uses.emplace_back(U);
+else
+  transform(U.getUser()->uses(), std::back_inserter(Tmp),
+[](auto &&U) { return std::ref(U); });
+  }
+
+  return Uses;
+}
+
+static inline GlobalVariable *getGlobalForName(GlobalVariable *G) {
+  // Create an anonymous global which stores the variable's name, which will be
+  // used by the HIPSTDPAR runtime to look up the program-wide symbol.
+  LLVMContext &Ctx = G->getContext();
+  auto *CDS = ConstantDataArray::getString(Ctx, G->getName());
+
+  GlobalVariable *N = G->getParent()->getOrInsertGlobal("", CDS->getType());
+  N->setInitializer(CDS);
+  N->setLinkage(GlobalValue::LinkageTypes::PrivateLinkage);
+  N->setConstant(true);
+
+  return N;
+}
+
+static inline GlobalVariable *getIndirectionGlobal(Module *M) {

jmmartinez wrote:

Several functions in this source file are marked as inline. Does it make any 
sense in here?

I know that they are already there for some other functions. But I cannot see 
what do they bring in this context (specially since the functions are already 
marked as static).

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


[clang] [clang][CompundLiteralExpr] Don't defer evaluation for CLEs (PR #137163)

2025-07-07 Thread kadir çetinkaya via cfe-commits

kadircet wrote:

@AaronBallman @ilya-biryukov ping here, I am planning to merge this soon. 
please LMK if you still have any concerns.

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


[libclc] [libclc] Reduce include usage in OpenCL builtins (PR #146840)

2025-07-07 Thread Fraser Cormack via cfe-commits

https://github.com/frasercrmck updated 
https://github.com/llvm/llvm-project/pull/146840

>From eea3f1a2f5af14ac83c11bfb8da1d4be620d3078 Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Thu, 3 Jul 2025 10:45:05 +0100
Subject: [PATCH 1/3] [libclc] Reduce include usage in OpenCL builtins

This commit starts the process of reducing the amount of code included
by OpenCL builtins, hopefully reducing build times in the process.

It introduces a minimal OpenCL header - opencl-base.h - which includes
only the OpenCL type definitions and the macros necessary for
declaring/defining functions.

Where the OpenCL builtin implementations would currently include the
whole of , which defines *all* OpenCL builtins, now
they include only the specific declaration they need.

This mirrors how the CLC builtins are defined.
---
 libclc/opencl/include/clc/opencl/clc.h| 14 +-
 .../opencl/include/clc/opencl/integer/abs.h   |  7 +
 .../include/clc/opencl/integer/abs_diff.h |  7 +
 .../include/clc/opencl/integer/add_sat.h  |  7 +
 .../opencl/include/clc/opencl/integer/clz.h   |  7 +
 .../opencl/include/clc/opencl/integer/ctz.h   |  7 +
 .../opencl/include/clc/opencl/integer/hadd.h  |  7 +
 .../opencl/include/clc/opencl/integer/mad24.h |  7 +
 .../include/clc/opencl/integer/mad_hi.h   |  7 +
 .../include/clc/opencl/integer/mad_sat.h  |  7 +
 .../opencl/include/clc/opencl/integer/mul24.h |  7 +
 .../include/clc/opencl/integer/mul_hi.h   |  7 +
 .../include/clc/opencl/integer/popcount.h |  7 +
 .../include/clc/opencl/integer/rotate.h   |  7 +
 .../include/clc/opencl/integer/upsample.h |  7 +
 .../opencl/include/clc/opencl/opencl-base.h   | 26 +++
 libclc/opencl/lib/generic/integer/abs.cl  |  2 +-
 libclc/opencl/lib/generic/integer/abs_diff.cl |  2 +-
 libclc/opencl/lib/generic/integer/add_sat.cl  |  2 +-
 libclc/opencl/lib/generic/integer/clz.cl  |  2 +-
 libclc/opencl/lib/generic/integer/ctz.cl  |  2 +-
 libclc/opencl/lib/generic/integer/hadd.cl |  2 +-
 libclc/opencl/lib/generic/integer/mad24.cl|  2 +-
 libclc/opencl/lib/generic/integer/mad_hi.cl   |  2 +-
 libclc/opencl/lib/generic/integer/mad_sat.cl  |  2 +-
 libclc/opencl/lib/generic/integer/mul24.cl|  2 +-
 libclc/opencl/lib/generic/integer/mul_hi.cl   |  2 +-
 libclc/opencl/lib/generic/integer/popcount.cl |  2 +-
 libclc/opencl/lib/generic/integer/rotate.cl   |  2 +-
 libclc/opencl/lib/generic/integer/upsample.cl |  2 +-
 30 files changed, 139 insertions(+), 27 deletions(-)
 create mode 100644 libclc/opencl/include/clc/opencl/opencl-base.h

diff --git a/libclc/opencl/include/clc/opencl/clc.h 
b/libclc/opencl/include/clc/opencl/clc.h
index 5859a00c3158b..7d34f00113517 100644
--- a/libclc/opencl/include/clc/opencl/clc.h
+++ b/libclc/opencl/include/clc/opencl/clc.h
@@ -15,19 +15,7 @@
 
 #pragma OPENCL EXTENSION cl_clang_storage_class_specifiers : enable
 
-#ifdef cl_khr_fp64
-#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-#endif
-
-#ifdef cl_khr_fp16
-#pragma OPENCL EXTENSION cl_khr_fp16 : enable
-#endif
-
-/* Function Attributes */
-#include 
-
-/* 6.1 Supported Data Types */
-#include 
+#include 
 
 /* 6.2.3 Explicit Conversions */
 #include 
diff --git a/libclc/opencl/include/clc/opencl/integer/abs.h 
b/libclc/opencl/include/clc/opencl/integer/abs.h
index 22ba40fb40d42..be064fa33afbc 100644
--- a/libclc/opencl/include/clc/opencl/integer/abs.h
+++ b/libclc/opencl/include/clc/opencl/integer/abs.h
@@ -6,5 +6,12 @@
 //
 
//===--===//
 
+#ifndef __CLC_OPENCL_OPENCL_INTEGER_ABS_H__
+#define __CLC_OPENCL_OPENCL_INTEGER_ABS_H__
+
+#include 
+
 #define __CLC_BODY 
 #include 
+
+#endif // __CLC_OPENCL_OPENCL_INTEGER_ABS_H__
diff --git a/libclc/opencl/include/clc/opencl/integer/abs_diff.h 
b/libclc/opencl/include/clc/opencl/integer/abs_diff.h
index f22cc4d88afcf..1716eb24df614 100644
--- a/libclc/opencl/include/clc/opencl/integer/abs_diff.h
+++ b/libclc/opencl/include/clc/opencl/integer/abs_diff.h
@@ -6,5 +6,12 @@
 //
 
//===--===//
 
+#ifndef __CLC_OPENCL_OPENCL_INTEGER_ABS_DIFF_H__
+#define __CLC_OPENCL_OPENCL_INTEGER_ABS_DIFF_H__
+
+#include 
+
 #define __CLC_BODY 
 #include 
+
+#endif // __CLC_OPENCL_OPENCL_INTEGER_ABS_DIFF_H__
diff --git a/libclc/opencl/include/clc/opencl/integer/add_sat.h 
b/libclc/opencl/include/clc/opencl/integer/add_sat.h
index c0acb63e945d5..ff373b57ff3cc 100644
--- a/libclc/opencl/include/clc/opencl/integer/add_sat.h
+++ b/libclc/opencl/include/clc/opencl/integer/add_sat.h
@@ -6,9 +6,16 @@
 //
 
//===--===//
 
+#ifndef __CLC_OPENCL_OPENCL_INTEGER_ADD_SAT_H__
+#define __CLC_OPENCL_OPENCL_INTEGER_ADD_SAT_H__
+
+#include 
+
 #define FUNCTION add_sat
 #define __CLC_BODY 
 
 #include 
 
 #undef FUNCTION
+
+#endif // __CL

[clang] [analyzer] Add support for consteval in ConditionBRVisitor::VisitTerminator (PR #146859)

2025-07-07 Thread Balazs Benics via cfe-commits


@@ -0,0 +1,8 @@
+// RUN: %clang_analyze_cc1 -std=c++23 -analyzer-checker=core -verify %s

steakhal wrote:

I'd reject the idea of sprinkling ifdefs and feature detections.
Let's just move on. 

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


[clang] [analyzer] Add support for consteval in ConditionBRVisitor::VisitTerminator (PR #146859)

2025-07-07 Thread Balazs Benics via cfe-commits


@@ -0,0 +1,8 @@
+// RUN: %clang_analyze_cc1 -std=c++23 -analyzer-checker=core -verify %s

steakhal wrote:

I don't think it's possible to create RUN lines for standards of which the 
flags are rejected by clang right now.


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


[clang] [llvm] [AMDGPU] Add alignment attr & propagate alignment through make.buffer.rsrc inst (PR #145278)

2025-07-07 Thread via cfe-commits

https://github.com/Shoreshen updated 
https://github.com/llvm/llvm-project/pull/145278

>From 888df5412b37bd3f232bdb38c9f89786d042fe75 Mon Sep 17 00:00:00 2001
From: shore <372660...@qq.com>
Date: Mon, 23 Jun 2025 14:12:15 +0800
Subject: [PATCH 1/6] Add alignment attr & propagate alignment through
 make.buffer.rsrc inst

---
 llvm/include/llvm/Transforms/IPO/Attributor.h | 22 ++
 llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp   | 37 -
 .../Transforms/IPO/AttributorAttributes.cpp   | 14 ++-
 llvm/test/CodeGen/AMDGPU/attr-amdgpu-align.ll | 40 +++
 4 files changed, 110 insertions(+), 3 deletions(-)
 create mode 100644 llvm/test/CodeGen/AMDGPU/attr-amdgpu-align.ll

diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h 
b/llvm/include/llvm/Transforms/IPO/Attributor.h
index e6eb756df987d..64285c2114976 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -1355,6 +1355,12 @@ struct InformationCache {
   /// Return the flat address space if the associated target has.
   LLVM_ABI std::optional getFlatAddressSpace() const;
 
+  virtual bool shouldTrackUse(const AbstractAttribute *QueryingAA,
+  Value &AssociatedValue, const Use *U,
+  const Instruction *I) const {
+return false;
+  }
+
 private:
   struct FunctionInfo {
 LLVM_ABI ~FunctionInfo();
@@ -2042,6 +2048,19 @@ struct Attributor {
 SimplificationCallbacks[IRP].emplace_back(CB);
   }
 
+  using AlignmentCallbackTy =
+  std::function &)>;
+  void registerAlignmentCallback(const IRPosition &IRP,
+ const AlignmentCallbackTy &CB) {
+AlignmentCallBacks[IRP].emplace_back(CB);
+  }
+
+  SmallVector
+  getAlignmentCallback(const IRPosition &IRP) {
+return AlignmentCallBacks.lookup(IRP);
+  }
+
   /// Return true if there is a simplification callback for \p IRP.
   bool hasSimplificationCallback(const IRPosition &IRP) {
 return SimplificationCallbacks.count(IRP);
@@ -2093,6 +2112,9 @@ struct Attributor {
   DenseMap>
   SimplificationCallbacks;
 
+  /// The vector with AAAlign callbacks registered by outside AAs.
+  DenseMap> AlignmentCallBacks;
+
   /// The vector with all simplification callbacks for global variables
   /// registered by outside AAs.
   DenseMap(AA)) {
+if (const auto *II = dyn_cast(I)) {
+  if (II->getIntrinsicID() == Intrinsic::amdgcn_make_buffer_rsrc)
+return true;
+}
+  }
+
+  return false;
+}
+
 namespace {
 class AMDGPUInformationCache : public InformationCache {
 public:
@@ -235,6 +247,12 @@ class AMDGPUInformationCache : public InformationCache {
 return ST.getMaxWavesPerEU();
   }
 
+  bool shouldTrackUse(const AbstractAttribute *QueryingAA,
+  Value &AssociatedValue, const Use *U,
+  const Instruction *I) const override {
+return isAlignAndMakeBuffer(QueryingAA, I);
+  }
+
 private:
   /// Check if the ConstantExpr \p CE uses an addrspacecast from private or
   /// local to flat. These casts may require the queue pointer.
@@ -1381,7 +1399,7 @@ static bool runImpl(Module &M, AnalysisGetter &AG, 
TargetMachine &TM,
&AAAMDMaxNumWorkgroups::ID, &AAAMDWavesPerEU::ID, &AAAMDGPUNoAGPR::ID,
&AACallEdges::ID, &AAPointerInfo::ID, &AAPotentialConstantValues::ID,
&AAUnderlyingObjects::ID, &AAAddressSpace::ID, &AAIndirectCallInfo::ID,
-   &AAInstanceInfo::ID});
+   &AAInstanceInfo::ID, &AAAlign::ID});
 
   AttributorConfig AC(CGUpdater);
   AC.IsClosedWorldModule = Options.IsClosedWorld;
@@ -1432,6 +1450,23 @@ static bool runImpl(Module &M, AnalysisGetter &AG, 
TargetMachine &TM,
   } else if (auto *CmpX = dyn_cast(&I)) {
 A.getOrCreateAAFor(
 IRPosition::value(*CmpX->getPointerOperand()));
+  } else if (auto *II = dyn_cast(&I)) {
+if (II->getIntrinsicID() == Intrinsic::amdgcn_make_buffer_rsrc) {
+  IRPosition IRP = IRPosition::inst(*II);
+
+  Attributor::AlignmentCallbackTy ACB =
+  [](const IRPosition &IRP, const AbstractAttribute *AA,
+ SmallVectorImpl &Values) {
+if (auto *I = dyn_cast(&IRP.getAssociatedValue()))
+  if (isAlignAndMakeBuffer(AA, I)) {
+Values.push_back(
+AA::ValueAndContext{*I->getOperand(0), nullptr});
+  }
+  };
+  A.registerAlignmentCallback(IRP, ACB);
+
+  A.getOrCreateAAFor(IRP);
+}
   }
 }
   }
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp 
b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 3799a696f67af..cca03b30e75c7 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -5202,6 +5202,10 @@ static unsigned getKnownAlignForUse(Attributor &A, 
AAAlign &QueryingAA,
   TrackUse = true;
 return 0;
   }

[clang] [analyzer] Add support for consteval in ConditionBRVisitor::VisitTerminator (PR #146859)

2025-07-07 Thread via cfe-commits

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


[clang] [analyzer] Add support for consteval in ConditionBRVisitor::VisitTerminator (PR #146859)

2025-07-07 Thread via cfe-commits


@@ -0,0 +1,8 @@
+// RUN: %clang_analyze_cc1 -std=c++23 -analyzer-checker=core -verify %s

isuckatcs wrote:

I don't have anything against, but I don't see this pattern in the analyzer 
tests, so I'm a bit hesitant. We however have a lot of the `#if __cplusplus >= 
XXX` pattern, so I would prefer to check for the standard to keep things 
consistent.

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


[clang] [analyzer] Conversion to CheckerFamily: MallocChecker (PR #147080)

2025-07-07 Thread Donát Nagy via cfe-commits


@@ -327,39 +327,7 @@ void testArrayDestr() {
   clang_analyzer_warnIfReached(); // no-warning
 }
 
-// Invalidate Region even in case of default destructor
-class InvalidateDestTest {
-public:
-  int x;
-  int *y;
-  ~InvalidateDestTest();
-};
-
-int test_member_invalidation() {
-
-  //test invalidation of member variable
-  InvalidateDestTest *test = new InvalidateDestTest();
-  test->x = 5;
-  int *k = &(test->x);
-  clang_analyzer_eval(*k == 5); // expected-warning{{TRUE}}
-  delete test;
-  clang_analyzer_eval(*k == 5); // expected-warning{{UNKNOWN}}
-
-  //test invalidation of member pointer
-  int localVar = 5;
-  test = new InvalidateDestTest();
-  test->y = &localVar;
-  delete test;
-  clang_analyzer_eval(localVar == 5); // expected-warning{{UNKNOWN}}
-
-  // Test aray elements are invalidated.
-  int Var1 = 5;
-  int Var2 = 5;
-  InvalidateDestTest *a = new InvalidateDestTest[2];
-  a[0].y = &Var1;
-  a[1].y = &Var2;
-  delete[] a;
-  clang_analyzer_eval(Var1 == 5); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(Var2 == 5); // expected-warning{{UNKNOWN}}
-  return 0;
-}
+// See also test-member-invalidation.cpp which validates that calling an
+// unknown destructor invalidates the members of an object. This behavior
+// cannot be tested in this file because here `MallocChecker.cpp` sinks
+// execution paths that refer to members of a deleted object.

NagyDonat wrote:

In fact I think it would be better to just remove this testcase, because the 
original claim that this tests "Invalidate Region even in case of default 
description" is a big lie – the destructor of this class is a declared but not 
defined opaque function, so the test just validates that the default execution 
of an opaque (non-const) method invalidates the members of `this`. This is a 
very basic behavior of the analyzer engine, so I don't think that it deserves 
an explicit test, especially in a case where it is (often) superseded by the 
more accurate modeling done by `MallocChecker`.

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


[clang] [analyzer] Add support for consteval in ConditionBRVisitor::VisitTerminator (PR #146859)

2025-07-07 Thread Imad Aldij via cfe-commits

https://github.com/imdj updated https://github.com/llvm/llvm-project/pull/146859

>From 1077e164158965e824097542dc4c3ecc8821d6dc Mon Sep 17 00:00:00 2001
From: Imad Aldij 
Date: Thu, 3 Jul 2025 13:50:55 +0300
Subject: [PATCH 1/5] Add support for consteval if in ConditionBRVisitor

---
 clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp 
b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index 3686bd4488877..d81a3f5a2858b 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2794,6 +2794,9 @@ PathDiagnosticPieceRef 
ConditionBRVisitor::VisitTerminator(
   default:
 return nullptr;
   case Stmt::IfStmtClass:
+// Handle if consteval which doesn't have a traditional condition
+if (cast(Term)->isConsteval())
+  return nullptr;
 Cond = cast(Term)->getCond();
 break;
   case Stmt::ConditionalOperatorClass:

>From 27b793fcf2347d631991f9f83df7ef5787df17d6 Mon Sep 17 00:00:00 2001
From: Imad Aldij 
Date: Thu, 3 Jul 2025 15:52:35 +0300
Subject: [PATCH 2/5] add test case for consteval and ConditionBRVisitor

---
 clang/test/Analysis/consteval-if.cpp | 8 
 1 file changed, 8 insertions(+)
 create mode 100644 clang/test/Analysis/consteval-if.cpp

diff --git a/clang/test/Analysis/consteval-if.cpp 
b/clang/test/Analysis/consteval-if.cpp
new file mode 100644
index 0..2ce9a69067951
--- /dev/null
+++ b/clang/test/Analysis/consteval-if.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_analyze_cc1 -std=c++23 -analyzer-checker=core -verify %s
+
+void test_consteval() {
+  if consteval {
+int *ptr = nullptr;
+*ptr = 42; // expected-warning{{Dereference of null pointer (loaded from 
variable 'ptr')}}
+  }
+}
\ No newline at end of file

>From 90a235dfff9c6eaaa47f62d542de03868154a806 Mon Sep 17 00:00:00 2001
From: Imad Aldij 
Date: Thu, 3 Jul 2025 16:30:32 +0300
Subject: [PATCH 3/5] Update test formatting

Co-authored-by: Balazs Benics 
---
 clang/test/Analysis/consteval-if.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/Analysis/consteval-if.cpp 
b/clang/test/Analysis/consteval-if.cpp
index 2ce9a69067951..b7eae9db6a239 100644
--- a/clang/test/Analysis/consteval-if.cpp
+++ b/clang/test/Analysis/consteval-if.cpp
@@ -5,4 +5,4 @@ void test_consteval() {
 int *ptr = nullptr;
 *ptr = 42; // expected-warning{{Dereference of null pointer (loaded from 
variable 'ptr')}}
   }
-}
\ No newline at end of file
+}

>From d5015902c9faad0858c99b7b462055e48cc4 Mon Sep 17 00:00:00 2001
From: Imad Aldij 
Date: Mon, 7 Jul 2025 10:47:18 +0300
Subject: [PATCH 4/5] Improve code style

---
 clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp 
b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index d81a3f5a2858b..4631e0cad5546 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2793,12 +2793,14 @@ PathDiagnosticPieceRef 
ConditionBRVisitor::VisitTerminator(
   // more tricky because there are more than two branches to account for.
   default:
 return nullptr;
-  case Stmt::IfStmtClass:
-// Handle if consteval which doesn't have a traditional condition
-if (cast(Term)->isConsteval())
+  case Stmt::IfStmtClass: {
+const auto *IfStatement = cast(Term);
+// Handle if consteval which doesn't have a traditional condition.
+if (IfStatement->isConsteval())
   return nullptr;
-Cond = cast(Term)->getCond();
+Cond = IfStatement->getCond();
 break;
+  }
   case Stmt::ConditionalOperatorClass:
 Cond = cast(Term)->getCond();
 break;

>From 82a47298049a11d918e4e0d2a62bbd2683ce9aa1 Mon Sep 17 00:00:00 2001
From: Imad Aldij 
Date: Mon, 7 Jul 2025 10:47:23 +0300
Subject: [PATCH 5/5] Add test for not consteval

---
 clang/test/Analysis/consteval-if.cpp | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/clang/test/Analysis/consteval-if.cpp 
b/clang/test/Analysis/consteval-if.cpp
index b7eae9db6a239..f9caacf2949c9 100644
--- a/clang/test/Analysis/consteval-if.cpp
+++ b/clang/test/Analysis/consteval-if.cpp
@@ -6,3 +6,10 @@ void test_consteval() {
 *ptr = 42; // expected-warning{{Dereference of null pointer (loaded from 
variable 'ptr')}}
   }
 }
+
+void test_not_consteval() {
+  if !consteval {
+int *ptr = nullptr;
+*ptr = 42; // expected-warning{{Dereference of null pointer (loaded from 
variable 'ptr')}}
+  }
+}

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


[clang-tools-extra] [clangd][NFC] fix broken documentation link (PR #147088)

2025-07-07 Thread Tim Gymnich via cfe-commits

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


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


[clang] [analyzer] Conversion to CheckerFamily: MallocChecker (PR #147080)

2025-07-07 Thread Donát Nagy via cfe-commits


@@ -402,16 +449,19 @@ class MallocChecker
   const char *NL, const char *Sep) const override;
 
 private:
-  mutable std::unique_ptr BT_DoubleFree[CK_NumCheckKinds];
-  mutable std::unique_ptr BT_DoubleDelete;
-  mutable std::unique_ptr BT_Leak[CK_NumCheckKinds];
-  mutable std::unique_ptr BT_UseFree[CK_NumCheckKinds];
-  mutable std::unique_ptr BT_BadFree[CK_NumCheckKinds];
-  mutable std::unique_ptr BT_FreeAlloca[CK_NumCheckKinds];
-  mutable std::unique_ptr BT_MismatchedDealloc;
-  mutable std::unique_ptr BT_OffsetFree[CK_NumCheckKinds];
-  mutable std::unique_ptr BT_UseZerroAllocated[CK_NumCheckKinds];

NagyDonat wrote:

Let's say goodbye to Zerro, the younger brother of Zorro... :sweat_smile: 

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


[libclc] [libclc] Fix typo in OpenCL header math/sincos.h (PR #147244)

2025-07-07 Thread Wenju He via cfe-commits

wenju-he wrote:

> This isn't `NFC`, though?

Removed `NFC`. I was not seeing changes in OpenCL bitcode files.

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


[libclc] [libclc] Fix typo in OpenCL header math/sincos.h (PR #147244)

2025-07-07 Thread Wenju He via cfe-commits

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


[libclc] [libclc] Fix typo in OpenCL header math/sincos.h (PR #147244)

2025-07-07 Thread Wenju He via cfe-commits

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


[clang] [llvm] [NFC][PowerPC] Add test case for lockdown of vector compare greater than support for Zero vector comparisons (PR #147246)

2025-07-07 Thread via cfe-commits

https://github.com/Himadhith updated 
https://github.com/llvm/llvm-project/pull/147246

>From 118389439ac39b9d097b26450e5934a38be8f740 Mon Sep 17 00:00:00 2001
From: himadhith 
Date: Mon, 7 Jul 2025 07:31:59 +
Subject: [PATCH] NFC test cases lockdown for vector compare equal

---
 .../test/CodeGen/PowerPC/check-zero-vector.c  | 143 +++
 .../test/CodeGen/PowerPC/check-zero-vector.ll | 239 ++
 2 files changed, 382 insertions(+)
 create mode 100644 clang/test/CodeGen/PowerPC/check-zero-vector.c
 create mode 100644 llvm/test/CodeGen/PowerPC/check-zero-vector.ll

diff --git a/clang/test/CodeGen/PowerPC/check-zero-vector.c 
b/clang/test/CodeGen/PowerPC/check-zero-vector.c
new file mode 100644
index 0..82f782faf9a5e
--- /dev/null
+++ b/clang/test/CodeGen/PowerPC/check-zero-vector.c
@@ -0,0 +1,143 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// RUN: %clang_cc1  -triple powerpc64-unknown-unknown -emit-llvm %s -o -  | 
FileCheck %s --check-prefix=POWERPC_64
+// RUN: %clang_cc1  -triple powerpc64le-unknown-unknown -emit-llvm %s -o -  | 
FileCheck %s --check-prefix=POWERPC_64LE
+// RUN: %clang_cc1  -triple powerpc-unknown-unknown -emit-llvm %s -o -  | 
FileCheck %s --check-prefix=POWERPC_32
+
+// POWERPC_64-LABEL: define dso_local signext i32 @test_Greater_than(
+// POWERPC_64-SAME: ptr noundef [[COLAUTHS:%.*]]) #[[ATTR0:[0-9]+]] {
+// POWERPC_64-NEXT:  [[ENTRY:.*:]]
+// POWERPC_64-NEXT:[[COLAUTHS_ADDR:%.*]] = alloca ptr, align 8
+// POWERPC_64-NEXT:[[RESULT:%.*]] = alloca i16, align 2
+// POWERPC_64-NEXT:[[I:%.*]] = alloca i32, align 4
+// POWERPC_64-NEXT:store ptr [[COLAUTHS]], ptr [[COLAUTHS_ADDR]], align 8
+// POWERPC_64-NEXT:store i16 0, ptr [[RESULT]], align 2
+// POWERPC_64-NEXT:store i32 0, ptr [[I]], align 4
+// POWERPC_64-NEXT:br label %[[FOR_COND:.*]]
+// POWERPC_64:   [[FOR_COND]]:
+// POWERPC_64-NEXT:[[TMP0:%.*]] = load i32, ptr [[I]], align 4
+// POWERPC_64-NEXT:[[CMP:%.*]] = icmp slt i32 [[TMP0]], 4
+// POWERPC_64-NEXT:br i1 [[CMP]], label %[[FOR_BODY:.*]], label 
%[[FOR_END:.*]]
+// POWERPC_64:   [[FOR_BODY]]:
+// POWERPC_64-NEXT:[[TMP1:%.*]] = load ptr, ptr [[COLAUTHS_ADDR]], align 8
+// POWERPC_64-NEXT:[[TMP2:%.*]] = load i32, ptr [[I]], align 4
+// POWERPC_64-NEXT:[[IDXPROM:%.*]] = sext i32 [[TMP2]] to i64
+// POWERPC_64-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i16, ptr 
[[TMP1]], i64 [[IDXPROM]]
+// POWERPC_64-NEXT:[[TMP3:%.*]] = load i16, ptr [[ARRAYIDX]], align 2
+// POWERPC_64-NEXT:[[CONV:%.*]] = zext i16 [[TMP3]] to i32
+// POWERPC_64-NEXT:[[CMP1:%.*]] = icmp sgt i32 [[CONV]], 0
+// POWERPC_64-NEXT:br i1 [[CMP1]], label %[[IF_THEN:.*]], label 
%[[IF_END:.*]]
+// POWERPC_64:   [[IF_THEN]]:
+// POWERPC_64-NEXT:[[TMP4:%.*]] = load i16, ptr [[RESULT]], align 2
+// POWERPC_64-NEXT:[[INC:%.*]] = add i16 [[TMP4]], 1
+// POWERPC_64-NEXT:store i16 [[INC]], ptr [[RESULT]], align 2
+// POWERPC_64-NEXT:br label %[[IF_END]]
+// POWERPC_64:   [[IF_END]]:
+// POWERPC_64-NEXT:br label %[[FOR_INC:.*]]
+// POWERPC_64:   [[FOR_INC]]:
+// POWERPC_64-NEXT:[[TMP5:%.*]] = load i32, ptr [[I]], align 4
+// POWERPC_64-NEXT:[[INC3:%.*]] = add nsw i32 [[TMP5]], 1
+// POWERPC_64-NEXT:store i32 [[INC3]], ptr [[I]], align 4
+// POWERPC_64-NEXT:br label %[[FOR_COND]], !llvm.loop [[LOOP2:![0-9]+]]
+// POWERPC_64:   [[FOR_END]]:
+// POWERPC_64-NEXT:[[TMP6:%.*]] = load i16, ptr [[RESULT]], align 2
+// POWERPC_64-NEXT:[[CONV4:%.*]] = zext i16 [[TMP6]] to i32
+// POWERPC_64-NEXT:ret i32 [[CONV4]]
+//
+// POWERPC_64LE-LABEL: define dso_local signext i32 @test_Greater_than(
+// POWERPC_64LE-SAME: ptr noundef [[COLAUTHS:%.*]]) #[[ATTR0:[0-9]+]] {
+// POWERPC_64LE-NEXT:  [[ENTRY:.*:]]
+// POWERPC_64LE-NEXT:[[COLAUTHS_ADDR:%.*]] = alloca ptr, align 8
+// POWERPC_64LE-NEXT:[[RESULT:%.*]] = alloca i16, align 2
+// POWERPC_64LE-NEXT:[[I:%.*]] = alloca i32, align 4
+// POWERPC_64LE-NEXT:store ptr [[COLAUTHS]], ptr [[COLAUTHS_ADDR]], align 8
+// POWERPC_64LE-NEXT:store i16 0, ptr [[RESULT]], align 2
+// POWERPC_64LE-NEXT:store i32 0, ptr [[I]], align 4
+// POWERPC_64LE-NEXT:br label %[[FOR_COND:.*]]
+// POWERPC_64LE:   [[FOR_COND]]:
+// POWERPC_64LE-NEXT:[[TMP0:%.*]] = load i32, ptr [[I]], align 4
+// POWERPC_64LE-NEXT:[[CMP:%.*]] = icmp slt i32 [[TMP0]], 4
+// POWERPC_64LE-NEXT:br i1 [[CMP]], label %[[FOR_BODY:.*]], label 
%[[FOR_END:.*]]
+// POWERPC_64LE:   [[FOR_BODY]]:
+// POWERPC_64LE-NEXT:[[TMP1:%.*]] = load ptr, ptr [[COLAUTHS_ADDR]], align 
8
+// POWERPC_64LE-NEXT:[[TMP2:%.*]] = load i32, ptr [[I]], align 4
+// POWERPC_64LE-NEXT:[[IDXPROM:%.*]] = sext i32 [[TMP2]] to i64
+// POWERPC_64LE-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i16, ptr 
[[TMP1]], i64 [[IDXPROM]]
+// POWERPC_64LE-NEXT:[[TMP3:%.*]] = load i16, ptr

[clang-tools-extra] [clang-tidy] Make `bugprone-unhandled-self-assignment` check more general (PR #147066)

2025-07-07 Thread Andrey Karlov via cfe-commits

https://github.com/negativ updated 
https://github.com/llvm/llvm-project/pull/147066

>From 950b6dce92eb2a831e7bd7e7ba44b3e8cc354dd4 Mon Sep 17 00:00:00 2001
From: Andrey Karlov 
Date: Fri, 4 Jul 2025 17:13:20 +0300
Subject: [PATCH 1/6] Checking that some kind of constructor is called and
 followed by a `swap`

---
 .../bugprone/UnhandledSelfAssignmentCheck.cpp | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git 
a/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
index 1f432c4ccc5f0..8307e744a434c 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
@@ -68,7 +68,23 @@ void 
UnhandledSelfAssignmentCheck::registerMatchers(MatchFinder *Finder) {
   const auto HasNoNestedSelfAssign =
   
cxxMethodDecl(unless(hasDescendant(cxxMemberCallExpr(callee(cxxMethodDecl(
   hasName("operator="), ofClass(equalsBoundNode("class";
-
+  
+  // Checking that some kind of constructor is called and followed by a `swap`:
+  // T& operator=(const T& other) {
+  //T tmp{this->internal_data(), some, other, args};
+  //swap(tmp);
+  //return *this;
+  // }
+  const auto HasCopyAndSwap = cxxMethodDecl(
+  ofClass(cxxRecordDecl(unless(hasAncestor(classTemplateDecl(),
+  hasDescendant(
+  stmt(hasDescendant(
+   varDecl(hasType(cxxRecordDecl(equalsBoundNode("class"
+   .bind("tmp_var")),
+   hasDescendant(callExpr(callee(functionDecl(hasName("swap"))),
+  hasAnyArgument(declRefExpr(to(varDecl(
+  equalsBoundNode("tmp_var"));
+
   DeclarationMatcher AdditionalMatcher = cxxMethodDecl();
   if (WarnOnlyIfThisHasSuspiciousField) {
 // Matcher for standard smart pointers.
@@ -94,6 +110,7 @@ void 
UnhandledSelfAssignmentCheck::registerMatchers(MatchFinder *Finder) {
HasReferenceParam, HasNoSelfCheck,
unless(HasNonTemplateSelfCopy),
unless(HasTemplateSelfCopy),
+   unless(HasCopyAndSwap),
HasNoNestedSelfAssign, AdditionalMatcher)
  .bind("copyAssignmentOperator"),
  this);

>From 0cd33ec49693cfc6f5a72b72a9c50ba868634221 Mon Sep 17 00:00:00 2001
From: Andrey Karlov 
Date: Fri, 4 Jul 2025 17:19:02 +0300
Subject: [PATCH 2/6] Tests

---
 .../bugprone/unhandled-self-assignment.cpp| 90 +++
 1 file changed, 90 insertions(+)

diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-self-assignment.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-self-assignment.cpp
index 8610393449f97..f2f61062f883f 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-self-assignment.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-self-assignment.cpp
@@ -28,6 +28,13 @@ template 
 class auto_ptr {
 };
 
+namespace pmr {
+template 
+class allocator {};
+}
+
+struct allocator_arg_t {} allocator_arg;
+
 } // namespace std
 
 void assert(int expression){};
@@ -540,6 +547,89 @@ class NotACopyAssignmentOperator {
   Uy *getUy() const { return Ptr2; }
 };
 
+// Support "extended" copy/move constructors
+class AllocatorAwareClass {
+  // pointer member to trigger bugprone-unhandled-self-assignment
+  void *foo = nullptr;
+
+  public:
+using allocator_type = std::pmr::allocator<>;
+
+AllocatorAwareClass(const AllocatorAwareClass& other) {
+}
+
+AllocatorAwareClass(const AllocatorAwareClass& other, const 
allocator_type& alloc) {
+}
+
+AllocatorAwareClass& operator=(const AllocatorAwareClass& other) {
+AllocatorAwareClass tmp(other, get_allocator());
+swap(tmp);
+return *this;
+}
+
+void swap(AllocatorAwareClass& other) noexcept {
+}
+
+allocator_type get_allocator() const {
+return allocator_type();
+}
+};
+
+// Support "extended" copy/move constructors + std::swap
+class AllocatorAwareClassStdSwap {
+  // pointer member to trigger bugprone-unhandled-self-assignment
+  void *foo = nullptr;
+
+  public:
+using allocator_type = std::pmr::allocator<>;
+
+AllocatorAwareClassStdSwap(const AllocatorAwareClassStdSwap& other) {
+}
+
+AllocatorAwareClassStdSwap(const AllocatorAwareClassStdSwap& other, const 
allocator_type& alloc) {
+}
+
+AllocatorAwareClassStdSwap& operator=(const AllocatorAwareClassStdSwap& 
other) {
+using std::swap;
+
+AllocatorAwareClassStdSwap tmp(other, get_allocator());
+swap(*this, tmp);
+return *this;
+}
+
+allocator_type get_allocator() const {
+re

[clang] [analyzer] Add support for consteval in ConditionBRVisitor::VisitTerminator (PR #146859)

2025-07-07 Thread Balazs Benics via cfe-commits


@@ -0,0 +1,8 @@
+// RUN: %clang_analyze_cc1 -std=c++23 -analyzer-checker=core -verify %s

steakhal wrote:

I don't think we have tools for doing this.

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


[clang] Sema: filter out invalid base-specifiers before attaching (PR #147213)

2025-07-07 Thread Corentin Jabot via cfe-commits

https://github.com/cor3ntin commented:

Thanks for working on this

Did you try  to use `!isUsable` instead of IsInvalid in
`ParseBaseSpecifier` ? I think that might be a simpler fix.

---

This change needs a release note.
Please add an entry to `clang/docs/ReleaseNotes.rst` in the section the most 
adapted to the change, and referencing any Github issue this change fixes. 
Thanks!

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


[clang] [llvm] [DTLTO][Clang] Add support for Integrated Distributed ThinLTO (PR #147265)

2025-07-07 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: bd1976bris (bd1976bris)


Changes

This patch introduces support for Integrated Distributed ThinLTO (DTLTO) in 
Clang.

DTLTO enables the distribution of ThinLTO backend compilations via external 
distribution systems, such as Incredibuild, during the traditional link step: 
https://llvm.org/docs/DTLTO.html.

Testing:
- `lit` test coverage has been added to Clang's Driver tests.
- The DTLTO cross-project tests will use this Clang support.

For the design discussion of the DTLTO feature, see: 
https://github.com/llvm/llvm-project/pull/126654

Note that I have removed the forwarding of -mllvm options to the backend 
compilations which was discussed in the design review from this patch. LTO 
configuration for DTLTO will be addressed in a follow-up patch. In the meantime 
-mllvm options can be forwarded manually if required.

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


5 Files Affected:

- (modified) clang/docs/ThinLTO.rst (+32) 
- (modified) clang/include/clang/Driver/Options.td (+13-1) 
- (modified) clang/lib/Driver/ToolChains/Gnu.cpp (+15) 
- (added) clang/test/Driver/DTLTO/dtlto.c (+43) 
- (modified) cross-project-tests/dtlto/ld-dtlto.c (+13-18) 


``diff
diff --git a/clang/docs/ThinLTO.rst b/clang/docs/ThinLTO.rst
index c042547678919..687795ac655a7 100644
--- a/clang/docs/ThinLTO.rst
+++ b/clang/docs/ThinLTO.rst
@@ -240,6 +240,38 @@ The ``BOOTSTRAP_LLVM_ENABLE_LTO=Thin`` will enable ThinLTO 
for stage 2 and
 stage 3 in case the compiler used for stage 1 does not support the ThinLTO
 option.
 
+Integrated Distributed ThinLTO (DTLTO)
+--
+
+Integrated Distributed ThinLTO (DTLTO) enables the distribution of backend
+ThinLTO compilations via external distribution systems, such as Incredibuild,
+during the traditional link step.
+
+The implementation is documented here: https://llvm.org/docs/DTLTO.html.
+
+DTLTO requires the LLD linker (``-fuse-ld=lld``).
+
+``-fthinlto-distributor=``
+   - Specifies the  to the distributor process executable for DTLTO.
+   - If specified, ThinLTO backend compilations will be distributed by LLD.
+
+``-Xthinlto-distributor=``
+   - Passes  to the distributor process (see 
``-fthinlto-distributor=``).
+   - Can be specified multiple times to pass multiple options.
+   - Multiple options can also be specified by separating them with commas.
+
+Examples:
+   - ``clang -flto=thin -fthinlto-distributor=incredibuild.exe 
-Xthinlto-distributor=--verbose,--j10 -fuse-ld=lld``
+   - ``clang -flto=thin -fthinlto-distributor=$(which python) 
-Xthinlto-distributor=incredibuild.py -fuse-ld=lld``
+
+If ``-fthinlto-distributor=`` is specified, Clang supplies the path to a
+compiler to be executed remotely to perform the ThinLTO backend
+compilations. Currently, this is Clang itself.
+
+Note that currently, DTLTO is only supported in some LLD flavors. Support will
+be added to other LLD flavours in the future.
+See `DTLTO `_ for more information.
+
 More Information
 
 
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0c8a219b19bf4..9c6f77af97be0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -990,6 +990,13 @@ def Xlinker : Separate<["-"], "Xlinker">, 
Flags<[LinkerInput, RenderAsInput]>,
   Visibility<[ClangOption, CLOption, FlangOption]>,
   HelpText<"Pass  to the linker">, MetaVarName<"">,
   Group;
+def Xthinlto_distributor_EQ : CommaJoined<["-"], "Xthinlto-distributor=">,
+  Flags<[LinkOption]>,
+  Visibility<[ClangOption, CLOption]>,
+  HelpText<"Pass  to the ThinLTO distributor process. Can be specified "
+   "multiple times or with comma-separated values.">,
+  MetaVarName<"">,
+  Group;
 def Xoffload_linker : JoinedAndSeparate<["-"], "Xoffload-linker">,
   Visibility<[ClangOption, FlangOption]>,
   HelpText<"Pass  to the offload linkers or the ones identified by 
-">,
@@ -4233,7 +4240,12 @@ def ffinite_loops: Flag<["-"],  "ffinite-loops">, 
Group,
 def fno_finite_loops: Flag<["-"], "fno-finite-loops">, Group,
   HelpText<"Do not assume that any loop is finite.">,
   Visibility<[ClangOption, CC1Option]>;
-
+def fthinlto_distributor_EQ : Joined<["-"], "fthinlto-distributor=">,
+  Group,
+  HelpText<"Path to the ThinLTO distributor process. If specified, "
+   "ThinLTO backend compilations will be distributed by LLD">,
+  MetaVarName<"">,
+  Visibility<[ClangOption, CLOption]>;
 def ftrigraphs : Flag<["-"], "ftrigraphs">, Group,
   HelpText<"Process trigraph sequences">, Visibility<[ClangOption, CC1Option]>;
 def fno_trigraphs : Flag<["-"], "fno-trigraphs">, Group,
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index f5e2655857432..3e9ca8f79d160 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -455,6 +4

[clang] [Clang][AArch64] Fix feature guards for SVE2p1 builtins available in SME{2}. (PR #147086)

2025-07-07 Thread Jonathan Thackray via cfe-commits

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

Looks good.

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


[clang] [cir-translate] Fix crash issue where the data layout string is missing (PR #147209)

2025-07-07 Thread Henrich Lauko via cfe-commits

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


[clang] 3d64079 - [clang][OpenMP] Use DirectiveNameParser to parse directive names (#146779)

2025-07-07 Thread via cfe-commits

Author: Krzysztof Parzyszek
Date: 2025-07-07T07:54:50-05:00
New Revision: 3d6407965d5ab6df64919e725e9dd7b3be2bc235

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

LOG: [clang][OpenMP] Use DirectiveNameParser to parse directive names (#146779)

This simplifies the parsing code in clang quite a bit.

Added: 


Modified: 
clang/lib/Parse/ParseOpenMP.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 2c18f3e9306b6..941b8f9765426 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -25,6 +25,7 @@
 #include "clang/Sema/SemaOpenMP.h"
 #include "llvm/ADT/SmallBitVector.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Frontend/OpenMP/DirectiveNameParser.h"
 #include "llvm/Frontend/OpenMP/OMPAssume.h"
 #include "llvm/Frontend/OpenMP/OMPContext.h"
 #include 
@@ -37,48 +38,6 @@ using namespace llvm::omp;
 
//===--===//
 
 namespace {
-enum OpenMPDirectiveKindEx {
-  OMPD_cancellation = llvm::omp::Directive_enumSize + 1,
-  OMPD_data,
-  OMPD_declare,
-  OMPD_end,
-  OMPD_end_declare,
-  OMPD_enter,
-  OMPD_exit,
-  OMPD_point,
-  OMPD_reduction,
-  OMPD_target_enter,
-  OMPD_target_exit,
-  OMPD_update,
-  OMPD_distribute_parallel,
-  OMPD_teams_distribute_parallel,
-  OMPD_target_teams_distribute_parallel,
-  OMPD_mapper,
-  OMPD_variant,
-  OMPD_begin,
-  OMPD_begin_declare,
-};
-
-// Helper to unify the enum class OpenMPDirectiveKind with its extension
-// the OpenMPDirectiveKindEx enum which allows to use them together as if they
-// are unsigned values.
-struct OpenMPDirectiveKindExWrapper {
-  OpenMPDirectiveKindExWrapper(unsigned Value) : Value(Value) {}
-  OpenMPDirectiveKindExWrapper(OpenMPDirectiveKind DK) : Value(unsigned(DK)) {}
-  bool operator==(OpenMPDirectiveKindExWrapper V) const {
-return Value == V.Value;
-  }
-  bool operator!=(OpenMPDirectiveKindExWrapper V) const {
-return Value != V.Value;
-  }
-  bool operator==(OpenMPDirectiveKind V) const { return Value == unsigned(V); }
-  bool operator!=(OpenMPDirectiveKind V) const { return Value != unsigned(V); }
-  bool operator<(OpenMPDirectiveKind V) const { return Value < unsigned(V); }
-  operator unsigned() const { return Value; }
-  operator OpenMPDirectiveKind() const { return OpenMPDirectiveKind(Value); }
-  unsigned Value;
-};
-
 class DeclDirectiveListParserHelper final {
   SmallVector Identifiers;
   Parser *P;
@@ -97,130 +56,32 @@ class DeclDirectiveListParserHelper final {
 };
 } // namespace
 
-// Map token string to extended OMP token kind that are
-// OpenMPDirectiveKind + OpenMPDirectiveKindEx.
-static unsigned getOpenMPDirectiveKindEx(StringRef S) {
-  OpenMPDirectiveKindExWrapper DKind = getOpenMPDirectiveKind(S);
-  if (DKind != OMPD_unknown)
-return DKind;
-
-  return llvm::StringSwitch(S)
-  .Case("cancellation", OMPD_cancellation)
-  .Case("data", OMPD_data)
-  .Case("declare", OMPD_declare)
-  .Case("end", OMPD_end)
-  .Case("enter", OMPD_enter)
-  .Case("exit", OMPD_exit)
-  .Case("point", OMPD_point)
-  .Case("reduction", OMPD_reduction)
-  .Case("update", OMPD_update)
-  .Case("mapper", OMPD_mapper)
-  .Case("variant", OMPD_variant)
-  .Case("begin", OMPD_begin)
-  .Default(OMPD_unknown);
-}
+static OpenMPDirectiveKind parseOpenMPDirectiveKind(Parser &P) {
+  static const DirectiveNameParser DirParser;
+
+  const DirectiveNameParser::State *S = DirParser.initial();
 
-static OpenMPDirectiveKindExWrapper parseOpenMPDirectiveKind(Parser &P) {
-  // Array of foldings: F[i][0] F[i][1] ===> F[i][2].
-  // E.g.: OMPD_for OMPD_simd ===> OMPD_for_simd
-  // TODO: add other combined directives in topological order.
-  static const OpenMPDirectiveKindExWrapper F[][3] = {
-  {OMPD_begin, OMPD_declare, OMPD_begin_declare},
-  {OMPD_begin, OMPD_assumes, OMPD_begin_assumes},
-  {OMPD_end, OMPD_declare, OMPD_end_declare},
-  {OMPD_end, OMPD_assumes, OMPD_end_assumes},
-  {OMPD_cancellation, OMPD_point, OMPD_cancellation_point},
-  {OMPD_declare, OMPD_reduction, OMPD_declare_reduction},
-  {OMPD_declare, OMPD_mapper, OMPD_declare_mapper},
-  {OMPD_declare, OMPD_simd, OMPD_declare_simd},
-  {OMPD_declare, OMPD_target, OMPD_declare_target},
-  {OMPD_declare, OMPD_variant, OMPD_declare_variant},
-  {OMPD_begin_declare, OMPD_target, OMPD_begin_declare_target},
-  {OMPD_begin_declare, OMPD_variant, OMPD_begin_declare_variant},
-  {OMPD_end_declare, OMPD_variant, OMPD_end_declare_variant},
-  {OMPD_distribute, OMPD_parallel, OMPD_distribute_parallel},
-  {OMPD_distribute_parallel, OMPD_for, OMPD_distribute_parallel_for},
-  {OMPD_dist

[clang] [llvm] [clang][OpenMP] Issue a warning when parsing future directive spelling (PR #146933)

2025-07-07 Thread Krzysztof Parzyszek via cfe-commits

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


[clang] [llvm] [clang][OpenMP] Use DirectiveNameParser to parse directive names (PR #146779)

2025-07-07 Thread Krzysztof Parzyszek via cfe-commits

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


[clang-tools-extra] [clang-tidy][NFC] fix compilation by disambiguating equality operator (PR #147048)

2025-07-07 Thread Gregor Jasny via cfe-commits

gjasny wrote:

All builds are green, now.

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


[clang] [llvm] [clang][OpenMP] Issue a warning when parsing future directive spelling (PR #146933)

2025-07-07 Thread Krzysztof Parzyszek via cfe-commits

https://github.com/kparzysz updated 
https://github.com/llvm/llvm-project/pull/146933

>From 0e9eab649f7a515c0697c3fe58309c478108f6b1 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Wed, 2 Jul 2025 09:43:32 -0500
Subject: [PATCH 01/12] [Frontend][OpenMP] Implement directive name parser

Implement a state machine that consumes tokens (words delimited by white
space), and returns the corresponding directive id, or fails if the tokens
did not form a valid name.
---
 .../Frontend/OpenMP/DirectiveNameParser.h |  76 
 llvm/lib/Frontend/OpenMP/CMakeLists.txt   |   1 +
 .../Frontend/OpenMP/DirectiveNameParser.cpp   |  93 ++
 llvm/unittests/Frontend/CMakeLists.txt|   1 +
 .../OpenMPDirectiveNameParserTest.cpp | 171 ++
 5 files changed, 342 insertions(+)
 create mode 100644 llvm/include/llvm/Frontend/OpenMP/DirectiveNameParser.h
 create mode 100644 llvm/lib/Frontend/OpenMP/DirectiveNameParser.cpp
 create mode 100644 llvm/unittests/Frontend/OpenMPDirectiveNameParserTest.cpp

diff --git a/llvm/include/llvm/Frontend/OpenMP/DirectiveNameParser.h 
b/llvm/include/llvm/Frontend/OpenMP/DirectiveNameParser.h
new file mode 100644
index 0..db8986601b2ca
--- /dev/null
+++ b/llvm/include/llvm/Frontend/OpenMP/DirectiveNameParser.h
@@ -0,0 +1,76 @@
+//===- DirectiveNameParser.h  - 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_FRONTEND_OPENMP_DIRECTIVENAMEPARSER_H
+#define LLVM_FRONTEND_OPENMP_DIRECTIVENAMEPARSER_H
+
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Frontend/OpenMP/OMP.h"
+
+#include 
+
+namespace llvm::omp {
+/// Parser class for OpenMP directive names. It only recognizes names listed
+/// in OMP.td, in particular it does not recognize Fortran's end-directives
+/// if they are not explicitly listed in OMP.td.
+///
+/// The class itself may be a singleton, once it's constructed it never
+/// changes.
+///
+/// Usage:
+/// {
+///   DirectiveNameParser Parser;   // Could be static const.
+///
+///   DirectiveNameParser::State *S = Parser.initial();
+///   for (StringRef Token : Tokens)
+/// S = Parser.apply(S, Token); // Passing nullptr is ok.
+///
+///   if (S == nullptr) {
+/// // Error: ended up in a state from which there is no possible path
+/// // to a successful parse.
+///   } else if (S->Value == OMPD_unknown)
+/// // Parsed a sequence of tokens that are not a complete name, but
+/// // parsing more tokens could lead to a successful parse.
+///   } else {
+/// // Success.
+/// ParsedId = S->Value;
+///   }
+/// }
+struct DirectiveNameParser {
+  DirectiveNameParser(SourceLanguage L = SourceLanguage::C);
+
+  struct State {
+Directive Value = Directive::OMPD_unknown;
+
+  private:
+using TransitionMapTy = StringMap;
+std::unique_ptr Transition;
+
+State *next(StringRef Tok);
+bool isValid() const {
+  return Value != Directive::OMPD_unknown || !Transition->empty();
+}
+friend struct DirectiveNameParser;
+  };
+
+  const State *initial() const { return &InitialState; }
+  const State *apply(const State *Current, StringRef Tok) const;
+
+  static SmallVector tokenize(StringRef N);
+
+private:
+  void insertName(StringRef Name, Directive D);
+  State *insertTransition(State *From, StringRef Tok);
+
+  State InitialState;
+};
+} // namespace llvm::omp
+
+#endif // LLVM_FRONTEND_OPENMP_DIRECTIVENAMEPARSER_H
diff --git a/llvm/lib/Frontend/OpenMP/CMakeLists.txt 
b/llvm/lib/Frontend/OpenMP/CMakeLists.txt
index 5bf15ca3a8991..e60b59c1203b9 100644
--- a/llvm/lib/Frontend/OpenMP/CMakeLists.txt
+++ b/llvm/lib/Frontend/OpenMP/CMakeLists.txt
@@ -2,6 +2,7 @@ add_llvm_component_library(LLVMFrontendOpenMP
   OMP.cpp
   OMPContext.cpp
   OMPIRBuilder.cpp
+  DirectiveNameParser.cpp
 
   ADDITIONAL_HEADER_DIRS
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/Frontend
diff --git a/llvm/lib/Frontend/OpenMP/DirectiveNameParser.cpp 
b/llvm/lib/Frontend/OpenMP/DirectiveNameParser.cpp
new file mode 100644
index 0..02ff8327a3054
--- /dev/null
+++ b/llvm/lib/Frontend/OpenMP/DirectiveNameParser.cpp
@@ -0,0 +1,93 @@
+//===- DirectiveNameParser.cpp 
===//
+//
+// 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 "llvm/Frontend/OpenMP/DirectiveNameParser.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Frontend/OpenMP/OMP.h"
+
+#include 
+#inc

[clang] [llvm] [mlir] [DenseMap] Do not align pointer sentinel values (NFC) (PR #146595)

2025-07-07 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`sanitizer-x86_64-linux-fast` running on `sanitizer-buildbot4` while building 
`clang,llvm,mlir` at step 2 "annotate".

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


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

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using lld-link: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld64.lld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using wasm-ld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld.lld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld.lld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using lld-link: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld64.lld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using wasm-ld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/main.py:73:
 note: The test suite configuration requested an individual test timeout of 0 
seconds but a timeout of 900 seconds was requested on the command line. Forcing 
timeout to be 900 seconds.
-- Testing: 91041 tests, 96 workers --
Testing: 
FAIL: LLVM :: CodeGen/AMDGPU/global_atomics_scan_fsub.ll (1 of 91041)
 TEST 'LLVM :: CodeGen/AMDGPU/global_atomics_scan_fsub.ll' 
FAILED 
Exit Code: 2

Command Output (stderr):
--
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llc 
-mtriple=amdgcn -amdgpu-atomic-optimizer-strategy=Iterative 
-verify-machineinstrs < 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/AMDGPU/global_atomics_scan_fsub.ll
 | 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/FileCheck 
-enable-var-scope -check-prefix=GFX7LESS 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/AMDGPU/global_atomics_scan_fsub.ll
 # RUN: at line 2
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llc 
-mtriple=amdgcn -amdgpu-atomic-optimizer-strategy=Iterative 
-verify-machineinstrs
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/FileCheck 
-enable-var-scope -check-prefix=GFX7LESS 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/AMDGPU/global_atomics_scan_fsub.ll
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and 
include the crash backtrace.
Stack dump:
0.  Program arguments: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llc 
-mtriple=amdgcn -amdgpu-atomic-optimizer-strategy=Iterative 
-verify-machineinstrs
1.  Running pass 'Function Pass Manager' on module ''.
2.  Running pass 'Block Frequency Analysis' on function 
'@global_atomic_fsub_uni_address_uni_value_agent_scope_unsafe'
 #0 0x6471b2a47bf6 ___interceptor_backtrace 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:4497:13
 #1 0x6471babe68a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Support/Unix/Signals.inc:819:13
 #2 0x6471babe0509 llvm::sys::RunSignalHandlers() 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Support/Signals.cpp:0:5
 #3 0x6471babe87a7 SignalHandler(int, siginfo_t*, void*) 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Support/Unix/Signals.inc:0:3
 #4 0x79343ae45250 (/lib/x86_64-linux-gnu/libc.so.6+0x45250)
 #5 0x79343aea3f1c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0xa3f1c)
 #6 0x79343ae4519e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4519e)
 #7 0x79343ae28902 abort (/lib/x86_64-linux-gnu/libc.so.6+0x28902)
 #8 0x6471b2aca5ac 
(/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llc+0xbd7d5ac)
 #9 0x6471b2ac83de __sanitizer::Die() 
/home/b/sanitizer-x86_64-linux-fast

[clang] [Clang] accept @tparam on variable template partial specializations (PR #147219)

2025-07-07 Thread Corentin Jabot via cfe-commits

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


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


[clang] [llvm] [NFC][PowerPC] Add test case for lockdown of vector compare greater than support for Zero vector comparisons (PR #147246)

2025-07-07 Thread via cfe-commits

https://github.com/Himadhith created 
https://github.com/llvm/llvm-project/pull/147246

NFC patch to add testcase for locking down the support of Zero vector 
comparisons using the `vcmpgtuh (vector compare greater than unsigned 
halfword)` instruction. 
Currently `vcmpequh (vector compare equal unsigned halfword)` is in use.

>From dec770c9cee43bf13e334105f0aa1fd5bb6dd0b1 Mon Sep 17 00:00:00 2001
From: himadhith 
Date: Mon, 7 Jul 2025 07:31:59 +
Subject: [PATCH] NFC test cases lockdown for vector compare equal

---
 .../test/CodeGen/PowerPC/check-zero-vector.c  | 143 +++
 .../test/CodeGen/PowerPC/check-zero-vector.ll | 239 ++
 2 files changed, 382 insertions(+)
 create mode 100644 clang/test/CodeGen/PowerPC/check-zero-vector.c
 create mode 100644 llvm/test/CodeGen/PowerPC/check-zero-vector.ll

diff --git a/clang/test/CodeGen/PowerPC/check-zero-vector.c 
b/clang/test/CodeGen/PowerPC/check-zero-vector.c
new file mode 100644
index 0..82f782faf9a5e
--- /dev/null
+++ b/clang/test/CodeGen/PowerPC/check-zero-vector.c
@@ -0,0 +1,143 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// RUN: %clang_cc1  -triple powerpc64-unknown-unknown -emit-llvm %s -o -  | 
FileCheck %s --check-prefix=POWERPC_64
+// RUN: %clang_cc1  -triple powerpc64le-unknown-unknown -emit-llvm %s -o -  | 
FileCheck %s --check-prefix=POWERPC_64LE
+// RUN: %clang_cc1  -triple powerpc-unknown-unknown -emit-llvm %s -o -  | 
FileCheck %s --check-prefix=POWERPC_32
+
+// POWERPC_64-LABEL: define dso_local signext i32 @test_Greater_than(
+// POWERPC_64-SAME: ptr noundef [[COLAUTHS:%.*]]) #[[ATTR0:[0-9]+]] {
+// POWERPC_64-NEXT:  [[ENTRY:.*:]]
+// POWERPC_64-NEXT:[[COLAUTHS_ADDR:%.*]] = alloca ptr, align 8
+// POWERPC_64-NEXT:[[RESULT:%.*]] = alloca i16, align 2
+// POWERPC_64-NEXT:[[I:%.*]] = alloca i32, align 4
+// POWERPC_64-NEXT:store ptr [[COLAUTHS]], ptr [[COLAUTHS_ADDR]], align 8
+// POWERPC_64-NEXT:store i16 0, ptr [[RESULT]], align 2
+// POWERPC_64-NEXT:store i32 0, ptr [[I]], align 4
+// POWERPC_64-NEXT:br label %[[FOR_COND:.*]]
+// POWERPC_64:   [[FOR_COND]]:
+// POWERPC_64-NEXT:[[TMP0:%.*]] = load i32, ptr [[I]], align 4
+// POWERPC_64-NEXT:[[CMP:%.*]] = icmp slt i32 [[TMP0]], 4
+// POWERPC_64-NEXT:br i1 [[CMP]], label %[[FOR_BODY:.*]], label 
%[[FOR_END:.*]]
+// POWERPC_64:   [[FOR_BODY]]:
+// POWERPC_64-NEXT:[[TMP1:%.*]] = load ptr, ptr [[COLAUTHS_ADDR]], align 8
+// POWERPC_64-NEXT:[[TMP2:%.*]] = load i32, ptr [[I]], align 4
+// POWERPC_64-NEXT:[[IDXPROM:%.*]] = sext i32 [[TMP2]] to i64
+// POWERPC_64-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i16, ptr 
[[TMP1]], i64 [[IDXPROM]]
+// POWERPC_64-NEXT:[[TMP3:%.*]] = load i16, ptr [[ARRAYIDX]], align 2
+// POWERPC_64-NEXT:[[CONV:%.*]] = zext i16 [[TMP3]] to i32
+// POWERPC_64-NEXT:[[CMP1:%.*]] = icmp sgt i32 [[CONV]], 0
+// POWERPC_64-NEXT:br i1 [[CMP1]], label %[[IF_THEN:.*]], label 
%[[IF_END:.*]]
+// POWERPC_64:   [[IF_THEN]]:
+// POWERPC_64-NEXT:[[TMP4:%.*]] = load i16, ptr [[RESULT]], align 2
+// POWERPC_64-NEXT:[[INC:%.*]] = add i16 [[TMP4]], 1
+// POWERPC_64-NEXT:store i16 [[INC]], ptr [[RESULT]], align 2
+// POWERPC_64-NEXT:br label %[[IF_END]]
+// POWERPC_64:   [[IF_END]]:
+// POWERPC_64-NEXT:br label %[[FOR_INC:.*]]
+// POWERPC_64:   [[FOR_INC]]:
+// POWERPC_64-NEXT:[[TMP5:%.*]] = load i32, ptr [[I]], align 4
+// POWERPC_64-NEXT:[[INC3:%.*]] = add nsw i32 [[TMP5]], 1
+// POWERPC_64-NEXT:store i32 [[INC3]], ptr [[I]], align 4
+// POWERPC_64-NEXT:br label %[[FOR_COND]], !llvm.loop [[LOOP2:![0-9]+]]
+// POWERPC_64:   [[FOR_END]]:
+// POWERPC_64-NEXT:[[TMP6:%.*]] = load i16, ptr [[RESULT]], align 2
+// POWERPC_64-NEXT:[[CONV4:%.*]] = zext i16 [[TMP6]] to i32
+// POWERPC_64-NEXT:ret i32 [[CONV4]]
+//
+// POWERPC_64LE-LABEL: define dso_local signext i32 @test_Greater_than(
+// POWERPC_64LE-SAME: ptr noundef [[COLAUTHS:%.*]]) #[[ATTR0:[0-9]+]] {
+// POWERPC_64LE-NEXT:  [[ENTRY:.*:]]
+// POWERPC_64LE-NEXT:[[COLAUTHS_ADDR:%.*]] = alloca ptr, align 8
+// POWERPC_64LE-NEXT:[[RESULT:%.*]] = alloca i16, align 2
+// POWERPC_64LE-NEXT:[[I:%.*]] = alloca i32, align 4
+// POWERPC_64LE-NEXT:store ptr [[COLAUTHS]], ptr [[COLAUTHS_ADDR]], align 8
+// POWERPC_64LE-NEXT:store i16 0, ptr [[RESULT]], align 2
+// POWERPC_64LE-NEXT:store i32 0, ptr [[I]], align 4
+// POWERPC_64LE-NEXT:br label %[[FOR_COND:.*]]
+// POWERPC_64LE:   [[FOR_COND]]:
+// POWERPC_64LE-NEXT:[[TMP0:%.*]] = load i32, ptr [[I]], align 4
+// POWERPC_64LE-NEXT:[[CMP:%.*]] = icmp slt i32 [[TMP0]], 4
+// POWERPC_64LE-NEXT:br i1 [[CMP]], label %[[FOR_BODY:.*]], label 
%[[FOR_END:.*]]
+// POWERPC_64LE:   [[FOR_BODY]]:
+// POWERPC_64LE-NEXT:[[TMP1:%.*]] = load ptr, ptr [[COLAUTHS_ADDR]], align 
8
+// POWERPC_64LE-NEXT:[[TMP2:%.*]] = load i32, ptr [

[clang] [llvm] [NFC][PowerPC] Add test case for lockdown of vector compare greater than support for Zero vector comparisons (PR #147246)

2025-07-07 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-powerpc

Author: None (Himadhith)


Changes

NFC patch to add testcase for locking down the support of Zero vector 
comparisons using the `vcmpgtuh (vector compare greater than unsigned 
halfword)` instruction. 
Currently `vcmpequh (vector compare equal unsigned halfword)` is in use.

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


2 Files Affected:

- (added) clang/test/CodeGen/PowerPC/check-zero-vector.c (+143) 
- (added) llvm/test/CodeGen/PowerPC/check-zero-vector.ll (+239) 


``diff
diff --git a/clang/test/CodeGen/PowerPC/check-zero-vector.c 
b/clang/test/CodeGen/PowerPC/check-zero-vector.c
new file mode 100644
index 0..82f782faf9a5e
--- /dev/null
+++ b/clang/test/CodeGen/PowerPC/check-zero-vector.c
@@ -0,0 +1,143 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// RUN: %clang_cc1  -triple powerpc64-unknown-unknown -emit-llvm %s -o -  | 
FileCheck %s --check-prefix=POWERPC_64
+// RUN: %clang_cc1  -triple powerpc64le-unknown-unknown -emit-llvm %s -o -  | 
FileCheck %s --check-prefix=POWERPC_64LE
+// RUN: %clang_cc1  -triple powerpc-unknown-unknown -emit-llvm %s -o -  | 
FileCheck %s --check-prefix=POWERPC_32
+
+// POWERPC_64-LABEL: define dso_local signext i32 @test_Greater_than(
+// POWERPC_64-SAME: ptr noundef [[COLAUTHS:%.*]]) #[[ATTR0:[0-9]+]] {
+// POWERPC_64-NEXT:  [[ENTRY:.*:]]
+// POWERPC_64-NEXT:[[COLAUTHS_ADDR:%.*]] = alloca ptr, align 8
+// POWERPC_64-NEXT:[[RESULT:%.*]] = alloca i16, align 2
+// POWERPC_64-NEXT:[[I:%.*]] = alloca i32, align 4
+// POWERPC_64-NEXT:store ptr [[COLAUTHS]], ptr [[COLAUTHS_ADDR]], align 8
+// POWERPC_64-NEXT:store i16 0, ptr [[RESULT]], align 2
+// POWERPC_64-NEXT:store i32 0, ptr [[I]], align 4
+// POWERPC_64-NEXT:br label %[[FOR_COND:.*]]
+// POWERPC_64:   [[FOR_COND]]:
+// POWERPC_64-NEXT:[[TMP0:%.*]] = load i32, ptr [[I]], align 4
+// POWERPC_64-NEXT:[[CMP:%.*]] = icmp slt i32 [[TMP0]], 4
+// POWERPC_64-NEXT:br i1 [[CMP]], label %[[FOR_BODY:.*]], label 
%[[FOR_END:.*]]
+// POWERPC_64:   [[FOR_BODY]]:
+// POWERPC_64-NEXT:[[TMP1:%.*]] = load ptr, ptr [[COLAUTHS_ADDR]], align 8
+// POWERPC_64-NEXT:[[TMP2:%.*]] = load i32, ptr [[I]], align 4
+// POWERPC_64-NEXT:[[IDXPROM:%.*]] = sext i32 [[TMP2]] to i64
+// POWERPC_64-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i16, ptr 
[[TMP1]], i64 [[IDXPROM]]
+// POWERPC_64-NEXT:[[TMP3:%.*]] = load i16, ptr [[ARRAYIDX]], align 2
+// POWERPC_64-NEXT:[[CONV:%.*]] = zext i16 [[TMP3]] to i32
+// POWERPC_64-NEXT:[[CMP1:%.*]] = icmp sgt i32 [[CONV]], 0
+// POWERPC_64-NEXT:br i1 [[CMP1]], label %[[IF_THEN:.*]], label 
%[[IF_END:.*]]
+// POWERPC_64:   [[IF_THEN]]:
+// POWERPC_64-NEXT:[[TMP4:%.*]] = load i16, ptr [[RESULT]], align 2
+// POWERPC_64-NEXT:[[INC:%.*]] = add i16 [[TMP4]], 1
+// POWERPC_64-NEXT:store i16 [[INC]], ptr [[RESULT]], align 2
+// POWERPC_64-NEXT:br label %[[IF_END]]
+// POWERPC_64:   [[IF_END]]:
+// POWERPC_64-NEXT:br label %[[FOR_INC:.*]]
+// POWERPC_64:   [[FOR_INC]]:
+// POWERPC_64-NEXT:[[TMP5:%.*]] = load i32, ptr [[I]], align 4
+// POWERPC_64-NEXT:[[INC3:%.*]] = add nsw i32 [[TMP5]], 1
+// POWERPC_64-NEXT:store i32 [[INC3]], ptr [[I]], align 4
+// POWERPC_64-NEXT:br label %[[FOR_COND]], !llvm.loop [[LOOP2:![0-9]+]]
+// POWERPC_64:   [[FOR_END]]:
+// POWERPC_64-NEXT:[[TMP6:%.*]] = load i16, ptr [[RESULT]], align 2
+// POWERPC_64-NEXT:[[CONV4:%.*]] = zext i16 [[TMP6]] to i32
+// POWERPC_64-NEXT:ret i32 [[CONV4]]
+//
+// POWERPC_64LE-LABEL: define dso_local signext i32 @test_Greater_than(
+// POWERPC_64LE-SAME: ptr noundef [[COLAUTHS:%.*]]) #[[ATTR0:[0-9]+]] {
+// POWERPC_64LE-NEXT:  [[ENTRY:.*:]]
+// POWERPC_64LE-NEXT:[[COLAUTHS_ADDR:%.*]] = alloca ptr, align 8
+// POWERPC_64LE-NEXT:[[RESULT:%.*]] = alloca i16, align 2
+// POWERPC_64LE-NEXT:[[I:%.*]] = alloca i32, align 4
+// POWERPC_64LE-NEXT:store ptr [[COLAUTHS]], ptr [[COLAUTHS_ADDR]], align 8
+// POWERPC_64LE-NEXT:store i16 0, ptr [[RESULT]], align 2
+// POWERPC_64LE-NEXT:store i32 0, ptr [[I]], align 4
+// POWERPC_64LE-NEXT:br label %[[FOR_COND:.*]]
+// POWERPC_64LE:   [[FOR_COND]]:
+// POWERPC_64LE-NEXT:[[TMP0:%.*]] = load i32, ptr [[I]], align 4
+// POWERPC_64LE-NEXT:[[CMP:%.*]] = icmp slt i32 [[TMP0]], 4
+// POWERPC_64LE-NEXT:br i1 [[CMP]], label %[[FOR_BODY:.*]], label 
%[[FOR_END:.*]]
+// POWERPC_64LE:   [[FOR_BODY]]:
+// POWERPC_64LE-NEXT:[[TMP1:%.*]] = load ptr, ptr [[COLAUTHS_ADDR]], align 
8
+// POWERPC_64LE-NEXT:[[TMP2:%.*]] = load i32, ptr [[I]], align 4
+// POWERPC_64LE-NEXT:[[IDXPROM:%.*]] = sext i32 [[TMP2]] to i64
+// POWERPC_64LE-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i16, ptr 
[[TMP1]], i64 [[IDXPROM]]
+// POWERPC_64LE-NEXT:[[TMP3:%.*]] = load i16, ptr [[ARRAYIDX]], align 2

[clang] [llvm] [NFC][PowerPC] Add test case for lockdown of vector compare greater than support for Zero vector comparisons (PR #147246)

2025-07-07 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (Himadhith)


Changes

NFC patch to add testcase for locking down the support of Zero vector 
comparisons using the `vcmpgtuh (vector compare greater than unsigned 
halfword)` instruction. 
Currently `vcmpequh (vector compare equal unsigned halfword)` is in use.

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


2 Files Affected:

- (added) clang/test/CodeGen/PowerPC/check-zero-vector.c (+143) 
- (added) llvm/test/CodeGen/PowerPC/check-zero-vector.ll (+239) 


``diff
diff --git a/clang/test/CodeGen/PowerPC/check-zero-vector.c 
b/clang/test/CodeGen/PowerPC/check-zero-vector.c
new file mode 100644
index 0..82f782faf9a5e
--- /dev/null
+++ b/clang/test/CodeGen/PowerPC/check-zero-vector.c
@@ -0,0 +1,143 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// RUN: %clang_cc1  -triple powerpc64-unknown-unknown -emit-llvm %s -o -  | 
FileCheck %s --check-prefix=POWERPC_64
+// RUN: %clang_cc1  -triple powerpc64le-unknown-unknown -emit-llvm %s -o -  | 
FileCheck %s --check-prefix=POWERPC_64LE
+// RUN: %clang_cc1  -triple powerpc-unknown-unknown -emit-llvm %s -o -  | 
FileCheck %s --check-prefix=POWERPC_32
+
+// POWERPC_64-LABEL: define dso_local signext i32 @test_Greater_than(
+// POWERPC_64-SAME: ptr noundef [[COLAUTHS:%.*]]) #[[ATTR0:[0-9]+]] {
+// POWERPC_64-NEXT:  [[ENTRY:.*:]]
+// POWERPC_64-NEXT:[[COLAUTHS_ADDR:%.*]] = alloca ptr, align 8
+// POWERPC_64-NEXT:[[RESULT:%.*]] = alloca i16, align 2
+// POWERPC_64-NEXT:[[I:%.*]] = alloca i32, align 4
+// POWERPC_64-NEXT:store ptr [[COLAUTHS]], ptr [[COLAUTHS_ADDR]], align 8
+// POWERPC_64-NEXT:store i16 0, ptr [[RESULT]], align 2
+// POWERPC_64-NEXT:store i32 0, ptr [[I]], align 4
+// POWERPC_64-NEXT:br label %[[FOR_COND:.*]]
+// POWERPC_64:   [[FOR_COND]]:
+// POWERPC_64-NEXT:[[TMP0:%.*]] = load i32, ptr [[I]], align 4
+// POWERPC_64-NEXT:[[CMP:%.*]] = icmp slt i32 [[TMP0]], 4
+// POWERPC_64-NEXT:br i1 [[CMP]], label %[[FOR_BODY:.*]], label 
%[[FOR_END:.*]]
+// POWERPC_64:   [[FOR_BODY]]:
+// POWERPC_64-NEXT:[[TMP1:%.*]] = load ptr, ptr [[COLAUTHS_ADDR]], align 8
+// POWERPC_64-NEXT:[[TMP2:%.*]] = load i32, ptr [[I]], align 4
+// POWERPC_64-NEXT:[[IDXPROM:%.*]] = sext i32 [[TMP2]] to i64
+// POWERPC_64-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i16, ptr 
[[TMP1]], i64 [[IDXPROM]]
+// POWERPC_64-NEXT:[[TMP3:%.*]] = load i16, ptr [[ARRAYIDX]], align 2
+// POWERPC_64-NEXT:[[CONV:%.*]] = zext i16 [[TMP3]] to i32
+// POWERPC_64-NEXT:[[CMP1:%.*]] = icmp sgt i32 [[CONV]], 0
+// POWERPC_64-NEXT:br i1 [[CMP1]], label %[[IF_THEN:.*]], label 
%[[IF_END:.*]]
+// POWERPC_64:   [[IF_THEN]]:
+// POWERPC_64-NEXT:[[TMP4:%.*]] = load i16, ptr [[RESULT]], align 2
+// POWERPC_64-NEXT:[[INC:%.*]] = add i16 [[TMP4]], 1
+// POWERPC_64-NEXT:store i16 [[INC]], ptr [[RESULT]], align 2
+// POWERPC_64-NEXT:br label %[[IF_END]]
+// POWERPC_64:   [[IF_END]]:
+// POWERPC_64-NEXT:br label %[[FOR_INC:.*]]
+// POWERPC_64:   [[FOR_INC]]:
+// POWERPC_64-NEXT:[[TMP5:%.*]] = load i32, ptr [[I]], align 4
+// POWERPC_64-NEXT:[[INC3:%.*]] = add nsw i32 [[TMP5]], 1
+// POWERPC_64-NEXT:store i32 [[INC3]], ptr [[I]], align 4
+// POWERPC_64-NEXT:br label %[[FOR_COND]], !llvm.loop [[LOOP2:![0-9]+]]
+// POWERPC_64:   [[FOR_END]]:
+// POWERPC_64-NEXT:[[TMP6:%.*]] = load i16, ptr [[RESULT]], align 2
+// POWERPC_64-NEXT:[[CONV4:%.*]] = zext i16 [[TMP6]] to i32
+// POWERPC_64-NEXT:ret i32 [[CONV4]]
+//
+// POWERPC_64LE-LABEL: define dso_local signext i32 @test_Greater_than(
+// POWERPC_64LE-SAME: ptr noundef [[COLAUTHS:%.*]]) #[[ATTR0:[0-9]+]] {
+// POWERPC_64LE-NEXT:  [[ENTRY:.*:]]
+// POWERPC_64LE-NEXT:[[COLAUTHS_ADDR:%.*]] = alloca ptr, align 8
+// POWERPC_64LE-NEXT:[[RESULT:%.*]] = alloca i16, align 2
+// POWERPC_64LE-NEXT:[[I:%.*]] = alloca i32, align 4
+// POWERPC_64LE-NEXT:store ptr [[COLAUTHS]], ptr [[COLAUTHS_ADDR]], align 8
+// POWERPC_64LE-NEXT:store i16 0, ptr [[RESULT]], align 2
+// POWERPC_64LE-NEXT:store i32 0, ptr [[I]], align 4
+// POWERPC_64LE-NEXT:br label %[[FOR_COND:.*]]
+// POWERPC_64LE:   [[FOR_COND]]:
+// POWERPC_64LE-NEXT:[[TMP0:%.*]] = load i32, ptr [[I]], align 4
+// POWERPC_64LE-NEXT:[[CMP:%.*]] = icmp slt i32 [[TMP0]], 4
+// POWERPC_64LE-NEXT:br i1 [[CMP]], label %[[FOR_BODY:.*]], label 
%[[FOR_END:.*]]
+// POWERPC_64LE:   [[FOR_BODY]]:
+// POWERPC_64LE-NEXT:[[TMP1:%.*]] = load ptr, ptr [[COLAUTHS_ADDR]], align 
8
+// POWERPC_64LE-NEXT:[[TMP2:%.*]] = load i32, ptr [[I]], align 4
+// POWERPC_64LE-NEXT:[[IDXPROM:%.*]] = sext i32 [[TMP2]] to i64
+// POWERPC_64LE-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i16, ptr 
[[TMP1]], i64 [[IDXPROM]]
+// POWERPC_64LE-NEXT:[[TMP3:%.*]] = load i16, ptr [[ARRAYIDX]], align 2
+// POWER

[clang] [clang][CompundLiteralExpr] Don't defer evaluation for CLEs (PR #137163)

2025-07-07 Thread kadir çetinkaya via cfe-commits


@@ -9125,9 +9126,25 @@ bool
 LValueExprEvaluator::VisitCompoundLiteralExpr(const CompoundLiteralExpr *E) {
   assert((!Info.getLangOpts().CPlusPlus || E->isFileScope()) &&
  "lvalue compound literal in c++?");
-  // Defer visiting the literal until the lvalue-to-rvalue conversion. We can
-  // only see this when folding in C, so there's no standard to follow here.
-  return Success(E);
+  APValue *Lit;
+  // If CompountLiteral has static storage, its value can be used outside
+  // this expression. So evaluate it once and store it in ASTContext.
+  if (E->hasStaticStorage()) {
+Lit = E->getOrCreateStaticValue(Info.Ctx);
+Result.set(E);
+// Reset any previously evaluated state, otherwise evaluation below might
+// fail.
+// FIXME: Should we just re-use the previously evaluated value instead?
+*Lit = APValue();

kadircet wrote:

> It's not really about whether we re-evaluate it, it's about whether we 
> evaluate it in the right context

Thanks, you're right. But I think that's about usage of `EvaluateInPlace`, 
rather than resetting and re-evaluating expression here. Added another comment 
next to it.

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


[clang] 784bd61 - [clang] Speedup getFileIDLocal with a separate offset table. (#146604)

2025-07-07 Thread via cfe-commits

Author: Haojian Wu
Date: 2025-07-07T09:42:38+02:00
New Revision: 784bd61fc497b11a6d8d30abb6157c8a3597ffbf

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

LOG: [clang] Speedup getFileIDLocal with a separate offset table. (#146604)

The `SLocEntry` structure is 24 bytes, and the binary search only needs
the offset. Loading an entry's offset might pull the entire SLocEntry
object into the CPU cache.

To make the binary search much more cache-efficient, we use a separate
offset table.

See
https://llvm-compile-time-tracker.com/compare.php?from=650d0151c623c123e4e9736fe50421624a329260&to=6af564c0d75aff28a2784a8554448c0679877792&stat=instructions:u.

Added: 


Modified: 
clang/include/clang/Basic/SourceManager.h
clang/lib/Basic/SourceManager.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index a90cc70825ffd..ed967fd47dc83 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -719,6 +719,8 @@ class SourceManager : public RefCountedBase {
   /// Positive FileIDs are indexes into this table. Entry 0 indicates an 
invalid
   /// expansion.
   SmallVector LocalSLocEntryTable;
+  /// An in-parallel offset table, merely used for speeding up FileID lookup.
+  SmallVector LocalLocOffsetTable;
 
   /// The table of SLocEntries that are loaded from other modules.
   ///

diff  --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 7d1b23bbc3b2c..79a0d9d28c40b 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -329,6 +329,7 @@ SourceManager::~SourceManager() {
 void SourceManager::clearIDTables() {
   MainFileID = FileID();
   LocalSLocEntryTable.clear();
+  LocalLocOffsetTable.clear();
   LoadedSLocEntryTable.clear();
   SLocEntryLoaded.clear();
   SLocEntryOffsetLoaded.clear();
@@ -628,9 +629,11 @@ FileID SourceManager::createFileIDImpl(ContentCache &File, 
StringRef Filename,
 noteSLocAddressSpaceUsage(Diag);
 return FileID();
   }
+  assert(LocalSLocEntryTable.size() == LocalLocOffsetTable.size());
   LocalSLocEntryTable.push_back(
   SLocEntry::get(NextLocalOffset,
  FileInfo::get(IncludePos, File, FileCharacter, 
Filename)));
+  LocalLocOffsetTable.push_back(NextLocalOffset);
   LastLookupStartOffset = NextLocalOffset;
   // 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.
@@ -684,7 +687,9 @@ SourceManager::createExpansionLocImpl(const ExpansionInfo 
&Info,
 SLocEntryLoaded[Index] = SLocEntryOffsetLoaded[Index] = true;
 return SourceLocation::getMacroLoc(LoadedOffset);
   }
+  assert(LocalSLocEntryTable.size() == LocalLocOffsetTable.size());
   LocalSLocEntryTable.push_back(SLocEntry::get(NextLocalOffset, Info));
+  LocalLocOffsetTable.push_back(NextLocalOffset);
   if (NextLocalOffset + Length + 1 <= NextLocalOffset ||
   NextLocalOffset + Length + 1 > CurrentLoadedOffset) {
 Diag.Report(diag::err_sloc_space_too_large);
@@ -807,6 +812,7 @@ FileID SourceManager::getFileIDLocal(SourceLocation::UIntTy 
SLocOffset) const {
   assert(SLocOffset < NextLocalOffset && "Bad function choice");
   assert(SLocOffset >= LocalSLocEntryTable[0].getOffset() && SLocOffset > 0 &&
  "Invalid SLocOffset");
+  assert(LocalSLocEntryTable.size() == LocalLocOffsetTable.size());
   assert(LastFileIDLookup.ID >= 0 && "Only cache local file sloc entry");
 
   // After the first and second level caches, I see two common sorts of
@@ -837,8 +843,8 @@ FileID SourceManager::getFileIDLocal(SourceLocation::UIntTy 
SLocOffset) const {
   unsigned NumProbes = 0;
   while (true) {
 --GreaterIndex;
-assert(GreaterIndex < LocalSLocEntryTable.size());
-if (LocalSLocEntryTable[GreaterIndex].getOffset() <= SLocOffset) {
+assert(GreaterIndex < LocalLocOffsetTable.size());
+if (LocalLocOffsetTable[GreaterIndex] <= SLocOffset) {
   FileID Res = FileID::get(int(GreaterIndex));
   // Remember it.  We have good locality across FileID lookups.
   LastFileIDLookup = Res;
@@ -858,11 +864,7 @@ FileID 
SourceManager::getFileIDLocal(SourceLocation::UIntTy SLocOffset) const {
 ++NumBinaryProbes;
 
 unsigned MiddleIndex = LessIndex + (GreaterIndex - LessIndex) / 2;
-
-SourceLocation::UIntTy MidOffset =
-LocalSLocEntryTable[MiddleIndex].getOffset();
-
-if (MidOffset <= SLocOffset)
+if (LocalLocOffsetTable[MiddleIndex] <= SLocOffset)
   LessIndex = MiddleIndex + 1;
 else
   GreaterIndex = MiddleIndex;



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

[clang] [clang] Speedup getFileIDLocal with a separate offset table. (PR #146604)

2025-07-07 Thread Haojian Wu via cfe-commits

hokein wrote:

I'm landing this PR now, happy to address any post comments.

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


[clang] [llvm] [NFC][PowerPC] Add test case for lockdown of vector compare greater than support for Zero vector comparisons (PR #147246)

2025-07-07 Thread via cfe-commits

Himadhith wrote:

@tonykuttai @AditiRM @lei137 @amy-kwan @kamaub 

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


[clang-tools-extra] [clang-tidy] Make `bugprone-unhandled-self-assignment` check more general (PR #147066)

2025-07-07 Thread Andrey Karlov via cfe-commits

https://github.com/negativ updated 
https://github.com/llvm/llvm-project/pull/147066

>From 950b6dce92eb2a831e7bd7e7ba44b3e8cc354dd4 Mon Sep 17 00:00:00 2001
From: Andrey Karlov 
Date: Fri, 4 Jul 2025 17:13:20 +0300
Subject: [PATCH 1/3] Checking that some kind of constructor is called and
 followed by a `swap`

---
 .../bugprone/UnhandledSelfAssignmentCheck.cpp | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git 
a/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
index 1f432c4ccc5f0..8307e744a434c 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
@@ -68,7 +68,23 @@ void 
UnhandledSelfAssignmentCheck::registerMatchers(MatchFinder *Finder) {
   const auto HasNoNestedSelfAssign =
   
cxxMethodDecl(unless(hasDescendant(cxxMemberCallExpr(callee(cxxMethodDecl(
   hasName("operator="), ofClass(equalsBoundNode("class";
-
+  
+  // Checking that some kind of constructor is called and followed by a `swap`:
+  // T& operator=(const T& other) {
+  //T tmp{this->internal_data(), some, other, args};
+  //swap(tmp);
+  //return *this;
+  // }
+  const auto HasCopyAndSwap = cxxMethodDecl(
+  ofClass(cxxRecordDecl(unless(hasAncestor(classTemplateDecl(),
+  hasDescendant(
+  stmt(hasDescendant(
+   varDecl(hasType(cxxRecordDecl(equalsBoundNode("class"
+   .bind("tmp_var")),
+   hasDescendant(callExpr(callee(functionDecl(hasName("swap"))),
+  hasAnyArgument(declRefExpr(to(varDecl(
+  equalsBoundNode("tmp_var"));
+
   DeclarationMatcher AdditionalMatcher = cxxMethodDecl();
   if (WarnOnlyIfThisHasSuspiciousField) {
 // Matcher for standard smart pointers.
@@ -94,6 +110,7 @@ void 
UnhandledSelfAssignmentCheck::registerMatchers(MatchFinder *Finder) {
HasReferenceParam, HasNoSelfCheck,
unless(HasNonTemplateSelfCopy),
unless(HasTemplateSelfCopy),
+   unless(HasCopyAndSwap),
HasNoNestedSelfAssign, AdditionalMatcher)
  .bind("copyAssignmentOperator"),
  this);

>From 0cd33ec49693cfc6f5a72b72a9c50ba868634221 Mon Sep 17 00:00:00 2001
From: Andrey Karlov 
Date: Fri, 4 Jul 2025 17:19:02 +0300
Subject: [PATCH 2/3] Tests

---
 .../bugprone/unhandled-self-assignment.cpp| 90 +++
 1 file changed, 90 insertions(+)

diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-self-assignment.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-self-assignment.cpp
index 8610393449f97..f2f61062f883f 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-self-assignment.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-self-assignment.cpp
@@ -28,6 +28,13 @@ template 
 class auto_ptr {
 };
 
+namespace pmr {
+template 
+class allocator {};
+}
+
+struct allocator_arg_t {} allocator_arg;
+
 } // namespace std
 
 void assert(int expression){};
@@ -540,6 +547,89 @@ class NotACopyAssignmentOperator {
   Uy *getUy() const { return Ptr2; }
 };
 
+// Support "extended" copy/move constructors
+class AllocatorAwareClass {
+  // pointer member to trigger bugprone-unhandled-self-assignment
+  void *foo = nullptr;
+
+  public:
+using allocator_type = std::pmr::allocator<>;
+
+AllocatorAwareClass(const AllocatorAwareClass& other) {
+}
+
+AllocatorAwareClass(const AllocatorAwareClass& other, const 
allocator_type& alloc) {
+}
+
+AllocatorAwareClass& operator=(const AllocatorAwareClass& other) {
+AllocatorAwareClass tmp(other, get_allocator());
+swap(tmp);
+return *this;
+}
+
+void swap(AllocatorAwareClass& other) noexcept {
+}
+
+allocator_type get_allocator() const {
+return allocator_type();
+}
+};
+
+// Support "extended" copy/move constructors + std::swap
+class AllocatorAwareClassStdSwap {
+  // pointer member to trigger bugprone-unhandled-self-assignment
+  void *foo = nullptr;
+
+  public:
+using allocator_type = std::pmr::allocator<>;
+
+AllocatorAwareClassStdSwap(const AllocatorAwareClassStdSwap& other) {
+}
+
+AllocatorAwareClassStdSwap(const AllocatorAwareClassStdSwap& other, const 
allocator_type& alloc) {
+}
+
+AllocatorAwareClassStdSwap& operator=(const AllocatorAwareClassStdSwap& 
other) {
+using std::swap;
+
+AllocatorAwareClassStdSwap tmp(other, get_allocator());
+swap(*this, tmp);
+return *this;
+}
+
+allocator_type get_allocator() const {
+re

[clang] [llvm] [mlir] [DenseMap] Do not align pointer sentinel values (NFC) (PR #146595)

2025-07-07 Thread Nikita Popov via cfe-commits

https://github.com/nikic updated 
https://github.com/llvm/llvm-project/pull/146595

>From 28d67e3da912a0f6b09921874d1beb35a0548816 Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Tue, 1 Jul 2025 13:51:43 +0200
Subject: [PATCH 1/3] [DenseMap] Do not align pointer sentinel values (NFC)

DenseMapInfo for pointers currently uses empty/tombstone values
that are aligned (by assuming a very conservative alignment).
However, this means that we have to work with large immediates.

This patch proposed to use the values -1 and -2 instead, without
caring about pointer alignment. This puts us into unspecified
territory from the perspective of the C standard, but it is
Clang's explicit position that raw pointers do not carry alignment
guarantees (only accesses do).

We already have lots of places that do variations on
`reinterpret_cast(-1)` and assume that to work, so I'm not
sure it's worthwhile to be strictly standards conforming in this
single place.
---
 llvm/include/llvm/ADT/DenseMapInfo.h | 25 -
 llvm/include/llvm/ADT/PointerUnion.h | 14 ++
 2 files changed, 14 insertions(+), 25 deletions(-)

diff --git a/llvm/include/llvm/ADT/DenseMapInfo.h 
b/llvm/include/llvm/ADT/DenseMapInfo.h
index 07c37e353a40b..b371611e7d948 100644
--- a/llvm/include/llvm/ADT/DenseMapInfo.h
+++ b/llvm/include/llvm/ADT/DenseMapInfo.h
@@ -56,30 +56,13 @@ struct DenseMapInfo {
   //static bool isEqual(const T &LHS, const T &RHS);
 };
 
-// Provide DenseMapInfo for all pointers. Come up with sentinel pointer values
-// that are aligned to alignof(T) bytes, but try to avoid requiring T to be
-// complete. This allows clients to instantiate DenseMap with forward
-// declared key types. Assume that no pointer key type requires more than 4096
-// bytes of alignment.
-template
-struct DenseMapInfo {
-  // The following should hold, but it would require T to be complete:
-  // static_assert(alignof(T) <= (1 << Log2MaxAlign),
-  //   "DenseMap does not support pointer keys requiring more than 
"
-  //   "Log2MaxAlign bits of alignment");
-  static constexpr uintptr_t Log2MaxAlign = 12;
-
+template  struct DenseMapInfo {
   static inline T* getEmptyKey() {
-uintptr_t Val = static_cast(-1);
-Val <<= Log2MaxAlign;
-return reinterpret_cast(Val);
+// We assume that raw pointers do not carry alignment requirements.
+return reinterpret_cast(-1);
   }
 
-  static inline T* getTombstoneKey() {
-uintptr_t Val = static_cast(-2);
-Val <<= Log2MaxAlign;
-return reinterpret_cast(Val);
-  }
+  static inline T *getTombstoneKey() { return reinterpret_cast(-2); }
 
   static unsigned getHashValue(const T *PtrVal) {
 return (unsigned((uintptr_t)PtrVal) >> 4) ^
diff --git a/llvm/include/llvm/ADT/PointerUnion.h 
b/llvm/include/llvm/ADT/PointerUnion.h
index cdbd76d7f505b..86248a2cf836f 100644
--- a/llvm/include/llvm/ADT/PointerUnion.h
+++ b/llvm/include/llvm/ADT/PointerUnion.h
@@ -286,13 +286,19 @@ struct PointerLikeTypeTraits> {
 // Teach DenseMap how to use PointerUnions as keys.
 template  struct DenseMapInfo> {
   using Union = PointerUnion;
-  using FirstInfo =
-  DenseMapInfo::type>;
+  using FirstTypeTraits = PointerLikeTypeTraits<
+  typename pointer_union_detail::GetFirstType::type>;
 
-  static inline Union getEmptyKey() { return Union(FirstInfo::getEmptyKey()); }
+  static inline Union getEmptyKey() {
+uintptr_t Val = static_cast(-1);
+Val <<= FirstTypeTraits::NumLowBitsAvailable;
+return FirstTypeTraits::getFromVoidPointer(reinterpret_cast(Val));
+  }
 
   static inline Union getTombstoneKey() {
-return Union(FirstInfo::getTombstoneKey());
+uintptr_t Val = static_cast(-2);
+Val <<= FirstTypeTraits::NumLowBitsAvailable;
+return FirstTypeTraits::getFromVoidPointer(reinterpret_cast(Val));
   }
 
   static unsigned getHashValue(const Union &UnionVal) {

>From 28b0ceb084a0c6bba29232a3d2cae5dfd848a7dc Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Wed, 2 Jul 2025 09:53:39 +0200
Subject: [PATCH 2/3] Update DenseMapInfo for LValueBase

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

diff --git a/clang/lib/AST/APValue.cpp b/clang/lib/AST/APValue.cpp
index c641ff6b99bab..acba55742a967 100644
--- a/clang/lib/AST/APValue.cpp
+++ b/clang/lib/AST/APValue.cpp
@@ -187,14 +187,14 @@ APValue::LValueBase::operator bool () const {
 clang::APValue::LValueBase
 llvm::DenseMapInfo::getEmptyKey() {
   clang::APValue::LValueBase B;
-  B.Ptr = DenseMapInfo::getEmptyKey();
+  B.Ptr = DenseMapInfo::getEmptyKey();
   return B;
 }
 
 clang::APValue::LValueBase
 llvm::DenseMapInfo::getTombstoneKey() {
   clang::APValue::LValueBase B;
-  B.Ptr = DenseMapInfo::getTombstoneKey();
+  B.Ptr = DenseMapInfo::getTombstoneKey();
   return B;
 }
 

>From a7d8fe34b57939a77502da1f2667a19374c19d0d Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Wed, 2 Jul 2025 15:39:10 +0200
Subject: [PATCH 3/3] Adjust TypeID DenseMapInfo

[clang] [clang] Speedup getFileIDLocal with a separate offset table. (PR #146604)

2025-07-07 Thread Haojian Wu via cfe-commits

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


[clang] [win][clang] Do not inject static_assert macro definition (PR #147030)

2025-07-07 Thread Mariya Podchishchaeva via cfe-commits

https://github.com/Fznamznon updated 
https://github.com/llvm/llvm-project/pull/147030

>From 3060e6f416ea62bdf62470e6636278d736cc49d0 Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" 
Date: Fri, 4 Jul 2025 02:50:38 -0700
Subject: [PATCH 1/3] [win][clang] Do not inject static_assert macro definition

In ms-compatibility mode we inject static_assert macro definition if
assert macro is defined. This is done by 
8da090381d567d0ec555840f6b2a651d2997e4b3
for the sake of better diagnosing, in particular to emit a compatibility
warning when static_assert keyword is used without inclusion of
. Unfortunately it doesn't do a good job in c99 mode adding
that macro unexpectedly for the users, so this patch removes macro
injection and the disagnostic.
---
 clang/docs/ReleaseNotes.rst |  2 ++
 clang/lib/Lex/PPDirectives.cpp  | 17 ---
 clang/lib/Parse/ParseDeclCXX.cpp|  3 ---
 clang/test/Parser/static_assert.c   |  1 -
 clang/test/Preprocessor/static_assert.c | 12 ---
 clang/test/Sema/static-assert.c | 28 ++---
 6 files changed, 22 insertions(+), 41 deletions(-)
 delete mode 100644 clang/test/Preprocessor/static_assert.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 023f8ff7951d3..b66b2c0b7b707 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -750,6 +750,8 @@ Bug Fixes in This Version
 - Fixed an infinite recursion when checking constexpr destructors. (#GH141789)
 - Fixed a crash when a malformed using declaration appears in a ``constexpr`` 
function. (#GH144264)
 - Fixed a bug when use unicode character name in macro concatenation. 
(#GH145240)
+- Clang doesn't erroneously inject static_assert macro in ms-compatibility and
+  -std=c99 mode.
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index e6da19d24f1c5..3fa060f7ec1bd 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -3304,23 +3304,6 @@ void Preprocessor::HandleDefineDirective(
   // If the callbacks want to know, tell them about the macro definition.
   if (Callbacks)
 Callbacks->MacroDefined(MacroNameTok, MD);
-
-  // If we're in MS compatibility mode and the macro being defined is the
-  // assert macro, implicitly add a macro definition for static_assert to work
-  // around their broken assert.h header file in C. Only do so if there isn't
-  // already a static_assert macro defined.
-  if (!getLangOpts().CPlusPlus && getLangOpts().MSVCCompat &&
-  MacroNameTok.getIdentifierInfo()->isStr("assert") &&
-  !isMacroDefined("static_assert")) {
-MacroInfo *MI = AllocateMacroInfo(SourceLocation());
-
-Token Tok;
-Tok.startToken();
-Tok.setKind(tok::kw__Static_assert);
-Tok.setIdentifierInfo(getIdentifierInfo("_Static_assert"));
-MI->setTokens({Tok}, BP);
-(void)appendDefMacroDirective(getIdentifierInfo("static_assert"), MI);
-  }
 }
 
 /// HandleUndefDirective - Implements \#undef.
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index bd5c28b1992c4..a8832209d32b7 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -937,9 +937,6 @@ Decl *Parser::ParseStaticAssertDeclaration(SourceLocation 
&DeclEnd) {
 if (!getLangOpts().CPlusPlus) {
   if (getLangOpts().C23)
 Diag(Tok, diag::warn_c23_compat_keyword) << Tok.getName();
-  else
-Diag(Tok, diag::ext_ms_static_assert) << FixItHint::CreateReplacement(
-Tok.getLocation(), "_Static_assert");
 } else
   Diag(Tok, diag::warn_cxx98_compat_static_assert);
   }
diff --git a/clang/test/Parser/static_assert.c 
b/clang/test/Parser/static_assert.c
index e9d7d3f0833f3..1b9b6b676e3e6 100644
--- a/clang/test/Parser/static_assert.c
+++ b/clang/test/Parser/static_assert.c
@@ -20,7 +20,6 @@ static_assert(1, ""); // c17-warning {{'static_assert' is a 
keyword in C23}} \
   // c17-error {{expected ')'}} \
   // c17-note {{to match this '('}} \
   // c17-error {{type specifier missing, defaults to 
'int'; ISO C99 and later do not support implicit int}} \
-  // c17-ms-warning {{use of 'static_assert' without 
inclusion of  is a Microsoft extension}}
 
 #endif
 
diff --git a/clang/test/Preprocessor/static_assert.c 
b/clang/test/Preprocessor/static_assert.c
deleted file mode 100644
index 7fa9975e1d468..0
--- a/clang/test/Preprocessor/static_assert.c
+++ /dev/null
@@ -1,12 +0,0 @@
-// RUN: %clang_cc1 -E -dM %s | FileCheck --strict-whitespace 
--check-prefix=NOMS %s
-// RUN: %clang_cc1 -fms-compatibility -E -dM %s | FileCheck 
--strict-whitespace --check-prefix=MS %s
-
-// If the assert macro is defined in MS compatibility mode in C, we
-// automatically inject a macro definition for static_assert. Test that the
-// macro is properl

[clang] [llvm] [AArch64] Add support for -mcpu=gb10. (PR #146515)

2025-07-07 Thread Ricardo Jesus via cfe-commits

https://github.com/rj-jesus updated 
https://github.com/llvm/llvm-project/pull/146515

>From cdaa8f58630ff30ad7719ca2a670238859648211 Mon Sep 17 00:00:00 2001
From: Ricardo Jesus 
Date: Wed, 2 Apr 2025 10:37:59 -0700
Subject: [PATCH 1/3] [AArch64] Add support for -mcpu=gb10.

This patch adds support for -mcpu=gb10 (NVIDIA GB10). This is a
big.LITTLE cluster of Cortex-X925 and Cortex-A725 cores. The appropriate
MIDR numbers are added to detect them in -mcpu=native.

We did not add an -mcpu=cortex-x925.cortex-a725 option because GB10 does
include the crypto instructions which we want on by default, and the
current convention is to not enable such extensions for Arm Cortex cores
in -mcpu where they are optional in the IP.
---
 .../print-enabled-extensions/aarch64-gb10.c   | 69 +++
 .../Misc/target-invalid-cpu-note/aarch64.c|  1 +
 llvm/lib/Target/AArch64/AArch64Processors.td  |  3 +
 llvm/lib/TargetParser/Host.cpp| 21 +-
 llvm/unittests/TargetParser/Host.cpp  |  8 +++
 .../TargetParser/TargetParserTest.cpp |  3 +-
 6 files changed, 102 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Driver/print-enabled-extensions/aarch64-gb10.c

diff --git a/clang/test/Driver/print-enabled-extensions/aarch64-gb10.c 
b/clang/test/Driver/print-enabled-extensions/aarch64-gb10.c
new file mode 100644
index 0..589f7e3e5ee4e
--- /dev/null
+++ b/clang/test/Driver/print-enabled-extensions/aarch64-gb10.c
@@ -0,0 +1,69 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang --target=aarch64 --print-enabled-extensions -mcpu=gb10 | 
FileCheck --strict-whitespace --implicit-check-not=FEAT_ %s
+
+// CHECK: Extensions enabled for the given AArch64 target
+// CHECK-EMPTY:
+// CHECK-NEXT: Architecture Feature(s)
Description
+// CHECK-NEXT: FEAT_AES, FEAT_PMULL   
Enable AES support
+// CHECK-NEXT: FEAT_AMUv1 
Enable Armv8.4-A Activity Monitors extension
+// CHECK-NEXT: FEAT_AMUv1p1   
Enable Armv8.6-A Activity Monitors Virtualization support
+// CHECK-NEXT: FEAT_AdvSIMD   
Enable Advanced SIMD instructions
+// CHECK-NEXT: FEAT_BF16  
Enable BFloat16 Extension
+// CHECK-NEXT: FEAT_BTI   
Enable Branch Target Identification
+// CHECK-NEXT: FEAT_CCIDX 
Enable Armv8.3-A Extend of the CCSIDR number of sets
+// CHECK-NEXT: FEAT_CRC32 
Enable Armv8.0-A CRC-32 checksum instructions
+// CHECK-NEXT: FEAT_CSV2_2
Enable architectural speculation restriction
+// CHECK-NEXT: FEAT_DIT   
Enable Armv8.4-A Data Independent Timing instructions
+// CHECK-NEXT: FEAT_DPB   
Enable Armv8.2-A data Cache Clean to Point of Persistence
+// CHECK-NEXT: FEAT_DPB2  
Enable Armv8.5-A Cache Clean to Point of Deep Persistence
+// CHECK-NEXT: FEAT_DotProd   
Enable dot product support
+// CHECK-NEXT: FEAT_ECV   
Enable enhanced counter virtualization extension
+// CHECK-NEXT: FEAT_ETE   
Enable Embedded Trace Extension
+// CHECK-NEXT: FEAT_FCMA  
Enable Armv8.3-A Floating-point complex number support
+// CHECK-NEXT: FEAT_FGT   
Enable fine grained virtualization traps extension
+// CHECK-NEXT: FEAT_FHM   
Enable FP16 FML instructions
+// CHECK-NEXT: FEAT_FP
Enable Armv8.0-A Floating Point Extensions
+// CHECK-NEXT: FEAT_FP16  
Enable half-precision floating-point data processing
+// CHECK-NEXT: FEAT_FPAC  
Enable Armv8.3-A Pointer Authentication Faulting enhancement
+// CHECK-NEXT: FEAT_FRINTTS   
Enable FRInt[32|64][Z|X] instructions that round a floating-point number to an 
integer (in FP format) forcing it to fit into a 32- or 64-bit int
+// CHECK-NEXT: FEAT_FlagM 
Enable Armv8.4-A Flag Manipulation instructions
+// CHECK-NEXT: FEAT_FlagM2
Enable alternative NZCV format for floating point comparisons
+// CHECK-NEXT: FEAT_HCX   
Enable Armv8.7-A HCRX_EL2 system register
+// CHECK-NEXT: FEAT_I8MM  

[clang-tools-extra] [clang-tidy] Make `bugprone-unhandled-self-assignment` check more general (PR #147066)

2025-07-07 Thread Mike Weller via cfe-commits

MikeWeller wrote:

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

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


[clang] [llvm] [AArch64] Add support for -mcpu=gb10. (PR #146515)

2025-07-07 Thread Ricardo Jesus via cfe-commits

rj-jesus wrote:

I've just rebased this to solve a conflict in `llvm/lib/TargetParser/Host.cpp` 
created due to 29b2b2263f9eb7b310ee38628e43be76f2c9caf4.

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


[clang] [analyzer] Add support for consteval in ConditionBRVisitor::VisitTerminator (PR #146859)

2025-07-07 Thread via cfe-commits


@@ -0,0 +1,8 @@
+// RUN: %clang_analyze_cc1 -std=c++23 -analyzer-checker=core -verify %s

isuckatcs wrote:

I thought the [infrastructure used in 
clang-tidy](https://github.com/llvm/llvm-project/blob/c50415bb82a740426a5559ff7f1e350f394e9fcf/clang-tools-extra/test/clang-tidy/check_clang_tidy.py#L40)
 was incorporated into other projects as well, but it seems like it wasn't. For 
clang we do have an automatic standard picker in our 
[`config.py`](https://github.com/llvm/llvm-project/blob/c50415bb82a740426a5559ff7f1e350f394e9fcf/llvm/utils/lit/lit/llvm/config.py#L711)
 though. 😅 

> What is the best approach to do this? I noticed in some files they duplicate 
> the line for each subsequent standard but that seems impractical.

Duplicating the lines is the only way right now.

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


[clang] 84e5451 - [AArch64] Add support for -mcpu=gb10. (#146515)

2025-07-07 Thread via cfe-commits

Author: Ricardo Jesus
Date: 2025-07-07T11:14:26+01:00
New Revision: 84e54515bc4e9dd4938121f4df7cc27bb89a0a43

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

LOG: [AArch64] Add support for -mcpu=gb10. (#146515)

This patch adds support for -mcpu=gb10 (NVIDIA GB10). This is a
big.LITTLE cluster of Cortex-X925 and Cortex-A725 cores. The appropriate
MIDR numbers are added to detect them in -mcpu=native.

We did not add an -mcpu=cortex-x925.cortex-a725 option because GB10 does
include the crypto instructions which we want on by default, and the
current convention is to not enable such extensions for Arm Cortex cores
in -mcpu where they are optional in the IP.

Relevant GCC patch:
https://gcc.gnu.org/pipermail/gcc-patches/2025-June/687005.html

Added: 
clang/test/Driver/print-enabled-extensions/aarch64-gb10.c

Modified: 
clang/test/Misc/target-invalid-cpu-note/aarch64.c
llvm/lib/Target/AArch64/AArch64Processors.td
llvm/lib/TargetParser/Host.cpp
llvm/unittests/TargetParser/Host.cpp
llvm/unittests/TargetParser/TargetParserTest.cpp

Removed: 




diff  --git a/clang/test/Driver/print-enabled-extensions/aarch64-gb10.c 
b/clang/test/Driver/print-enabled-extensions/aarch64-gb10.c
new file mode 100644
index 0..589f7e3e5ee4e
--- /dev/null
+++ b/clang/test/Driver/print-enabled-extensions/aarch64-gb10.c
@@ -0,0 +1,69 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang --target=aarch64 --print-enabled-extensions -mcpu=gb10 | 
FileCheck --strict-whitespace --implicit-check-not=FEAT_ %s
+
+// CHECK: Extensions enabled for the given AArch64 target
+// CHECK-EMPTY:
+// CHECK-NEXT: Architecture Feature(s)
Description
+// CHECK-NEXT: FEAT_AES, FEAT_PMULL   
Enable AES support
+// CHECK-NEXT: FEAT_AMUv1 
Enable Armv8.4-A Activity Monitors extension
+// CHECK-NEXT: FEAT_AMUv1p1   
Enable Armv8.6-A Activity Monitors Virtualization support
+// CHECK-NEXT: FEAT_AdvSIMD   
Enable Advanced SIMD instructions
+// CHECK-NEXT: FEAT_BF16  
Enable BFloat16 Extension
+// CHECK-NEXT: FEAT_BTI   
Enable Branch Target Identification
+// CHECK-NEXT: FEAT_CCIDX 
Enable Armv8.3-A Extend of the CCSIDR number of sets
+// CHECK-NEXT: FEAT_CRC32 
Enable Armv8.0-A CRC-32 checksum instructions
+// CHECK-NEXT: FEAT_CSV2_2
Enable architectural speculation restriction
+// CHECK-NEXT: FEAT_DIT   
Enable Armv8.4-A Data Independent Timing instructions
+// CHECK-NEXT: FEAT_DPB   
Enable Armv8.2-A data Cache Clean to Point of Persistence
+// CHECK-NEXT: FEAT_DPB2  
Enable Armv8.5-A Cache Clean to Point of Deep Persistence
+// CHECK-NEXT: FEAT_DotProd   
Enable dot product support
+// CHECK-NEXT: FEAT_ECV   
Enable enhanced counter virtualization extension
+// CHECK-NEXT: FEAT_ETE   
Enable Embedded Trace Extension
+// CHECK-NEXT: FEAT_FCMA  
Enable Armv8.3-A Floating-point complex number support
+// CHECK-NEXT: FEAT_FGT   
Enable fine grained virtualization traps extension
+// CHECK-NEXT: FEAT_FHM   
Enable FP16 FML instructions
+// CHECK-NEXT: FEAT_FP
Enable Armv8.0-A Floating Point Extensions
+// CHECK-NEXT: FEAT_FP16  
Enable half-precision floating-point data processing
+// CHECK-NEXT: FEAT_FPAC  
Enable Armv8.3-A Pointer Authentication Faulting enhancement
+// CHECK-NEXT: FEAT_FRINTTS   
Enable FRInt[32|64][Z|X] instructions that round a floating-point number to an 
integer (in FP format) forcing it to fit into a 32- or 64-bit int
+// CHECK-NEXT: FEAT_FlagM 
Enable Armv8.4-A Flag Manipulation instructions
+// CHECK-NEXT: FEAT_FlagM2
Enable alternative NZCV format for floating point comparisons
+// CHECK-NEXT: FEAT_HCX  

[clang] [llvm] [AArch64] Add support for -mcpu=gb10. (PR #146515)

2025-07-07 Thread Ricardo Jesus via cfe-commits

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


[clang] [analyzer] Add support for consteval in ConditionBRVisitor::VisitTerminator (PR #146859)

2025-07-07 Thread Imad Aldij via cfe-commits


@@ -0,0 +1,8 @@
+// RUN: %clang_analyze_cc1 -std=c++23 -analyzer-checker=core -verify %s

imdj wrote:

> Duplicating the lines is the only way right now.

I added a line for the c++26 standard for now

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


[clang-tools-extra] [clang-tidy] added `RespectOpaqueTypes` option to `readability-qualified-auto check` (PR #147060)

2025-07-07 Thread Baranov Victor via cfe-commits

vbvictor wrote:

> In that case the default should be true though right?

Yes, that would be just as current default behavior.


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


[clang] [analyzer] Add support for consteval in ConditionBRVisitor::VisitTerminator (PR #146859)

2025-07-07 Thread via cfe-commits

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


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


[clang] [analyzer] Add support for consteval in ConditionBRVisitor::VisitTerminator (PR #146859)

2025-07-07 Thread Imad Aldij via cfe-commits


@@ -0,0 +1,8 @@
+// RUN: %clang_analyze_cc1 -std=c++23 -analyzer-checker=core -verify %s

imdj wrote:

Could we rely on feature detection? like
```
// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s

#if __cpp_if_consteval >= 202106L
void test_consteval() {
...
#endif
```

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


[clang] [llvm] [SPIRV] Add more id and range builtIns (PR #143909)

2025-07-07 Thread Victor Lomuller via cfe-commits

https://github.com/Naghasan updated 
https://github.com/llvm/llvm-project/pull/143909

>From b2e45fdf15b28187463b5afda89bbe26c5083d80 Mon Sep 17 00:00:00 2001
From: Victor Lomuller 
Date: Thu, 5 Jun 2025 16:17:10 +0100
Subject: [PATCH] [SPIRV] Add more id and range builtIns

The patch adds intrinsics and lowering logic for GlobalSize, GlobalOffset, 
SubgroupMaxSize,
NumWorkgroups, WorkgroupSize, WorkgroupId, LocalInvocationId, 
GlobalInvocationId,
SubgroupSize, NumSubgroups, SubgroupId and SubgroupLocalInvocationId SPIR-V 
builtins.

The patch also extend spv_thread_id, spv_group_id and spv_thread_id_in_group
to return anyint rather than i32. This allows the intrinsics to support the 
opencl environment.

For each of the intrinsics, new clang builtins were added as well as a binding 
for the SPIR-V "friendly" format.
The original format doesn't define such binding (uses global variables) but it 
is not possible to express
the Input SC which is normally required by the environement specs, and using 
builtin functions is
the most usual approach for other backend and programming models.
---
 clang/include/clang/Basic/BuiltinsSPIRVCL.td  |   3 +
 .../clang/Basic/BuiltinsSPIRVCommon.td|  10 ++
 clang/lib/CodeGen/CGHLSLRuntime.cpp   |  16 +-
 clang/lib/CodeGen/TargetBuiltins/SPIR.cpp |  42 ++
 clang/lib/Headers/__clang_spirv_builtins.h|  40 -
 .../semantics/DispatchThreadID.hlsl   |   8 +-
 .../CodeGenHLSL/semantics/SV_GroupID.hlsl |  18 ++-
 .../semantics/SV_GroupThreadID.hlsl   |  18 ++-
 .../CodeGenSPIRV/Builtins/ids_and_ranges.c| 106 ++
 clang/test/Headers/spirv_ids.cpp  | 110 ++
 .../test/SemaSPIRV/BuiltIns/ids_and_ranges.c  |  77 ++
 llvm/include/llvm/IR/IntrinsicsSPIRV.td   |  22 ++-
 llvm/lib/IR/Intrinsics.cpp|   1 +
 .../Target/SPIRV/SPIRVInstructionSelector.cpp |  30 +++-
 .../CodeGen/SPIRV/builtin_intrinsics_32.ll| 136 +
 .../CodeGen/SPIRV/builtin_intrinsics_64.ll| 137 ++
 .../hlsl-intrinsics/SV_DispatchThreadID.ll|   8 +-
 .../SPIRV/hlsl-intrinsics/SV_GroupID.ll   |   8 +-
 .../SPIRV/hlsl-intrinsics/SV_GroupThreadID.ll |   8 +-
 19 files changed, 761 insertions(+), 37 deletions(-)
 create mode 100644 clang/test/CodeGenSPIRV/Builtins/ids_and_ranges.c
 create mode 100644 clang/test/Headers/spirv_ids.cpp
 create mode 100644 clang/test/SemaSPIRV/BuiltIns/ids_and_ranges.c
 create mode 100644 llvm/test/CodeGen/SPIRV/builtin_intrinsics_32.ll
 create mode 100644 llvm/test/CodeGen/SPIRV/builtin_intrinsics_64.ll

diff --git a/clang/include/clang/Basic/BuiltinsSPIRVCL.td 
b/clang/include/clang/Basic/BuiltinsSPIRVCL.td
index 1103a0d088e8b..10320fab34a6c 100644
--- a/clang/include/clang/Basic/BuiltinsSPIRVCL.td
+++ b/clang/include/clang/Basic/BuiltinsSPIRVCL.td
@@ -10,3 +10,6 @@ include "clang/Basic/BuiltinsSPIRVBase.td"
 
 def generic_cast_to_ptr_explicit
 : SPIRVBuiltin<"void*(void*, int)", [NoThrow, Const, CustomTypeChecking]>;
+def global_size : SPIRVBuiltin<"size_t(int)", [NoThrow, Const]>;
+def global_offset : SPIRVBuiltin<"size_t(int)", [NoThrow, Const]>;
+def subgroup_max_size : SPIRVBuiltin<"uint32_t()", [NoThrow, Const]>;
diff --git a/clang/include/clang/Basic/BuiltinsSPIRVCommon.td 
b/clang/include/clang/Basic/BuiltinsSPIRVCommon.td
index 17bcd0b9cb783..d2ef6f99a0502 100644
--- a/clang/include/clang/Basic/BuiltinsSPIRVCommon.td
+++ b/clang/include/clang/Basic/BuiltinsSPIRVCommon.td
@@ -8,6 +8,16 @@
 
 include "clang/Basic/BuiltinsSPIRVBase.td"
 
+def num_workgroups : SPIRVBuiltin<"size_t(int)", [NoThrow, Const]>;
+def workgroup_size : SPIRVBuiltin<"size_t(int)", [NoThrow, Const]>;
+def workgroup_id : SPIRVBuiltin<"size_t(int)", [NoThrow, Const]>;
+def local_invocation_id : SPIRVBuiltin<"size_t(int)", [NoThrow, Const]>;
+def global_invocation_id : SPIRVBuiltin<"size_t(int)", [NoThrow, Const]>;
+def subgroup_size : SPIRVBuiltin<"uint32_t()", [NoThrow, Const]>;
+def num_subgroups : SPIRVBuiltin<"uint32_t()", [NoThrow, Const]>;
+def subgroup_id : SPIRVBuiltin<"uint32_t()", [NoThrow, Const]>;
+def subgroup_local_invocation_id : SPIRVBuiltin<"uint32_t()", [NoThrow, 
Const]>;
+
 def distance : SPIRVBuiltin<"void(...)", [NoThrow, Const]>;
 def length : SPIRVBuiltin<"void(...)", [NoThrow, Const]>;
 def smoothstep : SPIRVBuiltin<"void(...)", [NoThrow, Const, 
CustomTypeChecking]>;
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index c1fd6f22f693b..a47d1cc22980d 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -393,17 +393,27 @@ llvm::Value *CGHLSLRuntime::emitInputSemantic(IRBuilder<> 
&B,
 return B.CreateCall(FunctionCallee(GroupIndex));
   }
   if (D.hasAttr()) {
+llvm::Intrinsic::ID IntrinID = getThreadIdIntrinsic();
 llvm::Function *ThreadIDIntrinsic =
-CGM.getIntrinsic(getThreadIdIntrinsic());
+llvm::Intrinsic::isOverload

[libclc] [NFC][libclc] Fix typo in OpenCL header math/sincos.h (PR #147244)

2025-07-07 Thread Fraser Cormack via cfe-commits

frasercrmck wrote:

This isn't `NFC`, though?

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


[libclc] [NFC][libclc] Fix typo in OpenCL header math/sincos.h (PR #147244)

2025-07-07 Thread Fraser Cormack via cfe-commits

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


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


[clang] [LifetimeSafety] Introduce intra-procedural analysis in Clang (PR #142313)

2025-07-07 Thread Utkarsh Saxena via cfe-commits


@@ -0,0 +1,13 @@
+#ifndef LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIME_SAFETY_H

usx95 wrote:

Done. Thanks.

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


[clang] [LifetimeSafety] Introduce intra-procedural analysis in Clang (PR #142313)

2025-07-07 Thread Utkarsh Saxena via cfe-commits


@@ -0,0 +1,13 @@
+#ifndef LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIME_SAFETY_H

usx95 wrote:

Done.

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


[clang] [LifetimeSafety] Introduce intra-procedural analysis in Clang (PR #142313)

2025-07-07 Thread Gábor Horváth via cfe-commits


@@ -0,0 +1,728 @@
+#include "clang/Analysis/Analyses/LifetimeSafety.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/StmtVisitor.h"
+#include "clang/AST/Type.h"
+#include "clang/Analysis/AnalysisDeclContext.h"
+#include "clang/Analysis/CFG.h"
+#include "clang/Analysis/FlowSensitive/DataflowWorklist.h"
+#include "llvm/ADT/ImmutableMap.h"
+#include "llvm/ADT/ImmutableSet.h"
+#include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/TimeProfiler.h"
+#include 
+
+namespace clang {
+namespace {
+
+struct Point {
+  const clang::CFGBlock *Block;
+  /// Index into Block->Elements().
+  unsigned ElementIndex;
+
+  Point(const clang::CFGBlock *B = nullptr, unsigned Idx = 0)
+  : Block(B), ElementIndex(Idx) {}
+
+  bool operator==(const Point &Other) const {
+return Block == Other.Block && ElementIndex == Other.ElementIndex;
+  }
+};
+
+/// Represents the storage location being borrowed, e.g., a specific stack
+/// variable.
+/// TODO: Handle member accesseslike `s.y`.
+struct Path {
+  const clang::ValueDecl *D;
+
+  enum class Kind : uint8_t {
+StackVariable,
+Heap,// TODO: Handle.
+Field,   // TODO: Handle.
+ArrayElement,// TODO: Handle.
+TemporaryObject, // TODO: Handle.
+StaticOrGlobal,  // TODO: Handle.
+  };
+
+  Kind PathKind;
+
+  Path(const clang::ValueDecl *D, Kind K) : D(D), PathKind(K) {}
+};
+
+using LoanID = uint32_t;
+using OriginID = uint32_t;
+
+/// Information about a single borrow, or "Loan". A loan is created when a
+/// reference or pointer is taken.
+struct LoanInfo {
+  /// TODO: Represent opaque loans.
+  /// TODO: Represent nullptr: loans to no path. Accessing it UB! Currently it
+  /// is represented as empty LoanSet
+  LoanID ID;
+  Path SourcePath;
+  SourceLocation IssueLoc;
+
+  LoanInfo(LoanID id, Path path, SourceLocation loc)
+  : ID(id), SourcePath(path), IssueLoc(loc) {}
+};
+
+enum class OriginKind : uint8_t { Variable, ExpressionResult };
+
+/// An Origin is a symbolic identifier that represents the set of possible
+/// loans a pointer-like object could hold at any given time.
+/// TODO: Also represent Origins of complex types (fields, inner types).
+struct OriginInfo {
+  OriginID ID;
+  OriginKind Kind;
+  union {
+const clang::ValueDecl *Decl;
+const clang::Expr *Expression;
+  };
+  OriginInfo(OriginID id, OriginKind kind, const clang::ValueDecl *D)
+  : ID(id), Kind(kind), Decl(D) {}
+  OriginInfo(OriginID id, OriginKind kind, const clang::Expr *E)
+  : ID(id), Kind(kind), Expression(E) {}
+};
+
+class LoanManager {
+public:
+  LoanManager() = default;
+
+  LoanInfo &addLoanInfo(Path path, SourceLocation loc) {
+NextLoanIDVal++;
+AllLoans.emplace_back(NextLoanIDVal, path, loc);
+return AllLoans.back();
+  }
+
+  const LoanInfo *getLoanInfo(LoanID id) const {
+if (id < AllLoans.size())
+  return &AllLoans[id];
+return nullptr;
+  }
+  llvm::ArrayRef getLoanInfos() const { return AllLoans; }
+
+private:
+  LoanID NextLoanIDVal = 0;
+  llvm::SmallVector AllLoans;
+};
+
+class OriginManager {
+public:
+  OriginManager() = default;
+
+  OriginID getNextOriginID() { return NextOriginIDVal++; }
+  OriginInfo &addOriginInfo(OriginID id, const clang::ValueDecl *D) {
+assert(D != nullptr);
+AllOrigins.emplace_back(id, OriginKind::Variable, D);
+return AllOrigins.back();
+  }
+  OriginInfo &addOriginInfo(OriginID id, const clang::Expr *E) {
+assert(E != nullptr);
+AllOrigins.emplace_back(id, OriginKind::ExpressionResult, E);
+return AllOrigins.back();
+  }
+
+  OriginID getOrCreate(const Expr *E) {
+auto It = ExprToOriginID.find(E);
+if (It != ExprToOriginID.end())
+  return It->second;
+
+if (const auto *DRE = dyn_cast(E)) {
+  // Origin of DeclRefExpr is that of the declaration it refers to.
+  return getOrCreate(DRE->getDecl());
+}
+OriginID NewID = getNextOriginID();
+addOriginInfo(NewID, E);
+ExprToOriginID[E] = NewID;
+return NewID;
+  }
+
+  const OriginInfo *getOriginInfo(OriginID id) const {
+if (id < AllOrigins.size())
+  return &AllOrigins[id];
+return nullptr;
+  }
+
+  llvm::ArrayRef getOriginInfos() const { return AllOrigins; }
+
+  OriginID getOrCreate(const ValueDecl *D) {
+auto It = DeclToOriginID.find(D);
+if (It != DeclToOriginID.end())
+  return It->second;
+OriginID NewID = getNextOriginID();
+addOriginInfo(NewID, D);
+DeclToOriginID[D] = NewID;
+return NewID;
+  }
+
+private:
+  OriginID NextOriginIDVal = 0;
+  llvm::SmallVector AllOrigins;
+  llvm::DenseMap DeclToOriginID;
+  llvm::DenseMap ExprToOriginID;
+};
+
+/// An abstract base class for a single, atomic lifetime-relevant event.
+class Fact {
+
+public:
+  enum class Kind : uint8_t {
+/// A new loan is issued from a borrow expression (e.g., &x).
+Issue,
+/// A loan expires

[clang] [LifetimeSafety] Introduce intra-procedural analysis in Clang (PR #142313)

2025-07-07 Thread Gábor Horváth via cfe-commits

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


[clang] [flang] [flang] Add -fcomplex-arithmetic= option and select complex division algorithm (PR #146641)

2025-07-07 Thread Kiran Chandramohan via cfe-commits


@@ -1023,12 +1023,12 @@ defm offload_uniform_block : 
BoolFOption<"offload-uniform-block",
   BothFlags<[], [ClangOption], " that kernels are launched with uniform block 
sizes (default true for CUDA/HIP and false otherwise)">>;
 
 def fcomplex_arithmetic_EQ : Joined<["-"], "fcomplex-arithmetic=">, 
Group,
-  Visibility<[ClangOption, CC1Option]>,
+  Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
   Values<"full,improved,promoted,basic">, NormalizedValuesScope<"LangOptions">,
   NormalizedValues<["CX_Full", "CX_Improved", "CX_Promoted", "CX_Basic"]>;

kiranchandramohan wrote:

It looks fine to me. Thanks for the additional content.

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


[clang] [LifetimeSafety] Propagate loans using dataflow analysis (PR #147208)

2025-07-07 Thread Utkarsh Saxena via cfe-commits

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


[clang] [flang] [flang] Add -fcomplex-arithmetic= option and select complex division algorithm (PR #146641)

2025-07-07 Thread Kiran Chandramohan via cfe-commits

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

LG.

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


[clang] [llvm] [AArch64] Add support for -mcpu=gb10. (PR #146515)

2025-07-07 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `fuchsia-x86_64-linux` 
running on `fuchsia-debian-64-us-central1-a-1` while building `clang,llvm` at 
step 4 "annotate".

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


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

```
Step 4 (annotate) failure: 'python 
../llvm-zorg/zorg/buildbot/builders/annotated/fuchsia-linux.py ...' (failure)
...
[674/1380] Building CXX object 
unittests/ADT/CMakeFiles/ADTTests.dir/PackedVectorTest.cpp.o
[675/1380] Building CXX object 
unittests/ADT/CMakeFiles/ADTTests.dir/PointerSumTypeTest.cpp.o
[676/1380] Linking CXX executable bin/yaml2obj
[676/1380] Running lld test suite
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld.lld: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/bin/ld.lld
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using lld-link: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/bin/lld-link
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld64.lld: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/bin/ld64.lld
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using wasm-ld: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/bin/wasm-ld
-- Testing: 3107 tests, 60 workers --
Testing:  0.. 10.
FAIL: lld :: ELF/aarch64-adrp-ldr-got.s (528 of 3107)
 TEST 'lld :: ELF/aarch64-adrp-ldr-got.s' FAILED 

Exit Code: 1

Command Output (stderr):
--
rm -rf 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/tools/lld/test/ELF/Output/aarch64-adrp-ldr-got.s.tmp
 && split-file 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/lld/test/ELF/aarch64-adrp-ldr-got.s
 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/tools/lld/test/ELF/Output/aarch64-adrp-ldr-got.s.tmp
 # RUN: at line 2
+ rm -rf 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/tools/lld/test/ELF/Output/aarch64-adrp-ldr-got.s.tmp
+ split-file 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/lld/test/ELF/aarch64-adrp-ldr-got.s
 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/tools/lld/test/ELF/Output/aarch64-adrp-ldr-got.s.tmp
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/bin/llvm-mc 
-filetype=obj -triple=aarch64 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/tools/lld/test/ELF/Output/aarch64-adrp-ldr-got.s.tmp/a.s
 -o 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/tools/lld/test/ELF/Output/aarch64-adrp-ldr-got.s.tmp/a.o
 # RUN: at line 4
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/bin/llvm-mc 
-filetype=obj -triple=aarch64 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/tools/lld/test/ELF/Output/aarch64-adrp-ldr-got.s.tmp/a.s
 -o 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/tools/lld/test/ELF/Output/aarch64-adrp-ldr-got.s.tmp/a.o
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/bin/llvm-mc 
-filetype=obj -triple=aarch64 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/tools/lld/test/ELF/Output/aarch64-adrp-ldr-got.s.tmp/unpaired.s
 -o 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/tools/lld/test/ELF/Output/aarch64-adrp-ldr-got.s.tmp/unpaired.o
 # RUN: at line 5
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/bin/llvm-mc 
-filetype=obj -triple=aarch64 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/tools/lld/test/ELF/Output/aarch64-adrp-ldr-got.s.tmp/unpaired.s
 -o 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/tools/lld/test/ELF/Output/aarch64-adrp-ldr-got.s.tmp/unpaired.o
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/bin/llvm-mc 
-filetype=obj -triple=aarch64 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/tools/lld/test/ELF/Output/aarch64-adrp-ldr-got.s.tmp/lone-ldr.s
 -o 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/tools/lld/test/ELF/Output/aarch64-adrp-ldr-got.s.tmp/lone-ldr.o
 # RUN: at line 6
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/bin/llvm-mc 
-filetype=obj -triple=aarch64 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/tools/lld/test/ELF/Output/aarch64-adrp-ldr-got.s.tmp/lone-ldr.s
 -o 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/tools/lld/test/ELF/Output/aarch64-adrp-ldr-got.s.tmp/lone-ldr.o
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/bin/ld.lld 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-eir2nopv/tools/lld/test/ELF/Output/aarch64-adrp-ldr-got.s.tmp/a.o
 -T 
/var/lib/buildbot/fuchs

[clang] [Driver][RISCV] Fix incorrect compiler-rt path override in BareMetal toolchain after RISCVToolChain removal (PR #146849)

2025-07-07 Thread Garvit Gupta via cfe-commits

https://github.com/quic-garvgupt updated 
https://github.com/llvm/llvm-project/pull/146849

>From 3d0220ecce368a481981c414f789d9dbbfc49c81 Mon Sep 17 00:00:00 2001
From: Garvit Gupta 
Date: Thu, 3 Jul 2025 02:56:01 -0700
Subject: [PATCH] [Driver][RISCV] Fix and print appropriate compiler-rt path
 when GCCInstallation is valid

RISCVToolChain which recently got removed in commit f8cb798, used a
different compiler-rt path relative to resource-dir. However,
this behavior got override when it was merged in BareMetal toolchain.

This patch fixes that.

Without valid GCCInstallation:
//lib/baremetal/libclang_rt.builtins-.a

With valid GCCInstalltion:
//lib/libclang_rt.builtins.a

Change-Id: I37670b24019e3d473139ad6df8c3e6b92196fa6d
---
 clang/lib/Driver/ToolChains/BareMetal.cpp  | 10 ++
 clang/lib/Driver/ToolChains/BareMetal.h|  1 +
 clang/test/Driver/print-libgcc-file-name-clangrt.c |  9 +
 3 files changed, 20 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 981395deb9dbc..e670696cd59ae 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -206,6 +206,16 @@ std::string BareMetal::computeSysRoot() const {
   return computeClangRuntimesSysRoot(D, /*IncludeTriple*/ true);
 }
 
+std::string BareMetal::getCompilerRTPath() const {
+  const Driver &D = getDriver();
+  if (IsGCCInstallationValid || detectGCCToolchainAdjacent(getDriver())) {
+SmallString<128> Path(D.ResourceDir);
+llvm::sys::path::append(Path, "lib");
+return std::string(Path.str());
+  }
+  return ToolChain::getCompilerRTPath();
+}
+
 static void addMultilibsFilePaths(const Driver &D, const MultilibSet 
&Multilibs,
   const Multilib &Multilib,
   StringRef InstallPath,
diff --git a/clang/lib/Driver/ToolChains/BareMetal.h 
b/clang/lib/Driver/ToolChains/BareMetal.h
index cc57fa21867a2..d3d415b337a0b 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.h
+++ b/clang/lib/Driver/ToolChains/BareMetal.h
@@ -76,6 +76,7 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public Generic_ELF {
   addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
   std::string computeSysRoot() const override;
+  std::string getCompilerRTPath() const override;
   SanitizerMask getSupportedSanitizers() const override;
 
   SmallVector
diff --git a/clang/test/Driver/print-libgcc-file-name-clangrt.c 
b/clang/test/Driver/print-libgcc-file-name-clangrt.c
index a902eedc85209..1cb28d43748ec 100644
--- a/clang/test/Driver/print-libgcc-file-name-clangrt.c
+++ b/clang/test/Driver/print-libgcc-file-name-clangrt.c
@@ -63,3 +63,12 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-BAREMETAL-PER-TARGET %s
 // CHECK-CLANGRT-ARM-BAREMETAL-PER-TARGET: libclang_rt.builtins.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name \
+// RUN: --target=riscv32-unknown-elf \
+// RUN: --sysroot=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: --gcc-toolchain=%S/Inputs/basic_riscv32_tree 2>&1 \
+// RUN:| FileCheck --check-prefix=CHECK-CLANGRT-RISCV-BAREMETAL %s
+// CHECK-CLANGRT-RISCV-BAREMETAL-NOT: 
baremetal{{/|\\}}libclang_rt.builtins-riscv32.a
+// CHECK-CLANGRT-RISCV-BAREMETAL: libclang_rt.builtins.a

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


[clang] [Driver][RISCV] Fix incorrect compiler-rt path override in BareMetal toolchain after RISCVToolChain removal (PR #146849)

2025-07-07 Thread Garvit Gupta via cfe-commits


@@ -206,6 +206,15 @@ std::string BareMetal::computeSysRoot() const {
   return computeClangRuntimesSysRoot(D, /*IncludeTriple*/ true);
 }
 
+std::string BareMetal::getCompilerRTPath() const {
+  if (IsGCCInstallationValid || detectGCCToolchainAdjacent(getDriver())) {
+SmallString<128> Path(getDriver().ResourceDir);

quic-garvgupt wrote:

Done

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


[clang] [LifetimeSafety] Introduce intra-procedural analysis in Clang (PR #142313)

2025-07-07 Thread Gábor Horváth via cfe-commits

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

There are some discussions open on this PR e.g., whether access paths need 
kinds. But I don't think those are blockers, this is exploratory work and it is 
expected that some design decisions might be revisited along the way when we 
learn something new. I am OK with the current status of this PR.

Something for future PRs: I think it would be nice to have some sort of 
coverage statistics. While initially you do not aim to cover all of C++, it 
would be good to know what portion of nodes are missing from the fact 
generation when we run this on some real world code. That can give us some 
progress indicators. 

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


[clang] [LifetimeSafety] Introduce intra-procedural analysis in Clang (PR #142313)

2025-07-07 Thread Gábor Horváth via cfe-commits

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


[clang] [LifetimeSafety] Introduce intra-procedural analysis in Clang (PR #142313)

2025-07-07 Thread Gábor Horváth via cfe-commits


@@ -0,0 +1,508 @@
+//===- LifetimeSafety.cpp - C++ Lifetime Safety Analysis -*- 
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
+//
+//===--===//
+#include "clang/Analysis/Analyses/LifetimeSafety.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/StmtVisitor.h"
+#include "clang/AST/Type.h"
+#include "clang/Analysis/Analyses/PostOrderCFGView.h"
+#include "clang/Analysis/AnalysisDeclContext.h"
+#include "clang/Analysis/CFG.h"
+#include "llvm/ADT/FoldingSet.h"
+#include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/TimeProfiler.h"
+#include 
+
+namespace clang {
+namespace {
+
+/// Represents the storage location being borrowed, e.g., a specific stack
+/// variable.
+struct AccessPath {
+  const clang::ValueDecl *D;
+
+  enum class Kind : uint8_t {
+StackVariable,
+Temporary,// TODO: Handle.
+Field,// TODO: Handle like `s.y`.
+Heap, // TODO: Handle.
+ArrayElement, // TODO: Handle.
+Static,   // TODO: Handle.
+  };
+
+  Kind PathKind;
+
+  AccessPath(const clang::ValueDecl *D, Kind K) : D(D), PathKind(K) {}
+};
+
+/// A generic, type-safe wrapper for an ID, distinguished by its `Tag` type.
+/// Used for giving ID to loans and origins.
+template  struct ID {
+  uint32_t Value = 0;
+
+  bool operator==(const ID &Other) const { return Value == Other.Value; }
+  bool operator!=(const ID &Other) const { return !(*this == Other); }
+  bool operator<(const ID &Other) const { return Value < Other.Value; }
+  ID operator++(int) {
+ID Tmp = *this;
+++Value;
+return Tmp;
+  }
+  void Profile(llvm::FoldingSetNodeID &IDBuilder) const {
+IDBuilder.AddInteger(Value);
+  }
+};
+
+template 
+inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, ID ID) {
+  return OS << ID.Value;
+}
+
+using LoanID = ID;
+using OriginID = ID;
+
+/// Information about a single borrow, or "Loan". A loan is created when a
+/// reference or pointer is taken.
+struct Loan {
+  /// TODO: Represent opaque loans.

Xazax-hun wrote:

Could you elaborate what do you mean by an opaque loan? Would this be something 
coming from a e.g., a function call?

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


[clang] [clang][AST] Fix positioning of preserve cconv attributes in TypePrinter (PR #147285)

2025-07-07 Thread via cfe-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[clang] [llvm] [clang][OpenMP] Use DirectiveNameParser to parse directive names (PR #146779)

2025-07-07 Thread Krzysztof Parzyszek via cfe-commits

kparzysz wrote:

Hi @alexey-bataev, did you miss this one?

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


[clang] [clang][diagnostics] Refactor "warn_doc_api_container_decl_mismatch" to use enum_select (PR #146433)

2025-07-07 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> Can we merge this with private email address?

Community policy is to have public email addresses: 
https://llvm.org/docs/DeveloperPolicy.html#email-addresses

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


[clang] [libclc] [llvm] [libclc] Add initial LIT tests (PR #87989)

2025-07-07 Thread Fraser Cormack via cfe-commits

https://github.com/frasercrmck updated 
https://github.com/llvm/llvm-project/pull/87989

>From b41b2032fdb01bd91d32255bf22a94315b58a017 Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Mon, 30 Jun 2025 10:59:02 +0100
Subject: [PATCH 01/10] [libclc] Place libclc files in clang's resource dir

---
 libclc/CMakeLists.txt | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index e2871d1b01a16..8bc3a75739fcd 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -63,6 +63,9 @@ if( LIBCLC_STANDALONE_BUILD OR CMAKE_SOURCE_DIR STREQUAL 
CMAKE_CURRENT_SOURCE_DI
   set( ${tool}_target )
 endforeach()
   endif()
+
+  # Setup the paths where libclc runtimes should be stored.
+  set( LIBCLC_OUTPUT_LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR} )
 else()
   # In-tree configuration
   set( LIBCLC_STANDALONE_BUILD FALSE )
@@ -82,10 +85,14 @@ else()
 get_host_tool_path( llvm-link LLVM_LINK llvm-link_exe llvm-link_target )
 get_host_tool_path( opt OPT opt_exe opt_target )
   endif()
-endif()
 
-# Setup the paths where libclc runtimes should be stored.
-set( LIBCLC_OUTPUT_LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR} )
+  # Setup the paths where libclc runtimes should be stored. By default, in an
+  # in-tree build we place the libraries in clang's resource driectory.
+  get_clang_resource_dir( LIBCLC_OUTPUT_DIR PREFIX 
${LLVM_LIBRARY_OUTPUT_INTDIR}/.. )
+
+  # Note we do not adhere to LLVM_ENABLE_PER_TARGET_RUNTIME_DIR.
+  set( LIBCLC_OUTPUT_LIBRARY_DIR ${LIBCLC_OUTPUT_DIR}/lib/libclc )
+endif()
 
 if( EXISTS ${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR} )
   message( WARNING "Using custom LLVM tools to build libclc: "

>From 4057b6af7db11b59878739bff4d826a9fc616bbf Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Tue, 1 Jul 2025 10:56:54 +0100
Subject: [PATCH 02/10] [clang] Add the ability to link libclc OpenCL libraries

This commit adds driver support for linking libclc OpenCL libraries. It
takes the form of a new optional flag: --libclc-lib=namespec. Nothing is
linked unless this flag is specified.

Not all libclc targets have corresponding clang targets. For this reason
it is desirable for users to be able to specify a libclc library name.
We support this by taking both a library name (without the .bc suffix)
or a filename. Both of these are searched for in the clang resource
directory or in the LIBRARY_PATH environment variable. Filenames are
also checked themselves so that absolute paths can be provided. The
syntax for specifying filenames (as opposed to library names) uses a
leading colon (:), inspired by the -l option.

To accommodate this option, libclc libraries are now placed into clang's
resource directory in an in-tree configuration. The aliases are not
currently placed there to avoid polluting the directory, but that can be
changed. The libraries are all placed in /lib/libclc and
are not grouped under host-specific directories as some other runtime
libraries are; it is not expected that OpenCL libraries will differ
depending on the host toolchain.

Currently only the AMDGPU toolchain supports this option as a proof of
concept. Other targets such as NVPTX or SPIR/SPIR-V could support it
too. We could optionally let target toolchains search for libclc
libraries themselves, possibly when passed an empty --libclc-lib.
---
 .../clang/Basic/DiagnosticDriverKinds.td  |  3 +
 clang/include/clang/Driver/CommonArgs.h   |  3 +
 clang/include/clang/Driver/Options.td |  2 +
 clang/lib/Driver/ToolChains/AMDGPU.cpp|  2 +
 clang/lib/Driver/ToolChains/CommonArgs.cpp| 59 +++
 clang/test/Driver/Inputs/libclc/libclc.bc |  0
 .../Driver/Inputs/libclc/subdir/libclc.bc |  0
 clang/test/Driver/opencl-libclc.cl| 10 
 8 files changed, 79 insertions(+)
 create mode 100644 clang/test/Driver/Inputs/libclc/libclc.bc
 create mode 100644 clang/test/Driver/Inputs/libclc/subdir/libclc.bc
 create mode 100644 clang/test/Driver/opencl-libclc.cl

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 34b6c0d7a8acd..019161c22a24f 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -392,6 +392,9 @@ def warn_drv_fraw_string_literals_in_cxx11 : Warning<
   "ignoring '-f%select{no-|}0raw-string-literals', which is only valid for C 
and C++ standards before C++11">,
   InGroup;
 
+def err_drv_libclc_not_found : Error<
+  "no libclc library '%0' found in the clang resource directory or in 
LIBRARY_PATH">;
+
 def err_drv_invalid_malign_branch_EQ : Error<
   "invalid argument '%0' to -malign-branch=; each element must be one of: %1">;
 
diff --git a/clang/include/clang/Driver/CommonArgs.h 
b/clang/include/clang/Driver/CommonArgs.h
index 26aa3ccf84786..7e8ab82eb7863 100644
--- a/clang/include/clang/Driver/CommonArgs.h
+++ b/clang/include/clang/Driver/CommonArg

[clang] [clang-cl] Support /std:clatest (PR #147284)

2025-07-07 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> > You've got the same typo (?) in a bunch of places. You have `/stdc:latest` 
> > instead of `/std:clatest`. Same for `/std:c++latest`.
> 
> Good catch! Sheesh, fingers. Work!

Those are all addressed. This is what I get for typing `__STDC_*` as often as I 
do. :-D

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


[clang] [llvm] [RISCV] Implement Clang Builtins for XAndesPerf Extension (PR #147018)

2025-07-07 Thread Jim Lin via cfe-commits

https://github.com/tclin914 updated 
https://github.com/llvm/llvm-project/pull/147018

>From 4ee3cbce0032f57c30692654be160e2745955f04 Mon Sep 17 00:00:00 2001
From: Jim Lin 
Date: Mon, 5 May 2025 13:58:59 +0800
Subject: [PATCH 1/2] [RISCV] Implement Clang Builtins for XAndesPerf Extension

This patch adds the Clang builtins for byte comparision instructions in
XAndesPerf Extension. These instructions are hardly generated by
compiler. So we provide the Clang builtins for the user.
---
 clang/include/clang/Basic/BuiltinsRISCV.td|   5 +
 .../clang/Basic/BuiltinsRISCVXAndes.td|  29 
 clang/lib/CodeGen/TargetBuiltins/RISCV.cpp|  18 ++
 clang/lib/Headers/CMakeLists.txt  |   1 +
 clang/lib/Headers/riscv_nds.h |  47 ++
 .../CodeGen/RISCV/riscv-xandesperf-c-api.c| 159 ++
 clang/test/CodeGen/RISCV/riscv-xandesperf.c   | 109 
 llvm/include/llvm/IR/IntrinsicsRISCVXAndes.td |  14 ++
 llvm/lib/Target/RISCV/RISCVInstrInfoXAndes.td |  11 ++
 llvm/test/CodeGen/RISCV/rv32xandesperf.ll |  47 ++
 llvm/test/CodeGen/RISCV/rv64xandesperf.ll |  47 ++
 11 files changed, 487 insertions(+)
 create mode 100644 clang/include/clang/Basic/BuiltinsRISCVXAndes.td
 create mode 100644 clang/lib/Headers/riscv_nds.h
 create mode 100644 clang/test/CodeGen/RISCV/riscv-xandesperf-c-api.c
 create mode 100644 clang/test/CodeGen/RISCV/riscv-xandesperf.c

diff --git a/clang/include/clang/Basic/BuiltinsRISCV.td 
b/clang/include/clang/Basic/BuiltinsRISCV.td
index b2cd5648e008f..5927eaf80d57a 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.td
+++ b/clang/include/clang/Basic/BuiltinsRISCV.td
@@ -157,3 +157,8 @@ def pause : RISCVBuiltin<"void()">;
 // XCV extensions.
 
//===--===//
 include "clang/Basic/BuiltinsRISCVXCV.td"
+
+//===--===//
+// XAndes extensions.
+//===--===//
+include "clang/Basic/BuiltinsRISCVXAndes.td"
diff --git a/clang/include/clang/Basic/BuiltinsRISCVXAndes.td 
b/clang/include/clang/Basic/BuiltinsRISCVXAndes.td
new file mode 100644
index 0..8ebcc18889d6c
--- /dev/null
+++ b/clang/include/clang/Basic/BuiltinsRISCVXAndes.td
@@ -0,0 +1,29 @@
+//==- BuiltinsRISCVXAndes.td - RISC-V Andes Builtin database -*- C++ 
-*-==//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file defines the Andes-specific builtin function database.  Users of
+// this file must define the BUILTIN macro to make use of this information.
+//
+//===--===//
+
+class RISCVXAndesBuiltin : 
TargetBuiltin {
+  let Spellings = ["__builtin_riscv_nds_" # NAME];
+  let Prototype = prototype;
+  let Features = features;
+}
+
+let Attributes = [NoThrow, Const] in {
+//===--===//
+// XAndesPerf extension.
+//===--===//
+
+def ffb : RISCVXAndesBuiltin<"long int(unsigned long int, unsigned long 
int)", "xandesperf">;
+def ffzmism : RISCVXAndesBuiltin<"long int(unsigned long int, unsigned long 
int)", "xandesperf">;
+def ffmism  : RISCVXAndesBuiltin<"long int(unsigned long int, unsigned long 
int)", "xandesperf">;
+def flmism  : RISCVXAndesBuiltin<"long int(unsigned long int, unsigned long 
int)", "xandesperf">;
+} // Attributes = [NoThrow, Const]
diff --git a/clang/lib/CodeGen/TargetBuiltins/RISCV.cpp 
b/clang/lib/CodeGen/TargetBuiltins/RISCV.cpp
index 89e3f6f203df3..48a497b32a4a6 100644
--- a/clang/lib/CodeGen/TargetBuiltins/RISCV.cpp
+++ b/clang/lib/CodeGen/TargetBuiltins/RISCV.cpp
@@ -413,6 +413,24 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
 ID = Intrinsic::riscv_cv_alu_subuRN;
 break;
 
+  // XAndesPerf
+  case RISCV::BI__builtin_riscv_nds_ffb:
+IntrinsicTypes = {ResultType};
+ID = Intrinsic::riscv_nds_ffb;
+break;
+  case RISCV::BI__builtin_riscv_nds_ffzmism:
+IntrinsicTypes = {ResultType};
+ID = Intrinsic::riscv_nds_ffzmism;
+break;
+  case RISCV::BI__builtin_riscv_nds_ffmism:
+IntrinsicTypes = {ResultType};
+ID = Intrinsic::riscv_nds_ffmism;
+break;
+  case RISCV::BI__builtin_riscv_nds_flmism:
+IntrinsicTypes = {ResultType};
+ID = Intrinsic::riscv_nds_flmism;
+break;
+
 // Vector builtins are handled from here.
 #include "clang/Basic/riscv_vector_builtin_cg.inc"
 
diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index c96d209c1fc0c..44e2d4b1174c0 100644
--- a/clang/lib/Headers/

[clang] [clang] Fix manual memory management with SmallVector in ConceptRef (PR #147231)

2025-07-07 Thread Corentin Jabot via cfe-commits

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


[clang] 95862d0 - [clang] Fix manual memory management with SmallVector in ConceptRef (#147231)

2025-07-07 Thread via cfe-commits

Author: Bogdan Vetrenko
Date: 2025-07-07T14:09:04+02:00
New Revision: 95862d0897352de4bc7f4815def819639533bfc7

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

LOG: [clang] Fix manual memory management with SmallVector in ConceptRef 
(#147231)

This change replaces manual `new[]`/`delete[]` with `llvm::SmallVector`
for `TemplateArgumentLocInfo` in `createTrivialConceptReference`.

Added: 


Modified: 
clang/lib/AST/TypeLoc.cpp

Removed: 




diff  --git a/clang/lib/AST/TypeLoc.cpp b/clang/lib/AST/TypeLoc.cpp
index 1bdb86ad445a4..5c45c596538f8 100644
--- a/clang/lib/AST/TypeLoc.cpp
+++ b/clang/lib/AST/TypeLoc.cpp
@@ -22,6 +22,7 @@
 #include "clang/AST/TypeLocVisitor.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/MathExtras.h"
 #include 
@@ -652,9 +653,9 @@ static ConceptReference 
*createTrivialConceptReference(ASTContext &Context,
   DeclarationNameInfo(AT->getTypeConstraintConcept()->getDeclName(), Loc,
   AT->getTypeConstraintConcept()->getDeclName());
   unsigned size = AT->getTypeConstraintArguments().size();
-  TemplateArgumentLocInfo *TALI = new TemplateArgumentLocInfo[size];
+  llvm::SmallVector TALI(size);
   TemplateSpecializationTypeLoc::initializeArgLocs(
-  Context, AT->getTypeConstraintArguments(), TALI, Loc);
+  Context, AT->getTypeConstraintArguments(), TALI.data(), Loc);
   TemplateArgumentListInfo TAListI;
   for (unsigned i = 0; i < size; ++i) {
 TAListI.addArgument(
@@ -666,7 +667,6 @@ static ConceptReference 
*createTrivialConceptReference(ASTContext &Context,
   Context, NestedNameSpecifierLoc{}, Loc, DNI, nullptr,
   AT->getTypeConstraintConcept(),
   ASTTemplateArgumentListInfo::Create(Context, TAListI));
-  delete[] TALI;
   return ConceptRef;
 }
 



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


  1   2   3   4   5   6   >