[clang] [CIR] Upstream support for operator assign (PR #145979)

2025-06-27 Thread Henrich Lauko via cfe-commits

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

lgtm

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


[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

2025-06-27 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions c,cpp -- 
clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp 
clang/lib/StaticAnalyzer/Core/RegionStore.cpp 
clang/test/Analysis/call-and-message.c clang/test/Analysis/call-and-message.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
index 677cc6ee5..64587b205 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
@@ -259,7 +259,7 @@ public:
 if (T->getAsStructureType()) {
   if (Find(FR))
 return true;
-} else if (!I->isUnnamedBitField()){
+} else if (!I->isUnnamedBitField()) {
   SVal V = StoreMgr.getBinding(store, loc::MemRegionVal(FR));
   if (V.isUndef())
 return true;
diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp 
b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
index 120803670..2e509d09c 100644
--- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2133,7 +2133,7 @@ SVal 
RegionStoreManager::getBindingForField(RegionBindingsConstRef B,
   // The bits of the unnamed bit-field in local variable a can be anything.
   const FieldDecl *FD = R->getDecl();
   if (FD->isUnnamedBitField()) {
-  return UndefinedVal();
+return UndefinedVal();
   }
 
   // If the containing record was initialized, try to get its constant value.

``




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


[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-06-27 Thread Balázs Benics via cfe-commits

balazs-benics-sonarsource wrote:

Backporting this updated version to clang-19 was not easy but it allowed to 
verify this PR.
Unfortunately, there is a bug in this updated version, that I'll explain.
Even after I fixed this bug, however, on a sample it ran about 19.36% slower 
under analyzing hashing-heavy real-world code.

Example hashing-heavy real-world code from 
hyperscan:state_compress.c:storecompressed512_64bit


typedef unsigned long long __attribute__((aligned((8 u64a;

u64a compress64(u64a x, u64a m) {
  if ((x & m) == 0)
  return 0;
  x &= m;
  u64a mk = ~m << 1;
  for (unsigned i = 0; i < 6; i++) {
u64a mp = mk ^ (mk << 1);
mp ^= mp << 2;
mp ^= mp << 4;
mp ^= mp << 8;
mp ^= mp << 16;
mp ^= mp << 32;
u64a mv = mp & m;
m = (m ^ mv) | (mv >> (1 << i));
u64a t = x & mv;
x = (x ^ t) | (t >> (1 << i));
mk = mk & ~mp;
  }
  return x;
}

void storecompressed512_64bit(u64a *m, u64a *x) {
  u64a v[8] = {
compress64(x[0], m[0]),
compress64(x[1], m[1]),
compress64(x[2], m[2]),
compress64(x[3], m[3]),
compress64(x[4], m[4]),
compress64(x[5], m[5]),
compress64(x[6], m[6]),
compress64(x[7], m[7]),
  };
  (void)v;
}



The bug was that we inserted the `T` into the expected `InsertPos` 
corresponding to the `Profile` of `T` - so far so good, but instead of 
returning that, we checked if this is "overly complicated", and if so, we 
created the new `SymbolOverlyComplex` symbol and returned that instead. 
However, when the next time we get to call `acquired`, we would simply get a 
successful lookup for the `Profile` of `T` and return the symbol we actually 
wanted to hide! instead of returning the `SymbolOverlyComplex` that we returned 
in the previous `acquire` call. This took a while to debug.
My solution to this is pretty complicated and ugly. In short, check the 
complexity of the symbol before we do insertion/lookup.
If the complexity of this symbol would be below the threshold, then find or 
insert just like we did before.
Otherwise, we need to look up the wrapped symbol first, then check if we have a 
`SymbolOverlyComplex` with that wrapped symbol in the map. If there is, just 
return that one, otherwise we create it.

As you can tell, this is pretty convoluted. And its still slow. On the attached 
test case, I observed 19.36% slowdown (went from 1.503s to 1.794s).
So I have 2 ways of resolving this:
1) Continue the investigation about why this implementation is slow.
2) Revert back to the variant I originally proposed when I opened this PR.


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


[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

2025-06-27 Thread Baranov Victor via cfe-commits

vbvictor wrote:

Please fix formatting issues.

For first-time contributors, build workflows don't run automatically, members 
need to start them on each commit manually.

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


[clang] [CIR] Initial extra attributes for call operation (PR #145178)

2025-06-27 Thread Henrich Lauko via cfe-commits


@@ -368,4 +368,34 @@ def CIR_VisibilityAttr : CIR_Attr<"Visibility", 
"visibility"> {
   }];
 }
 
+//===--===//
+// ExtraFuncAttributesAttr
+//===--===//
+
+def ExtraFuncAttributesAttr : CIR_Attr<"ExtraFuncAttributes", "extra"> {

xlauko wrote:

Yeah, I am trying to get it work without custom unit attributes and 
`ExtraFuncAttributesAttr` but it will take me a bit more time. I first need to 
finish assembly format for FuncOp, so its easier to pull out these extra attrs. 
But I am almost there.

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


[clang] [clang]Fix Handle structs exceeding 1EB size limit (PR #146032)

2025-06-27 Thread via cfe-commits

https://github.com/Karthikdhondi updated 
https://github.com/llvm/llvm-project/pull/146032

>From c6bf84fd57c550b1c160c4497b0de2f2db87c31f Mon Sep 17 00:00:00 2001
From: Karthikdhondi 
Date: Fri, 27 Jun 2025 11:43:31 +0530
Subject: [PATCH 1/2] Fix: Handle structs exceeding 1EB size limit

---
 clang/include/clang/Basic/DiagnosticASTKinds.td |  2 ++
 clang/lib/AST/RecordLayoutBuilder.cpp   |  7 +++
 clang/test/AST/absurdly_big_struct.cpp  | 12 
 clang/test/Sema/offsetof-64.c   |  4 ++--
 4 files changed, 23 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/AST/absurdly_big_struct.cpp

diff --git a/clang/include/clang/Basic/DiagnosticASTKinds.td 
b/clang/include/clang/Basic/DiagnosticASTKinds.td
index d2cd86d05d55a..e3be4ab47633d 100644
--- a/clang/include/clang/Basic/DiagnosticASTKinds.td
+++ b/clang/include/clang/Basic/DiagnosticASTKinds.td
@@ -999,6 +999,8 @@ def note_module_odr_violation_mismatch_decl_unknown : Note<
   "different friend declaration|different function template|different method|"
   "different instance variable|different property|another unexpected decl}2">;
 
+def err_struct_too_large : Error<
+  "structure '%0' is too large, which exceeds maximum allowed size of %1 
bytes">;
 
 def remark_sanitize_address_insert_extra_padding_accepted : Remark<
 "-fsanitize-address-field-padding applied to %0">, ShowInSystemHeader,
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index aacc079f2521d..f6a4f76bcc7f6 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -3463,6 +3463,13 @@ ASTContext::getASTRecordLayout(const RecordDecl *D) 
const {
 
   ASTRecordLayouts[D] = NewEntry;
 
+  constexpr uint64_t MaxStructSizeInBytes = 1ULL << 60; 
+  CharUnits StructSize = NewEntry->getSize(); 
+  if (static_cast(StructSize.getQuantity()) >= MaxStructSizeInBytes) 
{
+getDiagnostics().Report(D->getLocation(), diag::err_struct_too_large)
+  << D->getName() << MaxStructSizeInBytes;
+  }
+
   if (getLangOpts().DumpRecordLayouts) {
 llvm::outs() << "\n*** Dumping AST Record Layout\n";
 DumpRecordLayout(D, llvm::outs(), getLangOpts().DumpRecordLayoutsSimple);
diff --git a/clang/test/AST/absurdly_big_struct.cpp 
b/clang/test/AST/absurdly_big_struct.cpp
new file mode 100644
index 0..04ac4d7ef6b74
--- /dev/null
+++ b/clang/test/AST/absurdly_big_struct.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu
+
+struct a { // expected-error {{structure 'a' is too large, which exceeds 
maximum allowed size of 1152921504606846976 bytes}}
+  char x[1ull<<60]; 
+  char x2[1ull<<60]; 
+};
+
+a z[1];
+long long x() { return sizeof(a); }
+long long x2() { return sizeof(a::x); }
+long long x3() { return sizeof(a::x2); }
+long long x4() { return sizeof(z); }
diff --git a/clang/test/Sema/offsetof-64.c b/clang/test/Sema/offsetof-64.c
index 8ffc3af985880..692698fe39e00 100644
--- a/clang/test/Sema/offsetof-64.c
+++ b/clang/test/Sema/offsetof-64.c
@@ -2,7 +2,7 @@
 
 // PR15216
 // Don't crash when taking computing the offset of structs with large arrays.
-const unsigned long Size = (1l << 60);
+const unsigned long Size = (1l << 58);
 
 struct Chunk1 {
   char padding[Size]; // expected-warning {{folded to constant}}
@@ -10,7 +10,7 @@ struct Chunk1 {
   char data;
 };
 
-int test1 = __builtin_offsetof(struct Chunk1, data);
+unsigned long test1 = __builtin_offsetof(struct Chunk1, data);
 
 struct Chunk2 {
   char padding[Size][Size][Size];  // expected-error {{array is too large}}

>From 49fcccdba686c7cf3f4bbbd10696c66c3527d942 Mon Sep 17 00:00:00 2001
From: Karthikdhondi 
Date: Fri, 27 Jun 2025 13:02:58 +0530
Subject: [PATCH 2/2] Fix: Handle structs exceeding 1EB size limit

---
 clang/lib/AST/RecordLayoutBuilder.cpp | 197 --
 1 file changed, 93 insertions(+), 104 deletions(-)

diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index f6a4f76bcc7f6..08bbc7b81dad9 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -43,7 +43,7 @@ struct BaseSubobjectInfo {
   bool IsVirtual;
 
   /// Bases - Information about the base subobjects.
-  SmallVector Bases;
+  SmallVector Bases;
 
   /// PrimaryVirtualBaseInfo - Holds the base info for the primary virtual base
   /// of this base info (if one exists).
@@ -77,8 +77,7 @@ struct ExternalLayout {
   /// Get the offset of the given field. The external source must provide
   /// entries for all fields in the record.
   uint64_t getExternalFieldOffset(const FieldDecl *FD) {
-assert(FieldOffsets.count(FD) &&
-   "Field does not have an external offset");
+assert(FieldOffsets.count(FD) && "Field does not have an external offset");
 return FieldOffsets[FD];
   }
 
@@ -167,16 +166,15 @@ class EmptySubobjectMap {
   CharUnits SizeOfLargestEmptySubobject;
 
   EmptyS

[clang] [analyzer][NFC] Fix clang-tidy warning in Malloc and UnixApi checkers (PR #145719)

2025-06-27 Thread Baranov Victor via cfe-commits

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


[clang] 8a839ea - [analyzer][NFC] Fix clang-tidy warning in Malloc and UnixApi checkers (#145719)

2025-06-27 Thread via cfe-commits

Author: Baranov Victor
Date: 2025-06-27T10:33:09+03:00
New Revision: 8a839ea79123175c940a64beea6abd29b8b302fb

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

LOG: [analyzer][NFC] Fix clang-tidy warning in Malloc and UnixApi checkers 
(#145719)

Mostly `else-after-return` and `else-after-continue` warnings

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index fa6e8e4146804..a33e61fabc2c1 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -34,7 +34,7 @@
 //   Depends on NewDeleteChecker.
 //
 //   * MismatchedDeallocatorChecker
-//   Enables checking whether memory is deallocated with the correspending
+//   Enables checking whether memory is deallocated with the corresponding
 //   allocation function in MallocChecker, such as malloc() allocated
 //   regions are only freed by free(), new by delete, new[] by delete[].
 //
@@ -1372,8 +1372,8 @@ void MallocChecker::checkIfFreeNameIndex(ProgramStateRef 
State,
   C.addTransition(State);
 }
 
-const Expr *getPlacementNewBufferArg(const CallExpr *CE,
- const FunctionDecl *FD) {
+static const Expr *getPlacementNewBufferArg(const CallExpr *CE,
+const FunctionDecl *FD) {
   // Checking for signature:
   // void* operator new  ( std::size_t count, void* ptr );
   // void* operator new[]( std::size_t count, void* ptr );
@@ -1682,17 +1682,15 @@ ProgramStateRef MallocChecker::ProcessZeroAllocCheck(
 const RefState *RS = State->get(Sym);
 if (RS) {
   if (RS->isAllocated())
-return TrueState->set(Sym,
-  
RefState::getAllocatedOfSizeZero(RS));
-  else
-return State;
-} else {
-  // Case of zero-size realloc. Historically 'realloc(ptr, 0)' is treated 
as
-  // 'free(ptr)' and the returned value from 'realloc(ptr, 0)' is not
-  // tracked. Add zero-reallocated Sym to the state to catch references
-  // to zero-allocated memory.
-  return TrueState->add(Sym);
+return TrueState->set(
+Sym, RefState::getAllocatedOfSizeZero(RS));
+  return State;
 }
+// Case of zero-size realloc. Historically 'realloc(ptr, 0)' is treated as
+// 'free(ptr)' and the returned value from 'realloc(ptr, 0)' is not
+// tracked. Add zero-reallocated Sym to the state to catch references
+// to zero-allocated memory.
+return TrueState->add(Sym);
   }
 
   // Assume the value is non-zero going forward.
@@ -1890,7 +1888,7 @@ void MallocChecker::reportTaintBug(StringRef Msg, 
ProgramStateRef State,
 "Tainted Memory Allocation",
 categories::TaintedData));
 auto R = std::make_unique(*BT_TaintedAlloc, Msg, 
N);
-for (auto TaintedSym : TaintedSyms) {
+for (const auto *TaintedSym : TaintedSyms) {
   R->markInteresting(TaintedSym);
 }
 C.emitReport(std::move(R));
@@ -2277,11 +2275,12 @@ MallocChecker::FreeMemAux(CheckerContext &C, const Expr 
*ArgExpr,
   HandleDoubleFree(C, ParentExpr->getSourceRange(), RsBase->isReleased(),
SymBase, PreviousRetStatusSymbol);
   return nullptr;
+}
 
 // If the pointer is allocated or escaped, but we are now trying to free 
it,
 // check that the call to free is proper.
-} else if (RsBase->isAllocated() || RsBase->isAllocatedOfSizeZero() ||
-   RsBase->isEscaped()) {
+if (RsBase->isAllocated() || RsBase->isAllocatedOfSizeZero() ||
+RsBase->isEscaped()) {
 
   // Check if an expected deallocation function matches the real one.
   bool DeallocMatchesAlloc = RsBase->getAllocationFamily() == Family;
@@ -2857,9 +2856,7 @@ MallocChecker::ReallocMemAux(CheckerContext &C, const 
CallEvent &Call,
 
   const CallExpr *CE = cast(Call.getOriginExpr());
 
-  if (SuffixWithN && CE->getNumArgs() < 3)
-return nullptr;
-  else if (CE->getNumArgs() < 2)
+  if ((SuffixWithN && CE->getNumArgs() < 3) || CE->getNumArgs() < 2)
 return nullptr;
 
   const Expr *arg0Expr = CE->getArg(0);

diff  --git a/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
index ce5887d56b181..e12261603757f 100644
--- a/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
@@ -223,6 +223,10 @@ void UnixAPIMisuseChecker::CheckOpenVariant(CheckerContext 
&C,
   //

[clang] [Clang][Sema] Allow qualified type names in `swift_name` attribute (PR #145947)

2025-06-27 Thread Gábor Horváth via cfe-commits

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


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


[clang] [llvm] AMDGPU: Add MC layer support for load transpose instructions for gfx1250 (PR #146024)

2025-06-27 Thread Jay Foad via cfe-commits

jayfoad wrote:

> Co-authored with @jayfoad

For future reference, please don't do this! 
https://discourse.llvm.org/t/forbidding-username-in-commits/86997

You could use a standard git `Co-authored-by:` tag instead or just omit it. I 
don't need the credit.

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


[clang] [llvm] [AMDGPU][Clang] Allow amdgpu-waves-per-eu attribute to lower target occupancy range (PR #138284)

2025-06-27 Thread Matt Arsenault via cfe-commits


@@ -0,0 +1,40 @@
+; RUN: not llvm-as -disable-output %s 2>&1 | FileCheck %s
+
+target triple = "amdgcn-amd-amdhsa"
+
+define void @valid_amdgpu_waves_per_eu_range() "amdgpu-waves-per-eu"="2,4" {
+  ret void
+}
+
+define void @valid_amdgpu_waves_per_eu_min_only() "amdgpu-waves-per-eu"="2" {
+  ret void
+}
+
+define void @valid_amdgpu_waves_per_eu_max_only() "amdgpu-waves-per-eu"="0,4" {
+  ret void
+}
+
+; CHECK: minimum for 'amdgpu-waves-per-eu' must be integer: x
+define void @invalid_amdgpu_waves_per_eu_min_nan() "amdgpu-waves-per-eu"="x" {
+  ret void
+}
+
+; CHECK: maximum for 'amdgpu-waves-per-eu' must be integer: x
+define void @invalid_amdgpu_waves_per_eu_max_nan() "amdgpu-waves-per-eu"="0,x" 
{
+  ret void
+}
+
+; CHECK: minimum for 'amdgpu-waves-per-eu' must be non-zero when maximum is 
not provided
+define void @invalid_amdgpu_waves_per_eu_min_zero() "amdgpu-waves-per-eu"="0" {
+  ret void
+}
+
+; CHECK: maximum for 'amdgpu-waves-per-eu' must be non-zero
+define void @invalid_amdgpu_waves_per_eu_max_zero() 
"amdgpu-waves-per-eu"="2,0" {
+  ret void
+}
+
+; CHECK: minimum must be less than or equal to maximum for 
'amdgpu-waves-per-eu': 2 > 1
+define void @invalid_amdgpu_waves_per_eu_max_lt_min() 
"amdgpu-waves-per-eu"="2,1" {
+  ret void
+}

arsenm wrote:

Test negative number 

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


[clang] [llvm] [AMDGPU][Clang] Allow amdgpu-waves-per-eu attribute to lower target occupancy range (PR #138284)

2025-06-27 Thread Matt Arsenault via cfe-commits


@@ -46,7 +46,6 @@ __attribute__((amdgpu_num_sgpr(4294967296))) kernel void 
kernel_num_sgpr_L() {}
 __attribute__((amdgpu_num_vgpr(4294967296))) kernel void kernel_num_vgpr_L() 
{} // expected-error {{integer constant expression evaluates to value 
4294967296 that cannot be represented in a 32-bit unsigned integer type}}
 
 __attribute__((amdgpu_flat_work_group_size(0, 64))) kernel void 
kernel_flat_work_group_size_0_64() {} // expected-error 
{{'amdgpu_flat_work_group_size' attribute argument is invalid: max must be 0 
since min is 0}}
-__attribute__((amdgpu_waves_per_eu(0, 4))) kernel void 
kernel_waves_per_eu_0_4() {} // expected-error {{'amdgpu_waves_per_eu' 
attribute argument is invalid: max must be 0 since min is 0}}

arsenm wrote:

Missing clang codegen test changes that show the new accepted values. This is 
still not emitting minimums of 0 though, so this is just losing a test? 


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


[clang] [llvm] [AMDGPU][Clang] Allow amdgpu-waves-per-eu attribute to lower target occupancy range (PR #138284)

2025-06-27 Thread Matt Arsenault via cfe-commits


@@ -2519,6 +2519,29 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, 
AttributeList Attrs,
   CheckFailed("invalid value for 'denormal-fp-math-f32' attribute: " + S,
   V);
   }
+
+  if (TT.isAMDGPU()) {
+if (auto A = Attrs.getFnAttr("amdgpu-waves-per-eu"); A.isValid()) {

arsenm wrote:

Probably should split this into a separate function 

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


[clang] [llvm] [AMDGPU][Clang] Allow amdgpu-waves-per-eu attribute to lower target occupancy range (PR #138284)

2025-06-27 Thread Matt Arsenault via cfe-commits


@@ -0,0 +1,40 @@
+; RUN: not llvm-as -disable-output %s 2>&1 | FileCheck %s
+
+target triple = "amdgcn-amd-amdhsa"
+
+define void @valid_amdgpu_waves_per_eu_range() "amdgpu-waves-per-eu"="2,4" {
+  ret void
+}

arsenm wrote:

valid cases are tested in test/Assembler or just implicitly from their other 
uses 

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


[clang] [llvm] [mlir] [debuginfo][coro] Emit debug info labels for coroutine resume points (PR #141937)

2025-06-27 Thread Chuanqi Xu via cfe-commits

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

I don't feel there are coroutine specific things, but if you want, I can accept 
this.

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


[clang] [llvm] [AMDGPU][Clang] Allow amdgpu-waves-per-eu attribute to lower target occupancy range (PR #138284)

2025-06-27 Thread Matt Arsenault via cfe-commits


@@ -2519,6 +2519,29 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, 
AttributeList Attrs,
   CheckFailed("invalid value for 'denormal-fp-math-f32' attribute: " + S,
   V);
   }
+
+  if (TT.isAMDGPU()) {
+if (auto A = Attrs.getFnAttr("amdgpu-waves-per-eu"); A.isValid()) {
+  std::pair Strs = A.getValueAsString().split(',');
+  unsigned Min = 0;
+  StringRef MinStr = Strs.first.trim();
+  Check(!MinStr.getAsInteger(0, Min),
+"minimum for 'amdgpu-waves-per-eu' must be integer: " + MinStr);
+  if (!Strs.second.empty()) {
+unsigned Max = 0;
+StringRef MaxStr = Strs.second.trim();
+Check(!MaxStr.getAsInteger(0, Max),
+  "maximum for 'amdgpu-waves-per-eu' must be integer: " + MaxStr);
+Check(Max, "maximum for 'amdgpu-waves-per-eu' must be non-zero");
+Check(Min <= Max, "minimum must be less than or equal to maximum for "
+  "'amdgpu-waves-per-eu': " +
+  MinStr + " > " + MaxStr);
+  } else {
+Check(Min, "minimum for 'amdgpu-waves-per-eu' must be non-zero when "
+   "maximum is not provided");
+  }
+}
+  }

arsenm wrote:

Should do this in separate patch. We could also drop some of the error messages 
we emit in the backend on parse failures of these 

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


[clang] [llvm] [NFC][analyzer] Remove Z3-as-constraint-manager hacks from lit test code (PR #145731)

2025-06-27 Thread Balazs Benics via cfe-commits
=?utf-8?q?Don=C3=A1t?= Nagy ,
=?utf-8?q?Don=C3=A1t?= Nagy ,
=?utf-8?q?Don=C3=A1t?= Nagy ,
=?utf-8?q?Don=C3=A1t?= Nagy 
Message-ID:
In-Reply-To: 


steakhal wrote:

@NagyDonat Can you look into this reported failure?

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


[clang] [clang] Add option for -nolibc in Driver/ToolChains/Baremetal.cpp (PR #145700)

2025-06-27 Thread William Huynh via cfe-commits


@@ -143,6 +143,20 @@
 // RUN:   | FileCheck %s --check-prefix=CHECK-RTLIB-GCC
 // CHECK-RTLIB-GCC: -lgcc
 
+// RUN: %clang -### --target=arm-none-eabi -nolibc %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-NOLIBC
+// CHECK-NOLIBC-NOT: "-lc"
+// CHECK-NOLIBC-NOT: "-lm"
+// CHECK-NOLIBC-NOT: "-lc++"
+// CHECK-NOLIBC: "{{[^"]*}}libclang_rt.builtins.a"
+
+// RUN: %clang -### --target=arm-none-eabi -nostdlib %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-NOSTDLIB
+// CHECK-NOSTDLIB-NOT: "-lc"
+// CHECK-NOSTDLIB-NOT: "-lm"
+// CHECK-NOSTDLIB-NOT: "-lc++"
+// CHECK-NOSTDLIB-NOT: "{{[^"]*}}libclang_rt.builtins.a"

saturn691 wrote:

Ditto previous comment

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


[clang] [CIR] Refactor type interfaces (PR #146044)

2025-06-27 Thread Henrich Lauko via cfe-commits

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


[clang] [llvm] [NFC][analyzer] Remove Z3-as-constraint-manager hacks from lit test code (PR #145731)

2025-06-27 Thread Donát Nagy via cfe-commits

NagyDonat wrote:

@mgorny I was unable to reproduce the failure that you observed -- based on the 
error message that you posted, you're in a situation where Z3_INCLUDE_DIR is 
not set by the clang build system _but_ these two tests which are marked with 
`REQUIRES: z3` are still executed somehow. (Perhaps you have Z3 installed in a 
standard system include directory?)

Nevertheless, my fix https://github.com/llvm/llvm-project/pull/146042 should 
work even in this case.

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


[clang] [llvm] [Clang][OpenMP] Capture mapped pointers on `target` by reference. (PR #145454)

2025-06-27 Thread Alexey Bataev via cfe-commits


@@ -8811,8 +8829,19 @@ class MappableExprsHandler {
 ++EI;
   }
 }
-llvm::stable_sort(DeclComponentLists, [](const MapData &LHS,
- const MapData &RHS) {
+llvm::stable_sort(DeclComponentLists, [VD](const MapData &LHS,
+   const MapData &RHS) {
+  // For cases like map(p, p[0], p[0][0]), the shortest map, like map(p)

alexey-bataev wrote:

Try to fix in a single loop at first. If it does not work, try splitting

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


[clang] [CIR] Refactor type interfaces (PR #146044)

2025-06-27 Thread Erich Keane via cfe-commits

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


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


[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-06-27 Thread Donát Nagy via cfe-commits

NagyDonat wrote:

I'm still convinced that the solution that returns `UnknownVal`s is 
unacceptable from a code readability and maintainability perspective. In my 
opinion adding so much complexity would be only acceptable if it was the only 
way to fix regularly occurring crash, and enforcing this invariant is not worth 
the change.

Of course, I understand that this is my personal opinion and can accept if 
other members of the community overrule it, but I'm strongly against it.

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


[clang] [llvm] [PowerPC] Add BCDCOPYSIGN and BCDSETSIGN Instruction Support (PR #144874)

2025-06-27 Thread Lei Huang via cfe-commits


@@ -515,6 +515,10 @@ TARGET_BUILTIN(__builtin_altivec_vctzh, "V8UsV8Us", "", 
"power9-vector")
 TARGET_BUILTIN(__builtin_altivec_vctzw, "V4UiV4Ui", "", "power9-vector")
 TARGET_BUILTIN(__builtin_altivec_vctzd, "V2ULLiV2ULLi", "", "power9-vector")
 
+//P9 BCD builtins
+TARGET_BUILTIN(__builtin_ppc_bcdcopysign, "V16UcV16UcV16Uc", "", 
"power9-vector")

lei137 wrote:

> We have [some similar bcd related builtins 
> ](https://github.com/llvm/llvm-project/blob/fe0568389d68eb828a2591fd519711694f8c1543/clang/include/clang/Basic/BuiltinsPPC.def#L528)
>  introduced on power8 and those are using the isa as a feature key as opposed 
> to power 8 builtin despite also using vector types.
> 
> > While they were introduced in ISA 3.0, they operate on vector types and 
> > require the vector unit.
> 
> FWIW I am guessing you have the right feature set and those others are 
> incorrect, but I'm not 100% sure on when we draw the distinction between the 
> 2 and so can't say for sure. The xl documentation you linked says it's 
> enabled by just -qarch=power9 (no mentioned of -qaltivec) which would be the 
> equivalent of the isa, not the vector feature.
> 
> @nemanjai @lei137 Do we split out the vector functionality because we can 
> disable the vector unit and so even though all power9s have the unit, you 
> cannot count on it being enabled?

Yes, we are able to specifically disable vector units via options so for 
instructions that require vectors we need to used the features that include 
vector units so it can error out gracefully if it is turned off.

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


[clang] [mlir] [OpenACC][CIR] Implement copyin/copyout/create lowering for compute/c… (PR #145976)

2025-06-27 Thread Erich Keane via cfe-commits

erichkeane wrote:

All fixed up!  

I had to make some changes to the dialect, so I'd very much like 
@razvanlupusoru to confirm/approve.

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


[clang] [Clang][NFC] - Move attr-cpuspecific-cpus test over to Sema (PR #146065)

2025-06-27 Thread Aaron Ballman via cfe-commits

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


[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-06-27 Thread Donát Nagy via cfe-commits

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


[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-06-27 Thread Donát Nagy via cfe-commits

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


[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-06-27 Thread Donát Nagy via cfe-commits

NagyDonat wrote:

> I'm still convinced that the solution that returns `UnknownVal`s is 
> unacceptable from a code readability and maintainability perspective. In my 
> opinion adding so much complexity would be only acceptable if it was the only 
> way to fix regularly occurring crash, and enforcing this invariant is not 
> worth the change.
> 
> Of course, I understand that this is my personal opinion and can accept if 
> other members of the community overrule it, but I'm strongly against it.



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


[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-06-27 Thread Donát Nagy via cfe-commits

NagyDonat wrote:

Closing this ticket was a misclick, sorry.

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


[clang] [llvm] [PowerPC] Add BCDCOPYSIGN and BCDSETSIGN Instruction Support (PR #144874)

2025-06-27 Thread Lei Huang via cfe-commits

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


[clang] [CIR] Upstream support for operator assign (PR #145979)

2025-06-27 Thread Erich Keane via cfe-commits


@@ -85,23 +85,24 @@ RValue 
CIRGenFunction::emitCXXMemberOrOperatorMemberCallExpr(
 return RValue::get(nullptr);
   }
 
-  bool trivialForCodegen =
-  md->isTrivial() || (md->isDefaulted() && md->getParent()->isUnion());
-  bool trivialAssignment =
-  trivialForCodegen &&
-  (md->isCopyAssignmentOperator() || md->isMoveAssignmentOperator()) &&
-  !md->getParent()->mayInsertExtraPadding();
-  (void)trivialAssignment;
+  // Note on trivial assignment
+  // --
+  // Classic codegen avoids generating the trivial copy/move assignment 
operator
+  // when it isn't necessary, choosing instead to just produce IR with an
+  // equivalent effect. We have chosen not to do that in CIR, instead emitting
+  // trivial copy/move assignment operators and allowing later transformations
+  // to optimize them away if appropriate.

erichkeane wrote:

I like this FWIW, and I think we should do MORE of this if we can get away with 
it.  The 'premature optimizations' in the FE are only there because LLVM-IR 
isn't expressive enough to make it clear it is legal.  CIR should make sure it 
is expressive enough for these situations.

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


[clang] [CIR] Upstream support for operator assign (PR #145979)

2025-06-27 Thread Erich Keane via cfe-commits


@@ -258,6 +258,30 @@ void CIRGenFunction::emitDelegateCXXConstructorCall(
  /*Delegating=*/true, thisAddr, delegateArgs, loc);
 }
 
+void CIRGenFunction::emitImplicitAssignmentOperatorBody(FunctionArgList &args) 
{
+  const auto *assignOp = cast(curGD.getDecl());

erichkeane wrote:

`assert(assignOp->isCopyAssignmentOperator() || 
assignOp->isMoveAssignmentOperator());`

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


[clang] [libcxx] [Clang] Add __builtin_invoke and use it in libc++ (PR #116709)

2025-06-27 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 updated 
https://github.com/llvm/llvm-project/pull/116709

>From e0bb550672326e21a556ac727f2e2a6ef65f0469 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser 
Date: Tue, 1 Oct 2024 11:08:02 +0200
Subject: [PATCH 01/12] [Clang] Add __builtin_invoke and recognize std::invoke
 as a builtin

---
 clang/include/clang/Basic/Builtins.td |   6 +
 clang/include/clang/Sema/Sema.h   |   9 +
 clang/lib/Parse/ParseDeclCXX.cpp  |  24 +--
 clang/lib/Sema/SemaChecking.cpp   |  97 +++
 clang/lib/Sema/SemaExprCXX.cpp| 105 ++--
 clang/test/CodeGenCXX/builtin-invoke.cpp  |  61 +++
 clang/test/SemaCXX/builtin-invoke.cpp | 133 +++
 libcxx/include/__type_traits/invoke.h | 155 ++
 .../__type_traits/is_core_convertible.h   |  11 ++
 9 files changed, 499 insertions(+), 102 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/builtin-invoke.cpp
 create mode 100644 clang/test/SemaCXX/builtin-invoke.cpp

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 187d3b5ed24a7..58cc35088c40a 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4272,6 +4272,12 @@ def MoveIfNsoexcept : CxxLibBuiltin<"utility"> {
   let Namespace = "std";
 }
 
+def Invoke : Builtin {
+  let Spellings = ["__builtin_invoke"];
+  let Attributes = [CustomTypeChecking, Constexpr];
+  let Prototype = "void(...)";
+}
+
 def Annotation : Builtin {
   let Spellings = ["__builtin_annotation"];
   let Attributes = [NoThrow, CustomTypeChecking];
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 5ec67087aeea4..22d66e8688906 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -2594,6 +2594,8 @@ class Sema final : public SemaBase {
SourceLocation BuiltinLoc,
SourceLocation RParenLoc);
 
+  ExprResult BuiltinInvoke(CallExpr *TheCall);
+
   static StringRef GetFormatStringTypeName(FormatStringType FST);
   static FormatStringType GetFormatStringType(StringRef FormatFlavor);
   static FormatStringType GetFormatStringType(const FormatAttr *Format);
@@ -15220,11 +15222,18 @@ class Sema final : public SemaBase {
SourceLocation Loc);
   QualType BuiltinRemoveReference(QualType BaseType, UTTKind UKind,
   SourceLocation Loc);
+
+  QualType BuiltinRemoveCVRef(QualType BaseType, SourceLocation Loc) {
+return BuiltinRemoveReference(BaseType, UTTKind::RemoveCVRef, Loc);
+  }
+
   QualType BuiltinChangeCVRQualifiers(QualType BaseType, UTTKind UKind,
   SourceLocation Loc);
   QualType BuiltinChangeSignedness(QualType BaseType, UTTKind UKind,
SourceLocation Loc);
 
+  bool BuiltinIsBaseOf(SourceLocation RhsTLoc, QualType LhsT, QualType RhsT);
+
   /// Ensure that the type T is a literal type.
   ///
   /// This routine checks whether the type @p T is a literal type. If @p T is 
an
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 316bc30edf1f0..aeb1112bad8b4 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -1611,29 +1611,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind 
TagTokKind,
   Tok.isOneOf(
 #define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) tok::kw___##Trait,
 #include "clang/Basic/TransformTypeTraits.def"
-  tok::kw___is_abstract,
-  tok::kw___is_aggregate,
-  tok::kw___is_arithmetic,
-  tok::kw___is_array,
-  tok::kw___is_assignable,
-  tok::kw___is_base_of,
-  tok::kw___is_bounded_array,
-  tok::kw___is_class,
-  tok::kw___is_complete_type,
-  tok::kw___is_compound,
-  tok::kw___is_const,
-  tok::kw___is_constructible,
-  tok::kw___is_convertible,
-  tok::kw___is_convertible_to,
-  tok::kw___is_destructible,
-  tok::kw___is_empty,
-  tok::kw___is_enum,
-  tok::kw___is_floating_point,
-  tok::kw___is_final,
-  tok::kw___is_function,
-  tok::kw___is_fundamental,
-  tok::kw___is_integral,
-  tok::kw___is_interface_class,
+  tok::kw___is_convertible, // Last use in libc++ was removed in 
925a11a
   tok::kw___is_literal,
   tok::kw___is_lvalue_expr,
   tok::kw___is_lvalue_reference,
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index a960b9931ddfd..26579de25bdf0 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2368,6 +2368,8 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
 return BuiltinShuffleVector(TheCall);
 // TheCall will be freed by the smart pointer here, but that's fine,

[clang] Suppress noreturn warning if last statement in a function is a throw (PR #145166)

2025-06-27 Thread Erich Keane via cfe-commits

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


[clang] Suppress noreturn warning if last statement in a function is a throw (PR #145166)

2025-06-27 Thread Erich Keane via cfe-commits


@@ -2434,9 +2434,12 @@ Sema::PopFunctionScopeInfo(const 
AnalysisBasedWarnings::Policy *WP,
 OpenMP().popOpenMPFunctionRegion(Scope.get());
 
   // Issue any analysis-based warnings.
-  if (WP && D)
+  if (WP && D) {
+if (auto *FD = dyn_cast(D)) {

erichkeane wrote:

Instead of doing the cast here, can we have `inferNoReturnAttr` just take 
`Decl`, and early-exist if the cast isn't valid?  Cleans this up a little.

Additionally, this is a case where you'd have to skip curley braces per coding 
standard.

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


[clang] Suppress noreturn warning if last statement in a function is a throw (PR #145166)

2025-06-27 Thread Erich Keane via cfe-commits

https://github.com/erichkeane commented:

Want 1 more test and a preference on interface, else I'm pretty good here.

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


[clang] [mlir] [OpenACC][CIR] Implement copyin/copyout/create lowering for compute/c… (PR #145976)

2025-06-27 Thread Erich Keane via cfe-commits

https://github.com/erichkeane updated 
https://github.com/llvm/llvm-project/pull/145976

>From b1c4ebc8e9efba38f2cda2696f60cc4a86c3fd89 Mon Sep 17 00:00:00 2001
From: erichkeane 
Date: Thu, 26 Jun 2025 09:02:15 -0700
Subject: [PATCH 1/2] [OpenACC][CIR] Implement copyin/copyout/create lowering
 for compute/combined

This patch does the lowering of copyin (represented as a
acc.copyin/acc.delete), copyout (acc.create/acc.copyin), and create
(acc.create/acc.delete).

Additionally, it found a few problems with #144806, so it fixes those as
well.
---
 clang/lib/CIR/CodeGen/CIRGenOpenACCClause.cpp |  51 ++
 .../combined-copyin-copyout-create.c  | 160 ++
 .../compute-copyin-copyout-create.c   | 128 ++
 mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp   |   6 +-
 mlir/test/Dialect/OpenACC/ops.mlir|  12 +-
 5 files changed, 354 insertions(+), 3 deletions(-)
 create mode 100644 
clang/test/CIR/CodeGenOpenACC/combined-copyin-copyout-create.c
 create mode 100644 
clang/test/CIR/CodeGenOpenACC/compute-copyin-copyout-create.c

diff --git a/clang/lib/CIR/CodeGen/CIRGenOpenACCClause.cpp 
b/clang/lib/CIR/CodeGen/CIRGenOpenACCClause.cpp
index 1454cee336a09..fe4145959b206 100644
--- a/clang/lib/CIR/CodeGen/CIRGenOpenACCClause.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenOpenACCClause.cpp
@@ -858,6 +858,57 @@ class OpenACCClauseCIREmitter final
 }
   }
 
+  void VisitCopyInClause(const OpenACCCopyInClause &clause) {
+if constexpr (isOneOfTypes) {
+  for (auto var : clause.getVarList())
+addDataOperand(
+var, mlir::acc::DataClause::acc_copyin, clause.getModifierList(),
+/*structured=*/true,
+/*implicit=*/false);
+} else if constexpr (isCombinedType) {
+  applyToComputeOp(clause);
+} else {
+  // TODO: When we've implemented this for everything, switch this to an
+  // unreachable. data, declare, combined constructs remain.
+  return clauseNotImplemented(clause);
+}
+  }
+
+  void VisitCopyOutClause(const OpenACCCopyOutClause &clause) {
+if constexpr (isOneOfTypes) {
+  for (auto var : clause.getVarList())
+addDataOperand(
+var, mlir::acc::DataClause::acc_copyout, clause.getModifierList(),
+/*structured=*/true,
+/*implicit=*/false);
+} else if constexpr (isCombinedType) {
+  applyToComputeOp(clause);
+} else {
+  // TODO: When we've implemented this for everything, switch this to an
+  // unreachable. data, declare, combined constructs remain.
+  return clauseNotImplemented(clause);
+}
+  }
+
+  void VisitCreateClause(const OpenACCCreateClause &clause) {
+if constexpr (isOneOfTypes) {
+  for (auto var : clause.getVarList())
+addDataOperand(
+var, mlir::acc::DataClause::acc_create, clause.getModifierList(),
+/*structured=*/true,
+/*implicit=*/false);
+} else if constexpr (isCombinedType) {
+  applyToComputeOp(clause);
+} else {
+  // TODO: When we've implemented this for everything, switch this to an
+  // unreachable. data, declare, combined constructs remain.
+  return clauseNotImplemented(clause);
+}
+  }
+
   void VisitUseDeviceClause(const OpenACCUseDeviceClause &clause) {
 if constexpr (isOneOfTypes) {
   for (auto var : clause.getVarList())
diff --git a/clang/test/CIR/CodeGenOpenACC/combined-copyin-copyout-create.c 
b/clang/test/CIR/CodeGenOpenACC/combined-copyin-copyout-create.c
new file mode 100644
index 0..d6179c012ee91
--- /dev/null
+++ b/clang/test/CIR/CodeGenOpenACC/combined-copyin-copyout-create.c
@@ -0,0 +1,160 @@
+// RUN: %clang_cc1 -fopenacc -Wno-openacc-self-if-potential-conflict -emit-cir 
-fclangir %s -o - | FileCheck %s
+
+void acc_combined(int parmVar) {
+  // CHECK: cir.func{{.*}} @acc_combined(%[[ARG:.*]]: !s32i{{.*}}) {
+  // CHECK-NEXT: %[[PARM:.*]] = cir.alloca !s32i, !cir.ptr, ["parmVar", 
init]
+
+  int localVar1;
+  // CHECK-NEXT: %[[LV1:.*]] = cir.alloca !s32i, !cir.ptr, ["localVar1"]
+  float localVar2;
+  // CHECK-NEXT: %[[LV2:.*]] = cir.alloca !cir.float, !cir.ptr, 
["localVar2"]
+  // CHECK-NEXT: cir.store %[[ARG]], %[[PARM]]
+#pragma acc parallel loop copyin(parmVar) copyout(localVar1) create(localVar2)
+  for(int i = 0; i < 5; ++i);
+  // CHECK-NEXT: %[[COPYIN1:.*]] = acc.copyin varPtr(%[[PARM]] : 
!cir.ptr) -> !cir.ptr {name = "parmVar"}
+  // CHECK-NEXT: %[[CREATE1:.*]] = acc.create varPtr(%[[LV1]] : 
!cir.ptr) -> !cir.ptr {dataClause = #acc, name = "localVar1"}
+  // CHECK-NEXT: %[[CREATE2:.*]] = acc.create varPtr(%[[LV2]] : 
!cir.ptr) -> !cir.ptr {name = "localVar2"}
+  // CHECK-NEXT: acc.parallel combined(loop) dataOperands(%[[COPYIN1]], 
%[[CREATE1]], %[[CREATE2]] : !cir.ptr, !cir.ptr, 
!cir.ptr) {
+  // CHECK-NEXT: acc.loop combined(parallel) {
+  // CHECK: acc.yield
+  // CHECK-NEXT: } loc
+  // CHECK-NEXT: acc.yield
+  // CHECK-NEXT: } loc
+  // CHECK-NEXT: acc.delete accPt

[clang] [CIR] Upstream support for operator assign (PR #145979)

2025-06-27 Thread Erich Keane via cfe-commits

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


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


[clang] [CIR] Add basic support for operator new (PR #145802)

2025-06-27 Thread Erich Keane via cfe-commits

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


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


[clang] [CIR] Upstream support for operator assign (PR #145979)

2025-06-27 Thread Erich Keane via cfe-commits


@@ -258,6 +258,30 @@ void CIRGenFunction::emitDelegateCXXConstructorCall(
  /*Delegating=*/true, thisAddr, delegateArgs, loc);
 }
 
+void CIRGenFunction::emitImplicitAssignmentOperatorBody(FunctionArgList &args) 
{
+  const auto *assignOp = cast(curGD.getDecl());
+  const Stmt *rootS = assignOp->getBody();
+  assert(isa(rootS) &&
+ "Body of an implicit assignment operator should be compound stmt.");
+  const auto *rootCS = cast(rootS);
+
+  // LexicalScope Scope(*this, RootCS->getSourceRange());
+  // FIXME(cir): add all of the below under a new scope.
+
+  assert(!cir::MissingFeatures::incrementProfileCounter());
+  // Classic codegen uses a special class to attempt to replace member
+  // initializers with memcpy. We could possibly defer that to the
+  // lowering or optimization phases to keep the memory accesses more
+  // explicit. For now, we don't insert memcpy at all, though in some
+  // cases the AST contains a call to memcpy.

erichkeane wrote:

FWIW, this is another case where CIR should be more expressive, and the FE 
shouldn't be doing this calculation.

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


[clang] c15f422 - [RISCV] Remove required features zvfhmin/zvfbfmin from plain f16/bf16 intrinsics (#145891)

2025-06-27 Thread via cfe-commits

Author: Jim Lin
Date: 2025-06-27T16:10:10+08:00
New Revision: c15f4225419f9857d255ca46674ce1af69156bda

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

LOG: [RISCV] Remove required features zvfhmin/zvfbfmin from plain f16/bf16 
intrinsics (#145891)

We've checked f16/bf16 vector type support using `checkRVVTypeSupport`.
So it's not necessary to add the required features for plain f16/bf16
intrinsics that do not use actual instructions from zvfhmin/zvfbfmin.

Added: 


Modified: 
clang/include/clang/Basic/riscv_vector.td

Removed: 




diff  --git a/clang/include/clang/Basic/riscv_vector.td 
b/clang/include/clang/Basic/riscv_vector.td
index f880f4876764a..5faf81272ec53 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -116,10 +116,7 @@ multiclass RVVIndexedLoad {
   foreach eew_list = EEWList[0-2] in {
 defvar eew = eew_list[0];
 defvar eew_type = eew_list[1];
-let Name = op # eew # "_v", IRName = op, MaskedIRName = op # "_mask",
-RequiredFeatures = !if(!eq(type, "x"), ["zvfhmin"],
-   !if(!eq(type, "y"), ["zvfbfmin"],
-   [])) in {
+let Name = op # eew # "_v", IRName = op, MaskedIRName = op # "_mask" 
in {
   def: RVVOutOp0Op1Builtin<"v", "vPCe" # eew_type # "Uv", type>;
 if !not(IsFloat.val) then {
   def: RVVOutOp0Op1Builtin<"Uv", "UvPCUe" # eew_type # "Uv", type>;
@@ -129,9 +126,7 @@ multiclass RVVIndexedLoad {
   defvar eew64 = "64";
   defvar eew64_type = "(Log2EEW:6)";
   let Name = op # eew64 # "_v", IRName = op, MaskedIRName = op # "_mask",
-  RequiredFeatures = !if(!eq(type, "x"), ["zvfhmin", "64bit"],
- !if(!eq(type, "y"), ["zvfbfmin", "64bit"],
- ["64bit"])) in {
+  RequiredFeatures = ["64bit"] in {
   def: RVVOutOp0Op1Builtin<"v", "vPCe" # eew64_type # "Uv", type>;
 if !not(IsFloat.val) then {
   def: RVVOutOp0Op1Builtin<"Uv", "UvPCUe" # eew64_type # "Uv", 
type>;
@@ -223,10 +218,7 @@ multiclass RVVIndexedStore {
 foreach eew_list = EEWList[0-2] in {
   defvar eew = eew_list[0];
   defvar eew_type = eew_list[1];
-  let Name = op # eew  # "_v", IRName = op, MaskedIRName = op # 
"_mask",
-  RequiredFeatures = !if(!eq(type, "x"), ["zvfhmin"],
- !if(!eq(type, "y"), ["zvfbfmin"],
- [])) in  {
+  let Name = op # eew  # "_v", IRName = op, MaskedIRName = op # 
"_mask" in {
 def : RVVBuiltin<"v", "0Pe" # eew_type # "Uvv", type>;
 if !not(IsFloat.val) then {
   def : RVVBuiltin<"Uv", "0PUe" # eew_type # "UvUv", type>;
@@ -236,9 +228,7 @@ multiclass RVVIndexedStore {
 defvar eew64 = "64";
 defvar eew64_type = "(Log2EEW:6)";
 let Name = op # eew64  # "_v", IRName = op, MaskedIRName = op # 
"_mask",
-RequiredFeatures = !if(!eq(type, "x"), ["zvfhmin", "64bit"],
-   !if(!eq(type, "y"), ["zvfbfmin", "64bit"],
-   ["64bit"])) in  {
+RequiredFeatures = ["64bit"] in {
   def : RVVBuiltin<"v", "0Pe" # eew64_type # "Uvv", type>;
   if !not(IsFloat.val) then {
 def : RVVBuiltin<"Uv", "0PUe" # eew64_type # "UvUv", type>;
@@ -361,15 +351,7 @@ multiclass RVVNonTupleVCreateBuiltin src_lmul_list> {
 defvar src_s = FixedVString.S;
 def vcreate # src_v # dst_v : RVVBuiltin;
-let RequiredFeatures = ["zvfhmin"] in
-  def vcreate_h # src_v # dst_v : RVVBuiltin;
-let RequiredFeatures = ["zvfbfmin"] in
-  def vcreate_bf16 # src_v # dst_v : RVVBuiltin;
+ "csilxfdy">;
 
 defvar src_uv = FixedVString.V;
 defvar src_us = FixedVString.S;
@@ -688,40 +670,24 @@ let HasBuiltinAlias = false,
 // 7.4. Vector Unit-Stride Instructions
 def vlm: RVVVLEMaskBuiltin;
 defm vle8: RVVVLEBuiltin<["c"]>;
-defm vle16: RVVVLEBuiltin<["s"]>;
-let Name = "vle16_v", RequiredFeatures = ["zvfhmin"] in
-  defm vle16_h: RVVVLEBuiltin<["x"]>;
-let Name = "vle16_v", RequiredFeatures = ["zvfbfmin"] in
-  defm vle16_bf16 : RVVVLEBuiltin<["y"]>;
+defm vle16: RVVVLEBuiltin<["s","x","y"]>;
 defm vle32: RVVVLEBuiltin<["i","f"]>;
 defm vle64: RVVVLEBuiltin<["l","d"]>;
 
 def vsm : RVVVSEMaskBuiltin;
 defm vse8 : RVVVSEBuiltin<["c"]>;
-defm vse16: RVVVSEBuiltin<["s"]>;
-let Name = "vse16_v", RequiredFeatures = ["zvfhmin"] in
-  defm vse16_h: RVVVSEBuiltin<["x"]>;
-let Name = "vse16_v", RequiredFeatu

[clang] [Clang] [CodeGen] UBSan Trap Reasons (PR #145967)

2025-06-27 Thread Michael Buch via cfe-commits

https://github.com/Michael137 commented:

LGTM (modulo the question about one of the message strings)

I'll let @delcypher comment on whether all his concerns have been addressed

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


[clang] [llvm] [NFC][analyzer] Remove Z3-as-constraint-manager hacks from lit test code (PR #145731)

2025-06-27 Thread Donát Nagy via cfe-commits

NagyDonat wrote:

I created PR https://github.com/llvm/llvm-project/pull/146042 which should 
hopefully fix this issue. (Right now I'm rebuilding clang to ensure that it is 
indeed working.)

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


[clang] [analyzer] Fix tests broken by empty %z3_include_dir (PR #146042)

2025-06-27 Thread via cfe-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r HEAD~1...HEAD clang/test/lit.cfg.py
``





View the diff from darker here.


``diff
--- lit.cfg.py  2025-06-27 09:22:29.00 +
+++ lit.cfg.py  2025-06-27 09:26:11.277653 +
@@ -178,13 +178,11 @@
 config.available_features.add("z3")
 if config.clang_staticanalyzer_z3_include_dir:
 I_z3_include_dir = '-I "%s"' % 
config.clang_staticanalyzer_z3_include_dir
 else:
 config.available_features.add("no-z3")
-config.substitutions.append(
-("%I_z3_include_dir", I_z3_include_dir)
-)
+config.substitutions.append(("%I_z3_include_dir", I_z3_include_dir))
 
 check_analyzer_fixit_path = os.path.join(
 config.test_source_root, "Analysis", "check-analyzer-fixit.py"
 )
 config.substitutions.append(

``




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


[clang] [CIR] Refactor type interfaces (PR #146044)

2025-06-27 Thread Henrich Lauko via cfe-commits

https://github.com/xlauko created 
https://github.com/llvm/llvm-project/pull/146044

- Generalizes CIRFPTypeInterface files to CIRTypeInterfaces for future type 
interfaces additions.
- Renames CIRFPTypeInterface to FPTypeInterface.
- Fixes FPTypeInterface tablegen prefix.

This mirrors incubator changes from https://github.com/llvm/clangir/pull/1713

>From 6d5e70e7fcc4f56f9f1c8a2ac519339e02720f21 Mon Sep 17 00:00:00 2001
From: xlauko 
Date: Fri, 27 Jun 2025 10:01:26 +0200
Subject: [PATCH] [CIR] Refactor type interfaces

- Generalizes CIRFPTypeInterface files to CIRTypeInterfaces for future type 
interfaces additions.
- Renames CIRFPTypeInterface to FPTypeInterface.
- Fixes FPTypeInterface tablegen prefix.

This mirrors incubator changes from https://github.com/llvm/clangir/pull/1713
---
 clang/include/clang/CIR/Dialect/IR/CIRAttrs.td   |  7 +++
 clang/include/clang/CIR/Dialect/IR/CIRTypes.h|  2 +-
 clang/include/clang/CIR/Dialect/IR/CIRTypes.td   |  4 ++--
 ...{CIRFPTypeInterface.h => CIRTypeInterfaces.h} | 10 +-
 ...IRFPTypeInterface.td => CIRTypeInterfaces.td} | 10 +-
 .../include/clang/CIR/Interfaces/CMakeLists.txt  |  2 +-
 clang/lib/CIR/CodeGen/CIRGenBuilder.cpp  |  3 +--
 clang/lib/CIR/CodeGen/CIRGenBuilder.h|  5 ++---
 clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp  |  2 +-
 clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp |  4 ++--
 clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp   | 12 ++--
 clang/lib/CIR/Dialect/IR/CIRAttrs.cpp|  8 
 clang/lib/CIR/Dialect/IR/CIRDialect.cpp  | 12 ++--
 clang/lib/CIR/Dialect/IR/CIRTypes.cpp|  3 +--
 ...FPTypeInterface.cpp => CIRTypeInterfaces.cpp} |  6 +++---
 clang/lib/CIR/Interfaces/CMakeLists.txt  |  4 ++--
 .../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp| 16 
 clang/lib/CIR/Lowering/LoweringHelpers.cpp   |  2 +-
 18 files changed, 54 insertions(+), 58 deletions(-)
 rename clang/include/clang/CIR/Interfaces/{CIRFPTypeInterface.h => 
CIRTypeInterfaces.h} (62%)
 rename clang/include/clang/CIR/Interfaces/{CIRFPTypeInterface.td => 
CIRTypeInterfaces.td} (81%)
 rename clang/lib/CIR/Interfaces/{CIRFPTypeInterface.cpp => 
CIRTypeInterfaces.cpp} (73%)

diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td 
b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
index 03e970db2847d..9a6560519eec4 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
@@ -160,18 +160,17 @@ def FPAttr : CIR_Attr<"FP", "fp", [TypedAttrInterface]> {
 value of the specified floating-point type. Supporting only CIR FP types.
   }];
   let parameters = (ins
-AttributeSelfTypeParameter<"", "::cir::CIRFPTypeInterface">:$type,
+AttributeSelfTypeParameter<"", "::cir::FPTypeInterface">:$type,
 APFloatParameter<"">:$value
   );
   let builders = [
 AttrBuilderWithInferredContext<(ins "mlir::Type":$type,
 "const llvm::APFloat &":$value), [{
-  return $_get(type.getContext(), mlir::cast(type),
-   value);
+  return $_get(type.getContext(), mlir::cast(type), 
value);
 }]>,
 AttrBuilder<(ins "mlir::Type":$type,
  "const llvm::APFloat &":$value), [{
-  return $_get($_ctxt, mlir::cast(type), value);
+  return $_get($_ctxt, mlir::cast(type), value);
 }]>,
   ];
   let extraClassDeclaration = [{
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.h 
b/clang/include/clang/CIR/Dialect/IR/CIRTypes.h
index 49933be724a04..620c72ef9023e 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.h
+++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.h
@@ -16,7 +16,7 @@
 #include "mlir/IR/BuiltinAttributes.h"
 #include "mlir/IR/Types.h"
 #include "mlir/Interfaces/DataLayoutInterfaces.h"
-#include "clang/CIR/Interfaces/CIRFPTypeInterface.h"
+#include "clang/CIR/Interfaces/CIRTypeInterfaces.h"
 
 namespace cir {
 
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td 
b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td
index 41d7d725a09e0..75c42a08c185f 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td
@@ -15,7 +15,7 @@
 
 include "clang/CIR/Dialect/IR/CIRDialect.td"
 include "clang/CIR/Dialect/IR/CIRTypeConstraints.td"
-include "clang/CIR/Interfaces/CIRFPTypeInterface.td"
+include "clang/CIR/Interfaces/CIRTypeInterfaces.td"
 include "mlir/Interfaces/DataLayoutInterfaces.td"
 include "mlir/IR/AttrTypeBase.td"
 
@@ -82,7 +82,7 @@ def CIR_IntType : CIR_Type<"Int", "int",
 
 class CIR_FloatType : CIR_Type,
-  DeclareTypeInterfaceMethods
+  DeclareTypeInterfaceMethods
 ]>;
 
 def CIR_Single : CIR_FloatType<"Single", "float"> {
diff --git a/clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.h 
b/clang/include/clang/CIR/Interfaces/CIRTypeInterfaces.h
similarity index 62%
rename from clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.h
rename to c

[clang] [CIR] Refactor type interfaces (PR #146044)

2025-06-27 Thread Henrich Lauko via cfe-commits

xlauko wrote:

* **#146045** https://app.graphite.dev/github/pr/llvm/llvm-project/146045?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#146044** https://app.graphite.dev/github/pr/llvm/llvm-project/146044?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/146044?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* `main`




This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn 
more about https://stacking.dev/?utm_source=stack-comment";>stacking.


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


[clang] [CIR] Refactor type interfaces (PR #146044)

2025-06-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clangir

Author: Henrich Lauko (xlauko)


Changes

- Generalizes CIRFPTypeInterface files to CIRTypeInterfaces for future type 
interfaces additions.
- Renames CIRFPTypeInterface to FPTypeInterface.
- Fixes FPTypeInterface tablegen prefix.

This mirrors incubator changes from https://github.com/llvm/clangir/pull/1713

---

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


18 Files Affected:

- (modified) clang/include/clang/CIR/Dialect/IR/CIRAttrs.td (+3-4) 
- (modified) clang/include/clang/CIR/Dialect/IR/CIRTypes.h (+1-1) 
- (modified) clang/include/clang/CIR/Dialect/IR/CIRTypes.td (+2-2) 
- (renamed) clang/include/clang/CIR/Interfaces/CIRTypeInterfaces.h (+5-5) 
- (renamed) clang/include/clang/CIR/Interfaces/CIRTypeInterfaces.td (+5-5) 
- (modified) clang/include/clang/CIR/Interfaces/CMakeLists.txt (+1-1) 
- (modified) clang/lib/CIR/CodeGen/CIRGenBuilder.cpp (+1-2) 
- (modified) clang/lib/CIR/CodeGen/CIRGenBuilder.h (+2-3) 
- (modified) clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp (+1-1) 
- (modified) clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp (+2-2) 
- (modified) clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp (+6-6) 
- (modified) clang/lib/CIR/Dialect/IR/CIRAttrs.cpp (+4-4) 
- (modified) clang/lib/CIR/Dialect/IR/CIRDialect.cpp (+6-6) 
- (modified) clang/lib/CIR/Dialect/IR/CIRTypes.cpp (+1-2) 
- (renamed) clang/lib/CIR/Interfaces/CIRTypeInterfaces.cpp (+3-3) 
- (modified) clang/lib/CIR/Interfaces/CMakeLists.txt (+2-2) 
- (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp (+8-8) 
- (modified) clang/lib/CIR/Lowering/LoweringHelpers.cpp (+1-1) 


``diff
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td 
b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
index 03e970db2847d..9a6560519eec4 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
@@ -160,18 +160,17 @@ def FPAttr : CIR_Attr<"FP", "fp", [TypedAttrInterface]> {
 value of the specified floating-point type. Supporting only CIR FP types.
   }];
   let parameters = (ins
-AttributeSelfTypeParameter<"", "::cir::CIRFPTypeInterface">:$type,
+AttributeSelfTypeParameter<"", "::cir::FPTypeInterface">:$type,
 APFloatParameter<"">:$value
   );
   let builders = [
 AttrBuilderWithInferredContext<(ins "mlir::Type":$type,
 "const llvm::APFloat &":$value), [{
-  return $_get(type.getContext(), mlir::cast(type),
-   value);
+  return $_get(type.getContext(), mlir::cast(type), 
value);
 }]>,
 AttrBuilder<(ins "mlir::Type":$type,
  "const llvm::APFloat &":$value), [{
-  return $_get($_ctxt, mlir::cast(type), value);
+  return $_get($_ctxt, mlir::cast(type), value);
 }]>,
   ];
   let extraClassDeclaration = [{
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.h 
b/clang/include/clang/CIR/Dialect/IR/CIRTypes.h
index 49933be724a04..620c72ef9023e 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.h
+++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.h
@@ -16,7 +16,7 @@
 #include "mlir/IR/BuiltinAttributes.h"
 #include "mlir/IR/Types.h"
 #include "mlir/Interfaces/DataLayoutInterfaces.h"
-#include "clang/CIR/Interfaces/CIRFPTypeInterface.h"
+#include "clang/CIR/Interfaces/CIRTypeInterfaces.h"
 
 namespace cir {
 
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td 
b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td
index 41d7d725a09e0..75c42a08c185f 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td
@@ -15,7 +15,7 @@
 
 include "clang/CIR/Dialect/IR/CIRDialect.td"
 include "clang/CIR/Dialect/IR/CIRTypeConstraints.td"
-include "clang/CIR/Interfaces/CIRFPTypeInterface.td"
+include "clang/CIR/Interfaces/CIRTypeInterfaces.td"
 include "mlir/Interfaces/DataLayoutInterfaces.td"
 include "mlir/IR/AttrTypeBase.td"
 
@@ -82,7 +82,7 @@ def CIR_IntType : CIR_Type<"Int", "int",
 
 class CIR_FloatType : CIR_Type,
-  DeclareTypeInterfaceMethods
+  DeclareTypeInterfaceMethods
 ]>;
 
 def CIR_Single : CIR_FloatType<"Single", "float"> {
diff --git a/clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.h 
b/clang/include/clang/CIR/Interfaces/CIRTypeInterfaces.h
similarity index 62%
rename from clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.h
rename to clang/include/clang/CIR/Interfaces/CIRTypeInterfaces.h
index 40b85ef6cfb62..d5d2f5a7fa657 100644
--- a/clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.h
+++ b/clang/include/clang/CIR/Interfaces/CIRTypeInterfaces.h
@@ -6,17 +6,17 @@
 //
 //===-===//
 //
-// Defines the interface to generically handle CIR floating-point types.
+// Defines cir type interfaces.
 //
 
//===--===//
 
-#ifndef LLVM_CLANG_INCLUDE_

[clang] [CIR] Refactor type interfaces (PR #146044)

2025-06-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Henrich Lauko (xlauko)


Changes

- Generalizes CIRFPTypeInterface files to CIRTypeInterfaces for future type 
interfaces additions.
- Renames CIRFPTypeInterface to FPTypeInterface.
- Fixes FPTypeInterface tablegen prefix.

This mirrors incubator changes from https://github.com/llvm/clangir/pull/1713

---

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


18 Files Affected:

- (modified) clang/include/clang/CIR/Dialect/IR/CIRAttrs.td (+3-4) 
- (modified) clang/include/clang/CIR/Dialect/IR/CIRTypes.h (+1-1) 
- (modified) clang/include/clang/CIR/Dialect/IR/CIRTypes.td (+2-2) 
- (renamed) clang/include/clang/CIR/Interfaces/CIRTypeInterfaces.h (+5-5) 
- (renamed) clang/include/clang/CIR/Interfaces/CIRTypeInterfaces.td (+5-5) 
- (modified) clang/include/clang/CIR/Interfaces/CMakeLists.txt (+1-1) 
- (modified) clang/lib/CIR/CodeGen/CIRGenBuilder.cpp (+1-2) 
- (modified) clang/lib/CIR/CodeGen/CIRGenBuilder.h (+2-3) 
- (modified) clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp (+1-1) 
- (modified) clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp (+2-2) 
- (modified) clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp (+6-6) 
- (modified) clang/lib/CIR/Dialect/IR/CIRAttrs.cpp (+4-4) 
- (modified) clang/lib/CIR/Dialect/IR/CIRDialect.cpp (+6-6) 
- (modified) clang/lib/CIR/Dialect/IR/CIRTypes.cpp (+1-2) 
- (renamed) clang/lib/CIR/Interfaces/CIRTypeInterfaces.cpp (+3-3) 
- (modified) clang/lib/CIR/Interfaces/CMakeLists.txt (+2-2) 
- (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp (+8-8) 
- (modified) clang/lib/CIR/Lowering/LoweringHelpers.cpp (+1-1) 


``diff
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td 
b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
index 03e970db2847d..9a6560519eec4 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
@@ -160,18 +160,17 @@ def FPAttr : CIR_Attr<"FP", "fp", [TypedAttrInterface]> {
 value of the specified floating-point type. Supporting only CIR FP types.
   }];
   let parameters = (ins
-AttributeSelfTypeParameter<"", "::cir::CIRFPTypeInterface">:$type,
+AttributeSelfTypeParameter<"", "::cir::FPTypeInterface">:$type,
 APFloatParameter<"">:$value
   );
   let builders = [
 AttrBuilderWithInferredContext<(ins "mlir::Type":$type,
 "const llvm::APFloat &":$value), [{
-  return $_get(type.getContext(), mlir::cast(type),
-   value);
+  return $_get(type.getContext(), mlir::cast(type), 
value);
 }]>,
 AttrBuilder<(ins "mlir::Type":$type,
  "const llvm::APFloat &":$value), [{
-  return $_get($_ctxt, mlir::cast(type), value);
+  return $_get($_ctxt, mlir::cast(type), value);
 }]>,
   ];
   let extraClassDeclaration = [{
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.h 
b/clang/include/clang/CIR/Dialect/IR/CIRTypes.h
index 49933be724a04..620c72ef9023e 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.h
+++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.h
@@ -16,7 +16,7 @@
 #include "mlir/IR/BuiltinAttributes.h"
 #include "mlir/IR/Types.h"
 #include "mlir/Interfaces/DataLayoutInterfaces.h"
-#include "clang/CIR/Interfaces/CIRFPTypeInterface.h"
+#include "clang/CIR/Interfaces/CIRTypeInterfaces.h"
 
 namespace cir {
 
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td 
b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td
index 41d7d725a09e0..75c42a08c185f 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td
@@ -15,7 +15,7 @@
 
 include "clang/CIR/Dialect/IR/CIRDialect.td"
 include "clang/CIR/Dialect/IR/CIRTypeConstraints.td"
-include "clang/CIR/Interfaces/CIRFPTypeInterface.td"
+include "clang/CIR/Interfaces/CIRTypeInterfaces.td"
 include "mlir/Interfaces/DataLayoutInterfaces.td"
 include "mlir/IR/AttrTypeBase.td"
 
@@ -82,7 +82,7 @@ def CIR_IntType : CIR_Type<"Int", "int",
 
 class CIR_FloatType : CIR_Type,
-  DeclareTypeInterfaceMethods
+  DeclareTypeInterfaceMethods
 ]>;
 
 def CIR_Single : CIR_FloatType<"Single", "float"> {
diff --git a/clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.h 
b/clang/include/clang/CIR/Interfaces/CIRTypeInterfaces.h
similarity index 62%
rename from clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.h
rename to clang/include/clang/CIR/Interfaces/CIRTypeInterfaces.h
index 40b85ef6cfb62..d5d2f5a7fa657 100644
--- a/clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.h
+++ b/clang/include/clang/CIR/Interfaces/CIRTypeInterfaces.h
@@ -6,17 +6,17 @@
 //
 //===-===//
 //
-// Defines the interface to generically handle CIR floating-point types.
+// Defines cir type interfaces.
 //
 
//===--===//
 
-#ifndef LLVM_CLANG_INCLUDE_CL

[clang] [analyzer] Fix tests broken by empty %z3_include_dir (PR #146042)

2025-06-27 Thread Donát Nagy via cfe-commits

https://github.com/NagyDonat updated 
https://github.com/llvm/llvm-project/pull/146042

From b7bfc546397c42b1e26cfd0d10bdf583d0091ff4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Don=C3=A1t=20Nagy?= 
Date: Fri, 27 Jun 2025 11:22:29 +0200
Subject: [PATCH 1/2] [analyzer] Fix tests broken by empty %z3_include_dir

---
 clang/test/Analysis/z3-crosscheck-max-attempts.cpp | 2 +-
 clang/test/Analysis/z3/D83660.c| 2 +-
 clang/test/lit.cfg.py  | 9 ++---
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/clang/test/Analysis/z3-crosscheck-max-attempts.cpp 
b/clang/test/Analysis/z3-crosscheck-max-attempts.cpp
index 572e452fdcac2..1c93f32fc21f5 100644
--- a/clang/test/Analysis/z3-crosscheck-max-attempts.cpp
+++ b/clang/test/Analysis/z3-crosscheck-max-attempts.cpp
@@ -4,7 +4,7 @@
 // CHECK: crosscheck-with-z3-max-attempts-per-query = 3
 
 // RUN: rm -rf %t && mkdir %t
-// RUN: %host_cxx -shared -fPIC -I %z3_include_dir\
+// RUN: %host_cxx -shared -fPIC %I_z3_include_dir \
 // RUN:   %S/z3/Inputs/MockZ3_solver_check.cpp\
 // RUN:   -o %t/MockZ3_solver_check.so
 
diff --git a/clang/test/Analysis/z3/D83660.c b/clang/test/Analysis/z3/D83660.c
index 0a7c8bab8e345..a24566adbc7d1 100644
--- a/clang/test/Analysis/z3/D83660.c
+++ b/clang/test/Analysis/z3/D83660.c
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t && mkdir %t
-// RUN: %host_cxx -shared -fPIC -I %z3_include_dir \
+// RUN: %host_cxx -shared -fPIC %I_z3_include_dir \
 // RUN:   %S/Inputs/MockZ3_solver_check.cpp \
 // RUN:   -o %t/MockZ3_solver_check.so
 //
diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 24bcdb5b668fc..3d79f44ff8967 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -173,13 +173,16 @@ def have_host_clang_repl_cuda():
 config.available_features.add("staticanalyzer")
 tools.append("clang-check")
 
+I_z3_include_dir = ""
 if config.clang_staticanalyzer_z3:
 config.available_features.add("z3")
-config.substitutions.append(
-("%z3_include_dir", config.clang_staticanalyzer_z3_include_dir)
-)
+if config.clang_staticanalyzer_z3_include_dir:
+I_z3_include_dir = '-I "%s"' % 
config.clang_staticanalyzer_z3_include_dir
 else:
 config.available_features.add("no-z3")
+config.substitutions.append(
+("%I_z3_include_dir", I_z3_include_dir)
+)
 
 check_analyzer_fixit_path = os.path.join(
 config.test_source_root, "Analysis", "check-analyzer-fixit.py"

From e4e8428a21e4a4fec426395a4856ff0621e88afe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Don=C3=A1t=20Nagy?= 
Date: Fri, 27 Jun 2025 11:28:31 +0200
Subject: [PATCH 2/2] Satisfy darker code formatting

---
 clang/test/lit.cfg.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 3d79f44ff8967..1581ae4463a28 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -180,9 +180,7 @@ def have_host_clang_repl_cuda():
 I_z3_include_dir = '-I "%s"' % 
config.clang_staticanalyzer_z3_include_dir
 else:
 config.available_features.add("no-z3")
-config.substitutions.append(
-("%I_z3_include_dir", I_z3_include_dir)
-)
+config.substitutions.append(("%I_z3_include_dir", I_z3_include_dir))
 
 check_analyzer_fixit_path = os.path.join(
 config.test_source_root, "Analysis", "check-analyzer-fixit.py"

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


[clang] [libcxx] [Clang] Add __builtin_invoke and use it in libc++ (PR #116709)

2025-06-27 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 updated 
https://github.com/llvm/llvm-project/pull/116709

>From e0bb550672326e21a556ac727f2e2a6ef65f0469 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser 
Date: Tue, 1 Oct 2024 11:08:02 +0200
Subject: [PATCH 01/11] [Clang] Add __builtin_invoke and recognize std::invoke
 as a builtin

---
 clang/include/clang/Basic/Builtins.td |   6 +
 clang/include/clang/Sema/Sema.h   |   9 +
 clang/lib/Parse/ParseDeclCXX.cpp  |  24 +--
 clang/lib/Sema/SemaChecking.cpp   |  97 +++
 clang/lib/Sema/SemaExprCXX.cpp| 105 ++--
 clang/test/CodeGenCXX/builtin-invoke.cpp  |  61 +++
 clang/test/SemaCXX/builtin-invoke.cpp | 133 +++
 libcxx/include/__type_traits/invoke.h | 155 ++
 .../__type_traits/is_core_convertible.h   |  11 ++
 9 files changed, 499 insertions(+), 102 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/builtin-invoke.cpp
 create mode 100644 clang/test/SemaCXX/builtin-invoke.cpp

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 187d3b5ed24a7..58cc35088c40a 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4272,6 +4272,12 @@ def MoveIfNsoexcept : CxxLibBuiltin<"utility"> {
   let Namespace = "std";
 }
 
+def Invoke : Builtin {
+  let Spellings = ["__builtin_invoke"];
+  let Attributes = [CustomTypeChecking, Constexpr];
+  let Prototype = "void(...)";
+}
+
 def Annotation : Builtin {
   let Spellings = ["__builtin_annotation"];
   let Attributes = [NoThrow, CustomTypeChecking];
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 5ec67087aeea4..22d66e8688906 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -2594,6 +2594,8 @@ class Sema final : public SemaBase {
SourceLocation BuiltinLoc,
SourceLocation RParenLoc);
 
+  ExprResult BuiltinInvoke(CallExpr *TheCall);
+
   static StringRef GetFormatStringTypeName(FormatStringType FST);
   static FormatStringType GetFormatStringType(StringRef FormatFlavor);
   static FormatStringType GetFormatStringType(const FormatAttr *Format);
@@ -15220,11 +15222,18 @@ class Sema final : public SemaBase {
SourceLocation Loc);
   QualType BuiltinRemoveReference(QualType BaseType, UTTKind UKind,
   SourceLocation Loc);
+
+  QualType BuiltinRemoveCVRef(QualType BaseType, SourceLocation Loc) {
+return BuiltinRemoveReference(BaseType, UTTKind::RemoveCVRef, Loc);
+  }
+
   QualType BuiltinChangeCVRQualifiers(QualType BaseType, UTTKind UKind,
   SourceLocation Loc);
   QualType BuiltinChangeSignedness(QualType BaseType, UTTKind UKind,
SourceLocation Loc);
 
+  bool BuiltinIsBaseOf(SourceLocation RhsTLoc, QualType LhsT, QualType RhsT);
+
   /// Ensure that the type T is a literal type.
   ///
   /// This routine checks whether the type @p T is a literal type. If @p T is 
an
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 316bc30edf1f0..aeb1112bad8b4 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -1611,29 +1611,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind 
TagTokKind,
   Tok.isOneOf(
 #define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) tok::kw___##Trait,
 #include "clang/Basic/TransformTypeTraits.def"
-  tok::kw___is_abstract,
-  tok::kw___is_aggregate,
-  tok::kw___is_arithmetic,
-  tok::kw___is_array,
-  tok::kw___is_assignable,
-  tok::kw___is_base_of,
-  tok::kw___is_bounded_array,
-  tok::kw___is_class,
-  tok::kw___is_complete_type,
-  tok::kw___is_compound,
-  tok::kw___is_const,
-  tok::kw___is_constructible,
-  tok::kw___is_convertible,
-  tok::kw___is_convertible_to,
-  tok::kw___is_destructible,
-  tok::kw___is_empty,
-  tok::kw___is_enum,
-  tok::kw___is_floating_point,
-  tok::kw___is_final,
-  tok::kw___is_function,
-  tok::kw___is_fundamental,
-  tok::kw___is_integral,
-  tok::kw___is_interface_class,
+  tok::kw___is_convertible, // Last use in libc++ was removed in 
925a11a
   tok::kw___is_literal,
   tok::kw___is_lvalue_expr,
   tok::kw___is_lvalue_reference,
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index a960b9931ddfd..26579de25bdf0 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2368,6 +2368,8 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
 return BuiltinShuffleVector(TheCall);
 // TheCall will be freed by the smart pointer here, but that's fine,

[clang] [llvm] [RISCV] Added the MIPS prefetch extensions for MIPS RV64 P8700. (PR #145647)

2025-06-27 Thread via cfe-commits

https://github.com/ukalappa-mips updated 
https://github.com/llvm/llvm-project/pull/145647

>From 8a1f98820b280b02f0662c7129a078680d67497f Mon Sep 17 00:00:00 2001
From: Umesh Kalappa 
Date: Wed, 25 Jun 2025 06:58:37 +
Subject: [PATCH 1/4] Added prefetch extensions for MIPS RV64 P8700 and enable
 with xmipscbop option.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Please refer "MIPS RV64 P8700/P8700-F Multiprocessing System Programmer’s 
Guide" for more info on the extension
at 
https://mips.com/wp-content/uploads/2025/06/P8700_Programmers_Reference_Manual_Rev1.84_5-31-2025.pdf
---
 .../Driver/print-supported-extensions-riscv.c |  1 +
 llvm/docs/RISCVUsage.rst  |  3 ++
 .../Target/RISCV/AsmParser/RISCVAsmParser.cpp |  5 ++
 .../RISCV/Disassembler/RISCVDisassembler.cpp  | 18 +++
 .../Target/RISCV/MCTargetDesc/RISCVBaseInfo.h |  1 +
 llvm/lib/Target/RISCV/RISCVFeatures.td|  7 +++
 llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp   | 48 +++
 llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h |  4 ++
 llvm/lib/Target/RISCV/RISCVISelLowering.cpp   |  2 +-
 llvm/lib/Target/RISCV/RISCVInstrInfo.cpp  |  3 ++
 llvm/lib/Target/RISCV/RISCVInstrInfoXMips.td  | 38 +++
 llvm/lib/Target/RISCV/RISCVInstrInfoZicbo.td  |  4 +-
 llvm/test/CodeGen/RISCV/features-info.ll  |  1 +
 llvm/test/CodeGen/RISCV/xmips-cbop.ll | 40 
 llvm/test/MC/RISCV/xmips-invalid.s| 11 -
 llvm/test/MC/RISCV/xmips-valid.s  | 18 +--
 .../TargetParser/RISCVISAInfoTest.cpp |  1 +
 17 files changed, 198 insertions(+), 7 deletions(-)
 create mode 100644 llvm/test/CodeGen/RISCV/xmips-cbop.ll

diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 5008c2b7f789d..204e6860b6d67 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -169,6 +169,7 @@
 // CHECK-NEXT: xcvmac   1.0   'XCVmac' (CORE-V 
Multiply-Accumulate)
 // CHECK-NEXT: xcvmem   1.0   'XCVmem' (CORE-V 
Post-incrementing Load & Store)
 // CHECK-NEXT: xcvsimd  1.0   'XCVsimd' (CORE-V SIMD ALU)
+// CHECK-NEXT: xmipscbop1.0   'XMIPSCBOP' (MIPS Software 
Prefetch)
 // CHECK-NEXT: xmipscmov1.0   'XMIPSCMov' (MIPS 
conditional move instruction (mips.ccmov))
 // CHECK-NEXT: xmipslsp 1.0   'XMIPSLSP' (MIPS 
optimization for hardware load-store bonding)
 // CHECK-NEXT: xsfcease 1.0   'XSfcease' (SiFive sf.cease 
Instruction)
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 81684ba30f12c..82114791b3c0c 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -498,6 +498,9 @@ The current vendor extensions supported are:
 ``experimental-Xqcisync``
   LLVM implements `version 0.3 of the Qualcomm uC Sync Delay extension 
specification 
`__ by 
Qualcomm. These instructions are only available for riscv32.
 
+``Xmipscbop``
+  LLVM implements MIPS prefetch extension `p8700 processor 
`__ by MIPS.
+
 ``Xmipscmov``
   LLVM implements conditional move for the `p8700 processor 
`__ by MIPS.
 
diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index e5d8ab07891ac..edb319e460e35 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -732,6 +732,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
   bool isUImm6() const { return isUImm<6>(); }
   bool isUImm7() const { return isUImm<7>(); }
   bool isUImm8() const { return isUImm<8>(); }
+  bool isUImm9() const { return isUImm<9>(); }
   bool isUImm10() const { return isUImm<10>(); }
   bool isUImm11() const { return isUImm<11>(); }
   bool isUImm16() const { return isUImm<16>(); }
@@ -1523,6 +1524,10 @@ bool RISCVAsmParser::matchAndEmitInstruction(SMLoc 
IDLoc, unsigned &Opcode,
 return generateImmOutOfRangeError(
 Operands, ErrorInfo, 0, (1 << 8) - 8,
 "immediate must be a multiple of 8 bytes in the range");
+  case Match_InvalidUImm9:
+return generateImmOutOfRangeError(
+Operands, ErrorInfo, 0, (1 << 9) - 1,
+"immediate must be a multiple of 9 bytes in the range");
   case Match_InvalidBareSImm9Lsb0:
 return generateImmOutOfRangeError(
 Operands, ErrorInfo, -(1 << 8), (1 << 8) - 2,
diff --git a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp 
b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
index 27e04c0cb1f8b..043aaec11e8c5 100644
--- a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
+++ b/llvm/lib/Target/RISCV/D

[clang] [clang] Add option for -nolibc in Driver/ToolChains/Baremetal.cpp (PR #145700)

2025-06-27 Thread William Huynh via cfe-commits


@@ -143,6 +143,20 @@
 // RUN:   | FileCheck %s --check-prefix=CHECK-RTLIB-GCC
 // CHECK-RTLIB-GCC: -lgcc
 
+// RUN: %clang -### --target=arm-none-eabi -nolibc %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-NOLIBC
+// CHECK-NOLIBC-NOT: "-lc"
+// CHECK-NOLIBC-NOT: "-lm"
+// CHECK-NOLIBC-NOT: "-lc++"
+// CHECK-NOLIBC: "{{[^"]*}}libclang_rt.builtins.a"

saturn691 wrote:

The thing I'm trying to test is the follows, I think it _still_ makes sense to 
test `libclang_rt.builtings.a`:

-nolibc
Do not use the C library or system libraries tightly coupled with it when 
linking. **Still link with the startup files, libgcc** or toolchain provided 
language support libraries such as libgnat, libgfortran or libstdc++ unless 
options preventing their inclusion are used as well.


-nostdlib
Do not use the standard system startup files or libraries when linking. No 
startup files and only the libraries you specify are passed to the linker, and 
options specifying linkage of the system libraries, such as -static-libgcc or 
-shared-libgcc, are ignored.

The compiler may generate calls to memcmp, memset, memcpy and memmove. These 
entries are usually resolved by entries in libc. These entry points should be 
supplied through some other mechanism when this option is specified.

**One of the standard libraries bypassed by -nostdlib and -nodefaultlibs is 
libgcc.a**, a library of internal subroutines which GCC uses to overcome 
shortcomings of particular machines, or special needs for some languages. 

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


[clang] [clang] Add option for -nolibc in Driver/ToolChains/Baremetal.cpp (PR #145700)

2025-06-27 Thread William Huynh via cfe-commits

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


[clang] [clang-format][NFC] Remove `\brief` from comments (PR #145853)

2025-06-27 Thread via cfe-commits

https://github.com/mydeveloperday commented:

Looks good, thank you

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


[clang] [Clang][AArch64] Add FP8 variants of Neon store intrinsics (PR #145346)

2025-06-27 Thread Kerry McLaughlin via cfe-commits

https://github.com/kmclaughlin-arm updated 
https://github.com/llvm/llvm-project/pull/145346

>From b2d9f70eb33ebbb26166bea4ba79f05204fc3cc2 Mon Sep 17 00:00:00 2001
From: Kerry McLaughlin 
Date: Mon, 23 Jun 2025 13:07:34 +
Subject: [PATCH 1/3] [Clang][AArch64] Add FP8 variants of Neon store
 intrinsics

Adds FP8 variants for existing VST1, VST2, VST3 & VST4 intrinsics.
---
 clang/include/clang/Basic/arm_neon.td |  22 +-
 clang/lib/CodeGen/TargetBuiltins/ARM.cpp  |  22 +
 .../fp8-intrinsics/acle_neon_fp8_stores.c | 475 ++
 3 files changed, 518 insertions(+), 1 deletion(-)
 create mode 100644 
clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_stores.c

diff --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index 7251cc2d1759a..314330ed9fde6 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -2119,6 +2119,26 @@ let ArchGuard = "defined(__aarch64__)", TargetGuard = 
"lut" in {
   }
 }
 
+let ArchGuard = "defined(__aarch64__)", TargetGuard = "fp8,neon" in {
+  def VST1_MF8 : WInst<"vst1", "v*(.!)", "mQm">;
+  def VST2_MF8 : WInst<"vst2", "v*(2!)", "mQm">;
+  def VST3_MF8 : WInst<"vst3", "v*(3!)", "mQm">;
+  def VST4_MF8 : WInst<"vst4", "v*(4!)", "mQm">;
+
+  def VST1_X2_MF8 : WInst<"vst1_x2", "v*(2!)", "mQm">;
+  def VST1_X3_MF8 : WInst<"vst1_x3", "v*(3!)", "mQm">;
+  def VST1_X4_MF8 : WInst<"vst1_x4", "v*(4!)", "mQm">;
+
+  def VST1_LANE_MF8 : WInst<"vst1_lane", "v*(.!)I", "mQm",
+   [ImmCheck<2, ImmCheckLaneIndex, 1>]>;
+  def VST2_LANE_MF8 : WInst<"vst2_lane", "v*(2!)I", "mQm",
+   [ImmCheck<3, ImmCheckLaneIndex, 1>]>;
+  def VST3_LANE_MF8 : WInst<"vst3_lane", "v*(3!)I", "mQm",
+   [ImmCheck<4, ImmCheckLaneIndex, 1>]>;
+  def VST4_LANE_MF8 : WInst<"vst4_lane", "v*(4!)I", "mQm",
+   [ImmCheck<5, ImmCheckLaneIndex, 1>]>;
+}
+
 let ArchGuard = "defined(__aarch64__)", TargetGuard = "fp8,neon" in {
   def VBF1CVT_BF16_MF8: VInst<"vcvt1_bf16_mf8_fpm",  "(QB).V", 
"m">;
   def VBF1CVT_LOW_BF16_MF8: VInst<"vcvt1_low_bf16_mf8_fpm",  "B.V",
"Hm">;
@@ -2194,4 +2214,4 @@ let ArchGuard = "defined(__aarch64__)", TargetGuard = 
"fp8,neon" in {
   // fscale
   def FSCALE_V128 : WInst<"vscale", "..(.S)", "QdQfQh">;
   def FSCALE_V64 : WInst<"vscale", "(.q)(.q)(.qS)", "fh">;
-}
\ No newline at end of file
+}
diff --git a/clang/lib/CodeGen/TargetBuiltins/ARM.cpp 
b/clang/lib/CodeGen/TargetBuiltins/ARM.cpp
index 6738d4be6dd21..3bd5054050036 100644
--- a/clang/lib/CodeGen/TargetBuiltins/ARM.cpp
+++ b/clang/lib/CodeGen/TargetBuiltins/ARM.cpp
@@ -1553,6 +1553,28 @@ static const std::pair 
NEONEquivalentIntrinsicMap[] = {
   { NEON::BI__builtin_neon_vst4_lane_bf16, NEON::BI__builtin_neon_vst4_lane_v 
},
   { NEON::BI__builtin_neon_vst4q_bf16, NEON::BI__builtin_neon_vst4q_v },
   { NEON::BI__builtin_neon_vst4q_lane_bf16, 
NEON::BI__builtin_neon_vst4q_lane_v },
+  { NEON::BI__builtin_neon_vst1_mf8_x2, NEON::BI__builtin_neon_vst1_x2_v },
+  { NEON::BI__builtin_neon_vst1_mf8_x3, NEON::BI__builtin_neon_vst1_x3_v },
+  { NEON::BI__builtin_neon_vst1_mf8_x4, NEON::BI__builtin_neon_vst1_x4_v },
+  { NEON::BI__builtin_neon_vst1_mf8, NEON::BI__builtin_neon_vst1_v },
+  { NEON::BI__builtin_neon_vst1_lane_mf8, NEON::BI__builtin_neon_vst1_lane_v },
+  { NEON::BI__builtin_neon_vst1q_mf8_x2, NEON::BI__builtin_neon_vst1q_x2_v },
+  { NEON::BI__builtin_neon_vst1q_mf8_x3, NEON::BI__builtin_neon_vst1q_x3_v },
+  { NEON::BI__builtin_neon_vst1q_mf8_x4, NEON::BI__builtin_neon_vst1q_x4_v },
+  { NEON::BI__builtin_neon_vst1q_mf8, NEON::BI__builtin_neon_vst1q_v },
+  { NEON::BI__builtin_neon_vst1q_lane_mf8, NEON::BI__builtin_neon_vst1q_lane_v 
},
+  { NEON::BI__builtin_neon_vst2_mf8, NEON::BI__builtin_neon_vst2_v },
+  { NEON::BI__builtin_neon_vst2_lane_mf8, NEON::BI__builtin_neon_vst2_lane_v },
+  { NEON::BI__builtin_neon_vst2q_mf8, NEON::BI__builtin_neon_vst2q_v },
+  { NEON::BI__builtin_neon_vst2q_lane_mf8, NEON::BI__builtin_neon_vst2q_lane_v 
},
+  { NEON::BI__builtin_neon_vst3_mf8, NEON::BI__builtin_neon_vst3_v },
+  { NEON::BI__builtin_neon_vst3_lane_mf8, NEON::BI__builtin_neon_vst3_lane_v },
+  { NEON::BI__builtin_neon_vst3q_mf8, NEON::BI__builtin_neon_vst3q_v },
+  { NEON::BI__builtin_neon_vst3q_lane_mf8, NEON::BI__builtin_neon_vst3q_lane_v 
},
+  { NEON::BI__builtin_neon_vst4_mf8, NEON::BI__builtin_neon_vst4_v },
+  { NEON::BI__builtin_neon_vst4_lane_mf8, NEON::BI__builtin_neon_vst4_lane_v },
+  { NEON::BI__builtin_neon_vst4q_mf8, NEON::BI__builtin_neon_vst4q_v },
+  { NEON::BI__builtin_neon_vst4q_lane_mf8, NEON::BI__builtin_neon_vst4q_lane_v 
},
   // The mangling rules cause us to have one ID for each type for 
vldap1(q)_lane
   // and vstl1(q)_lane, but codegen is equivalent for all of them. Choose an
   // arbitrary one to be handled as tha canonical variation.
diff --git a/clang/test/CodeGen/AArch64/fp8-

[clang] [NFC][analyzer] Use %clang_analyze_cc1 consistently (PR #145895)

2025-06-27 Thread Balazs Benics via cfe-commits
=?utf-8?q?Don=C3=A1t?= Nagy 
Message-ID:
In-Reply-To: 


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


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


[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

2025-06-27 Thread via cfe-commits

https://github.com/Tedlion updated 
https://github.com/llvm/llvm-project/pull/145066

>From 03004d9a9348e365a2d2d05e69f83fc404ddb605 Mon Sep 17 00:00:00 2001
From: tangwy 
Date: Sat, 21 Jun 2025 00:22:10 +0800
Subject: [PATCH 1/4] [clang][analyzer] Fix the false positive
 ArgInitializedness warning on unnamed bit-field

For the following code:
 struct B{
   int i  :2;
   int:30;  // unnamed bit-field
 };

 extern void consume_B(B);

 void bitfield_B_init(void) {
   B b1;
   b1.i = 1; // b1 is initialized
   consume_B(b1);
 }

The current clang static analyzer gives false positive warning "Passed-by-value 
struct argument contains uninitialized data (e.g., field: '') 
[core.CallAndMessage]" when taking the source as C code. However, no such 
warning is generated when clang takes the source as C++ code.

After comparing the CallAndMessageChecker's different behaviors between C and 
C++, the reason is found:
When FindUninitializedField::Find(const TypedValueRegion *R) is invoked, the 
concrete type of R is different. In C, 'b1' is considered to be a 
'StackLocalsSpaceRegion', which makes 'StoreMgr.getBinding(store, 
loc::MemRegionVal(FR))' return an 'UndefinedVal'. While in c++, 'b1' is 
considered to be a 'tackArgumentsSpaceRegion', which finally makes the 
'getBinding' return a SymbolVal. I am not quite sure about the region 
difference, maybe in C++ there is an implicit copy constructor function?

 Anyway, the unnamed bit-field is undefined, for it cannot be written unless 
using memory operation such
as 'memset'. So a special check FD->isUnnamedBitField() is added in 
RegionStoreManager::getBindingForField in
file RegionStore.cpp.

To handle the false warning, a check isUnnamedBitField is also added in 
FindUninitializedField::Find in file CallAndMessageChecker.cpp.

Testcases of unnamed bit-field are added in file call-and-message.c and 
call-and-message.cpp. I do not know what to do on the hash, so it may be 
updated?
---
 .../Checkers/CallAndMessageChecker.cpp|  2 +-
 clang/lib/StaticAnalyzer/Core/RegionStore.cpp | 15 ++-
 clang/test/Analysis/call-and-message.c| 27 ++-
 clang/test/Analysis/call-and-message.cpp  | 16 +++
 4 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
index 86476b32309c3..677cc6ee57ad2 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
@@ -259,7 +259,7 @@ class FindUninitializedField {
 if (T->getAsStructureType()) {
   if (Find(FR))
 return true;
-} else {
+} else if (!I->isUnnamedBitField()){
   SVal V = StoreMgr.getBinding(store, loc::MemRegionVal(FR));
   if (V.isUndef())
 return true;
diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp 
b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
index 388034b087789..1208036700f32 100644
--- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2122,8 +2122,21 @@ SVal 
RegionStoreManager::getBindingForField(RegionBindingsConstRef B,
   if (const std::optional &V = B.getDirectBinding(R))
 return *V;
 
-  // If the containing record was initialized, try to get its constant value.
+  // UnnamedBitField is always Undefined unless using memory operation such
+  // as 'memset'.
+  // For example, for code
+  //typedef struct {
+  //  int i  :2;
+  //  int:30;  // unnamed bit-field
+  //} A;
+  //A a = {1};
+  // The bits of the unnamed bit-field in local variable a can be anything.
   const FieldDecl *FD = R->getDecl();
+  if (FD->isUnnamedBitField()) {
+  return UndefinedVal();
+  }
+
+  // If the containing record was initialized, try to get its constant value.
   QualType Ty = FD->getType();
   const MemRegion* superR = R->getSuperRegion();
   if (const auto *VR = dyn_cast(superR)) {
diff --git a/clang/test/Analysis/call-and-message.c 
b/clang/test/Analysis/call-and-message.c
index b79ec8c344b6c..e2fba55d3343d 100644
--- a/clang/test/Analysis/call-and-message.c
+++ b/clang/test/Analysis/call-and-message.c
@@ -1,12 +1,19 @@
 // RUN: %clang_analyze_cc1 %s -verify \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-config core.CallAndMessage:ArgPointeeInitializedness=true \
+// RUN:   -analyzer-config core.CallAndMessage:ArgInitializedness=false \
 // RUN:   -analyzer-output=plist -o %t.plist
 // RUN: cat %t.plist | FileCheck %s
 
 // RUN: %clang_analyze_cc1 %s -verify=no-pointee \
 // RUN:   -analyzer-checker=core \
-// RUN:   -analyzer-config core.CallAndMessage:ArgPointeeInitializedness=false
+// RUN:   -analyzer-config core.CallAndMessage:ArgPointeeInitializedness=false 
\
+// RUN:   -analyzer-config core.CallAndMessage:ArgInitializedness=false
+
+// RUN: %clang_analyze_cc1 %s -verify=arg-init \
+// RU

[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

2025-06-27 Thread via cfe-commits

https://github.com/Tedlion updated 
https://github.com/llvm/llvm-project/pull/145066

>From 03004d9a9348e365a2d2d05e69f83fc404ddb605 Mon Sep 17 00:00:00 2001
From: tangwy 
Date: Sat, 21 Jun 2025 00:22:10 +0800
Subject: [PATCH 1/3] [clang][analyzer] Fix the false positive
 ArgInitializedness warning on unnamed bit-field

For the following code:
 struct B{
   int i  :2;
   int:30;  // unnamed bit-field
 };

 extern void consume_B(B);

 void bitfield_B_init(void) {
   B b1;
   b1.i = 1; // b1 is initialized
   consume_B(b1);
 }

The current clang static analyzer gives false positive warning "Passed-by-value 
struct argument contains uninitialized data (e.g., field: '') 
[core.CallAndMessage]" when taking the source as C code. However, no such 
warning is generated when clang takes the source as C++ code.

After comparing the CallAndMessageChecker's different behaviors between C and 
C++, the reason is found:
When FindUninitializedField::Find(const TypedValueRegion *R) is invoked, the 
concrete type of R is different. In C, 'b1' is considered to be a 
'StackLocalsSpaceRegion', which makes 'StoreMgr.getBinding(store, 
loc::MemRegionVal(FR))' return an 'UndefinedVal'. While in c++, 'b1' is 
considered to be a 'tackArgumentsSpaceRegion', which finally makes the 
'getBinding' return a SymbolVal. I am not quite sure about the region 
difference, maybe in C++ there is an implicit copy constructor function?

 Anyway, the unnamed bit-field is undefined, for it cannot be written unless 
using memory operation such
as 'memset'. So a special check FD->isUnnamedBitField() is added in 
RegionStoreManager::getBindingForField in
file RegionStore.cpp.

To handle the false warning, a check isUnnamedBitField is also added in 
FindUninitializedField::Find in file CallAndMessageChecker.cpp.

Testcases of unnamed bit-field are added in file call-and-message.c and 
call-and-message.cpp. I do not know what to do on the hash, so it may be 
updated?
---
 .../Checkers/CallAndMessageChecker.cpp|  2 +-
 clang/lib/StaticAnalyzer/Core/RegionStore.cpp | 15 ++-
 clang/test/Analysis/call-and-message.c| 27 ++-
 clang/test/Analysis/call-and-message.cpp  | 16 +++
 4 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
index 86476b32309c3..677cc6ee57ad2 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
@@ -259,7 +259,7 @@ class FindUninitializedField {
 if (T->getAsStructureType()) {
   if (Find(FR))
 return true;
-} else {
+} else if (!I->isUnnamedBitField()){
   SVal V = StoreMgr.getBinding(store, loc::MemRegionVal(FR));
   if (V.isUndef())
 return true;
diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp 
b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
index 388034b087789..1208036700f32 100644
--- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2122,8 +2122,21 @@ SVal 
RegionStoreManager::getBindingForField(RegionBindingsConstRef B,
   if (const std::optional &V = B.getDirectBinding(R))
 return *V;
 
-  // If the containing record was initialized, try to get its constant value.
+  // UnnamedBitField is always Undefined unless using memory operation such
+  // as 'memset'.
+  // For example, for code
+  //typedef struct {
+  //  int i  :2;
+  //  int:30;  // unnamed bit-field
+  //} A;
+  //A a = {1};
+  // The bits of the unnamed bit-field in local variable a can be anything.
   const FieldDecl *FD = R->getDecl();
+  if (FD->isUnnamedBitField()) {
+  return UndefinedVal();
+  }
+
+  // If the containing record was initialized, try to get its constant value.
   QualType Ty = FD->getType();
   const MemRegion* superR = R->getSuperRegion();
   if (const auto *VR = dyn_cast(superR)) {
diff --git a/clang/test/Analysis/call-and-message.c 
b/clang/test/Analysis/call-and-message.c
index b79ec8c344b6c..e2fba55d3343d 100644
--- a/clang/test/Analysis/call-and-message.c
+++ b/clang/test/Analysis/call-and-message.c
@@ -1,12 +1,19 @@
 // RUN: %clang_analyze_cc1 %s -verify \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-config core.CallAndMessage:ArgPointeeInitializedness=true \
+// RUN:   -analyzer-config core.CallAndMessage:ArgInitializedness=false \
 // RUN:   -analyzer-output=plist -o %t.plist
 // RUN: cat %t.plist | FileCheck %s
 
 // RUN: %clang_analyze_cc1 %s -verify=no-pointee \
 // RUN:   -analyzer-checker=core \
-// RUN:   -analyzer-config core.CallAndMessage:ArgPointeeInitializedness=false
+// RUN:   -analyzer-config core.CallAndMessage:ArgPointeeInitializedness=false 
\
+// RUN:   -analyzer-config core.CallAndMessage:ArgInitializedness=false
+
+// RUN: %clang_analyze_cc1 %s -verify=arg-init \
+// RU

[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

2025-06-27 Thread via cfe-commits

https://github.com/Tedlion updated 
https://github.com/llvm/llvm-project/pull/145066

>From 03004d9a9348e365a2d2d05e69f83fc404ddb605 Mon Sep 17 00:00:00 2001
From: tangwy 
Date: Sat, 21 Jun 2025 00:22:10 +0800
Subject: [PATCH 1/4] [clang][analyzer] Fix the false positive
 ArgInitializedness warning on unnamed bit-field

For the following code:
 struct B{
   int i  :2;
   int:30;  // unnamed bit-field
 };

 extern void consume_B(B);

 void bitfield_B_init(void) {
   B b1;
   b1.i = 1; // b1 is initialized
   consume_B(b1);
 }

The current clang static analyzer gives false positive warning "Passed-by-value 
struct argument contains uninitialized data (e.g., field: '') 
[core.CallAndMessage]" when taking the source as C code. However, no such 
warning is generated when clang takes the source as C++ code.

After comparing the CallAndMessageChecker's different behaviors between C and 
C++, the reason is found:
When FindUninitializedField::Find(const TypedValueRegion *R) is invoked, the 
concrete type of R is different. In C, 'b1' is considered to be a 
'StackLocalsSpaceRegion', which makes 'StoreMgr.getBinding(store, 
loc::MemRegionVal(FR))' return an 'UndefinedVal'. While in c++, 'b1' is 
considered to be a 'tackArgumentsSpaceRegion', which finally makes the 
'getBinding' return a SymbolVal. I am not quite sure about the region 
difference, maybe in C++ there is an implicit copy constructor function?

 Anyway, the unnamed bit-field is undefined, for it cannot be written unless 
using memory operation such
as 'memset'. So a special check FD->isUnnamedBitField() is added in 
RegionStoreManager::getBindingForField in
file RegionStore.cpp.

To handle the false warning, a check isUnnamedBitField is also added in 
FindUninitializedField::Find in file CallAndMessageChecker.cpp.

Testcases of unnamed bit-field are added in file call-and-message.c and 
call-and-message.cpp. I do not know what to do on the hash, so it may be 
updated?
---
 .../Checkers/CallAndMessageChecker.cpp|  2 +-
 clang/lib/StaticAnalyzer/Core/RegionStore.cpp | 15 ++-
 clang/test/Analysis/call-and-message.c| 27 ++-
 clang/test/Analysis/call-and-message.cpp  | 16 +++
 4 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
index 86476b32309c3..677cc6ee57ad2 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
@@ -259,7 +259,7 @@ class FindUninitializedField {
 if (T->getAsStructureType()) {
   if (Find(FR))
 return true;
-} else {
+} else if (!I->isUnnamedBitField()){
   SVal V = StoreMgr.getBinding(store, loc::MemRegionVal(FR));
   if (V.isUndef())
 return true;
diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp 
b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
index 388034b087789..1208036700f32 100644
--- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2122,8 +2122,21 @@ SVal 
RegionStoreManager::getBindingForField(RegionBindingsConstRef B,
   if (const std::optional &V = B.getDirectBinding(R))
 return *V;
 
-  // If the containing record was initialized, try to get its constant value.
+  // UnnamedBitField is always Undefined unless using memory operation such
+  // as 'memset'.
+  // For example, for code
+  //typedef struct {
+  //  int i  :2;
+  //  int:30;  // unnamed bit-field
+  //} A;
+  //A a = {1};
+  // The bits of the unnamed bit-field in local variable a can be anything.
   const FieldDecl *FD = R->getDecl();
+  if (FD->isUnnamedBitField()) {
+  return UndefinedVal();
+  }
+
+  // If the containing record was initialized, try to get its constant value.
   QualType Ty = FD->getType();
   const MemRegion* superR = R->getSuperRegion();
   if (const auto *VR = dyn_cast(superR)) {
diff --git a/clang/test/Analysis/call-and-message.c 
b/clang/test/Analysis/call-and-message.c
index b79ec8c344b6c..e2fba55d3343d 100644
--- a/clang/test/Analysis/call-and-message.c
+++ b/clang/test/Analysis/call-and-message.c
@@ -1,12 +1,19 @@
 // RUN: %clang_analyze_cc1 %s -verify \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-config core.CallAndMessage:ArgPointeeInitializedness=true \
+// RUN:   -analyzer-config core.CallAndMessage:ArgInitializedness=false \
 // RUN:   -analyzer-output=plist -o %t.plist
 // RUN: cat %t.plist | FileCheck %s
 
 // RUN: %clang_analyze_cc1 %s -verify=no-pointee \
 // RUN:   -analyzer-checker=core \
-// RUN:   -analyzer-config core.CallAndMessage:ArgPointeeInitializedness=false
+// RUN:   -analyzer-config core.CallAndMessage:ArgPointeeInitializedness=false 
\
+// RUN:   -analyzer-config core.CallAndMessage:ArgInitializedness=false
+
+// RUN: %clang_analyze_cc1 %s -verify=arg-init \
+// RU

[clang] [Clang] include attribute scope in diagnostics (PR #144619)

2025-06-27 Thread Oleksandr T. via cfe-commits


@@ -292,6 +297,45 @@ inline bool doesKeywordAttributeTakeArgs(tok::TokenKind 
Kind) {
   }
 }
 
+inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
+ const AttributeCommonInfo &CI) {
+  DB.AddTaggedVal(reinterpret_cast(&CI),
+  DiagnosticsEngine::ak_attr_info);
+  return DB;
+}
+
+inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
+ const AttributeCommonInfo *CI) {
+  DB.AddTaggedVal(reinterpret_cast(CI),
+  DiagnosticsEngine::ak_attr_info);
+  return DB;
+}
+
+/// AttributeCommonInfo has a non-explicit constructor which takes an
+/// SourceRange as its only argument, this constructor has many uses so making
+/// it explicit is hard. This constructor causes ambiguity with
+/// DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, SourceRange R).
+/// We use SFINAE to disable any conversion and remove any ambiguity.
+template <
+typename ACI,
+std::enable_if_t::value, int> = 0>
+inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
+ const ACI &CI) {
+  DB.AddTaggedVal(reinterpret_cast(&CI),
+  DiagnosticsEngine::ak_attr_info);
+  return DB;
+}
+
+template <
+typename ACI,
+std::enable_if_t::value, int> = 0>
+inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,

a-tarasyuk wrote:

I've removed these overloads

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


[clang] [Clang] include attribute scope in diagnostics (PR #144619)

2025-06-27 Thread Oleksandr T. via cfe-commits


@@ -4694,9 +4695,9 @@ def note_protocol_decl : Note<
   "protocol is declared here">;
 def note_protocol_decl_undefined : Note<
   "protocol %0 has no definition">;
-def err_attribute_preferred_name_arg_invalid : Error<
-  "argument %0 to 'preferred_name' attribute is not a typedef for "
-  "a specialization of %1">;
+def err_attribute_preferred_name_arg_invalid

a-tarasyuk wrote:

@AaronBallman I've updated both messages

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


[clang] [REAPPLY][Clang-Repl] Add support for out-of-process execution. #110418 (PR #144064)

2025-06-27 Thread Vassil Vassilev via cfe-commits

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

>From 05943c9542cd89ae672ddc0f14514e0c7b1e0bd7 Mon Sep 17 00:00:00 2001
From: SahilPatidar 
Date: Tue, 3 Dec 2024 15:07:56 +0530
Subject: [PATCH 1/6] Re-Land: [Clang-Repl] Add support for out-of-process
 execution. #110418

---
 clang/include/clang/Interpreter/Interpreter.h |   7 +-
 .../clang/Interpreter/RemoteJITUtils.h|  38 +++
 clang/lib/Interpreter/CMakeLists.txt  |   1 +
 clang/lib/Interpreter/Interpreter.cpp |  37 ++-
 clang/lib/Interpreter/RemoteJITUtils.cpp  | 267 ++
 clang/tools/clang-repl/CMakeLists.txt |   2 +
 clang/tools/clang-repl/ClangRepl.cpp  | 123 +++-
 7 files changed, 465 insertions(+), 10 deletions(-)
 create mode 100644 clang/include/clang/Interpreter/RemoteJITUtils.h
 create mode 100644 clang/lib/Interpreter/RemoteJITUtils.cpp

diff --git a/clang/include/clang/Interpreter/Interpreter.h 
b/clang/include/clang/Interpreter/Interpreter.h
index f8663e3193a18..78dff1165dcf5 100644
--- a/clang/include/clang/Interpreter/Interpreter.h
+++ b/clang/include/clang/Interpreter/Interpreter.h
@@ -20,6 +20,7 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ExecutionEngine/JITSymbol.h"
+#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
 #include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
 #include "llvm/Support/Error.h"
 #include 
@@ -136,10 +137,14 @@ class Interpreter {
 public:
   virtual ~Interpreter();
   static llvm::Expected>
-  create(std::unique_ptr CI);
+  create(std::unique_ptr CI,
+ std::unique_ptr JITBuilder = nullptr);
   static llvm::Expected>
   createWithCUDA(std::unique_ptr CI,
  std::unique_ptr DCI);
+  static llvm::Expected>
+  createLLJITBuilder(std::unique_ptr EPC,
+ llvm::StringRef OrcRuntimePath);
   const ASTContext &getASTContext() const;
   ASTContext &getASTContext();
   const CompilerInstance *getCompilerInstance() const;
diff --git a/clang/include/clang/Interpreter/RemoteJITUtils.h 
b/clang/include/clang/Interpreter/RemoteJITUtils.h
new file mode 100644
index 0..8705a3b1f669d
--- /dev/null
+++ b/clang/include/clang/Interpreter/RemoteJITUtils.h
@@ -0,0 +1,38 @@
+//===-- RemoteJITUtils.h - Utilities for remote-JITing --*- 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
+//
+//===--===//
+//
+// Utilities for ExecutorProcessControl-based remote JITing with Orc and
+// JITLink.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_INTERPRETER_REMOTEJITUTILS_H
+#define LLVM_CLANG_INTERPRETER_REMOTEJITUTILS_H
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ExecutionEngine/Orc/Core.h"
+#include "llvm/ExecutionEngine/Orc/Layer.h"
+#include "llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h"
+#include "llvm/Support/Error.h"
+
+#include 
+#include 
+#include 
+
+llvm::Expected>
+launchExecutor(llvm::StringRef ExecutablePath, bool UseSharedMemory,
+   llvm::StringRef SlabAllocateSizeString);
+
+/// Create a JITLinkExecutor that connects to the given network address
+/// through a TCP socket. A valid NetworkAddress provides hostname and port,
+/// e.g. localhost:2.
+llvm::Expected>
+connectTCPSocket(llvm::StringRef NetworkAddress, bool UseSharedMemory,
+ llvm::StringRef SlabAllocateSizeString);
+
+#endif // LLVM_CLANG_INTERPRETER_REMOTEJITUTILS_H
diff --git a/clang/lib/Interpreter/CMakeLists.txt 
b/clang/lib/Interpreter/CMakeLists.txt
index bf70cdfbee01e..38cf139fa86a6 100644
--- a/clang/lib/Interpreter/CMakeLists.txt
+++ b/clang/lib/Interpreter/CMakeLists.txt
@@ -27,6 +27,7 @@ add_clang_library(clangInterpreter
   Interpreter.cpp
   InterpreterValuePrinter.cpp
   InterpreterUtils.cpp
+  RemoteJITUtils.cpp
   Value.cpp
   ${WASM_SRC}
   PARTIAL_SOURCES_INTENDED
diff --git a/clang/lib/Interpreter/Interpreter.cpp 
b/clang/lib/Interpreter/Interpreter.cpp
index 84feff82c63a7..30051a24662c6 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -46,6 +46,7 @@
 #include "clang/Sema/Lookup.h"
 #include "clang/Serialization/ObjectFilePCHContainerReader.h"
 #include "llvm/ExecutionEngine/JITSymbol.h"
+#include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h"
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Support/Errc.h"
@@ -455,10 +456,11 @@ const char *const Runtimes = R"(
 )";
 
 llvm::Expected>
-Interpreter::create(std::unique_ptr CI) {
+Interpreter::create(std::unique_ptr CI,
+std::unique_ptr JB) {
   llvm::Error Err = llvm::Error::success();
-  auto Interp =
-  std::unique_ptr(new Interpreter(std::move(CI), Er

[clang] [Clang] include attribute scope in diagnostics (PR #144619)

2025-06-27 Thread Oleksandr T. via cfe-commits


@@ -292,6 +297,45 @@ inline bool doesKeywordAttributeTakeArgs(tok::TokenKind 
Kind) {
   }
 }
 
+inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
+ const AttributeCommonInfo &CI) {
+  DB.AddTaggedVal(reinterpret_cast(&CI),
+  DiagnosticsEngine::ak_attr_info);
+  return DB;

a-tarasyuk wrote:

I've updated to make it cleaner

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


[clang] [PS5][Driver] Allow selection of CRT with `-L` (PR #145869)

2025-06-27 Thread Jeremy Morse via cfe-commits


@@ -200,12 +200,10 @@
 // CHECK-NO-TARGETLIB-SAME: "-L."
 
 // RUN: mkdir -p %t.dir/myroot/target/lib
-// RUN: touch %t.dir/myroot/target/lib/crti.o
 // RUN: env SCE_PROSPERO_SDK_DIR=%t.dir/myroot %clang --target=x64_64-sie-ps5 
%s -### -Luser 2>&1 | FileCheck --check-prefixes=CHECK-TARGETLIB %s
 // RUN: %clang --target=x64_64-sie-ps5 %s -### -Luser --sysroot=%t.dir/myroot 
2>&1 | FileCheck --check-prefixes=CHECK-TARGETLIB %s
 
 // CHECK-TARGETLIB: {{ld(\.exe)?}}"
 // CHECK-TARGETLIB-SAME: "-Luser"
 // CHECK-TARGETLIB-SAME: "-L{{.*}}myroot{{/|}}target{{/|}}lib"
 // CHECK-TARGETLIB-SAME: "-L."

jmorse wrote:

Just to check the thinking: we don't need to check how the linker is directed 
to crti.o, these check lines are purely about ensuring the correct `-L` flags 
come out of the driver? (Seeing deleted lines suggests to me we're losing 
coverage, but I suppose it's not truly meaningful coverage).

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


[clang] [NFC][analyzer] Use %clang_analyze_cc1 consistently (PR #145895)

2025-06-27 Thread Donát Nagy via cfe-commits

NagyDonat wrote:

I will postpone merging this until the issues with 
https://github.com/llvm/llvm-project/commit/40cc4379cda6e0d6efe72c55d1968f9cf427a16a
 are fixed (for the unlikely case if that commit ends up being reverted).

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


[clang] [llvm] [NFC][analyzer] Remove Z3-as-constraint-manager hacks from lit test code (PR #145731)

2025-06-27 Thread Donát Nagy via cfe-commits

NagyDonat wrote:

Thank you, that would be very helpful! I'm not familiar with the cmake 
implementation details of the standalone build (until now I didn't even know 
about its existence), so finding a solution would've taken lots of time for me.

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


[clang] [PS5][Driver] Allow selection of CRT with `-L` (PR #145869)

2025-06-27 Thread Jeremy Morse via cfe-commits

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

LGTM with a question

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


[clang] [PS5][Driver] Allow selection of CRT with `-L` (PR #145869)

2025-06-27 Thread Jeremy Morse via cfe-commits

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


[clang] [analyzer] Fix tests broken by empty %z3_include_dir (PR #146042)

2025-06-27 Thread Donát Nagy via cfe-commits


@@ -173,13 +173,16 @@ def have_host_clang_repl_cuda():
 config.available_features.add("staticanalyzer")
 tools.append("clang-check")
 
+I_z3_include_dir = ""
 if config.clang_staticanalyzer_z3:
 config.available_features.add("z3")
-config.substitutions.append(
-("%z3_include_dir", config.clang_staticanalyzer_z3_include_dir)
-)
+if config.clang_staticanalyzer_z3_include_dir:

NagyDonat wrote:

Thanks for researching this!

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


[clang] [llvm] [FMV][AArch64] Allow user to override version priority. (PR #146092)

2025-06-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Alexandros Lamprineas (labrinea)


Changes

Implements option one of the proposal 
https://github.com/ARM-software/acle/issues/403

---

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


12 Files Affected:

- (modified) clang/lib/CodeGen/Targets/AArch64.cpp (+4-1) 
- (modified) clang/test/CodeGen/AArch64/fmv-duplicate-mangled-name.c (+16) 
- (added) clang/test/CodeGen/AArch64/fmv-explicit-priority.c (+193) 
- (modified) llvm/include/llvm/Analysis/TargetTransformInfo.h (+5-1) 
- (modified) llvm/include/llvm/Analysis/TargetTransformInfoImpl.h (+1) 
- (modified) llvm/include/llvm/TargetParser/AArch64FeatPriorities.inc (+6-1) 
- (modified) llvm/lib/Analysis/TargetTransformInfo.cpp (+4) 
- (modified) llvm/lib/Target/AArch64/AArch64FMV.td (+5) 
- (modified) llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp (+14-3) 
- (modified) llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h (+1) 
- (modified) llvm/lib/TargetParser/AArch64TargetParser.cpp (+19-10) 
- (modified) llvm/lib/Transforms/IPO/GlobalOpt.cpp (+15-7) 


``diff
diff --git a/clang/lib/CodeGen/Targets/AArch64.cpp 
b/clang/lib/CodeGen/Targets/AArch64.cpp
index b82c46966cf0b..e2ede08942183 100644
--- a/clang/lib/CodeGen/Targets/AArch64.cpp
+++ b/clang/lib/CodeGen/Targets/AArch64.cpp
@@ -1336,10 +1336,13 @@ void AArch64ABIInfo::appendAttributeMangling(StringRef 
AttrStr,
   });
 
   llvm::SmallDenseSet UniqueFeats;
-  for (auto &Feat : Features)
+  for (auto &Feat : Features) {
+if (!getTarget().doesFeatureAffectCodeGen(Feat))
+  continue;
 if (auto Ext = llvm::AArch64::parseFMVExtension(Feat))
   if (UniqueFeats.insert(Ext->Name).second)
 Out << 'M' << Ext->Name;
+  }
 }
 
 std::unique_ptr
diff --git a/clang/test/CodeGen/AArch64/fmv-duplicate-mangled-name.c 
b/clang/test/CodeGen/AArch64/fmv-duplicate-mangled-name.c
index e7e611e09542e..44a798a84a8a2 100644
--- a/clang/test/CodeGen/AArch64/fmv-duplicate-mangled-name.c
+++ b/clang/test/CodeGen/AArch64/fmv-duplicate-mangled-name.c
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -triple aarch64-linux-gnu -verify -emit-llvm-only %s 
-DCHECK_IMPLICIT_DEFAULT
 // RUN: %clang_cc1 -triple aarch64-linux-gnu -verify -emit-llvm-only %s 
-DCHECK_EXPLICIT_DEFAULT
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -verify -emit-llvm-only %s 
-DCHECK_EXPLICIT_VERSION_PRIORITY
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -verify -emit-llvm-only %s 
-DCHECK_EXPLICIT_CLONES_PRIORITY
 
 #if defined(CHECK_IMPLICIT_DEFAULT)
 
@@ -21,4 +23,18 @@ __attribute__((target_version("default"))) int 
explicit_default_bad(void) { retu
 // expected-note@-2 {{previous definition is here}}
 __attribute__((target_clones("aes", "lse", "default"))) int 
explicit_default_bad(void) { return 1; }
 
+#elif defined(CHECK_EXPLICIT_VERSION_PRIORITY)
+
+__attribute__((target_version("aes"))) int explicit_version_priority(void) { 
return 0; }
+// expected-error@+2 {{definition with same mangled name 
'explicit_version_priority._Maes' as another definition}}
+// expected-note@-2 {{previous definition is here}}
+__attribute__((target_version("priority1+aes"))) int 
explicit_version_priority(void) { return 1; }
+
+#elif defined(CHECK_EXPLICIT_CLONES_PRIORITY)
+
+__attribute__((target_version("aes+priority2"))) int 
explicit_clones_priority(void) { return 0; }
+// expected-error@+2 {{definition with same mangled name 
'explicit_clones_priority._Maes' as another definition}}
+// expected-note@-2 {{previous definition is here}}
+__attribute__((target_clones("priority1+aes", "lse"))) int 
explicit_clones_priority(void) { return 1; }
+
 #endif
diff --git a/clang/test/CodeGen/AArch64/fmv-explicit-priority.c 
b/clang/test/CodeGen/AArch64/fmv-explicit-priority.c
new file mode 100644
index 0..95a246fea425b
--- /dev/null
+++ b/clang/test/CodeGen/AArch64/fmv-explicit-priority.c
@@ -0,0 +1,193 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --check-globals 
--include-generated-funcs
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -O3 -fno-inline -emit-llvm 
-o - %s | FileCheck %s
+
+__attribute__((target_version("priority1+lse"))) int foo(void) { return 1; }
+__attribute__((target_version("priority2+sve2"))) int foo(void) { return 2; }
+__attribute__((target_version("priority3+sve"))) int foo(void) { return 3; }
+__attribute__((target_version( "default"))) int foo(void) { return 0; }
+
+__attribute__((target_clones("priority1+lse+sve2", "priority2+lse", 
"priority3+sve", "default")))
+int fmv_caller(void) { return foo(); }
+
+
+__attribute__((target_version("aes"))) int bar(void) { return 1; }
+__attribute__((target_version("priority1+sm4"))) int bar(void) { return 2; }
+__attribute__((target_version("default"))) int bar(void) { return 0; }
+
+__attribute__((target("aes"))) int regular_caller_aes() { return bar(); }
+__attr

[clang] [llvm] [FMV][AArch64] Allow user to override version priority. (PR #146092)

2025-06-27 Thread Alexandros Lamprineas via cfe-commits

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


[clang] Suppress noreturn warning if last statement in a function is a throw (PR #145166)

2025-06-27 Thread Erich Keane via cfe-commits


@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions -Wreturn-type 
-verify %s
+// expected-no-diagnostics
+
+namespace std {
+  class string {
+  public:
+string(const char*); // constructor for runtime_error
+  };
+  class runtime_error {
+  public:
+runtime_error(const string &); 
+  };
+}
+
+void throwError(const std::string& msg) {
+  throw std::runtime_error(msg);
+}
+
+int ensureZero(const int i) {
+  if (i == 0) return 0;
+  throwError("ERROR"); // no-warning
+}
+
+int alwaysThrows() {

erichkeane wrote:

Please write a test where the one/both of the involved functions (caller and 
throw func) are both templates to make sure we handle instantiation correctly.

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


[clang] [llvm] [FMV][AArch64] Allow user to override version priority. (PR #146092)

2025-06-27 Thread Alexandros Lamprineas via cfe-commits

https://github.com/labrinea created 
https://github.com/llvm/llvm-project/pull/146092

Implements option one of the proposal 
https://github.com/ARM-software/acle/issues/403

>From c5bd398ad9116a29f363be4f0b9ec54fca0d7016 Mon Sep 17 00:00:00 2001
From: Alexandros Lamprineas 
Date: Thu, 26 Jun 2025 15:52:11 +0100
Subject: [PATCH 1/2] Supports option 1 of
 https://github.com/ARM-software/acle/issues/403

---
 clang/lib/CodeGen/Targets/AArch64.cpp|  5 -
 .../CodeGen/AArch64/fmv-duplicate-mangled-name.c | 16 
 .../llvm/TargetParser/AArch64FeatPriorities.inc  |  7 ++-
 llvm/lib/Target/AArch64/AArch64FMV.td|  5 +
 llvm/lib/TargetParser/AArch64TargetParser.cpp| 11 ---
 5 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/clang/lib/CodeGen/Targets/AArch64.cpp 
b/clang/lib/CodeGen/Targets/AArch64.cpp
index b82c46966cf0b..e2ede08942183 100644
--- a/clang/lib/CodeGen/Targets/AArch64.cpp
+++ b/clang/lib/CodeGen/Targets/AArch64.cpp
@@ -1336,10 +1336,13 @@ void AArch64ABIInfo::appendAttributeMangling(StringRef 
AttrStr,
   });
 
   llvm::SmallDenseSet UniqueFeats;
-  for (auto &Feat : Features)
+  for (auto &Feat : Features) {
+if (!getTarget().doesFeatureAffectCodeGen(Feat))
+  continue;
 if (auto Ext = llvm::AArch64::parseFMVExtension(Feat))
   if (UniqueFeats.insert(Ext->Name).second)
 Out << 'M' << Ext->Name;
+  }
 }
 
 std::unique_ptr
diff --git a/clang/test/CodeGen/AArch64/fmv-duplicate-mangled-name.c 
b/clang/test/CodeGen/AArch64/fmv-duplicate-mangled-name.c
index e7e611e09542e..44a798a84a8a2 100644
--- a/clang/test/CodeGen/AArch64/fmv-duplicate-mangled-name.c
+++ b/clang/test/CodeGen/AArch64/fmv-duplicate-mangled-name.c
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -triple aarch64-linux-gnu -verify -emit-llvm-only %s 
-DCHECK_IMPLICIT_DEFAULT
 // RUN: %clang_cc1 -triple aarch64-linux-gnu -verify -emit-llvm-only %s 
-DCHECK_EXPLICIT_DEFAULT
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -verify -emit-llvm-only %s 
-DCHECK_EXPLICIT_VERSION_PRIORITY
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -verify -emit-llvm-only %s 
-DCHECK_EXPLICIT_CLONES_PRIORITY
 
 #if defined(CHECK_IMPLICIT_DEFAULT)
 
@@ -21,4 +23,18 @@ __attribute__((target_version("default"))) int 
explicit_default_bad(void) { retu
 // expected-note@-2 {{previous definition is here}}
 __attribute__((target_clones("aes", "lse", "default"))) int 
explicit_default_bad(void) { return 1; }
 
+#elif defined(CHECK_EXPLICIT_VERSION_PRIORITY)
+
+__attribute__((target_version("aes"))) int explicit_version_priority(void) { 
return 0; }
+// expected-error@+2 {{definition with same mangled name 
'explicit_version_priority._Maes' as another definition}}
+// expected-note@-2 {{previous definition is here}}
+__attribute__((target_version("priority1+aes"))) int 
explicit_version_priority(void) { return 1; }
+
+#elif defined(CHECK_EXPLICIT_CLONES_PRIORITY)
+
+__attribute__((target_version("aes+priority2"))) int 
explicit_clones_priority(void) { return 0; }
+// expected-error@+2 {{definition with same mangled name 
'explicit_clones_priority._Maes' as another definition}}
+// expected-note@-2 {{previous definition is here}}
+__attribute__((target_clones("priority1+aes", "lse"))) int 
explicit_clones_priority(void) { return 1; }
+
 #endif
diff --git a/llvm/include/llvm/TargetParser/AArch64FeatPriorities.inc 
b/llvm/include/llvm/TargetParser/AArch64FeatPriorities.inc
index f2bad28ada93e..cde0d16e0b32e 100644
--- a/llvm/include/llvm/TargetParser/AArch64FeatPriorities.inc
+++ b/llvm/include/llvm/TargetParser/AArch64FeatPriorities.inc
@@ -59,7 +59,12 @@ enum FeatPriorities {
   PRIOR_SME_I64,
   PRIOR_SME2,
   PRIOR_MOPS,
-  PRIOR_CSSC
+  PRIOR_CSSC,
+  PRIOR_5,
+  PRIOR_4,
+  PRIOR_3,
+  PRIOR_2,
+  PRIOR_1
 };
 
 #endif
diff --git a/llvm/lib/Target/AArch64/AArch64FMV.td 
b/llvm/lib/Target/AArch64/AArch64FMV.td
index b0f76ec6a6480..efcb6f552d788 100644
--- a/llvm/lib/Target/AArch64/AArch64FMV.td
+++ b/llvm/lib/Target/AArch64/AArch64FMV.td
@@ -83,3 +83,8 @@ def : FMVExtension<"sve2-sha3", "SVE_SHA3">;
 def : FMVExtension<"sve2-sm4", "SVE_SM4">;
 def : FMVExtension<"wfxt", "WFXT">;
 def : FMVExtension<"cssc", "CSSC">;
+let FeatureBit = "FEAT_MAX" in def : FMVExtension<"priority1", "1">;
+let FeatureBit = "FEAT_MAX" in def : FMVExtension<"priority2", "2">;
+let FeatureBit = "FEAT_MAX" in def : FMVExtension<"priority3", "3">;
+let FeatureBit = "FEAT_MAX" in def : FMVExtension<"priority4", "4">;
+let FeatureBit = "FEAT_MAX" in def : FMVExtension<"priority5", "5">;
diff --git a/llvm/lib/TargetParser/AArch64TargetParser.cpp 
b/llvm/lib/TargetParser/AArch64TargetParser.cpp
index 4a2523440f0f0..612683dca9f34 100644
--- a/llvm/lib/TargetParser/AArch64TargetParser.cpp
+++ b/llvm/lib/TargetParser/AArch64TargetParser.cpp
@@ -58,18 +58,23 @@ std::optional 
lookupFMVByID(AArch64::ArchExtKind ExtID) {
 uint64_t AArch64::getFMVPriority(ArrayRef Features) {
   // Transitively enable the Arch Extensions whic

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-27 Thread Anton Korobeynikov via cfe-commits

asl wrote:

> The fact I'm worried about is whether implicit signing and authentication on 
> accesses to `__ptrauth`-qualified fields may introduce signing or 
> authentication oracles usable by an attacker, since many values stored to 
> these fields are initially non-signed. This is possibly mitigated by the fact 
> that all these fields use address diversity with distinct integer 
> discriminators and/or the original values are taken from read-only memory. On 
> the other hand, discriminator computation, auth / sign intrinsic and load / 
> store to memory are currently three separate operations when accessing a 
> `__ptrauth`-qualified field, thus spilling of intermediate values to the 
> stack is possible. Furthermore, even if the non-signed value originates from 
> a read-only memory, this is not expressed in LLVM IR terms, thus the 
> optimization pipeline may transform sensitive instruction sequences in an 
> unsafe way.

I think we will need to revise / reinvestigate this issue after this PR and see 
if we can move forward with more robust approach.

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


[clang] [llvm] [EarlyCSE] Add support for writeonly call CSE (PR #145474)

2025-06-27 Thread Nikita Popov via cfe-commits

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

>From 3d51cf4796fe5f1e1577ce23f2970975bd216157 Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Tue, 24 Jun 2025 10:08:40 +0200
Subject: [PATCH 1/4] [EarlyCSE] Add tests for writeonly

---
 llvm/test/Transforms/EarlyCSE/writeonly.ll | 153 -
 1 file changed, 152 insertions(+), 1 deletion(-)

diff --git a/llvm/test/Transforms/EarlyCSE/writeonly.ll 
b/llvm/test/Transforms/EarlyCSE/writeonly.ll
index 0bfffa3c825a3..354638e9f3fe1 100644
--- a/llvm/test/Transforms/EarlyCSE/writeonly.ll
+++ b/llvm/test/Transforms/EarlyCSE/writeonly.ll
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -S -passes=early-cse -earlycse-debug-hash < %s | FileCheck %s
+; RUN: opt -S -passes=early-cse -earlycse-debug-hash < %s | FileCheck %s 
--check-prefixes=CHECK,NO-MSSA
+; RUN: opt -S -passes='early-cse' < %s | FileCheck %s 
--check-prefixes=CHECK,MSSA
 
 @var = global i32 undef
 declare void @foo() nounwind
@@ -15,3 +16,153 @@ define void @test() {
   store i32 2, ptr @var
   ret void
 }
+
+declare void @writeonly_void() memory(write)
+
+; Can CSE writeonly calls, including non-nounwind/willreturn.
+define void @writeonly_cse() {
+; CHECK-LABEL: @writeonly_cse(
+; CHECK-NEXT:call void @writeonly_void()
+; CHECK-NEXT:call void @writeonly_void()
+; CHECK-NEXT:ret void
+;
+  call void @writeonly_void()
+  call void @writeonly_void()
+  ret void
+}
+
+; Can CSE, loads do not matter.
+define i32 @writeonly_cse_intervening_load(ptr %p) {
+; CHECK-LABEL: @writeonly_cse_intervening_load(
+; CHECK-NEXT:call void @writeonly_void()
+; CHECK-NEXT:[[V:%.*]] = load i32, ptr [[P:%.*]], align 4
+; CHECK-NEXT:call void @writeonly_void()
+; CHECK-NEXT:ret i32 [[V]]
+;
+  call void @writeonly_void()
+  %v = load i32, ptr %p
+  call void @writeonly_void()
+  ret i32 %v
+}
+
+; Cannot CSE, the store may be to the same memory.
+define void @writeonly_cse_intervening_store(ptr %p) {
+; CHECK-LABEL: @writeonly_cse_intervening_store(
+; CHECK-NEXT:call void @writeonly_void()
+; CHECK-NEXT:store i32 0, ptr [[P:%.*]], align 4
+; CHECK-NEXT:call void @writeonly_void()
+; CHECK-NEXT:ret void
+;
+  call void @writeonly_void()
+  store i32 0, ptr %p
+  call void @writeonly_void()
+  ret void
+}
+
+; Can CSE, the store does not alias the writeonly call.
+define void @writeonly_cse_intervening_noalias_store(ptr noalias %p) {
+; CHECK-LABEL: @writeonly_cse_intervening_noalias_store(
+; CHECK-NEXT:call void @writeonly_void()
+; CHECK-NEXT:store i32 0, ptr [[P:%.*]], align 4
+; CHECK-NEXT:call void @writeonly_void()
+; CHECK-NEXT:ret void
+;
+  call void @writeonly_void()
+  store i32 0, ptr %p
+  call void @writeonly_void()
+  ret void
+}
+
+; Cannot CSE loads across writeonly call.
+define i32 @load_cse_across_writeonly(ptr %p) {
+; CHECK-LABEL: @load_cse_across_writeonly(
+; CHECK-NEXT:[[V1:%.*]] = load i32, ptr [[P:%.*]], align 4
+; CHECK-NEXT:call void @writeonly_void()
+; CHECK-NEXT:[[V2:%.*]] = load i32, ptr [[P]], align 4
+; CHECK-NEXT:[[RES:%.*]] = sub i32 [[V1]], [[V2]]
+; CHECK-NEXT:ret i32 [[RES]]
+;
+  %v1 = load i32, ptr %p
+  call void @writeonly_void()
+  %v2 = load i32, ptr %p
+  %res = sub i32 %v1, %v2
+  ret i32 %res
+}
+
+; Can CSE loads across eliminated writeonly call.
+define i32 @load_cse_across_csed_writeonly(ptr %p) {
+; CHECK-LABEL: @load_cse_across_csed_writeonly(
+; CHECK-NEXT:call void @writeonly_void()
+; CHECK-NEXT:[[V1:%.*]] = load i32, ptr [[P:%.*]], align 4
+; CHECK-NEXT:call void @writeonly_void()
+; CHECK-NEXT:[[V2:%.*]] = load i32, ptr [[P]], align 4
+; CHECK-NEXT:[[RES:%.*]] = sub i32 [[V1]], [[V2]]
+; CHECK-NEXT:ret i32 [[RES]]
+;
+  call void @writeonly_void()
+  %v1 = load i32, ptr %p
+  call void @writeonly_void()
+  %v2 = load i32, ptr %p
+  %res = sub i32 %v1, %v2
+  ret i32 %res
+}
+
+declare i32 @writeonly(ptr %p) memory(write)
+
+; Can CSE writeonly calls with arg and return.
+define i32 @writeonly_ret_cse(ptr %p) {
+; CHECK-LABEL: @writeonly_ret_cse(
+; CHECK-NEXT:[[V1:%.*]] = call i32 @writeonly(ptr [[P:%.*]])
+; CHECK-NEXT:[[V2:%.*]] = call i32 @writeonly(ptr [[P]])
+; CHECK-NEXT:[[RES:%.*]] = sub i32 [[V1]], [[V2]]
+; CHECK-NEXT:ret i32 [[RES]]
+;
+  %v1 = call i32 @writeonly(ptr %p)
+  %v2 = call i32 @writeonly(ptr %p)
+  %res = sub i32 %v1, %v2
+  ret i32 %res
+}
+
+; Cannot CSE writeonly calls with different arguments.
+define i32 @writeonly_different_args(ptr %p1, ptr %p2) {
+; CHECK-LABEL: @writeonly_different_args(
+; CHECK-NEXT:[[V1:%.*]] = call i32 @writeonly(ptr [[P1:%.*]])
+; CHECK-NEXT:[[V2:%.*]] = call i32 @writeonly(ptr [[P2:%.*]])
+; CHECK-NEXT:[[RES:%.*]] = sub i32 [[V1]], [[V2]]
+; CHECK-NEXT:ret i32 [[RES]]
+;
+  %v1 = call i32 @writeonly(ptr %p1)
+  %v2 = call i32 @writeonly(ptr %p2)
+  %res = sub i32 %v1, %v2

[clang] [llvm] [FMV][AArch64] Allow user to override version priority. (PR #146092)

2025-06-27 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-backend-aarch64

@llvm/pr-subscribers-llvm-transforms

Author: Alexandros Lamprineas (labrinea)


Changes

Implements option one of the proposal 
https://github.com/ARM-software/acle/issues/403

---

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


12 Files Affected:

- (modified) clang/lib/CodeGen/Targets/AArch64.cpp (+4-1) 
- (modified) clang/test/CodeGen/AArch64/fmv-duplicate-mangled-name.c (+16) 
- (added) clang/test/CodeGen/AArch64/fmv-explicit-priority.c (+193) 
- (modified) llvm/include/llvm/Analysis/TargetTransformInfo.h (+5-1) 
- (modified) llvm/include/llvm/Analysis/TargetTransformInfoImpl.h (+1) 
- (modified) llvm/include/llvm/TargetParser/AArch64FeatPriorities.inc (+6-1) 
- (modified) llvm/lib/Analysis/TargetTransformInfo.cpp (+4) 
- (modified) llvm/lib/Target/AArch64/AArch64FMV.td (+5) 
- (modified) llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp (+14-3) 
- (modified) llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h (+1) 
- (modified) llvm/lib/TargetParser/AArch64TargetParser.cpp (+19-10) 
- (modified) llvm/lib/Transforms/IPO/GlobalOpt.cpp (+15-7) 


``diff
diff --git a/clang/lib/CodeGen/Targets/AArch64.cpp 
b/clang/lib/CodeGen/Targets/AArch64.cpp
index b82c46966cf0b..e2ede08942183 100644
--- a/clang/lib/CodeGen/Targets/AArch64.cpp
+++ b/clang/lib/CodeGen/Targets/AArch64.cpp
@@ -1336,10 +1336,13 @@ void AArch64ABIInfo::appendAttributeMangling(StringRef 
AttrStr,
   });
 
   llvm::SmallDenseSet UniqueFeats;
-  for (auto &Feat : Features)
+  for (auto &Feat : Features) {
+if (!getTarget().doesFeatureAffectCodeGen(Feat))
+  continue;
 if (auto Ext = llvm::AArch64::parseFMVExtension(Feat))
   if (UniqueFeats.insert(Ext->Name).second)
 Out << 'M' << Ext->Name;
+  }
 }
 
 std::unique_ptr
diff --git a/clang/test/CodeGen/AArch64/fmv-duplicate-mangled-name.c 
b/clang/test/CodeGen/AArch64/fmv-duplicate-mangled-name.c
index e7e611e09542e..44a798a84a8a2 100644
--- a/clang/test/CodeGen/AArch64/fmv-duplicate-mangled-name.c
+++ b/clang/test/CodeGen/AArch64/fmv-duplicate-mangled-name.c
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -triple aarch64-linux-gnu -verify -emit-llvm-only %s 
-DCHECK_IMPLICIT_DEFAULT
 // RUN: %clang_cc1 -triple aarch64-linux-gnu -verify -emit-llvm-only %s 
-DCHECK_EXPLICIT_DEFAULT
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -verify -emit-llvm-only %s 
-DCHECK_EXPLICIT_VERSION_PRIORITY
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -verify -emit-llvm-only %s 
-DCHECK_EXPLICIT_CLONES_PRIORITY
 
 #if defined(CHECK_IMPLICIT_DEFAULT)
 
@@ -21,4 +23,18 @@ __attribute__((target_version("default"))) int 
explicit_default_bad(void) { retu
 // expected-note@-2 {{previous definition is here}}
 __attribute__((target_clones("aes", "lse", "default"))) int 
explicit_default_bad(void) { return 1; }
 
+#elif defined(CHECK_EXPLICIT_VERSION_PRIORITY)
+
+__attribute__((target_version("aes"))) int explicit_version_priority(void) { 
return 0; }
+// expected-error@+2 {{definition with same mangled name 
'explicit_version_priority._Maes' as another definition}}
+// expected-note@-2 {{previous definition is here}}
+__attribute__((target_version("priority1+aes"))) int 
explicit_version_priority(void) { return 1; }
+
+#elif defined(CHECK_EXPLICIT_CLONES_PRIORITY)
+
+__attribute__((target_version("aes+priority2"))) int 
explicit_clones_priority(void) { return 0; }
+// expected-error@+2 {{definition with same mangled name 
'explicit_clones_priority._Maes' as another definition}}
+// expected-note@-2 {{previous definition is here}}
+__attribute__((target_clones("priority1+aes", "lse"))) int 
explicit_clones_priority(void) { return 1; }
+
 #endif
diff --git a/clang/test/CodeGen/AArch64/fmv-explicit-priority.c 
b/clang/test/CodeGen/AArch64/fmv-explicit-priority.c
new file mode 100644
index 0..95a246fea425b
--- /dev/null
+++ b/clang/test/CodeGen/AArch64/fmv-explicit-priority.c
@@ -0,0 +1,193 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --check-globals 
--include-generated-funcs
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -O3 -fno-inline -emit-llvm 
-o - %s | FileCheck %s
+
+__attribute__((target_version("priority1+lse"))) int foo(void) { return 1; }
+__attribute__((target_version("priority2+sve2"))) int foo(void) { return 2; }
+__attribute__((target_version("priority3+sve"))) int foo(void) { return 3; }
+__attribute__((target_version( "default"))) int foo(void) { return 0; }
+
+__attribute__((target_clones("priority1+lse+sve2", "priority2+lse", 
"priority3+sve", "default")))
+int fmv_caller(void) { return foo(); }
+
+
+__attribute__((target_version("aes"))) int bar(void) { return 1; }
+__attribute__((target_version("priority1+sm4"))) int bar(void) { return 2; }
+__attribute__((target_version("default"))) int bar(void) { return 0; }
+
+__attribute__((target("aes"))) int

[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

2025-06-27 Thread Balazs Benics via cfe-commits


@@ -2122,8 +2122,21 @@ SVal 
RegionStoreManager::getBindingForField(RegionBindingsConstRef B,
   if (const std::optional &V = B.getDirectBinding(R))
 return *V;
 
-  // If the containing record was initialized, try to get its constant value.
+  // UnnamedBitField is always Undefined unless using memory operation such
+  // as 'memset'.
+  // For example, for code
+  //typedef struct {
+  //  int i  :2;
+  //  int:30;  // unnamed bit-field
+  //} A;
+  //A a = {1};
+  // The bits of the unnamed bit-field in local variable a can be anything.
   const FieldDecl *FD = R->getDecl();
+  if (FD->isUnnamedBitField()) {
+  return UndefinedVal();
+  }
+
+  // If the containing record was initialized, try to get its constant value.

steakhal wrote:

Your understanding of `UndefinedVal` is correct, unlike with `SymbolVal`. 
Symbols (`SymbolVal` aka. `SymExpr`) we track values. We may or may not know 
anything about these symbols (most notably the value range that a symbol can 
hold). More importantly, we can combine such symbols into making larger 
symbols, basically embedding the history of the computation that the given 
variable holds at any given point in time. But this is likely not important 
here.

This is a critical component, so we don't accept patches without tests. Even 
tests are not enough to demonstrate correctness, thus we frequently ask for 
"measurements", or running differential analysis with and without a patch and 
observing the outcomes of many many real-world projects to have a better 
picture of what the implications are.

Frequently even doing the correct thing reveals untended other bugs that are 
actually worse than what we initially wanted to fix, thus effectively 
preventing us from doing the right thing. Don't worry, this is not the case 
with the `CallAndMessageChecker`.

You can propose a FIXME, but without more context it can do more harm than good 
if put at the wrong place with a misleading content. So to approve that, we 
will need to do some digging where the Symbol is coming from and why do we have 
that Symbol instead of Undef there?
Otherwise we are better off not having this FIXME I think.

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


[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

2025-06-27 Thread Balazs Benics via cfe-commits


@@ -22,3 +29,21 @@ void pointee_uninit(void) {
 // checker, as described in the CallAndMessage comments!
 // CHECK: issue_hash_content_of_line_in_context
 // CHECK-SAME: 97a74322d64dca40aa57303842c745a1
+
+typedef struct {
+  int i  :2;
+  int:30;  // unnamed bit-field
+} B;
+
+extern void consume_B(B);
+
+void bitfield_B_init(void) {
+  B b1;
+  b1.i = 1; // b1 is initialized
+  consume_B(b1);
+}
+
+void bitfield_B_uninit(void) {
+  B b2;
+  consume_B(b2); // arg-init-warning{{Passed-by-value struct argument contains 
uninitialized data (e.g., field: 'i') [core.CallAndMessage]}}
+}

steakhal wrote:

Can you add a newline to the end to make GH happy?

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


[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

2025-06-27 Thread Balazs Benics via cfe-commits


@@ -1,12 +1,19 @@
 // RUN: %clang_analyze_cc1 %s -verify \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-config core.CallAndMessage:ArgPointeeInitializedness=true \
+// RUN:   -analyzer-config core.CallAndMessage:ArgInitializedness=false \
 // RUN:   -analyzer-output=plist -o %t.plist
 // RUN: cat %t.plist | FileCheck %s
 
 // RUN: %clang_analyze_cc1 %s -verify=no-pointee \
 // RUN:   -analyzer-checker=core \
-// RUN:   -analyzer-config core.CallAndMessage:ArgPointeeInitializedness=false
+// RUN:   -analyzer-config core.CallAndMessage:ArgPointeeInitializedness=false 
\
+// RUN:   -analyzer-config core.CallAndMessage:ArgInitializedness=false
+
+// RUN: %clang_analyze_cc1 %s -verify=arg-init \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-config core.CallAndMessage:ArgPointeeInitializedness=false 
\
+// RUN:   -analyzer-config core.CallAndMessage:ArgInitializedness=true

steakhal wrote:

In general, if a test verifies the `plists`, we are usually better off not 
touching the test file because it may change a bunch of line numbers in the 
check expectations. It wasn't the case this time, so I guess it should be fine 
here too. As you wish.

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


[clang] a460aa1 - [Sema] Fix a warning

2025-06-27 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2025-06-27T08:15:06-07:00
New Revision: a460aa1071c90e849144a5ca2c11b3016e1dc2a0

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

LOG: [Sema] Fix a warning

This patch fixes:

  clang/lib/Sema/AnalysisBasedWarnings.cpp:686:23: error: variable
  'FD' set but not used [-Werror,-Wunused-but-set-variable]

Added: 


Modified: 
clang/lib/Sema/AnalysisBasedWarnings.cpp

Removed: 




diff  --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp 
b/clang/lib/Sema/AnalysisBasedWarnings.cpp
index f3798bb6a7450..7420ba2d461c6 100644
--- a/clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -683,7 +683,7 @@ static void CheckFallThroughForBody(Sema &S, const Decl *D, 
const Stmt *Body,
 } else if (!ReturnsVoid && CD.diag_FallThrough_ReturnsNonVoid) {
   // If the final statement is a call to an always-throwing function,
   // don't warn about the fall-through.
-  if (const auto *FD = D->getAsFunction()) {
+  if (D->getAsFunction()) {
 if (const auto *CS = dyn_cast(Body);
 CS && !CS->body_empty()) {
   const Stmt *LastStmt = CS->body_back();



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


[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-06-27 Thread Donát Nagy via cfe-commits

NagyDonat wrote:

> Let me know if you means something like this when you referred to "you can 
> insert one more early return".

Yes, I thought about something like your code example.

> > If you really want to bother with performance improvements that 
> > specifically target this 0.05% of the entrypoints, then you can insert one 
> > more early return here at the beginning of `evalBinOp` to skip some 
> > calculations if you encounter a `SymbolOverlyComplex`.
> 
> This is the point. I don't think I can special case these because the 
> computations still make sense to do.
> [...]
> Btw this would solve the performance problem (at least on the sample I 
> shared), and it's technically a correct implementation, but I still find it 
> unfair.

The whole "place a limit on symbol complexity" logic is a fundamentally 
_unfair_ heuristic that stops some calculations that "make sense" and are 
theoretically similar to other calculations.

Generally speaking, I'm trying to follow the dichotomy that:
- The normal, commonly occurring situation should be handled by effective and 
elegant code that runs quickly and produces many useful and accurate results -- 
even if this requires lots of code complexity.
- The rare corner cases should be short-circuited by simple logic, sacrificing 
theoretical elegance and accepting false negatives. (Even some performance hits 
are acceptable if they are overall negligible.)

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


[clang] [llvm] [EarlyCSE] Add support for writeonly call CSE (PR #145474)

2025-06-27 Thread Nikita Popov via cfe-commits

nikic wrote:

Skipping memsets for now. I added a PhaseOrdering test in 
https://github.com/llvm/llvm-project/commit/ec150a9944b2ce447c94944043fe1b87234e971f.
 I think what we're mainly missing is store sinking support in DSE.

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


[clang] [llvm] [OpenMP][clang] 6.0: parsing/sema for message/severity for parallel (PR #146093)

2025-06-27 Thread Robert Imschweiler via cfe-commits

https://github.com/ro-i created https://github.com/llvm/llvm-project/pull/146093

Implement parsing and semantic analysis support for the message and severity 
clauses that have been added to the parallel directive in OpenMP 6.0, 12.1.

>From b01bdf107f80f0f023270326e4a16b1dcadd69d8 Mon Sep 17 00:00:00 2001
From: Robert Imschweiler 
Date: Fri, 27 Jun 2025 10:07:01 -0500
Subject: [PATCH] [OpenMP][clang] 6.0: parsing/sema for message/severity for
 parallel

Implement parsing and semantic analysis support for the message and
severity clauses that have been added to the parallel directive in
OpenMP 6.0, 12.1.
---
 clang/include/clang/AST/OpenMPClause.h|  6 +-
 clang/lib/Sema/SemaOpenMP.cpp |  4 +-
 clang/test/OpenMP/parallel_ast_print.cpp  | 24 ++---
 .../test/OpenMP/parallel_message_messages.cpp | 89 +++
 .../OpenMP/parallel_severity_messages.cpp | 70 +++
 llvm/include/llvm/Frontend/OpenMP/OMP.td  |  2 +
 6 files changed, 179 insertions(+), 16 deletions(-)
 create mode 100644 clang/test/OpenMP/parallel_message_messages.cpp
 create mode 100644 clang/test/OpenMP/parallel_severity_messages.cpp

diff --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index c6f99fb21a0f0..8b602f49aefde 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -1775,7 +1775,8 @@ class OMPAtClause final : public OMPClause {
   }
 };
 
-/// This represents 'severity' clause in the '#pragma omp error' directive
+/// This represents the 'severity' clause in the '#pragma omp error' and the
+/// '#pragma omp parallel' directives.
 ///
 /// \code
 /// #pragma omp error severity(fatal)
@@ -1855,7 +1856,8 @@ class OMPSeverityClause final : public OMPClause {
   }
 };
 
-/// This represents 'message' clause in the '#pragma omp error' directive
+/// This represents the 'message' clause in the '#pragma omp error' and the
+/// '#pragma omp parallel' directives.
 ///
 /// \code
 /// #pragma omp error message("GNU compiler required.")
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index a30acbe9a4bca..4ecc9b0d4c5c8 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -6620,6 +6620,8 @@ StmtResult SemaOpenMP::ActOnOpenMPExecutableDirective(
   case OMPC_affinity:
   case OMPC_bind:
   case OMPC_filter:
+  case OMPC_severity:
+  case OMPC_message:
 continue;
   case OMPC_allocator:
   case OMPC_flush:
@@ -6637,8 +6639,6 @@ StmtResult SemaOpenMP::ActOnOpenMPExecutableDirective(
   case OMPC_match:
   case OMPC_when:
   case OMPC_at:
-  case OMPC_severity:
-  case OMPC_message:
   default:
 llvm_unreachable("Unexpected clause");
   }
diff --git a/clang/test/OpenMP/parallel_ast_print.cpp 
b/clang/test/OpenMP/parallel_ast_print.cpp
index 948baaff30d89..15439ea31215a 100644
--- a/clang/test/OpenMP/parallel_ast_print.cpp
+++ b/clang/test/OpenMP/parallel_ast_print.cpp
@@ -173,13 +173,13 @@ T tmain(T argc, T *argv) {
   foo();
 #endif
 #ifdef OMP60
-#pragma omp parallel default(none), private(argc,b) firstprivate(argv) shared 
(d) if (parallel:argc > 0) num_threads(strict: C) copyin(S::TS, thrp) 
proc_bind(primary) reduction(+:c, arr1[argc]) reduction(max:e, arr[:C][0:10])
+#pragma omp parallel default(none), private(argc,b) firstprivate(argv) shared 
(d) if (parallel:argc > 0) num_threads(strict: C) copyin(S::TS, thrp) 
proc_bind(primary) reduction(+:c, arr1[argc]) reduction(max:e, arr[:C][0:10]) 
message("msg") severity(fatal)
   foo();
 #endif
 #pragma omp parallel if (C) num_threads(s) proc_bind(close) reduction(^:e, f, 
arr[0:C][:argc]) reduction(default, && : g) reduction(task,+:argc)
   foo();
 #ifdef OMP60
-#pragma omp parallel if (C) num_threads(strict: s) proc_bind(close) 
reduction(^:e, f, arr[0:C][:argc]) reduction(default, && : g) 
reduction(task,+:argc)
+#pragma omp parallel if (C) num_threads(strict: s) proc_bind(close) 
reduction(^:e, f, arr[0:C][:argc]) reduction(default, && : g) 
reduction(task,+:argc) message("msg") severity(warning)
   foo();
 #endif
   return 0;
@@ -196,11 +196,11 @@ T tmain(T argc, T *argv) {
 // CHECK-NEXT: foo()
 // OMP51-NEXT: #pragma omp parallel default(none) private(argc,b) 
firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(C) 
copyin(S::TS,thrp) proc_bind(primary) reduction(+: c,arr1[argc]) 
reduction(max: e,arr[:C][0:10])
 // OMP51-NEXT: foo()
-// OMP60-NEXT: #pragma omp parallel default(none) private(argc,b) 
firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(strict: C) 
copyin(S::TS,thrp) proc_bind(primary) reduction(+: c,arr1[argc]) 
reduction(max: e,arr[:C][0:10])
+// OMP60-NEXT: #pragma omp parallel default(none) private(argc,b) 
firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(strict: C) 
copyin(S::TS,thrp) proc_bind(primary) reduction(+: c,arr1[argc]) 
reduction(max: e,arr[:C][0:10]) message("

[clang] [llvm] [OpenMP][clang] 6.0: parsing/sema for message/severity for parallel (PR #146093)

2025-06-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Robert Imschweiler (ro-i)


Changes

Implement parsing and semantic analysis support for the message and severity 
clauses that have been added to the parallel directive in OpenMP 6.0, 12.1.

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


6 Files Affected:

- (modified) clang/include/clang/AST/OpenMPClause.h (+4-2) 
- (modified) clang/lib/Sema/SemaOpenMP.cpp (+2-2) 
- (modified) clang/test/OpenMP/parallel_ast_print.cpp (+12-12) 
- (added) clang/test/OpenMP/parallel_message_messages.cpp (+89) 
- (added) clang/test/OpenMP/parallel_severity_messages.cpp (+70) 
- (modified) llvm/include/llvm/Frontend/OpenMP/OMP.td (+2) 


``diff
diff --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index c6f99fb21a0f0..8b602f49aefde 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -1775,7 +1775,8 @@ class OMPAtClause final : public OMPClause {
   }
 };
 
-/// This represents 'severity' clause in the '#pragma omp error' directive
+/// This represents the 'severity' clause in the '#pragma omp error' and the
+/// '#pragma omp parallel' directives.
 ///
 /// \code
 /// #pragma omp error severity(fatal)
@@ -1855,7 +1856,8 @@ class OMPSeverityClause final : public OMPClause {
   }
 };
 
-/// This represents 'message' clause in the '#pragma omp error' directive
+/// This represents the 'message' clause in the '#pragma omp error' and the
+/// '#pragma omp parallel' directives.
 ///
 /// \code
 /// #pragma omp error message("GNU compiler required.")
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index a30acbe9a4bca..4ecc9b0d4c5c8 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -6620,6 +6620,8 @@ StmtResult SemaOpenMP::ActOnOpenMPExecutableDirective(
   case OMPC_affinity:
   case OMPC_bind:
   case OMPC_filter:
+  case OMPC_severity:
+  case OMPC_message:
 continue;
   case OMPC_allocator:
   case OMPC_flush:
@@ -6637,8 +6639,6 @@ StmtResult SemaOpenMP::ActOnOpenMPExecutableDirective(
   case OMPC_match:
   case OMPC_when:
   case OMPC_at:
-  case OMPC_severity:
-  case OMPC_message:
   default:
 llvm_unreachable("Unexpected clause");
   }
diff --git a/clang/test/OpenMP/parallel_ast_print.cpp 
b/clang/test/OpenMP/parallel_ast_print.cpp
index 948baaff30d89..15439ea31215a 100644
--- a/clang/test/OpenMP/parallel_ast_print.cpp
+++ b/clang/test/OpenMP/parallel_ast_print.cpp
@@ -173,13 +173,13 @@ T tmain(T argc, T *argv) {
   foo();
 #endif
 #ifdef OMP60
-#pragma omp parallel default(none), private(argc,b) firstprivate(argv) shared 
(d) if (parallel:argc > 0) num_threads(strict: C) copyin(S::TS, thrp) 
proc_bind(primary) reduction(+:c, arr1[argc]) reduction(max:e, arr[:C][0:10])
+#pragma omp parallel default(none), private(argc,b) firstprivate(argv) shared 
(d) if (parallel:argc > 0) num_threads(strict: C) copyin(S::TS, thrp) 
proc_bind(primary) reduction(+:c, arr1[argc]) reduction(max:e, arr[:C][0:10]) 
message("msg") severity(fatal)
   foo();
 #endif
 #pragma omp parallel if (C) num_threads(s) proc_bind(close) reduction(^:e, f, 
arr[0:C][:argc]) reduction(default, && : g) reduction(task,+:argc)
   foo();
 #ifdef OMP60
-#pragma omp parallel if (C) num_threads(strict: s) proc_bind(close) 
reduction(^:e, f, arr[0:C][:argc]) reduction(default, && : g) 
reduction(task,+:argc)
+#pragma omp parallel if (C) num_threads(strict: s) proc_bind(close) 
reduction(^:e, f, arr[0:C][:argc]) reduction(default, && : g) 
reduction(task,+:argc) message("msg") severity(warning)
   foo();
 #endif
   return 0;
@@ -196,11 +196,11 @@ T tmain(T argc, T *argv) {
 // CHECK-NEXT: foo()
 // OMP51-NEXT: #pragma omp parallel default(none) private(argc,b) 
firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(C) 
copyin(S::TS,thrp) proc_bind(primary) reduction(+: c,arr1[argc]) 
reduction(max: e,arr[:C][0:10])
 // OMP51-NEXT: foo()
-// OMP60-NEXT: #pragma omp parallel default(none) private(argc,b) 
firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(strict: C) 
copyin(S::TS,thrp) proc_bind(primary) reduction(+: c,arr1[argc]) 
reduction(max: e,arr[:C][0:10])
+// OMP60-NEXT: #pragma omp parallel default(none) private(argc,b) 
firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(strict: C) 
copyin(S::TS,thrp) proc_bind(primary) reduction(+: c,arr1[argc]) 
reduction(max: e,arr[:C][0:10]) message("msg") severity(fatal)
 // OMP60-NEXT: foo()
 // CHECK-NEXT: #pragma omp parallel if(C) num_threads(s) proc_bind(close) 
reduction(^: e,f,arr[0:C][:argc]) reduction(default, &&: g) reduction(task, +: 
argc)
 // CHECK-NEXT: foo()
-// OMP60-NEXT: #pragma omp parallel if(C) num_threads(strict: s) 
proc_bind(close) reduction(^: e,f,arr[0:C][:argc]) reduction(default, &&: g) 
reduction(task, +: argc)
+// OMP60-NEXT: #pragma omp parallel if(C) num_threa

[clang] [Sema] Fix lifetime extension for temporaries in range-based for loops in C++23 (PR #145164)

2025-06-27 Thread via cfe-commits

yronglin wrote:

> but why can’t we use InLifetimeExtendingContext flag here? 
> Is there a subtle difference I’m missing?

This flag will tiger subroutines to collect `MaterializedTemporaryExpr` and 
rebuild default init/arg。 All we need to know here is that `ExtendingDecl` is a 
C++ `__range` var in for-range-loop, so I think we should introduce a new flag 
in VarDecl. We may need to also modify handling of VarDecl in ASTWriter and 
ASTReader to ensure that the AST serialization is correct. WDYT?

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


[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-06-27 Thread Donát Nagy via cfe-commits

NagyDonat wrote:

:thinking: I agree that it wouldn't be elegant to add

> ```
> +  if (isa_and_nonnull(lhs.getAsSymbol()) ||
> +  isa_and_nonnull(rhs.getAsSymbol()))
> +return UnknownVal();
> ```

because this way `SymbolOverlyComplex` would become an overcomplicated 
intermediate step that always leads to `UnknownVal`.

However, as I think about this situation, I realized that it's completely 
arbitrary that we're putting a complexity limit on the _result_ symbol -- we 
might as well introduce a complexity threshold above which symbols cannot 
_participate in calculations_:
```c++
if (lhs.getAsSymbol() && lhs.getAsSymbol()->complexity() > Threshold ||
lhs.getAsSymbol() && lhs.getAsSymbol()->complexity() > Threshold)
  return UnknownVal();
```
This different sort of limitation still guarantees that we cannot build overly 
complex symbols, but its implementation is significantly shorter (just three 
early return statements for unary operator, binary operator and cast 
evaluation). 

:bulb: In fact, you can add the complexity values of the two operands to get a 
heuristic which is practically equivalent to the complexity threshold that you 
want, but doesn't pass around `UnknownVal`s in already complex code and doesn't 
introduce a new symbol type.

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


[clang] [Clang] Verify data layout consistency (PR #144720)

2025-06-27 Thread Nikita Popov via cfe-commits

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

>From 4a70541ed734969f0db13c6fdf76c79702cc2b6e Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Wed, 18 Jun 2025 14:48:19 +0200
Subject: [PATCH] [Clang] Verify data layout consistency

Verify that the alignments specified by clang TargetInfo match
the alignments specified by LLVM data layout, which will hopefully
prevent accidental mismatches in the future.

This currently contains opt-outs for a lot of existing mismatches.

I'm also skipping the verification if options like `-malign-double`
are used, or a language that mandates sizes/alignments that differ
from C.
---
 clang/lib/CodeGen/CodeGenModule.cpp | 73 +
 1 file changed, 73 insertions(+)

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 96fdab212beb1..e546b0c643643 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -332,6 +332,76 @@ const TargetCodeGenInfo 
&CodeGenModule::getTargetCodeGenInfo() {
   return *TheTargetCodeGenInfo;
 }
 
+static void checkDataLayoutConsistency(const TargetInfo &Target,
+   llvm::LLVMContext &Context,
+   const LangOptions &Opts) {
+#ifndef NDEBUG
+  // Don't verify non-standard ABI configurations.
+  if (Opts.AlignDouble || Opts.OpenCL || Opts.HLSL)
+return;
+
+  llvm::Triple Triple = Target.getTriple();
+  llvm::DataLayout DL(Target.getDataLayoutString());
+  auto Check = [&](const char *Name, llvm::Type *Ty, unsigned Alignment) {
+llvm::Align DLAlign = DL.getABITypeAlign(Ty);
+llvm::Align ClangAlign(Alignment / 8);
+if (DLAlign != ClangAlign) {
+  llvm::errs() << "For target " << Triple.str() << " type " << Name
+   << " mapping to " << *Ty << " has data layout alignment "
+   << DLAlign.value() << " while clang specifies "
+   << ClangAlign.value() << "\n";
+  abort();
+}
+  };
+
+  Check("bool", llvm::Type::getIntNTy(Context, Target.BoolWidth),
+Target.BoolAlign);
+  Check("short", llvm::Type::getIntNTy(Context, Target.ShortWidth),
+Target.ShortAlign);
+  // FIXME: M68k specifies incorrect wrong int and long alignments in Clang
+  // and incorrect long long alignment in both LLVM and Clang.
+  if (Triple.getArch() != llvm::Triple::m68k) {
+Check("int", llvm::Type::getIntNTy(Context, Target.IntWidth),
+  Target.IntAlign);
+Check("long", llvm::Type::getIntNTy(Context, Target.LongWidth),
+  Target.LongAlign);
+Check("long long", llvm::Type::getIntNTy(Context, Target.LongLongWidth),
+  Target.LongLongAlign);
+  }
+  // FIXME: There are int128 alignment mismatches on multiple targets.
+  if (Target.hasInt128Type() && !Target.getTargetOpts().ForceEnableInt128 &&
+  !Triple.isAMDGPU() && !Triple.isSPIRV() &&
+  Triple.getArch() != llvm::Triple::ve)
+Check("__int128", llvm::Type::getIntNTy(Context, 128), Target.Int128Align);
+
+  if (Target.hasFloat16Type())
+Check("half", llvm::Type::getFloatingPointTy(Context, *Target.HalfFormat),
+  Target.HalfAlign);
+  if (Target.hasBFloat16Type())
+Check("bfloat", llvm::Type::getBFloatTy(Context), Target.BFloat16Align);
+  Check("float", llvm::Type::getFloatingPointTy(Context, *Target.FloatFormat),
+Target.FloatAlign);
+  // FIXME: AIX specifies wrong double alignment in DataLayout
+  if (!Triple.isOSAIX()) {
+Check("double",
+  llvm::Type::getFloatingPointTy(Context, *Target.DoubleFormat),
+  Target.DoubleAlign);
+Check("long double",
+  llvm::Type::getFloatingPointTy(Context, *Target.LongDoubleFormat),
+  Target.LongDoubleAlign);
+  }
+  // FIXME: Wasm has a mismatch in f128 alignment between Clang and LLVM.
+  if (Target.hasFloat128Type() && !Triple.isWasm())
+Check("__float128", llvm::Type::getFP128Ty(Context), Target.Float128Align);
+  if (Target.hasIbm128Type())
+Check("__ibm128", llvm::Type::getPPC_FP128Ty(Context), Target.Ibm128Align);
+
+  // FIXME: Clang specifies incorrect pointer alignment for m68k.
+  if (Triple.getArch() != llvm::Triple::m68k)
+Check("void*", llvm::PointerType::getUnqual(Context), Target.PointerAlign);
+#endif
+}
+
 CodeGenModule::CodeGenModule(ASTContext &C,
  IntrusiveRefCntPtr FS,
  const HeaderSearchOptions &HSO,
@@ -487,6 +557,9 @@ CodeGenModule::CodeGenModule(ASTContext &C,
 
 llvm::sort(this->MSHotPatchFunctions);
   }
+
+  if (!Context.getAuxTargetInfo())
+checkDataLayoutConsistency(Context.getTargetInfo(), LLVMContext, LangOpts);
 }
 
 CodeGenModule::~CodeGenModule() {}

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


[clang] [Clang] Verify data layout consistency (PR #144720)

2025-06-27 Thread Nikita Popov via cfe-commits

nikic wrote:

Ping :)

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


[clang] [llvm] [NFC][analyzer] Remove Z3-as-constraint-manager hacks from lit test code (PR #145731)

2025-06-27 Thread Michał Górny via cfe-commits

mgorny wrote:

No problem. I would have submitted a patch earlier but this bisect is literally 
taking all my resources.

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


[clang] [Clang][AArch64] Add mfloat8_t variants of Neon load intrinsics (PR #145666)

2025-06-27 Thread via cfe-commits


@@ -0,0 +1,825 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5

amilendra wrote:

Done. Moved tests to existing files
1. neon-intrinsics.c
2. neon-ldst-one.c

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


[clang] [llvm] [NFC][analyzer] Remove Z3-as-constraint-manager hacks from lit test code (PR #145731)

2025-06-27 Thread Donát Nagy via cfe-commits

NagyDonat wrote:

I'll be on vacation during the weekend and on Monday, so feel free to merge the 
fix without me if you have it.

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


[clang] [llvm] [NFC][analyzer] Remove Z3-as-constraint-manager hacks from lit test code (PR #145731)

2025-06-27 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy 
Message-ID:
In-Reply-To: 


steakhal wrote:

> No problem. I would have submitted a patch earlier but this bisect is 
> literally taking all my resources.

I'm pretty sure you have heard of 
[manyclangs](https://github.com/elfshaker/manyclangs). If you bisect clang 
builds, that should come handy. Saved me many hours already - and counting.

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


[clang] [llvm] [ADT] Remove a constructor (NFC) (PR #146010)

2025-06-27 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

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

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


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

```
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'LLVM :: tools/llvm-exegesis/RISCV/rvv/filter.test' 
FAILED 
Exit Code: 2

Command Output (stderr):
--
/build/buildbot/premerge-monolithic-linux/build/bin/llvm-exegesis 
-mtriple=riscv64 -mcpu=sifive-x280 -benchmark-phase=assemble-measured-code 
--mode=inverse_throughput --opcode-name=PseudoVNCLIPU_WX_M1_MASK 
--riscv-filter-config='vtype = {VXRM: rod, AVL: VLMAX, SEW: e(8|16), Policy: 
ta/mu}' --max-configs-per-opcode=1000 --min-instructions=10 | 
/build/buildbot/premerge-monolithic-linux/build/bin/FileCheck 
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/test/tools/llvm-exegesis/RISCV/rvv/filter.test
 # RUN: at line 1
+ /build/buildbot/premerge-monolithic-linux/build/bin/llvm-exegesis 
-mtriple=riscv64 -mcpu=sifive-x280 -benchmark-phase=assemble-measured-code 
--mode=inverse_throughput --opcode-name=PseudoVNCLIPU_WX_M1_MASK 
'--riscv-filter-config=vtype = {VXRM: rod, AVL: VLMAX, SEW: e(8|16), Policy: 
ta/mu}' --max-configs-per-opcode=1000 --min-instructions=10
+ /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck 
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/test/tools/llvm-exegesis/RISCV/rvv/filter.test
PseudoVNCLIPU_WX_M1_MASK: Failed to produce any snippet via: instruction has 
tied variables, avoiding Read-After-Write issue, picking random def and use 
registers not aliasing each other, for uses, one unique register for each 
position
FileCheck error: '' is empty.
FileCheck command line:  
/build/buildbot/premerge-monolithic-linux/build/bin/FileCheck 
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/test/tools/llvm-exegesis/RISCV/rvv/filter.test

--




```



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


[clang] [llvm] [NFC][analyzer] Remove Z3-as-constraint-manager hacks from lit test code (PR #145731)

2025-06-27 Thread Michał Górny via cfe-commits

mgorny wrote:

> @mgorny I'm pretty sure you have heard of 
> [manyclangs](https://github.com/elfshaker/manyclangs). If you bisect clang 
> builds, that should come handy. Saved me many hours already - and counting.

I haven't but I doubt they'll help me — this issue seems to surface only with 
our specific build of Flang somehow.

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


[clang] b76bc18 - [OpenACC][CIR] Add copy/etc clause lowering for 'data'.

2025-06-27 Thread via cfe-commits

Author: erichkeane
Date: 2025-06-27T08:51:46-07:00
New Revision: b76bc185a4f2ba68b55adffd9b66ff6c8b22b960

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

LOG: [OpenACC][CIR] Add copy/etc clause lowering for 'data'.

These work exactly the same way they do for compute constructs, so this
implements them identically and adds tests. The list of legal modifiers
is different, but that is all handled in Sema.

Added: 
clang/test/CIR/CodeGenOpenACC/data-copy-copyin-copyout-create.c

Modified: 
clang/lib/CIR/CodeGen/CIRGenOpenACCClause.cpp

Removed: 




diff  --git a/clang/lib/CIR/CodeGen/CIRGenOpenACCClause.cpp 
b/clang/lib/CIR/CodeGen/CIRGenOpenACCClause.cpp
index cce177056c6e0..1a078981a3a05 100644
--- a/clang/lib/CIR/CodeGen/CIRGenOpenACCClause.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenOpenACCClause.cpp
@@ -843,7 +843,7 @@ class OpenACCClauseCIREmitter final
 
   void VisitCopyClause(const OpenACCCopyClause &clause) {
 if constexpr (isOneOfTypes) {
+   mlir::acc::KernelsOp, mlir::acc::DataOp>) {
   for (const Expr *var : clause.getVarList())
 addDataOperand(
 var, mlir::acc::DataClause::acc_copy, clause.getModifierList(),
@@ -853,14 +853,14 @@ class OpenACCClauseCIREmitter final
   applyToComputeOp(clause);
 } else {
   // TODO: When we've implemented this for everything, switch this to an
-  // unreachable. data, declare, combined constructs remain.
+  // unreachable. declare construct remains.
   return clauseNotImplemented(clause);
 }
   }
 
   void VisitCopyInClause(const OpenACCCopyInClause &clause) {
 if constexpr (isOneOfTypes) {
+   mlir::acc::KernelsOp, mlir::acc::DataOp>) {
   for (const Expr *var : clause.getVarList())
 addDataOperand(
 var, mlir::acc::DataClause::acc_copyin, clause.getModifierList(),
@@ -870,14 +870,14 @@ class OpenACCClauseCIREmitter final
   applyToComputeOp(clause);
 } else {
   // TODO: When we've implemented this for everything, switch this to an
-  // unreachable. data, declare, combined constructs remain.
+  // unreachable. enter-data, declare constructs remain.
   return clauseNotImplemented(clause);
 }
   }
 
   void VisitCopyOutClause(const OpenACCCopyOutClause &clause) {
 if constexpr (isOneOfTypes) {
+   mlir::acc::KernelsOp, mlir::acc::DataOp>) {
   for (const Expr *var : clause.getVarList())
 addDataOperand(
 var, mlir::acc::DataClause::acc_copyout, clause.getModifierList(),
@@ -887,14 +887,14 @@ class OpenACCClauseCIREmitter final
   applyToComputeOp(clause);
 } else {
   // TODO: When we've implemented this for everything, switch this to an
-  // unreachable. data, declare, combined constructs remain.
+  // unreachable. exit data, declare constructs remain.
   return clauseNotImplemented(clause);
 }
   }
 
   void VisitCreateClause(const OpenACCCreateClause &clause) {
 if constexpr (isOneOfTypes) {
+   mlir::acc::KernelsOp, mlir::acc::DataOp>) {
   for (const Expr *var : clause.getVarList())
 addDataOperand(
 var, mlir::acc::DataClause::acc_create, clause.getModifierList(),
@@ -904,7 +904,7 @@ class OpenACCClauseCIREmitter final
   applyToComputeOp(clause);
 } else {
   // TODO: When we've implemented this for everything, switch this to an
-  // unreachable. data, declare, combined constructs remain.
+  // unreachable. enter-data, declare constructs remain.
   return clauseNotImplemented(clause);
 }
   }

diff  --git a/clang/test/CIR/CodeGenOpenACC/data-copy-copyin-copyout-create.c 
b/clang/test/CIR/CodeGenOpenACC/data-copy-copyin-copyout-create.c
new file mode 100644
index 0..7a541a8c62ea6
--- /dev/null
+++ b/clang/test/CIR/CodeGenOpenACC/data-copy-copyin-copyout-create.c
@@ -0,0 +1,190 @@
+// RUN: %clang_cc1 -fopenacc -Wno-openacc-self-if-potential-conflict -emit-cir 
-fclangir %s -o - | FileCheck %s
+
+void acc_data(int parmVar) {
+  // CHECK: cir.func{{.*}} @acc_data(%[[ARG:.*]]: !s32i{{.*}}) {
+  // CHECK-NEXT: %[[PARM:.*]] = cir.alloca !s32i, !cir.ptr, ["parmVar", 
init]
+  int localVar1;
+  // CHECK-NEXT: %[[LV1:.*]] = cir.alloca !s32i, !cir.ptr, ["localVar1"]
+  // CHECK-NEXT: cir.store %[[ARG]], %[[PARM]]
+
+#pragma acc data copy(parmVar)
+  ;
+  // CHECK-NEXT: %[[COPYIN1:.*]] = acc.copyin varPtr(%[[PARM]] : 
!cir.ptr) -> !cir.ptr {dataClause = #acc, 
name = "parmVar"}
+  // CHECK-NEXT: acc.data dataOperands(%[[COPYIN1]] : !cir.ptr) {
+  // CHECK-NEXT: acc.terminator
+  // CHECK-NEXT: } loc
+  // CHECK-NEXT: acc.copyout accPtr(%[[COPYIN1]] : !cir.ptr) to 
varPtr(%[[PARM]] : !cir.ptr) {dat

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-27 Thread Anatoly Trosinenko via cfe-commits


@@ -694,7 +705,12 @@ 
DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_arm64_jumpto)
   gcspushm x30
 Lnogcs:
 #endif
+
+#if __has_feature(ptrauth_calls)
+  retab
+#else

atrosinenko wrote:

By the way, if switching to `ptrauth_returns` here, we most probably want to 
retain compatibility with Armv8.2-a by replacing
```
#if __has_feature(ptrauth_calls)
  retab
#else
  retx30// jump to pc
#endif
```
with
```
#if __has_feature(ptrauth_returns)
  autibsp
#endif
  retx30// jump to pc
```
That is, simply insert `autibsp` into the existing code.

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


[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-27 Thread Anatoly Trosinenko via cfe-commits


@@ -681,7 +681,18 @@ 
DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_arm64_jumpto)
   // context struct, because it is allocated on the stack, and an exception
   // could clobber the de-allocated portion of the stack after sp has been
   // restored.
-  ldrx16, [x0, #0x0F8]
+
+  ldrx16, [x0, #0x0F8]  // load sp into scratch
+  ldrlr,  [x0, #0x100]  // restore pc into lr
+
+#if __has_feature(ptrauth_calls)
+  // The LR is signed with its address inside the register state.  Time
+  // to resign to be a regular ROP signed pointer
+  addx1, x0, #0x100
+  autib  lr, x1
+  pacib  lr, x16  // signed the scratch register for sp
+#endif

atrosinenko wrote:

Likewise, we should probably use `autib1716` and `pacib1716` here to retain 
compatibility with Armv8.2-a.

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


[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-27 Thread Anatoly Trosinenko via cfe-commits


@@ -129,26 +129,38 @@ struct UnwindInfoSections {
 defined(_LIBUNWIND_SUPPORT_COMPACT_UNWIND) ||  
\
 defined(_LIBUNWIND_USE_DL_ITERATE_PHDR)
   // No dso_base for SEH.
-  uintptr_t   dso_base;
+  uintptr_t
+  __LIBUNWIND_PTRAUTH_RI_PDD("UnwindInfoSections::dso_base") dso_base = 0;
 #endif
 #if defined(_LIBUNWIND_USE_DL_ITERATE_PHDR)
-  size_t  text_segment_length;
+  size_t __LIBUNWIND_PTRAUTH_RI_PDD("UnwindInfoSections::text_segment_length")
+  text_segment_length = 0;
 #endif
 #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
-  uintptr_t   dwarf_section;
-  size_t  dwarf_section_length;
+  uintptr_t __LIBUNWIND_PTRAUTH_RI_PDD("UnwindInfoSections::dwarf_section")
+  dwarf_section = 0;
+  size_t __LIBUNWIND_PTRAUTH_RI_PDD("UnwindInfoSections::dwarf_section_length")
+  dwarf_section_length = 0;
 #endif
 #if defined(_LIBUNWIND_SUPPORT_DWARF_INDEX)
-  uintptr_t   dwarf_index_section;
-  size_t  dwarf_index_section_length;
+  uintptr_t __LIBUNWIND_PTRAUTH_RI_PDD(
+  "UnwindInfoSections::dwarf_index_section") dwarf_index_section = 0;
+  size_t __LIBUNWIND_PTRAUTH_RI_PDD(
+  "UnwindInfoSections::dwarf_index_section_length")
+  dwarf_index_section_length = 0;
 #endif
 #if defined(_LIBUNWIND_SUPPORT_COMPACT_UNWIND)
-  uintptr_t   compact_unwind_section;
-  size_t  compact_unwind_section_length;
+  uintptr_t __LIBUNWIND_PTRAUTH_RI_PDD(
+  "UnwindInfoSections::compact_unwind_section") compact_unwind_section = 0;
+  size_t __LIBUNWIND_PTRAUTH_RI_PDD(
+  "UnwindInfoSections::compact_unwind_section_length")
+  compact_unwind_section_length = 0;
 #endif
 #if defined(_LIBUNWIND_ARM_EHABI)
-  uintptr_t   arm_section;
-  size_t  arm_section_length;
+  uintptr_t __LIBUNWIND_PTRAUTH_RI_PDD("UnwindInfoSections::arm_section")
+  arm_section = 0;
+  size_t __LIBUNWIND_PTRAUTH_RI_PDD("UnwindInfoSections::arm_section_length")
+  arm_section_length = 0;

atrosinenko wrote:

These two fields doesn't seem to be used on AArch64.

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


[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-27 Thread Anatoly Trosinenko via cfe-commits


@@ -807,7 +812,12 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
   strd31, [x0, #0x208]
 #endif
   movx0, #0   // return UNW_ESUCCESS
+
+#if __has_feature(ptrauth_calls)
+  retab
+#else

atrosinenko wrote:

Same comment here (`autibsp` + `ret` instead of `retab`).

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


  1   2   3   4   5   >