[clang] [CIR] Upstream DynamicCastOp (PR #161734)

2025-10-17 Thread Henrich Lauko via cfe-commits


@@ -232,6 +232,100 @@ def CIR_CastOp : CIR_Op<"cast", [
   }];
 }
 
+//===--===//
+// DynamicCastOp
+//===--===//
+
+def CIR_DynamicCastKind : CIR_I32EnumAttr<
+  "DynamicCastKind", "dynamic cast kind", [
+I32EnumAttrCase<"Ptr", 0, "ptr">,
+I32EnumAttrCase<"Ref", 1, "ref">
+]>;
+
+def CIR_DynamicCastOp : CIR_Op<"dyn_cast"> {
+  let summary = "Perform dynamic cast on record pointers";
+  let description = [{
+The `cir.dyn_cast` operation models part of the semantics of the
+`dynamic_cast` operator in C++. It can be used to perform 3 kinds of casts
+on record pointers:
+
+- Down-cast, which casts a base class pointer to a derived class pointer;
+- Side-cast, which casts a class pointer to a sibling class pointer;
+- Cast-to-complete, which casts a class pointer to a void pointer.
+
+The input of the operation must be a record pointer. The result of the
+operation is either a record pointer or a void pointer.
+
+The parameter `kind` specifies the semantics of this operation. If its 
value
+is `ptr`, then the operation models dynamic casts on pointers. Otherwise, 
if
+its value is `ref`, the operation models dynamic casts on references.
+Specifically:
+
+- When the input pointer is a null pointer value:
+  - If `kind` is `ref`, the operation will invoke undefined behavior. A
+sanitizer check will be emitted if sanitizer is on.
+  - Otherwise, the operation will return a null pointer value as its 
result.
+- When the runtime type check fails:
+  - If `kind` is `ref`, the operation will throw a `bad_cast` exception.
+  - Otherwise, the operation will return a null pointer value as its 
result.
+
+The `info` argument gives detailed information about the requested dynamic
+cast operation. It is an optional `#cir.dyn_cast_info` attribute that is
+only present when the operation models a down-cast or a side-cast.
+
+The `relative_layout` argument specifies whether the Itanium C++ ABI vtable
+uses relative layout. It is only meaningful when the operation models a
+cast-to-complete operation.
+
+Examples:
+
+```mlir
+%0 = cir.dyn_cast ptr %p : !cir.ptr -> !cir.ptr
+%1 = cir.dyn_cast ptr relative_layout %p : !cir.ptr
+  -> !cir.ptr
+%2 = cir.dyn_cast ref %r : !cir.ptr -> !cir.ptr
+  #cir.dyn_cast_info<
+#cir.global_view<@_ZTI4Base> : !cir.ptr,
+#cir.global_view<@_ZTI7Derived> : !cir.ptr,
+@__dynamic_cast,
+@__cxa_bad_cast,
+#cir.int<0> : !s64i
+  >
+```
+  }];
+
+  let arguments = (ins
+CIR_DynamicCastKind:$kind,
+CIR_PtrToRecordType:$src,
+OptionalAttr:$info,
+UnitAttr:$relative_layout
+  );
+
+  let results = (outs
+CIR_PtrToAnyOf<[CIR_VoidType, CIR_RecordType]>:$result
+  );
+
+  let assemblyFormat = [{
+$kind (`relative_layout` $relative_layout^)? $src
+`:` qualified(type($src)) `->` qualified(type($result))
+(qualified($info)^)? attr-dict
+  }];
+
+  let extraClassDeclaration = [{
+/// Determine whether this operation models reference casting in C++.
+bool isRefcast() {

xlauko wrote:

```suggestion
bool isRefCast() {
```

https://github.com/llvm/llvm-project/pull/161734
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HIP][SPIRV] Create an intermediate file for the llvm-link output (PR #162096)

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

https://github.com/jmmartinez edited 
https://github.com/llvm/llvm-project/pull/162096
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] Remove Zicntr from sifive-p450/p470/p670. (PR #161444)

2025-10-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Craig Topper (topperc)


Changes

These cores don't implement the `time` CSR. They require SBI to trap and 
emulate it which is allowed by RVA20U.

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


2 Files Affected:

- (modified) clang/test/Driver/riscv-cpus.c (-3) 
- (modified) llvm/lib/Target/RISCV/RISCVProcessors.td (+72-9) 


``diff
diff --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index cd92adc64a7d6..5d5fdd72baedb 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -462,7 +462,6 @@
 // MCPU-SIFIVE-P450-SAME: "-target-feature" "+ziccif"
 // MCPU-SIFIVE-P450-SAME: "-target-feature" "+zicclsm"
 // MCPU-SIFIVE-P450-SAME: "-target-feature" "+ziccrse"
-// MCPU-SIFIVE-P450-SAME: "-target-feature" "+zicntr"
 // MCPU-SIFIVE-P450-SAME: "-target-feature" "+zicsr"
 // MCPU-SIFIVE-P450-SAME: "-target-feature" "+zifencei"
 // MCPU-SIFIVE-P450-SAME: "-target-feature" "+zihintntl"
@@ -492,7 +491,6 @@
 // MCPU-SIFIVE-P470-SAME: "-target-feature" "+ziccif"
 // MCPU-SIFIVE-P470-SAME: "-target-feature" "+zicclsm"
 // MCPU-SIFIVE-P470-SAME: "-target-feature" "+ziccrse"
-// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zicntr"
 // MCPU-SIFIVE-P470-SAME: "-target-feature" "+zicsr"
 // MCPU-SIFIVE-P470-SAME: "-target-feature" "+zifencei"
 // MCPU-SIFIVE-P470-SAME: "-target-feature" "+zihintntl"
@@ -555,7 +553,6 @@
 // MCPU-SIFIVE-P670-SAME: "-target-feature" "+ziccif"
 // MCPU-SIFIVE-P670-SAME: "-target-feature" "+zicclsm"
 // MCPU-SIFIVE-P670-SAME: "-target-feature" "+ziccrse"
-// MCPU-SIFIVE-P670-SAME: "-target-feature" "+zicntr"
 // MCPU-SIFIVE-P670-SAME: "-target-feature" "+zicsr"
 // MCPU-SIFIVE-P670-SAME: "-target-feature" "+zifencei"
 // MCPU-SIFIVE-P670-SAME: "-target-feature" "+zihintntl"
diff --git a/llvm/lib/Target/RISCV/RISCVProcessors.td 
b/llvm/lib/Target/RISCV/RISCVProcessors.td
index 95f8a8789fa6c..17a794867be9e 100644
--- a/llvm/lib/Target/RISCV/RISCVProcessors.td
+++ b/llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -347,16 +347,58 @@ defvar SiFiveP400TuneFeatures = [TuneNoDefaultUnroll,
  TunePostRAScheduler];
 
 def SIFIVE_P450 : RISCVProcessorModel<"sifive-p450", SiFiveP400Model,
-  !listconcat(RVA22U64Features,
-  [FeatureStdExtZifencei,
+  [Feature64Bit,
+   FeatureStdExtI,
+   FeatureStdExtM,
+   FeatureStdExtA,
+   FeatureStdExtF,
+   FeatureStdExtD,
+   FeatureStdExtC,
+   FeatureStdExtZicsr,
+   FeatureStdExtZiccif,
+   FeatureStdExtZiccrse,
+   FeatureStdExtZiccamoa,
+   FeatureStdExtZicclsm,
+   FeatureStdExtZa64rs,
+   FeatureStdExtZihpm,
+   FeatureStdExtZihintpause,
+   FeatureStdExtB,
+   FeatureStdExtZic64b,
+   FeatureStdExtZicbom,
+   FeatureStdExtZicbop,
+   FeatureStdExtZicboz,
+   FeatureStdExtZfhmin,
+   FeatureStdExtZkt,
+   FeatureStdExtZifencei,
FeatureStdExtZihintntl,
FeatureUnalignedScalarMem,
-   FeatureUnalignedVectorMem]),
+   FeatureUnalignedVectorMem],
   SiFiveP400TuneFeatures>;
 
 def SIFIVE_P470 : RISCVProcessorModel<"sifive-p470", SiFiveP400Model,
-  !listconcat(RVA22U64Features,
-  [FeatureStdExtV,
+  [Feature64Bit,
+   FeatureStdExtI,
+   FeatureStdExtM,
+   FeatureStdExtA,
+   FeatureStdExtF,
+   FeatureStdExtD,
+   FeatureStdExtC,
+   FeatureStdExtZicsr,
+   FeatureStdExtZiccif,
+   FeatureStdExtZiccrse,
+   FeatureStdExtZiccamoa,
+ 

[clang] [HLSL][NFC] Refactor structured buffer methods tests (PR #161908)

2025-10-17 Thread Justin Bogner via cfe-commits

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

Looks generally good. One comment about check prefixes you can take or leave.

https://github.com/llvm/llvm-project/pull/161908
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][OpenMP] Support for reduction clause with array elements as modifier (PR #160846)

2025-10-17 Thread via cfe-commits

https://github.com/SunilKuravinakop updated 
https://github.com/llvm/llvm-project/pull/160846

>From 5e43cb51154479109e6596d83764e3b47183bd16 Mon Sep 17 00:00:00 2001
From: Sunil Kuravinakop 
Date: Fri, 26 Sep 2025 03:25:57 -0500
Subject: [PATCH 1/3] Changes for array elements in reduction e.g. "reduction
 (+:a[1])"

modified:   clang/lib/Sema/SemaOpenMP.cpp
---
 clang/lib/Sema/SemaOpenMP.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 63a56a6583efc..5a40603ecf320 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -2419,8 +2419,10 @@ VarDecl *SemaOpenMP::isOpenMPCapturedDecl(ValueDecl *D, 
bool CheckScopeInfo,
   return VD ? VD : Info.second;
 DSAStackTy::DSAVarData DVarTop =
 DSAStack->getTopDSA(D, DSAStack->isClauseParsingMode());
+
 if (DVarTop.CKind != OMPC_unknown && isOpenMPPrivate(DVarTop.CKind) &&
-(!VD || VD->hasLocalStorage() || !DVarTop.AppliedToPointee))
+(!VD || VD->hasLocalStorage() ||
+ !(DVarTop.AppliedToPointee && DVarTop.CKind != OMPC_reduction)))
   return VD ? VD : cast(DVarTop.PrivateCopy->getDecl());
 // Threadprivate variables must not be captured.
 if (isOpenMPThreadPrivate(DVarTop.CKind))

>From 129199109efedd8c7ebfc2d94a8232f55a82dfe2 Mon Sep 17 00:00:00 2001
From: Sunil Kuravinakop 
Date: Mon, 29 Sep 2025 04:11:23 -0500
Subject: [PATCH 2/3] lit test case changes for :   "Changes for array elements
 in reduction e.g. 'reduction (+:a[1])' "

---
 clang/test/OpenMP/for_reduction_codegen.cpp | 33 -
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/clang/test/OpenMP/for_reduction_codegen.cpp 
b/clang/test/OpenMP/for_reduction_codegen.cpp
index 83632db238484..698baa4a45823 100644
--- a/clang/test/OpenMP/for_reduction_codegen.cpp
+++ b/clang/test/OpenMP/for_reduction_codegen.cpp
@@ -27,7 +27,6 @@ struct S {
   ~S() {}
 };
 
-
 template 
 T tmain() {
   T t;
@@ -60,6 +59,15 @@ T tmain() {
 }
 
 extern S **foo();
+int g_arr[10];
+
+void reductionArrayElement() {
+#pragma omp parallel
+#pragma omp for reduction(+:g_arr[1])
+  for (int i = 0; i < 10; i++) {
+g_arr[1] += i;
+  }
+}
 
 int main() {
 #ifdef LAMBDA
@@ -164,6 +172,7 @@ int main() {
 #pragma omp for reduction(& : var3)
   for (int i = 0; i < 10; ++i)
 ;
+  reductionArrayElement();
   return tmain();
 #endif
 }
@@ -527,6 +536,7 @@ int main() {
 
 
 #endif
+
 //.
 // CHECK1: @.gomp_critical_user_.reduction.var = common global [8 x i32] 
zeroinitializer, align 8
 // CHECK1: @.gomp_critical_user_.atomic_reduction.var = common global [8 x 
i32] zeroinitializer, align 8
@@ -535,6 +545,26 @@ int main() {
 //.
 // CHECK4: @.gomp_critical_user_.reduction.var = common global [8 x i32] 
zeroinitializer, align 8
 //.
+
+// CHECK1-LABEL: define {{.*}}reductionArrayElement{{.*}}.omp_outlined{{.*}}
+// CHECK1-NEXT:  entry:
+// CHECK1-NEXT:[[DOTGLOBAL_TID__ADDR:%.*]] = alloca ptr, align 8
+// CHECK1: [[G_ARR:%.*]] = alloca i32, align 4
+// CHECK1: [[TMP0:%.*]] = sdiv exact i64 sub (i64 ptrtoint (ptr @g_arr 
to i64){{.*}}
+// CHECK1-NEXT:[[TMP1:%.*]] = getelementptr i32, ptr [[G_ARR:%.*]], i64 
[[TMP0]]
+// CHECK1:   omp.inner.for.body:
+// CHECK1: [[ARRAYIDX:%.*]] = getelementptr inbounds [10 x i32], ptr 
[[TMP1]], i64 0, i64 1
+// CHECK1-NEXT:[[TMP11:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
+// CHECK1-NEXT:[[ADD2:%.*]] = add nsw i32 [[TMP11]],{{.+}}
+// CHECK1-NEXT:store i32 [[ADD2]], ptr [[ARRAYIDX]], align 4
+// CHECK1:   omp.loop.exit:
+// CHECK1-NEXT:call void {{.*}}__kmpc_for_static_fini{{.+}}
+// CHECK1: {{.*}}call i32 {{.*}}__kmpc_reduce{{.+}}
+// CHECK1:   omp.reduction.default:
+// CHECK1-NEXT:call void @__kmpc_barrier{{.+}}
+// CHECK1-NEXT:ret void
+//
+
 // CHECK1-LABEL: define {{[^@]+}}@main
 // CHECK1-SAME: () #[[ATTR0:[0-9]+]] {
 // CHECK1-NEXT:  entry:
@@ -614,6 +644,7 @@ int main() {
 // CHECK1-NEXT:call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr 
@[[GLOB3]], i32 1, ptr @main.omp_outlined.11, ptr [[TMP7]])
 // CHECK1-NEXT:[[TMP8:%.*]] = load ptr, ptr [[VAR3]], align 8
 // CHECK1-NEXT:call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr 
@[[GLOB3]], i32 1, ptr @main.omp_outlined.12, ptr [[TMP8]])
+// CHECK1-NEXT:call void {{.*}}reductionArrayElement{{.*}}
 // CHECK1-NEXT:[[CALL10:%.*]] = call noundef i32 @_Z5tmainIiLi42EET_v()
 // CHECK1-NEXT:store i32 [[CALL10]], ptr [[RETVAL]], align 4
 // CHECK1-NEXT:[[TMP9:%.*]] = load ptr, ptr [[SAVED_STACK]], align 8

>From da0e5e470784d80081b72a7000e48e8d7e36be0a Mon Sep 17 00:00:00 2001
From: Sunil Kuravinakop 
Date: Mon, 29 Sep 2025 04:20:45 -0500
Subject: [PATCH 3/3] Removing extra empty lines.

---
 clang/lib/Sema/SemaOpenMP.cpp   | 1 -
 clang/test/OpenMP/for_reduction_codegen.cpp | 1 -
 2 files changed, 2 deletions(-)

diff --git a/cla

[clang] [C23] Implement WG14 N3037 (PR #132939)

2025-10-17 Thread Volodymyr Sapsai via cfe-commits


@@ -450,6 +453,41 @@ class StmtComparer {
 };
 } // namespace
 
+static bool
+CheckStructurallyEquivalentAttributes(StructuralEquivalenceContext &Context,
+  const Decl *D1, const Decl *D2,
+  const Decl *PrimaryDecl = nullptr) {
+  // If either declaration has an attribute on it, we treat the declarations
+  // as not being structurally equivalent.
+  // FIXME: this should be handled on a case-by-case basis via tablegen in
+  // Attr.td. There are multiple cases to consider: one declation with the
+  // attribute, another without it; different attribute syntax|spellings for
+  // the same semantic attribute, differences in attribute arguments, order
+  // in which attributes are applied, how to merge attributes if the types are
+  // structurally equivalent, etc.
+  const Attr *D1Attr = nullptr, *D2Attr = nullptr;
+  if (D1->hasAttrs())
+D1Attr = *D1->getAttrs().begin();
+  if (D2->hasAttrs())
+D2Attr = *D2->getAttrs().begin();
+  if (D1Attr || D2Attr) {
+const auto *DiagnoseDecl = cast(PrimaryDecl ? PrimaryDecl : D2);

vsapsai wrote:

As promised, a separate issue https://github.com/llvm/llvm-project/pull/162933

https://github.com/llvm/llvm-project/pull/132939
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy][NFC] Enable 'readability-simplify-boolean-expr' check (PR #158706)

2025-10-17 Thread Davide Cunial via cfe-commits

capitan-davide wrote:

> You have to build llvm with assertions enabled/in debug mode for that to 
> happen (most LLVM docs will use Release by default since debug is a large 
> build).

What I mean is that currently, no assertion expression is getting refactored as 
it's probably not too complex 

https://github.com/llvm/llvm-project/pull/158706
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Basic] Add helper APIs to get language version codes from LangOptions (PR #163348)

2025-10-17 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `sanitizer-ppc64le-linux` 
running on `ppc64le-sanitizer` while building `clang` at step 2 "annotate".

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


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

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
llvm-lit: 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/llvm/utils/lit/lit/discovery.py:276:
 warning: input 
'/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/compiler_rt_build/test/sanitizer_common/Unit'
 contained no tests
llvm-lit: 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60:
 warning: Path reported by clang does not exist: 
"/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/compiler_rt_build/lib/powerpc64le-unknown-linux-gnu".
 This path was found by running 
['/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/bin/clang',
 '--target=powerpc64le-unknown-linux-gnu', '-m64', '-fno-function-sections', 
'-nobuiltininc', 
'-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/include',
 '-idirafter', 
'/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/lib/clang/22/include',
 
'-resource-dir=/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/compiler_rt_build',
 
'-Wl,-rpath,/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/compiler_rt_build/lib/linux',
 '-print-runtime-dir'].
llvm-lit: 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60:
 warning: Path reported by clang does not exist: 
"/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/compiler_rt_build/lib/powerpc64le-unknown-linux-gnu".
 This path was found by running 
['/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/bin/clang',
 '--target=powerpc64le-unknown-linux-gnu', '-m64', '-fno-function-sections', 
'-nobuiltininc', 
'-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/include',
 '-idirafter', 
'/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/lib/clang/22/include',
 
'-resource-dir=/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/compiler_rt_build',
 
'-Wl,-rpath,/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/compiler_rt_build/lib/linux',
 '-print-runtime-dir'].
llvm-lit: 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60:
 warning: Path reported by clang does not exist: 
"/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/compiler_rt_build/lib/powerpc64le-unknown-linux-gnu".
 This path was found by running 
['/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/bin/clang',
 '--target=powerpc64le-unknown-linux-gnu', '-m64', '-fno-function-sections', 
'-nobuiltininc', 
'-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/include',
 '-idirafter', 
'/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/lib/clang/22/include',
 
'-resource-dir=/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/compiler_rt_build',
 
'-Wl,-rpath,/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/compiler_rt_build/lib/linux',
 '-print-runtime-dir'].
llvm-lit: 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60:
 warning: Path reported by clang does not exist: 
"/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/compiler_rt_build/lib/powerpc64le-unknown-linux-gnu".
 This path was found by running 
['/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/bin/clang',
 '--target=powerpc64le-unknown-linux-gnu', '-m64', '-fno-function-sections', 
'-nobuiltininc', 
'-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/include',
 '-idirafter', 
'/home/b

[clang] [llvm] workflows/release-binaries: Enable Windows x86 builds (PR #128274)

2025-10-17 Thread Tom Stellard via cfe-commits

https://github.com/tstellar updated 
https://github.com/llvm/llvm-project/pull/128274

>From 2110f92892dd72dfbe1a7d87116faa3693c7c586 Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Sat, 22 Feb 2025 03:08:24 +
Subject: [PATCH 01/36] workflows/release-binaries: Enable Windows x86 builds

---
 .github/workflows/release-binaries-all.yml |  1 +
 .github/workflows/release-binaries.yml | 17 +++--
 clang/cmake/caches/Release.cmake   |  5 -
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/.github/workflows/release-binaries-all.yml 
b/.github/workflows/release-binaries-all.yml
index 0b52a08202f1a..4e67b44ccbad3 100644
--- a/.github/workflows/release-binaries-all.yml
+++ b/.github/workflows/release-binaries-all.yml
@@ -92,6 +92,7 @@ jobs:
   - ubuntu-22.04-arm
   - macos-13
   - macos-14
+  - windows-2019
 
 uses: ./.github/workflows/release-binaries.yml
 with:
diff --git a/.github/workflows/release-binaries.yml 
b/.github/workflows/release-binaries.yml
index c113b42dc8ed4..2854fd36e31aa 100644
--- a/.github/workflows/release-binaries.yml
+++ b/.github/workflows/release-binaries.yml
@@ -118,9 +118,15 @@ jobs:
 echo "ref=$ref" >> $GITHUB_OUTPUT
 echo "upload=$upload" >> $GITHUB_OUTPUT
 
+if [ "$RUNNER_OS" = "Windows" ]; then
+  release_binary_suffix="exe"
+else
+  release_binary_suffix="tar.xz"
+fi
+
 release_binary_basename="LLVM-$release_version-$RUNNER_OS-$RUNNER_ARCH"
 echo "release-binary-basename=$release_binary_basename" >> 
$GITHUB_OUTPUT
-echo "release-binary-filename=$release_binary_basename.tar.xz" >> 
$GITHUB_OUTPUT
+echo 
"release-binary-filename=$release_binary_basename.$release_binary_suffix" >> 
$GITHUB_OUTPUT
 
 target="$RUNNER_OS-$RUNNER_ARCH"
 # The hendrikmuhs/ccache-action action does not support installing 
sccache
@@ -151,11 +157,6 @@ jobs:
 
 build_flang="true"
 
-if [ "$RUNNER_OS" = "Windows" ]; then
-  # The build times out on Windows, so we need to disable LTO.
-  target_cmake_flags="$target_cmake_flags 
-DLLVM_RELEASE_ENABLE_LTO=OFF"
-fi
-
 echo "target-cmake-flags=$target_cmake_flags" >> $GITHUB_OUTPUT
 echo "build-flang=$build_flang" >> $GITHUB_OUTPUT
 case "${{ inputs.runs-on }}" in
@@ -179,6 +180,10 @@ jobs:
 fi
 test_runs_on="${{ inputs.runs-on }}"
 ;;
+  windows-2019)
+build_runs_on="llvm-premerge-windows-runners"
+test_runs_on="$build_runs_on"
+;;
   *)
 test_runs_on="${{ inputs.runs-on }}"
 build_runs_on=$test_runs_on
diff --git a/clang/cmake/caches/Release.cmake b/clang/cmake/caches/Release.cmake
index fb12dfcdcb5a5..595552985b788 100644
--- a/clang/cmake/caches/Release.cmake
+++ b/clang/cmake/caches/Release.cmake
@@ -140,7 +140,10 @@ set_final_stage_var(LLVM_ENABLE_PROJECTS 
"${LLVM_RELEASE_ENABLE_PROJECTS}" STRIN
 if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux")
   set_final_stage_var(CLANG_BOLT "INSTRUMENT" STRING)
 endif()
-set_final_stage_var(CPACK_GENERATOR "TXZ" STRING)
++# We want to generate an installer on Windows.
+if(NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Windows")
+  set_final_stage_var(CPACK_GENERATOR "TXZ" STRING)
+endif()
 set_final_stage_var(CPACK_ARCHIVE_THREADS "0" STRING)
 
 set_final_stage_var(LLVM_USE_STATIC_ZSTD "ON" BOOL)

>From a0313b17419ef01b13d236852a8b242b8680a603 Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Mon, 24 Feb 2025 18:17:47 +
Subject: [PATCH 02/36] Fix typo

---
 clang/cmake/caches/Release.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/cmake/caches/Release.cmake b/clang/cmake/caches/Release.cmake
index 595552985b788..cd84df263cf1b 100644
--- a/clang/cmake/caches/Release.cmake
+++ b/clang/cmake/caches/Release.cmake
@@ -140,7 +140,7 @@ set_final_stage_var(LLVM_ENABLE_PROJECTS 
"${LLVM_RELEASE_ENABLE_PROJECTS}" STRIN
 if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux")
   set_final_stage_var(CLANG_BOLT "INSTRUMENT" STRING)
 endif()
-+# We want to generate an installer on Windows.
+# We want to generate an installer on Windows.
 if(NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Windows")
   set_final_stage_var(CPACK_GENERATOR "TXZ" STRING)
 endif()

>From 434b4f8d567c0df39032a99d1c9281fc7a337f89 Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Mon, 24 Feb 2025 18:37:28 +
Subject: [PATCH 03/36] Disable unsupported runtimes

---
 clang/cmake/caches/Release.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/cmake/caches/Release.cmake b/clang/cmake/caches/Release.cmake
index cd84df263cf1b..a2b9853b5c7e8 100644
--- a/clang/cmake/caches/Release.cmake
+++ b/clang/cmake/caches/Release.cmake
@@ -56,7 +56,7 @@ set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
 set(STAGE1_PROJECTS "clang")
 
 # Build all runtimes so we can statically l

[clang] [clang][DebugInfo] Re-enable VTable debug info on COFF platforms (PR #158450)

2025-10-17 Thread Martin Storsjö via cfe-commits

https://github.com/mstorsjo closed 
https://github.com/llvm/llvm-project/pull/158450
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [AIX] Implement the ifunc attribute. (PR #153049)

2025-10-17 Thread Wael Yehia via cfe-commits


@@ -2391,7 +2391,8 @@ MCSymbol *
 TargetLoweringObjectFileXCOFF::getTargetSymbol(const GlobalValue *GV,
const TargetMachine &TM) const {
   // We always use a qualname symbol for a GV that represents
-  // a declaration, a function descriptor, or a common symbol.
+  // a declaration, a function descriptor, or a common symbol. An IFunc is
+  // lowered as a function, so it has an entry point and a descriptor.

w2yehia wrote:

done

https://github.com/llvm/llvm-project/pull/153049
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC][clang] Quote literal builtin attribute markers in Builtins.def docs (PR #160080)

2025-10-17 Thread Erich Keane via cfe-commits
Radovan =?utf-8?q?Božić?= ,
Radovan =?utf-8?q?Božić?= ,
Radovan =?utf-8?q?Božić?= 
Message-ID:
In-Reply-To: 


https://github.com/erichkeane closed 
https://github.com/llvm/llvm-project/pull/160080
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][docs] Remove Python2 import handler in dump_ast_matchers.py (PR #163730)

2025-10-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: David Spickett (DavidSpickett)


Changes

LLVM requires Python >=3.8 and in Python 3.0 urllib2 was renamed to urllib.

https://docs.python.org/3/whatsnew/3.0.html#library-changes

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


1 Files Affected:

- (modified) clang/docs/tools/dump_ast_matchers.py (+1-4) 


``diff
diff --git a/clang/docs/tools/dump_ast_matchers.py 
b/clang/docs/tools/dump_ast_matchers.py
index 46b7bb718ba08..5db6826070934 100755
--- a/clang/docs/tools/dump_ast_matchers.py
+++ b/clang/docs/tools/dump_ast_matchers.py
@@ -6,11 +6,8 @@
 import collections
 import re
 import os
+from urllib.request import urlopen
 
-try:
-from urllib.request import urlopen
-except ImportError:
-from urllib2 import urlopen
 
 CLASS_INDEX_PAGE_URL = "https://clang.llvm.org/doxygen/classes.html";
 try:

``




https://github.com/llvm/llvm-project/pull/163730
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [clang][libc++] Fix spelling of "synthesize" (PR #158523)

2025-10-17 Thread Corentin Jabot via cfe-commits

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


https://github.com/llvm/llvm-project/pull/158523
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Headers][X86] Enable constexpr handling for MMX/SSE/AVX/AVX512 PMADDWD/PMADDUBSW intrinsics (PR #161563)

2025-10-17 Thread Bhasawut Singhaphan via cfe-commits

https://github.com/markbhasawut ready_for_review 
https://github.com/llvm/llvm-project/pull/161563
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [LifetimeSafety] Refactor the analysis into smaller files (PR #162474)

2025-10-17 Thread Utkarsh Saxena via cfe-commits

https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/162474
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [OpenACC][CIR] Implement 'reduction' combiner lowering for 5 ops (PR #162906)

2025-10-17 Thread Andy Kaylor via cfe-commits


@@ -527,16 +527,140 @@ void 
OpenACCRecipeBuilderBase::createFirstprivateRecipeCopy(
 // doesn't restore it aftewards.
 void OpenACCRecipeBuilderBase::createReductionRecipeCombiner(
 mlir::Location loc, mlir::Location locEnd, mlir::Value mainOp,
-mlir::acc::ReductionRecipeOp recipe, size_t numBounds) {
+mlir::acc::ReductionRecipeOp recipe, size_t numBounds, QualType origType,
+llvm::ArrayRef combinerRecipes) {
   mlir::Block *block =
   createRecipeBlock(recipe.getCombinerRegion(), mainOp.getType(), loc,
 numBounds, /*isInit=*/false);
   builder.setInsertionPointToEnd(&recipe.getCombinerRegion().back());
   CIRGenFunction::LexicalScope ls(cgf, loc, block);
 
-  mlir::BlockArgument lhsArg = block->getArgument(0);
+  mlir::Value lhsArg = block->getArgument(0);
+  mlir::Value rhsArg = block->getArgument(1);
+  llvm::MutableArrayRef boundsRange =
+  block->getArguments().drop_front(2);
+
+  if (llvm::any_of(combinerRecipes, [](auto &r) { return r.Op == nullptr; })) {
+cgf.cgm.errorNYI(loc, "OpenACC Reduction combiner not generated");
+mlir::acc::YieldOp::create(builder, locEnd, block->getArgument(0));
+return;
+  }
+
+  // apply the bounds so that we can get our bounds emitted correctly.
+  for (mlir::BlockArgument boundArg : llvm::reverse(boundsRange))
+std::tie(lhsArg, rhsArg) =
+createBoundsLoop(lhsArg, rhsArg, boundArg, loc, /*inverse=*/false);
+
+  // Emitter for when we know this isn't a struct or array we have to loop
+  // through. This should work for the 'field' once the get-element call has
+  // been made.
+  auto emitSingleCombiner =
+  [&](mlir::Value lhsArg, mlir::Value rhsArg,
+  const OpenACCReductionRecipe::CombinerRecipe &combiner) {
+mlir::Type elementTy =
+mlir::cast(lhsArg.getType()).getPointee();
+CIRGenFunction::DeclMapRevertingRAII declMapRAIILhs{cgf, combiner.LHS};
+cgf.setAddrOfLocalVar(
+combiner.LHS, Address{lhsArg, elementTy,
+  
cgf.getContext().getDeclAlign(combiner.LHS)});
+CIRGenFunction::DeclMapRevertingRAII declMapRAIIRhs{cgf, combiner.RHS};
+cgf.setAddrOfLocalVar(
+combiner.RHS, Address{rhsArg, elementTy,
+  
cgf.getContext().getDeclAlign(combiner.RHS)});
+
+[[maybe_unused]] mlir::LogicalResult stmtRes =
+cgf.emitStmt(combiner.Op, /*useCurrentScope=*/true);
+  };
+
+  // Emitter for when we know this is either a non-array or element of an array
+  // (which also shouldn't be an array type?). This function should generate 
the
+  // loop to do this on each individual array or struct element (if necessary).

andykaylor wrote:

I don't understand the comment. If we know this is a non-array, what does the 
part about a loop to do this on each individual array element mean?

https://github.com/llvm/llvm-project/pull/162906
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [AllocToken, Clang] Implement __builtin_infer_alloc_token() and llvm.alloc.token.id (PR #156842)

2025-10-17 Thread Marco Elver via cfe-commits

melver wrote:

I'll take another stab at this one now, and see if I can make it constexpr, 
too. From what I understood that was the biggest issue. One problem is that I'm 
trying to figure out a sane way to share the token ID generation logic, which 
depends on the way AllocTokenPass was instantiated as well, without actually 
instantiating that pass.

https://github.com/llvm/llvm-project/pull/156842
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Annotate ::operator and Foo::operator correctly (PR #164048)

2025-10-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: owenca (owenca)


Changes

This effectively reverts commit b5f6689dc93216f9272e790e787548cf29250566 and 
fixes #111011 more narrowly.

Fixes #160513

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


2 Files Affected:

- (modified) clang/lib/Format/TokenAnnotator.cpp (+3-7) 
- (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+5) 


``diff
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 5b784eded4601..ffbd3839e8eb7 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3794,18 +3794,12 @@ static bool isFunctionDeclarationName(const LangOptions 
&LangOpts,
   if (Current.is(TT_FunctionDeclarationName))
 return true;
 
-  if (!Current.Tok.getIdentifierInfo())
+  if (Current.isNoneOf(tok::identifier, tok::kw_operator))
 return false;
 
   const auto *Prev = Current.getPreviousNonComment();
   assert(Prev);
 
-  if (Prev->is(tok::coloncolon))
-Prev = Prev->Previous;
-
-  if (!Prev)
-return false;
-
   const auto &Previous = *Prev;
 
   if (const auto *PrevPrev = Previous.getPreviousNonComment();
@@ -3854,6 +3848,8 @@ static bool isFunctionDeclarationName(const LangOptions 
&LangOpts,
 
   // Find parentheses of parameter list.
   if (Current.is(tok::kw_operator)) {
+if (Line.startsWith(tok::kw_friend))
+  return true;
 if (Previous.Tok.getIdentifierInfo() &&
 Previous.isNoneOf(tok::kw_return, tok::kw_co_return)) {
   return true;
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 1152466b0179f..100251514a4bd 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -1129,6 +1129,11 @@ TEST_F(TokenAnnotatorTest, 
UnderstandsOverloadedOperators) {
   ASSERT_EQ(Tokens.size(), 7u) << Tokens;
   // Not TT_FunctionDeclarationName.
   EXPECT_TOKEN(Tokens[3], tok::kw_operator, TT_Unknown);
+
+  Tokens = annotate("SomeAPI::operator()();");
+  ASSERT_EQ(Tokens.size(), 9u) << Tokens;
+  // Not TT_FunctionDeclarationName.
+  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_Unknown);
 }
 
 TEST_F(TokenAnnotatorTest, OverloadedOperatorInTemplate) {

``




https://github.com/llvm/llvm-project/pull/164048
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Annotate ::operator and Foo::operator correctly (PR #164048)

2025-10-17 Thread via cfe-commits

https://github.com/owenca created 
https://github.com/llvm/llvm-project/pull/164048

This effectively reverts commit b5f6689dc93216f9272e790e787548cf29250566 and 
fixes #111011 more narrowly.

Fixes #160513

>From 5984b4c97fd8e1aed0d37c042f8218adb780e809 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Fri, 17 Oct 2025 20:50:48 -0700
Subject: [PATCH] [clang-format] Annotate ::operator and Foo::operator
 correctly

This effectively reverts commit b5f6689dc93216f9272e790e787548cf29250566 and
fixes #111011 more narrowly.

Fixes #160513
---
 clang/lib/Format/TokenAnnotator.cpp   | 10 +++---
 clang/unittests/Format/TokenAnnotatorTest.cpp |  5 +
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 5b784eded4601..ffbd3839e8eb7 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3794,18 +3794,12 @@ static bool isFunctionDeclarationName(const LangOptions 
&LangOpts,
   if (Current.is(TT_FunctionDeclarationName))
 return true;
 
-  if (!Current.Tok.getIdentifierInfo())
+  if (Current.isNoneOf(tok::identifier, tok::kw_operator))
 return false;
 
   const auto *Prev = Current.getPreviousNonComment();
   assert(Prev);
 
-  if (Prev->is(tok::coloncolon))
-Prev = Prev->Previous;
-
-  if (!Prev)
-return false;
-
   const auto &Previous = *Prev;
 
   if (const auto *PrevPrev = Previous.getPreviousNonComment();
@@ -3854,6 +3848,8 @@ static bool isFunctionDeclarationName(const LangOptions 
&LangOpts,
 
   // Find parentheses of parameter list.
   if (Current.is(tok::kw_operator)) {
+if (Line.startsWith(tok::kw_friend))
+  return true;
 if (Previous.Tok.getIdentifierInfo() &&
 Previous.isNoneOf(tok::kw_return, tok::kw_co_return)) {
   return true;
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 1152466b0179f..100251514a4bd 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -1129,6 +1129,11 @@ TEST_F(TokenAnnotatorTest, 
UnderstandsOverloadedOperators) {
   ASSERT_EQ(Tokens.size(), 7u) << Tokens;
   // Not TT_FunctionDeclarationName.
   EXPECT_TOKEN(Tokens[3], tok::kw_operator, TT_Unknown);
+
+  Tokens = annotate("SomeAPI::operator()();");
+  ASSERT_EQ(Tokens.size(), 9u) << Tokens;
+  // Not TT_FunctionDeclarationName.
+  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_Unknown);
 }
 
 TEST_F(TokenAnnotatorTest, OverloadedOperatorInTemplate) {

___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Implement ChooseExpr for Aggre Expr (PR #160999)

2025-10-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Amr Hesham (AmrDeveloper)


Changes

Implement the ChooseExpr for aggregate expr

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


3 Files Affected:

- (modified) clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp (+1-3) 
- (modified) clang/lib/CIR/CodeGen/CIRGenFunction.cpp (+2) 
- (modified) clang/test/CIR/CodeGen/struct.cpp (+24) 


``diff
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp
index 4a8aac900ee07..297fbccc6336e 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp
@@ -213,9 +213,7 @@ class AggExprEmitter : public StmtVisitor {
 cgf.cgm.errorNYI(e->getSourceRange(),
  "AggExprEmitter: VisitAbstractConditionalOperator");
   }
-  void VisitChooseExpr(const ChooseExpr *e) {
-cgf.cgm.errorNYI(e->getSourceRange(), "AggExprEmitter: VisitChooseExpr");
-  }
+  void VisitChooseExpr(const ChooseExpr *e) { Visit(e->getChosenSubExpr()); }
   void VisitCXXParenListInitExpr(CXXParenListInitExpr *e) {
 cgf.cgm.errorNYI(e->getSourceRange(),
  "AggExprEmitter: VisitCXXParenListInitExpr");
diff --git a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp 
b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp
index 0abb21a670719..9d98361a8b6a2 100644
--- a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp
@@ -841,6 +841,8 @@ LValue CIRGenFunction::emitLValue(const Expr *e) {
 return emitCastLValue(cast(e));
   case Expr::MaterializeTemporaryExprClass:
 return emitMaterializeTemporaryExpr(cast(e));
+  case Expr::ChooseExprClass:
+return emitLValue(cast(e)->getChosenSubExpr());
   }
 }
 
diff --git a/clang/test/CIR/CodeGen/struct.cpp 
b/clang/test/CIR/CodeGen/struct.cpp
index ee6c4cab7341f..0a0290e16a008 100644
--- a/clang/test/CIR/CodeGen/struct.cpp
+++ b/clang/test/CIR/CodeGen/struct.cpp
@@ -93,3 +93,27 @@ void f3() {
 // OGCG:   %[[O:.*]] = alloca %struct.Outer, align 4
 // OGCG:   %[[O_I:.*]] = getelementptr inbounds nuw %struct.Outer, ptr %[[O]], 
i32 0, i32 0
 // OGCG:   %[[O_I_N:.*]] = getelementptr inbounds nuw %struct.Inner, ptr 
%[[O_I]], i32 0, i32 0
+
+void choose_expr() {
+  CompleteS a;
+  CompleteS b;
+  CompleteS c = __builtin_choose_expr(true, a, b);
+}
+
+// CIR: cir.func{{.*}} @_Z11choose_exprv()
+// CIR:   %[[A_ADDR:.*]] = cir.alloca !rec_CompleteS, 
!cir.ptr, ["a"]
+// CIR:   %[[B_ADDR:.*]] = cir.alloca !rec_CompleteS, 
!cir.ptr, ["b"]
+// CIR:   %[[C_ADDR:.*]] = cir.alloca !rec_CompleteS, 
!cir.ptr, ["c", init]
+// CIR:   cir.call @_ZN9CompleteSC1ERKS_(%[[C_ADDR]], %[[A_ADDR]]) nothrow : 
(!cir.ptr, !cir.ptr) -> ()
+
+// LLVM: define{{.*}} void @_Z11choose_exprv()
+// LLVM:   %[[A_ADDR:.*]] = alloca %struct.CompleteS, i64 1, align 4
+// LLVM:   %[[B_ADDR:.*]] = alloca %struct.CompleteS, i64 1, align 4
+// LLVM:   %[[C_ADDR:.*]] = alloca %struct.CompleteS, i64 1, align 4
+// LLVM:   call void @_ZN9CompleteSC1ERKS_(ptr %[[C_ADDR]], ptr %[[A_ADDR]])
+
+// OGCG: define{{.*}} void @_Z11choose_exprv()
+// OGCG:   %[[A_ADDR:.*]] = alloca %struct.CompleteS, align 4
+// OGCG:   %[[B_ADDR:.*]] = alloca %struct.CompleteS, align 4
+// OGCG:   %[[C_ADDR:.*]] = alloca %struct.CompleteS, align 4
+// OGCG:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %[[C_ADDR]], ptr align 
4 %[[A_ADDR]], i64 8, i1 false)

``




https://github.com/llvm/llvm-project/pull/160999
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [ARM][AArch64] BTI, GCS, PAC Module flag update. (PR #86212)

2025-10-17 Thread Daniel Kiss via cfe-commits

https://github.com/DanielKristofKiss updated 
https://github.com/llvm/llvm-project/pull/86212

>From f2f3356da08d68dab4431f49d0921515560e4927 Mon Sep 17 00:00:00 2001
From: Daniel Kiss 
Date: Fri, 8 Mar 2024 15:06:28 +0100
Subject: [PATCH 1/4] BTI,GCS,PAC Module flag update.

Module flag is used to indicate the feature to be propagated to the
function. As now the frontend emits all attributes accoringly let's
help the automerger to only do work when old and new bitcodes are
merged.
Autoupgrade function attributes from Module attributes when needed.
---
 clang/lib/CodeGen/CodeGenModule.cpp   |  19 ++--
 .../CodeGen/aarch64-sign-return-address.c |  12 +--
 .../CodeGen/arm-branch-protection-attr-2.c|   8 +-
 .../arm-ignore-branch-protection-option.c |   2 +-
 llvm/include/llvm/IR/AutoUpgrade.h|   3 +
 llvm/lib/AsmParser/LLParser.cpp   |   1 +
 llvm/lib/Bitcode/Reader/BitcodeReader.cpp |   2 +
 llvm/lib/IR/AutoUpgrade.cpp   | 100 +
 llvm/lib/Linker/IRMover.cpp   |  10 ++
 llvm/lib/Target/ARM/ARMAsmPrinter.cpp |   2 +-
 llvm/lib/Transforms/IPO/LowerTypeTests.cpp|   2 +-
 .../test/Bitcode/upgrade-branch-protection.ll |  15 +--
 .../CodeGen/Thumb2/pacbti-m-outliner-5.ll |   2 +-
 llvm/test/LTO/AArch64/Inputs/foo.ll   |  16 ---
 llvm/test/LTO/AArch64/TestInputs/bar.ll   |  35 ++
 llvm/test/LTO/AArch64/TestInputs/foo.ll   |  38 +++
 llvm/test/LTO/AArch64/TestInputs/old.ll   |  46 
 .../AArch64/link-branch-target-enforcement.ll |   5 +-
 .../LTO/AArch64/link-sign-return-address.ll   | 102 ++
 llvm/test/Linker/link-arm-and-thumb.ll|   6 +-
 llvm/test/ThinLTO/AArch64/aarch64_inline.ll   |  86 +++
 llvm/test/ThinLTO/AArch64/lit.local.cfg   |   2 +
 22 files changed, 468 insertions(+), 46 deletions(-)
 delete mode 100644 llvm/test/LTO/AArch64/Inputs/foo.ll
 create mode 100644 llvm/test/LTO/AArch64/TestInputs/bar.ll
 create mode 100644 llvm/test/LTO/AArch64/TestInputs/foo.ll
 create mode 100644 llvm/test/LTO/AArch64/TestInputs/old.ll
 create mode 100644 llvm/test/LTO/AArch64/link-sign-return-address.ll
 create mode 100644 llvm/test/ThinLTO/AArch64/aarch64_inline.ll
 create mode 100644 llvm/test/ThinLTO/AArch64/lit.local.cfg

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 227813ad44e8b..6efc2283535f3 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1176,22 +1176,29 @@ void CodeGenModule::Release() {
   "tag-stack-memory-buildattr", 1);
 
   if (T.isARM() || T.isThumb() || T.isAArch64()) {
+// Previously 1 is used and meant for the backed to derive the function
+// attribute form it. 2 now means function attributes already set for all
+// functions in this module, so no need to propagate those from the module
+// flag. Value is only used in case of LTO module merge because the backend
+// will see all required function attribute set already. Value is used
+// before modules got merged. Any posive value means the feature is active
+// and required binary markings need to be emit accordingly.
 if (LangOpts.BranchTargetEnforcement)
   getModule().addModuleFlag(llvm::Module::Min, "branch-target-enforcement",
-1);
+2);
 if (LangOpts.BranchProtectionPAuthLR)
   getModule().addModuleFlag(llvm::Module::Min, 
"branch-protection-pauth-lr",
-1);
+2);
 if (LangOpts.GuardedControlStack)
-  getModule().addModuleFlag(llvm::Module::Min, "guarded-control-stack", 1);
+  getModule().addModuleFlag(llvm::Module::Min, "guarded-control-stack", 2);
 if (LangOpts.hasSignReturnAddress())
-  getModule().addModuleFlag(llvm::Module::Min, "sign-return-address", 1);
+  getModule().addModuleFlag(llvm::Module::Min, "sign-return-address", 2);
 if (LangOpts.isSignReturnAddressScopeAll())
   getModule().addModuleFlag(llvm::Module::Min, "sign-return-address-all",
-1);
+2);
 if (!LangOpts.isSignReturnAddressWithAKey())
   getModule().addModuleFlag(llvm::Module::Min,
-"sign-return-address-with-bkey", 1);
+"sign-return-address-with-bkey", 2);
 
 if (getTriple().isOSLinux()) {
   assert(getTriple().isOSBinFormatELF());
diff --git a/clang/test/CodeGen/aarch64-sign-return-address.c 
b/clang/test/CodeGen/aarch64-sign-return-address.c
index 8bc54b1a56c38..35c56889e0707 100644
--- a/clang/test/CodeGen/aarch64-sign-return-address.c
+++ b/clang/test/CodeGen/aarch64-sign-return-address.c
@@ -22,17 +22,17 @@
 // NONE-NOT:  !"branch-target-enforcement"
 // ALL-NOT:   !"branch-target-enforcement"
 // PART-NOT:  !"branch-target-e

[clang] [Clang][HIP][CUDA] Add `__cluster_dims__` and `__no_cluster__` attribute (PR #156686)

2025-10-17 Thread Shilei Tian via cfe-commits


@@ -5654,6 +5654,130 @@ static void handleLaunchBoundsAttr(Sema &S, Decl *D, 
const ParsedAttr &AL) {
 AL.getNumArgs() > 2 ? AL.getArgAsExpr(2) : nullptr);
 }
 
+static std::pair
+makeClusterDimsArgExpr(Sema &S, Expr *E, const CUDAClusterDimsAttr &AL,
+   const unsigned Idx) {
+  if (S.DiagnoseUnexpandedParameterPack(E))
+return {nullptr, 0};
+
+  // Accept template arguments for now as they depend on something else.
+  // We'll get to check them when they eventually get instantiated.
+  if (E->isValueDependent())
+return {E, 1};
+
+  std::optional I = llvm::APSInt(64);
+  if (!(I = E->getIntegerConstantExpr(S.Context))) {
+S.Diag(E->getExprLoc(), diag::err_attribute_argument_n_type)
+<< &AL << Idx << AANT_ArgumentIntegerConstant << E->getSourceRange();
+return {nullptr, 0};
+  }
+  // Make sure we can fit it in 4 bits.
+  if (!I->isIntN(4)) {
+S.Diag(E->getExprLoc(), diag::err_ice_too_large)
+<< toString(*I, 10, false) << 4 << /* Unsigned */ 1;
+return {nullptr, 0};
+  }
+  if (*I < 0)
+S.Diag(E->getExprLoc(), diag::warn_attribute_argument_n_negative)
+<< &AL << Idx << E->getSourceRange();
+
+  // We may need to perform implicit conversion of the argument.
+  InitializedEntity Entity = InitializedEntity::InitializeParameter(
+  S.Context, S.Context.getConstType(S.Context.IntTy), /*consume*/ false);
+  ExprResult ValArg = S.PerformCopyInitialization(Entity, SourceLocation(), E);

shiltian wrote:

My experiment shows that without this piece of code, the following cases would 
not work.

```
// CHECK: "amdgpu-cluster-dims"="2,6,1"
template
__global__ void __cluster_dims__(a, b) test_template_2d() {}
template __global__ void test_template_2d<2, 6>();

// CHECK: "amdgpu-cluster-dims"="1,2,3"
template
__global__ void __cluster_dims__(a, b, c) test_template_3d() {}
template __global__ void test_template_3d<1, 2, 3>();
```

https://github.com/llvm/llvm-project/pull/156686
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Mips] Fix mcpu flag with i6400/i6500 (PR #161330)

2025-10-17 Thread via cfe-commits

https://github.com/ArielCPU updated 
https://github.com/llvm/llvm-project/pull/161330

>From 0d63be935cdb6ba0530e74acbccf67cb6f0cca6f Mon Sep 17 00:00:00 2001
From: Ariel Mataev 
Date: Tue, 30 Sep 2025 10:27:45 +0300
Subject: [PATCH] [Mips] Fix mcpu flag with i6400/i6500

The compiler is missing cases where it checks mips64r6 but not
i6400/i6500 causing wrong defines to be generated
---
 clang/lib/Basic/Targets/Mips.cpp  |  7 ---
 clang/lib/Basic/Targets/Mips.h|  3 ++-
 clang/lib/Driver/ToolChains/Arch/Mips.cpp |  2 ++
 clang/test/Preprocessor/init-mips.c   | 22 ++
 4 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Basic/Targets/Mips.cpp b/clang/lib/Basic/Targets/Mips.cpp
index 34837cc363a37..de6ccff64f4eb 100644
--- a/clang/lib/Basic/Targets/Mips.cpp
+++ b/clang/lib/Basic/Targets/Mips.cpp
@@ -72,7 +72,7 @@ unsigned MipsTargetInfo::getISARev() const {
   .Cases("mips32r2", "mips64r2", "octeon", "octeon+", 2)
   .Cases("mips32r3", "mips64r3", 3)
   .Cases("mips32r5", "mips64r5", "p5600", 5)
-  .Cases("mips32r6", "mips64r6", 6)
+  .Cases("mips32r6", "mips64r6", "i6400", "i6500", 6)
   .Default(0);
 }
 
@@ -270,8 +270,9 @@ bool MipsTargetInfo::validateTarget(DiagnosticsEngine 
&Diags) const {
 return false;
   }
   // Mips revision 6 and -mfp32 are incompatible
-  if (FPMode != FP64 && FPMode != FPXX && (CPU == "mips32r6" ||
-  CPU == "mips64r6")) {
+  if (FPMode != FP64 && FPMode != FPXX &&
+  (CPU == "mips32r6" || CPU == "mips64r6" || CPU == "i6400" ||
+   CPU == "i6500")) {
 Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfp32" << CPU;
 return false;
   }
diff --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h
index e199df32f56ee..930271cee73ff 100644
--- a/clang/lib/Basic/Targets/Mips.h
+++ b/clang/lib/Basic/Targets/Mips.h
@@ -83,7 +83,8 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public 
TargetInfo {
   }
 
   bool isIEEE754_2008Default() const {
-return CPU == "mips32r6" || CPU == "mips64r6";
+return CPU == "mips32r6" || CPU == "mips64r6" || CPU == "i6400" ||
+   CPU == "i6500";
   }
 
   enum FPModeEnum getDefaultFPMode() const {
diff --git a/clang/lib/Driver/ToolChains/Arch/Mips.cpp 
b/clang/lib/Driver/ToolChains/Arch/Mips.cpp
index 8787c8276721c..bac8681921877 100644
--- a/clang/lib/Driver/ToolChains/Arch/Mips.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/Mips.cpp
@@ -442,6 +442,8 @@ bool mips::hasCompactBranches(StringRef &CPU) {
   return llvm::StringSwitch(CPU)
   .Case("mips32r6", true)
   .Case("mips64r6", true)
+  .Case("i6400", true)
+  .Case("i6500", true)
   .Default(false);
 }
 
diff --git a/clang/test/Preprocessor/init-mips.c 
b/clang/test/Preprocessor/init-mips.c
index 125872a001bac..c829eebdc9ec9 100644
--- a/clang/test/Preprocessor/init-mips.c
+++ b/clang/test/Preprocessor/init-mips.c
@@ -1649,6 +1649,28 @@
 // MIPS-ARCH-OCTEONP:#define __OCTEON__ 1
 // MIPS-ARCH-OCTEONP:#define __mips_isa_rev 2
 
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64-none-none \
+// RUN:-target-cpu i6400 < /dev/null \
+// RUN:   | FileCheck -match-full-lines -check-prefix MIPS-ARCH-I6400 %s
+//
+// MIPS-ARCH-I6400:#define _MIPS_ARCH "i6400"
+// MIPS-ARCH-I6400:#define _MIPS_ARCH_I6400 1
+// MIPS-ARCH-I6400:#define _MIPS_ISA _MIPS_ISA_MIPS64
+// MIPS-ARCH-I6400:#define __mips_abs2008 1
+// MIPS-ARCH-I6400:#define __mips_isa_rev 6
+// MIPS-ARCH-I6400:#define __mips_nan2008 1
+
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64-none-none \
+// RUN:-target-cpu i6500 < /dev/null \
+// RUN:   | FileCheck -match-full-lines -check-prefix MIPS-ARCH-I6500 %s
+//
+// MIPS-ARCH-I6500:#define _MIPS_ARCH "i6500"
+// MIPS-ARCH-I6500:#define _MIPS_ARCH_I6500 1
+// MIPS-ARCH-I6500:#define _MIPS_ISA _MIPS_ISA_MIPS64
+// MIPS-ARCH-I6500:#define __mips_abs2008 1
+// MIPS-ARCH-I6500:#define __mips_isa_rev 6
+// MIPS-ARCH-I6500:#define __mips_nan2008 1
+
 // Check MIPS float ABI macros
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding \

___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy][NFC] Clean up and slightly optimize `modernize-use-integer-sign-comparison` (PR #163492)

2025-10-17 Thread Baranov Victor via cfe-commits


@@ -119,23 +118,16 @@ void UseIntegerSignComparisonCheck::check(
   Expr::EvalResult EVResult;
   if (!SignedCastExpression->isValueDependent() &&
   SignedCastExpression->getSubExpr()->EvaluateAsInt(EVResult,
-*Result.Context)) {
-const llvm::APSInt SValue = EVResult.Val.getInt();
-if (SValue.isNonNegative())
-  return;
-  }
+*Result.Context) &&
+  EVResult.Val.getInt().isNonNegative())
+return;
 
   const auto *BinaryOp =
   Result.Nodes.getNodeAs("intComparison");
-  if (BinaryOp == nullptr)
-return;
-
-  const BinaryOperator::Opcode OpCode = BinaryOp->getOpcode();
+  assert(BinaryOp);
 
   const Expr *LHS = BinaryOp->getLHS()->IgnoreImpCasts();
   const Expr *RHS = BinaryOp->getRHS()->IgnoreImpCasts();
-  if (LHS == nullptr || RHS == nullptr)
-return;

vbvictor wrote:

I guess should not

https://github.com/llvm/llvm-project/pull/163492
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 092bc04 - [Driver][Hurd] Add AArch64 and RISCV64 support (#157212)

2025-10-17 Thread via cfe-commits

Author: Brad Smith
Date: 2025-09-22T01:41:00-04:00
New Revision: 092bc04acebe9fb763bf5ab5bc6d5cecc2d20353

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

LOG: [Driver][Hurd] Add AArch64 and RISCV64 support (#157212)

Added: 


Modified: 
clang/lib/Basic/Targets.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/Hurd.cpp
clang/lib/Driver/ToolChains/Hurd.h
clang/test/Driver/aarch64-features.c
llvm/unittests/TargetParser/TripleTest.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 1ae244edad878..d9aafc6c75d3b 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -172,6 +172,9 @@ std::unique_ptr AllocateTarget(const 
llvm::Triple &Triple,
 case llvm::Triple::OpenBSD:
   return std::make_unique>(Triple,
   Opts);
+case llvm::Triple::Hurd:
+  return std::make_unique>(Triple,
+   Opts);
 case llvm::Triple::Win32:
   switch (Triple.getEnvironment()) {
   case llvm::Triple::GNU:
@@ -464,6 +467,8 @@ std::unique_ptr AllocateTarget(const 
llvm::Triple &Triple,
 case llvm::Triple::Managarm:
   return std::make_unique>(Triple,
  Opts);
+case llvm::Triple::Hurd:
+  return std::make_unique>(Triple, Opts);
 default:
   return std::make_unique(Triple, Opts);
 }

diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 3dade2bdf2277..7616076847a2c 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2529,6 +2529,14 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
 
   if (TargetTriple.isOSHurd()) {
 switch (TargetTriple.getArch()) {
+case llvm::Triple::aarch64:
+  LibDirs.append(begin(AArch64LibDirs), end(AArch64LibDirs));
+  TripleAliases.push_back("aarch64-gnu");
+  break;
+case llvm::Triple::riscv64:
+  LibDirs.append(begin(RISCV64LibDirs), end(RISCV64LibDirs));
+  TripleAliases.push_back("riscv64-gnu");
+  break;
 case llvm::Triple::x86_64:
   LibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
   TripleAliases.push_back("x86_64-gnu");

diff  --git a/clang/lib/Driver/ToolChains/Hurd.cpp 
b/clang/lib/Driver/ToolChains/Hurd.cpp
index 8bcc7e6d9759e..43121233ea7d0 100644
--- a/clang/lib/Driver/ToolChains/Hurd.cpp
+++ b/clang/lib/Driver/ToolChains/Hurd.cpp
@@ -34,6 +34,12 @@ std::string Hurd::getMultiarchTriple(const Driver &D,
   default:
 break;
 
+  case llvm::Triple::aarch64:
+return "aarch64-gnu";
+
+  case llvm::Triple::riscv64:
+return "riscv64-gnu";
+
   case llvm::Triple::x86:
 // We use the existence of '/lib/' as a directory to detect some
 // common hurd triples that don't quite match the Clang triple for both
@@ -142,6 +148,10 @@ Tool *Hurd::buildAssembler() const {
 
 std::string Hurd::getDynamicLinker(const ArgList &Args) const {
   switch (getArch()) {
+  case llvm::Triple::aarch64:
+return "/lib/ld-aarch64.so.1";
+  case llvm::Triple::riscv64:
+return "/lib/ld-riscv64-lp64.so.1";
   case llvm::Triple::x86:
 return "/lib/ld.so";
   case llvm::Triple::x86_64:

diff  --git a/clang/lib/Driver/ToolChains/Hurd.h 
b/clang/lib/Driver/ToolChains/Hurd.h
index f301bc5f4269e..c7b72680dcd4b 100644
--- a/clang/lib/Driver/ToolChains/Hurd.h
+++ b/clang/lib/Driver/ToolChains/Hurd.h
@@ -30,6 +30,11 @@ class LLVM_LIBRARY_VISIBILITY Hurd : public Generic_ELF {
   addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
 
+  bool IsAArch64OutlineAtomicsDefault(
+  const llvm::opt::ArgList &Args) const override {
+return true;
+  }
+
   std::string getDynamicLinker(const llvm::opt::ArgList &Args) const override;
 
   void addExtraOpts(llvm::opt::ArgStringList &CmdArgs) const override;

diff  --git a/clang/test/Driver/aarch64-features.c 
b/clang/test/Driver/aarch64-features.c
index 2fbb8629997d9..faef3878c0ab0 100644
--- a/clang/test/Driver/aarch64-features.c
+++ b/clang/test/Driver/aarch64-features.c
@@ -82,6 +82,9 @@
 // RUN: --gcc-toolchain=%S/Inputs/aarch64-linux-gnu-tree/gcc-7.5.0 \
 // RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
 
+// RUN: %clang --target=aarch64-unknown-hurd-gnu -rtlib=libgcc \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+
 // RUN: %clang --target=aarch64-unknown-haiku -rtlib=libgcc \
 // RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
 

diff  --git a/ll

[clang] [clang] Fix catching pointers by reference on mingw targets (PR #162546)

2025-10-17 Thread Martin Storsjö via cfe-commits

https://github.com/mstorsjo milestoned 
https://github.com/llvm/llvm-project/pull/162546
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Remove special handling of comments after brace/paren (PR #71672)

2025-10-17 Thread Björn Schäpers via cfe-commits

https://github.com/HazardyKnusperkeks updated 
https://github.com/llvm/llvm-project/pull/71672

From 4c5525b88a4f191270fa363a2c62699fd5c1fa27 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Sch=C3=A4pers?= 
Date: Sat, 27 Sep 2025 22:32:12 +0200
Subject: [PATCH 1/4] [clang-format][NFC] Introduce isNotOneOf

And apply throughout the code base.
---
 clang/lib/Format/ContinuationIndenter.cpp | 34 -
 clang/lib/Format/FormatToken.h| 12 ++-
 .../lib/Format/NamespaceEndCommentsFixer.cpp  |  2 +-
 clang/lib/Format/TokenAnnotator.cpp   | 76 +--
 clang/lib/Format/UnwrappedLineFormatter.cpp   |  8 +-
 clang/lib/Format/UnwrappedLineParser.cpp  | 40 +-
 clang/lib/Format/WhitespaceManager.cpp|  4 +-
 7 files changed, 90 insertions(+), 86 deletions(-)

diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 9413c13a4137e..21e1856e639d7 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -523,9 +523,9 @@ bool ContinuationIndenter::mustBreak(const LineState 
&State) {
   if (Style.AlwaysBreakBeforeMultilineStrings &&
   (NewLineColumn == State.FirstIndent + Style.ContinuationIndentWidth ||
Previous.is(tok::comma) || Current.NestingLevel < 2) &&
-  !Previous.isOneOf(tok::kw_return, tok::lessless, tok::at,
-Keywords.kw_dollar) &&
-  !Previous.isOneOf(TT_InlineASMColon, TT_ConditionalExpr) &&
+  Previous.isNotOneOf(tok::kw_return, tok::lessless, tok::at,
+  Keywords.kw_dollar) &&
+  Previous.isNotOneOf(TT_InlineASMColon, TT_ConditionalExpr) &&
   nextIsMultilineString(State)) {
 return true;
   }
@@ -752,7 +752,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState 
&State, bool DryRun,
   return false;
 
 const auto *Next = Comma->getNextNonComment();
-return Next && !Next->isOneOf(TT_LambdaLSquare, tok::l_brace, tok::caret);
+return Next && Next->isNotOneOf(TT_LambdaLSquare, tok::l_brace, 
tok::caret);
   };
 
   if (DisallowLineBreaks())
@@ -835,7 +835,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState 
&State, bool DryRun,
   return Tok.is(tok::l_brace) && Tok.isNot(BK_Block) &&
  Style.Cpp11BracedListStyle;
 };
-if (!Tok.isOneOf(tok::l_paren, TT_TemplateOpener, tok::l_square) &&
+if (Tok.isNotOneOf(tok::l_paren, TT_TemplateOpener, tok::l_square) &&
 !IsStartOfBracedList()) {
   return false;
 }
@@ -843,8 +843,8 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState 
&State, bool DryRun,
   return true;
 if (Tok.Previous->isIf())
   return Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak;
-return !Tok.Previous->isOneOf(TT_CastRParen, tok::kw_for, tok::kw_while,
-  tok::kw_switch) &&
+return Tok.Previous->isNotOneOf(TT_CastRParen, tok::kw_for, tok::kw_while,
+tok::kw_switch) &&
!(Style.isJavaScript() && Tok.Previous->is(Keywords.kw_await));
   };
   auto IsFunctionCallParen = [](const FormatToken &Tok) {
@@ -920,9 +920,9 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState 
&State, bool DryRun,
   // align the commas with the opening paren.
   if (Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign &&
   !CurrentState.IsCSharpGenericTypeConstraint && Previous.opensScope() &&
-  Previous.isNot(TT_ObjCMethodExpr) && Previous.isNot(TT_RequiresClause) &&
-  Previous.isNot(TT_TableGenDAGArgOpener) &&
-  Previous.isNot(TT_TableGenDAGArgOpenerToBreak) &&
+  Previous.isNotOneOf(TT_ObjCMethodExpr, TT_RequiresClause,
+  TT_TableGenDAGArgOpener,
+  TT_TableGenDAGArgOpenerToBreak) &&
   !(Current.MacroParent && Previous.MacroParent) &&
   (Current.isNot(TT_LineComment) ||
Previous.isOneOf(BK_BracedInit, TT_VerilogMultiLineListLParen)) &&
@@ -1239,11 +1239,11 @@ unsigned 
ContinuationIndenter::addTokenOnNewLine(LineState &State,
   }
 
   if (PreviousNonComment &&
-  !PreviousNonComment->isOneOf(tok::comma, tok::colon, tok::semi) &&
+  PreviousNonComment->isNotOneOf(tok::comma, tok::colon, tok::semi) &&
   ((PreviousNonComment->isNot(TT_TemplateCloser) &&
 !PreviousNonComment->ClosesRequiresClause) ||
Current.NestingLevel != 0) &&
-  !PreviousNonComment->isOneOf(
+  PreviousNonComment->isNotOneOf(
   TT_BinaryOperator, TT_FunctionAnnotationRParen, TT_JavaAnnotation,
   TT_LeadingJavaAnnotation) &&
   Current.isNot(TT_BinaryOperator) && !PreviousNonComment->opensScope() &&
@@ -1281,8 +1281,8 @@ unsigned 
ContinuationIndenter::addTokenOnNewLine(LineState &State,
 bool AllowAllConstructorInitializersOnNextLine =
 Style.PackConstructorInitializers == FormatStyle::PCIS_NextLine ||
 Style.PackConstructorInitializ

[clang] [llvm] [Offload] Rename and move 'clang-offload-packager' -> 'llvm-offload-binary' (PR #161438)

2025-10-17 Thread Nick Sarnie via cfe-commits


@@ -43,7 +43,7 @@ const char *Action::getClassName(ActionClass AC) {
   case OffloadUnbundlingJobClass:
 return "clang-offload-unbundler";
   case OffloadPackagerJobClass:
-return "clang-offload-packager";
+return "llvm-offload-binary";

sarnex wrote:

the new name doesn't have a verb (or whatever packager is) so it's somewhat 
unclear what it does, is `llvm-offload-binary-packager` too long?

https://github.com/llvm/llvm-project/pull/161438
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix a crash when using ctad with a template template parameter. (PR #161488)

2025-10-17 Thread Younan Zhang via cfe-commits

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


https://github.com/llvm/llvm-project/pull/161488
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Upstream support Agg init with lvalue ComplexType (PR #159974)

2025-10-17 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/159974

>From 62c9484e43b14314c4bd3ceae5b41ca30c4cf5c6 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sun, 21 Sep 2025 08:51:14 +0200
Subject: [PATCH 1/2] [CIR] Upstream support Agg init with lvalue ComplexType

---
 clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp |  2 +-
 clang/test/CIR/CodeGen/array.cpp  | 22 +++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp
index dc34d2b3baa8d..f46a607830b82 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp
@@ -500,7 +500,7 @@ void AggExprEmitter::emitInitializationToLValue(Expr *e, 
LValue lv) {
 
   switch (cgf.getEvaluationKind(type)) {
   case cir::TEK_Complex:
-cgf.cgm.errorNYI("emitInitializationToLValue TEK_Complex");
+cgf.emitComplexExprIntoLValue(e, lv, /*isInit*/ true);
 break;
   case cir::TEK_Aggregate:
 cgf.emitAggExpr(e, AggValueSlot::forLValue(lv, AggValueSlot::IsDestructed,
diff --git a/clang/test/CIR/CodeGen/array.cpp b/clang/test/CIR/CodeGen/array.cpp
index a643de2d26189..5c6f049e45dff 100644
--- a/clang/test/CIR/CodeGen/array.cpp
+++ b/clang/test/CIR/CodeGen/array.cpp
@@ -575,3 +575,25 @@ void func12() {
 // LLVM: %[[ARR:.*]] = alloca [4 x %struct.Point], i64 1, align 16
 
 // OGCG: %[[ARR:.*]] = alloca [4 x %struct.Point], align 16
+
+void foo13() {
+  _Complex float arr[2] = {{1.1f, 2.2f}, {3.3f, 4.4f}};
+}
+
+// CIR: %[[ARR_ADDR:.*]] = cir.alloca !cir.array x 
2>, !cir.ptr x 2>>, ["arr", init]
+// CIR: %[[ARR_0:.*]] = cir.cast(array_to_ptrdecay, %[[ARR_ADDR]] : 
!cir.ptr x 2>>), 
!cir.ptr>
+// CIR: %[[CONST_COMPLEX_0:.*]] = cir.const 
#cir.const_complex<#cir.fp<1.10e+00> : !cir.float, #cir.fp<2.20e+00> : 
!cir.float> : !cir.complex
+// CIR: cir.store{{.*}} %[[CONST_COMPLEX_0]], %[[ARR_0]] : 
!cir.complex, !cir.ptr>
+// CIR: %[[IDX_1:.*]] = cir.const #cir.int<1> : !s64i
+// CIR: %[[ARR_1:.*]] = cir.ptr_stride(%1 : 
!cir.ptr>, %[[IDX_1]] : !s64i), 
!cir.ptr>
+// CIR: %[[CONST_COMPLEX_1:.*]] = cir.const 
#cir.const_complex<#cir.fp<3.30e+00> : !cir.float, #cir.fp<4.40e+00> : 
!cir.float> : !cir.complex
+// CIR: cir.store{{.*}} %[[CONST_COMPLEX_1]], %[[ARR_1]] : 
!cir.complex, !cir.ptr>
+
+// LLVM: %[[ARR_ADDR:.*]] = alloca [2 x { float, float }], i64 1, align 16
+// LLVM: %[[ARR_0:.*]] = getelementptr { float, float }, ptr %[[ARR_ADDR]], 
i32 0
+// LLVM: store { float, float } { float 0x3FF1A000, float 
0x4001A000 }, ptr %[[ARR_0]], align 8
+// LLVM: %[[ARR_1:.*]] = getelementptr { float, float }, ptr %[[ARR_0]], i64 1
+// LLVM: store { float, float } { float 0x400A6000, float 
0x4011A000 }, ptr %[[ARR_1]], align 8
+
+// OGCG: %[[ARR_ADDR:.*]] = alloca [2 x { float, float }], align 16
+// OGCG: call void @llvm.memcpy.p0.p0.i64(ptr align 16 %[[ARR_ADDR]], ptr 
align 16 @__const._Z5foo13v.arr, i64 16, i1 false)

>From ed03994abc6ea4abf741ae2a545d0706ac4609e1 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Tue, 23 Sep 2025 17:20:24 +0200
Subject: [PATCH 2/2] Update the name of test function

---
 clang/test/CIR/CodeGen/array.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/CIR/CodeGen/array.cpp b/clang/test/CIR/CodeGen/array.cpp
index 5c6f049e45dff..88913a52af58b 100644
--- a/clang/test/CIR/CodeGen/array.cpp
+++ b/clang/test/CIR/CodeGen/array.cpp
@@ -576,7 +576,7 @@ void func12() {
 
 // OGCG: %[[ARR:.*]] = alloca [4 x %struct.Point], align 16
 
-void foo13() {
+void array_with_complex_elements() {
   _Complex float arr[2] = {{1.1f, 2.2f}, {3.3f, 4.4f}};
 }
 

___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [C2y] Support WG14 N3457, the __COUNTER__ macro (PR #162662)

2025-10-17 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman updated 
https://github.com/llvm/llvm-project/pull/162662

>From 7a5e159aceef541c054a53f6508cdb7fdd9af04d Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Thu, 9 Oct 2025 10:12:55 -0400
Subject: [PATCH 1/6] [C2y] Support WG14 N3457, the __COUNTER__ macro

This implements the parts of 
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3457.htm
which were adopted at the recent meeting in Brno.

Clang already implemented __COUNTER__, but needed some changes for
conformance. Specifically, we now diagnose when the macro is expanded
more than 2147483647 times. Additionally, we now give the expected
extension and pre-compat warnings for the feature.

To support testing the limits, this also adds a -cc1-only option,
-finitial-counter-value=, which lets you specify the initial value the
__COUNTER__ macro should expand to.
---
 clang/docs/LanguageExtensions.rst |  4 +-
 clang/docs/ReleaseNotes.rst   |  5 +++
 .../include/clang/Basic/DiagnosticLexKinds.td |  8 
 clang/include/clang/Driver/Options.td |  4 ++
 clang/include/clang/Lex/Preprocessor.h|  6 +--
 clang/include/clang/Lex/PreprocessorOptions.h |  4 ++
 clang/include/clang/Serialization/ASTReader.h |  8 ++--
 clang/lib/Frontend/ASTUnit.cpp|  9 +++--
 clang/lib/Frontend/InitPreprocessor.cpp   |  3 ++
 clang/lib/Lex/PPMacroExpansion.cpp| 13 ++-
 clang/lib/Serialization/ASTReader.cpp |  4 +-
 clang/test/C/C2y/n3457.c  | 37 +++
 clang/test/C/C2y/n3457_1.c| 20 ++
 clang/test/C/C2y/n3457_2.c| 10 +
 clang/www/c_status.html   |  2 +-
 15 files changed, 122 insertions(+), 15 deletions(-)
 create mode 100644 clang/test/C/C2y/n3457.c
 create mode 100644 clang/test/C/C2y/n3457_1.c
 create mode 100644 clang/test/C/C2y/n3457_2.c

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 6bb99c757cd19..54c215e9ccfaa 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -385,7 +385,9 @@ Builtin Macros
 
 ``__COUNTER__``
   Defined to an integer value that starts at zero and is incremented each time
-  the ``__COUNTER__`` macro is expanded.
+  the ``__COUNTER__`` macro is expanded. This is a standard feature in C2y but
+  is an extension in earlier language modes and in C++. This macro can only be
+  expanded 2147483647 times at most.
 
 ``__INCLUDE_LEVEL__``
   Defined to an integral value that is the include depth of the file currently
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5e9a71e1e74d6..37e02e9638296 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -181,6 +181,11 @@ C Language Changes
 C2y Feature Support
 ^^^
 - Clang now supports `N3355 
`_ Named Loops.
+- Clang's implementation of ``__COUNTER__`` was updated to conform to
+  `WG14 N3457 `_.
+  This includes adding pedantic warnings for the feature being an extension in
+  other language modes as well as an error when the counter is expanded more
+  than 2147483647 times.
 
 C23 Feature Support
 ^^^
diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index c7fe6e1db6d1f..46a7a88f7a50b 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -90,6 +90,14 @@ def err_unterminated___pragma : Error<"missing terminating 
')' character">;
 
 def err_conflict_marker : Error<"version control conflict marker in file">;
 
+def err_counter_overflow : Error<
+  "'__COUNTER__' value cannot exceed 2147483647">;
+def ext_counter : Extension<
+  "'__COUNTER__' is a C2y extension">, InGroup;
+def warn_counter : Warning<
+  "'__COUNTER__' is incompatible with standards before C2y">,
+  InGroup, DefaultIgnore;
+
 def err_raw_delim_too_long : Error<
   "raw string delimiter longer than 16 characters"
   "; use PREFIX( )PREFIX to delimit raw string">;
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c8e96e125733c..2511f88f4e53c 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -8417,6 +8417,10 @@ def aligned_alloc_unavailable : Flag<["-"], 
"faligned-alloc-unavailable">,
   MarshallingInfoFlag>,
   ShouldParseIf;
 
+def finitial_counter_value_EQ : Joined<["-"], "finitial-counter-value=">,
+  HelpText<"Sets the initial value for __COUNTER__, defaults to 0.">,
+  MarshallingInfoInt, "0">;
+
 } // let Visibility = [CC1Option]
 
 
//===--===//
diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index 39754847a93e

[clang] 6fbc7d3 - [HLSL][SPIR-V] Add `-fspv-enable-maximal-reconvergence` flag to clang dxc. (#163474)

2025-10-17 Thread via cfe-commits

Author: Lucie Choi
Date: 2025-10-15T21:30:09-04:00
New Revision: 6fbc7d3d1f17e09aaa9ead004011f4204f0a691f

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

LOG: [HLSL][SPIR-V] Add `-fspv-enable-maximal-reconvergence` flag to clang dxc. 
(#163474)

Implement the frontend change to support maximal reconvergence feature.

The next work is to generate the corresponding SPIR-V instructions
(`OpExtension` and `OpExecutionMode`) based on the llvm ir added in this
CL `"enable-maximal-reconvergence"="true"`.


Addresses https://github.com/llvm/llvm-project/issues/136930

Added: 
clang/test/CodeGenHLSL/vk-features/maximal_reconvergence.hlsl

Modified: 
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CGHLSLRuntime.cpp
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 9e850089ad87f..5f70b5149e585 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -243,6 +243,7 @@ ENUM_LANGOPT(HLSLVersion, HLSLLangStd, 16, HLSL_Unset, 
NotCompatible, "HLSL Vers
 LANGOPT(HLSLStrictAvailability, 1, 0, NotCompatible,
 "Strict availability diagnostic mode for HLSL built-in functions.")
 LANGOPT(HLSLSpvUseUnknownImageFormat, 1, 0, NotCompatible, "For storage images 
and texel buffers, sets the default format to 'Unknown' when not specified via 
the `vk::image_format` attribute. If this option is not used, the format is 
inferred from the resource's data type.")
+LANGOPT(HLSLSpvEnableMaximalReconvergence, 1, 0, NotCompatible, "Enables the 
MaximallyReconvergesKHR execution mode for this module. This ensures that 
control flow reconverges at well-defined merge points as defined by the Vulkan 
spec.")
 
 LANGOPT(CUDAIsDevice  , 1, 0, NotCompatible, "compiling for CUDA device")
 LANGOPT(CUDAHostDeviceConstexpr, 1, 1, NotCompatible, "treating unattributed 
constexpr functions as __host__ __device__")

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 75c275b4efa4f..7ae153deb9a55 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -9601,6 +9601,15 @@ def fhlsl_spv_use_unknown_image_format
"from the resource's data type.">,
   MarshallingInfoFlag>;
 
+def fhlsl_spv_enable_maximal_reconvergence
+: Flag<["-"], "fspv-enable-maximal-reconvergence">,
+  Group,
+  Visibility<[CC1Option, DXCOption]>,
+  HelpText<"Enables the MaximallyReconvergesKHR execution mode for this "
+   "module. This ensures that control flow reconverges at "
+   "well-defined merge points as defined by the Vulkan spec.">,
+  MarshallingInfoFlag>;
+
 def no_wasm_opt : Flag<["--"], "no-wasm-opt">,
   Group,
   HelpText<"Disable the wasm-opt optimizer">,

diff  --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 603cef9116dc2..ecab9336a9f82 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -519,6 +519,10 @@ void clang::CodeGen::CGHLSLRuntime::setHLSLEntryAttributes(
   if (CGM.getCodeGenOpts().OptimizationLevel == 0)
 Fn->addFnAttr(llvm::Attribute::OptimizeNone);
   Fn->addFnAttr(llvm::Attribute::NoInline);
+
+  if (CGM.getLangOpts().HLSLSpvEnableMaximalReconvergence) {
+Fn->addFnAttr("enable-maximal-reconvergence", "true");
+  }
 }
 
 static Value *buildVectorInput(IRBuilder<> &B, Function *F, llvm::Type *Ty) {

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index f4bdfa5317933..a7310ba2da061 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3755,7 +3755,8 @@ static void RenderHLSLOptions(const ArgList &Args, 
ArgStringList &CmdArgs,
   options::OPT_hlsl_entrypoint,
   options::OPT_fdx_rootsignature_define,
   options::OPT_fdx_rootsignature_version,
-  options::OPT_fhlsl_spv_use_unknown_image_format};
+  options::OPT_fhlsl_spv_use_unknown_image_format,
+  options::OPT_fhlsl_spv_enable_maximal_reconvergence};
   if (!types::isHLSL(InputType))
 return;
   for (const auto &Arg : ForwardedArguments)

diff  --git a/clang/test/CodeGenHLSL/vk-features/maximal_reconvergence.hlsl 
b/clang/test/CodeGenHLSL/vk-features/maximal_reconvergence.hlsl
new file mode 100644
index 0..f23ac7c5434ab
--- /dev/null
+++ b/clang/test/CodeGenHLSL/vk-features/maximal_reconvergence.hlsl
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple spirv1.6-unknown-vulkan1.3-compute 
-fspv-enable-maximal-reconvergence -emit-llvm -o - -O0 %s | FileCheck %s 
--check-prefixes=CHECK
+// RUN: 

[clang] [clang][x86] bmi-builtins.c - add i386 test coverage (PR #161171)

2025-10-17 Thread Simon Pilgrim via cfe-commits

https://github.com/RKSimon closed 
https://github.com/llvm/llvm-project/pull/161171
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-10-17 Thread Kees Cook via cfe-commits

kees wrote:

@JustinStitt were looking over things, and I stumbled over something here...

> Thanks. So IIUC, the rule is:
> 
> 1. If the type of either operand of an arithmetic operator is `__ob_trap`,  
> the operator traps on overflow, and the result type is `__ob_trap`.

This is correct and what I was expecting.

> 2. If either the operand type or the destination type of an integer 
> conversion is `__ob_trap`, the conversion traps on overflow.

This one, however, I think it not what we want, but I may be missing something.

```
int __ob_trap src = bigger_than_255;
...
char dest = src;
```

I don't think we want a trap on the `dest` assignment, since it isn't 
`__ob_trap`. It doesn't care about the truncation. This is a "sided" operation, 
unlike the arithmetic.


https://github.com/llvm/llvm-project/pull/148914
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][LoongArch] Add support for UEFI target (PR #155598)

2025-10-17 Thread via cfe-commits

https://github.com/leecheechen updated 
https://github.com/llvm/llvm-project/pull/155598

>From e5f072058650433e2ec1e61449059267d107 Mon Sep 17 00:00:00 2001
From: chenli 
Date: Fri, 22 Aug 2025 18:02:23 +0800
Subject: [PATCH] [Clang][LoongArch] Add support for UEFI target

This patch adds basic UEFI target support for loongarch64, enabling
Clang to recognize and handle the loongarch64-unknown-uefi target
triple.
---
 clang/lib/Basic/Targets.cpp |  3 +++
 clang/lib/Basic/Targets/LoongArch.h |  3 +++
 clang/lib/Driver/Driver.cpp |  6 --
 clang/test/CodeGen/LoongArch/uefi-data-layout.c |  3 +++
 clang/test/Driver/uefi-constructed-args.c   | 15 +++
 5 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/CodeGen/LoongArch/uefi-data-layout.c

diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index d9aafc6c75d3b..be1369b9cb428 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -767,6 +767,9 @@ std::unique_ptr AllocateTarget(const 
llvm::Triple &Triple,
 case llvm::Triple::OpenBSD:
   return std::make_unique>(Triple,
 Opts);
+case llvm::Triple::UEFI:
+  return std::make_unique>(Triple,
+ Opts);
 default:
   return std::make_unique(Triple, Opts);
 }
diff --git a/clang/lib/Basic/Targets/LoongArch.h 
b/clang/lib/Basic/Targets/LoongArch.h
index 88dc433924d6c..ae0838a58dd63 100644
--- a/clang/lib/Basic/Targets/LoongArch.h
+++ b/clang/lib/Basic/Targets/LoongArch.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_LOONGARCH_H
 #define LLVM_CLANG_LIB_BASIC_TARGETS_LOONGARCH_H
 
+#include "OSTargets.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
 #include "llvm/Support/Compiler.h"
@@ -159,6 +160,8 @@ class LLVM_LIBRARY_VISIBILITY LoongArch64TargetInfo
 IntMaxType = Int64Type = SignedLong;
 HasUnalignedAccess = true;
 resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n32:64-S128");
+if (Triple.isUEFI())
+  resetDataLayout("e-m:w-p:64:64-i64:64-i128:128-n32:64-S128");
 // TODO: select appropriate ABI.
 setABI("lp64d");
   }
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index f110dbab3e5a5..e5d0940d3e081 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -698,8 +698,10 @@ static llvm::Triple computeTargetTriple(const Driver &D,
 }
   }
 
-  // Currently the only architecture supported by *-uefi triples are x86_64.
-  if (Target.isUEFI() && Target.getArch() != llvm::Triple::x86_64)
+  // Currently the only architectures supported by *-uefi triples are
+  // x86_64 and loongarch64.
+  if (Target.isUEFI() && Target.getArch() != llvm::Triple::x86_64 &&
+  Target.getArch() != llvm::Triple::loongarch64)
 D.Diag(diag::err_target_unknown_triple) << Target.str();
 
   // The `-maix[32|64]` flags are only valid for AIX targets.
diff --git a/clang/test/CodeGen/LoongArch/uefi-data-layout.c 
b/clang/test/CodeGen/LoongArch/uefi-data-layout.c
new file mode 100644
index 0..8c3e0b00d9d05
--- /dev/null
+++ b/clang/test/CodeGen/LoongArch/uefi-data-layout.c
@@ -0,0 +1,3 @@
+// RUN: %clang -target loongarch64-unknown-uefi -S -emit-llvm -o - %s | \
+// RUN: FileCheck --check-prefix=LA64_UEFI %s
+// LA64_UEFI: target datalayout = "e-m:w-p:64:64-i64:64-i128:128-n32:64-S128"
diff --git a/clang/test/Driver/uefi-constructed-args.c 
b/clang/test/Driver/uefi-constructed-args.c
index c06cce351d654..883b8553bdb0d 100644
--- a/clang/test/Driver/uefi-constructed-args.c
+++ b/clang/test/Driver/uefi-constructed-args.c
@@ -12,3 +12,18 @@
 // CHECK-SAME: "/entry:EfiMain"
 // CHECK-SAME: "/tsaware:no"
 // CHECK-SAME: "/debug"
+
+// RUN: %clang -### --target=loongarch64-unknown-uefi -g -- %s 2>&1 \
+// RUN: | FileCheck -check-prefixes=LA64 %s
+// RUN: %clang_cl -### --target=loongarch64-unknown-uefi -g -- %s 2>&1 \
+// RUN: | FileCheck -check-prefixes=LA64 %s
+// LA64: "-cc1"
+// LA64-SAME: "-triple" "loongarch64-unknown-uefi"
+// LA64-SAME: "-mrelocation-model" "pic" "-pic-level" "2"
+// LA64-SAME: "-mframe-pointer=all"
+// LA64-SAME: "-fms-extensions"
+// LA64-NEXT: "/nologo"
+// LA64-SAME: "/subsystem:efi_application"
+// LA64-SAME: "/entry:EfiMain"
+// LA64-SAME: "/tsaware:no"
+// LA64-SAME: "/debug"

___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [C2y] Support WG14 N3457, the __COUNTER__ macro (PR #162662)

2025-10-17 Thread via cfe-commits


@@ -1737,7 +1737,18 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
   Diag(getLastFPEvalPragmaLocation(), diag::note_pragma_entered_here);
 }
   } else if (II == Ident__COUNTER__) {
-// __COUNTER__ expands to a simple numeric value.
+Diag(Tok.getLocation(),
+ getLangOpts().C2y ? diag::warn_counter : diag::ext_counter);
+// __COUNTER__ expands to a simple numeric value that must be less than
+// 2147483647.
+if (CounterValue > 2147483647) {

Sirraide wrote:

I’d use `std::numeric_limits::max()` for this.

https://github.com/llvm/llvm-project/pull/162662
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86] Allow PSHUFD/PSHUFLW/PSHUFW intrinsics in constexpr. (PR #161210)

2025-10-17 Thread Nagraj Gaonkar via cfe-commits

https://github.com/NagrajMG updated 
https://github.com/llvm/llvm-project/pull/161210

>From 633a986a1e49698e05d109d69fafaa20989aa6c9 Mon Sep 17 00:00:00 2001
From: NagrajMG 
Date: Mon, 29 Sep 2025 20:08:07 +0530
Subject: [PATCH 1/4] FIxes #156611: Allow PSHUFD/PSHUFLW/PSHUFW intrinsics in
 constexpr

---
 clang/include/clang/Basic/BuiltinsX86.td |  45 ++-
 clang/lib/AST/ByteCode/InterpBuiltin.cpp | 245 
 clang/lib/AST/ExprConstant.cpp   | 287 +++
 clang/lib/Headers/mmintrin.h |   5 +
 clang/test/CodeGen/X86/avx2-builtins.c   |   6 +-
 clang/test/CodeGen/X86/avx512bw-builtins.c   |  11 +-
 clang/test/CodeGen/X86/avx512f-builtins.c|   9 +-
 clang/test/CodeGen/X86/avx512vl-builtins.c   |  17 ++
 clang/test/CodeGen/X86/avx512vlbw-builtins.c |  50 
 clang/test/CodeGen/X86/mmx-builtins.c|   2 +-
 clang/test/CodeGen/X86/sse2-builtins.c   |   6 +-
 11 files changed, 663 insertions(+), 20 deletions(-)

diff --git a/clang/include/clang/Basic/BuiltinsX86.td 
b/clang/include/clang/Basic/BuiltinsX86.td
index 77e599587edc3..e70691a30627a 100644
--- a/clang/include/clang/Basic/BuiltinsX86.td
+++ b/clang/include/clang/Basic/BuiltinsX86.td
@@ -145,6 +145,10 @@ let Features = "mmx", Header = "mmintrin.h", Attributes = 
[NoThrow, Const] in {
   def _m_prefetch : X86LibBuiltin<"void(void *)">;
 }
 
+let Features = "mmx", Attributes = [NoThrow, Const, Constexpr] in {
+  def pshufw : X86Builtin<"_Vector<4, short>(_Vector<4, short>, _Constant 
int)">;
+}
+
 // PRFCHW
 let Features = "prfchw", Header = "intrin.h", Attributes = [NoThrow, Const] in 
{
   def _m_prefetchw : X86LibBuiltin<"void(void volatile const *)">;
@@ -217,10 +221,13 @@ let Features = "sse2", Attributes = [NoThrow] in {
   def movnti : X86Builtin<"void(int *, int)">;
 }
 
-let Features = "sse2", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] 
in {
-  def pshufd : X86Builtin<"_Vector<4, int>(_Vector<4, int>, _Constant int)">;
+let Features = "sse2", Attributes = [NoThrow, Const, Constexpr, 
RequiredVectorWidth<128>] in {
   def pshuflw : X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Constant 
int)">;
+  def pshufd : X86Builtin<"_Vector<4, int>(_Vector<4, int>, _Constant int)">;
   def pshufhw : X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Constant 
int)">;
+}
+
+let Features = "sse2", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] 
in {
   def psadbw128 : X86Builtin<"_Vector<2, long long int>(_Vector<16, char>, 
_Vector<16, char>)">;
   def sqrtpd : X86Builtin<"_Vector<2, double>(_Vector<2, double>)">;
   def sqrtsd : X86Builtin<"_Vector<2, double>(_Vector<2, double>)">;
@@ -584,9 +591,6 @@ let Features = "avx2", Attributes = [NoThrow, Const, 
RequiredVectorWidth<256>] i
   def pmulhrsw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, 
_Vector<16, short>)">;
   def psadbw256 : X86Builtin<"_Vector<4, long long int>(_Vector<32, char>, 
_Vector<32, char>)">;
   def pshufb256 : X86Builtin<"_Vector<32, char>(_Vector<32, char>, _Vector<32, 
char>)">;
-  def pshufd256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Constant 
int)">;
-  def pshuflw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, 
_Constant int)">;
-  def pshufhw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, 
_Constant int)">;
   def psignb256 : X86Builtin<"_Vector<32, char>(_Vector<32, char>, _Vector<32, 
char>)">;
   def psignw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, 
_Vector<16, short>)">;
   def psignd256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Vector<8, 
int>)">;
@@ -647,6 +651,10 @@ let Features = "avx2", Attributes = [NoThrow, Const, 
Constexpr, RequiredVectorWi
   def packsswb256 : X86Builtin<"_Vector<32, char>(_Vector<16, short>, 
_Vector<16, short>)">;
   def packssdw256 : X86Builtin<"_Vector<16, short>(_Vector<8, int>, _Vector<8, 
int>)">;
   def packuswb256 : X86Builtin<"_Vector<32, char>(_Vector<16, short>, 
_Vector<16, short>)">;
+
+  def pshuflw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, 
_Constant int)">;
+  def pshufhw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, 
_Constant int)">;
+  def pshufd256  : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Constant 
int)">;
 }
 
 let Features = "avx2", Attributes = [NoThrow, Const, Constexpr, 
RequiredVectorWidth<128>] in {
@@ -1990,13 +1998,13 @@ let Features = "avx512vl", Attributes = [NoThrow, 
Const, Constexpr, RequiredVect
 }
 
 let Features = "avx512bw", Attributes = [NoThrow, Const, 
RequiredVectorWidth<512>] in {
-  def pshufhw512 : X86Builtin<"_Vector<32, short>(_Vector<32, short>, 
_Constant int)">;
-  def pshuflw512 : X86Builtin<"_Vector<32, short>(_Vector<32, short>, 
_Constant int)">;
   def psllw512 : X86Builtin<"_Vector<32, short>(_Vector<32, short>, _Vector<8, 
short>)">;
 }
 
 let Features = "avx512bw", Attributes = [NoThrow, Const, Constexpr, 
RequiredVectorWidth<512>] in {
   def psllv32hi : X86Builtin<"_Vector<32, short>(_Vector<32, short

[clang] [llvm] [LLVM] Add GNU make jobserver support (PR #145131)

2025-10-17 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `llvm-nvptx-nvidia-ubuntu` 
running on `as-builder-7` while building `clang,llvm` at step 6 
"test-build-unified-tree-check-llvm".

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


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

```
Step 6 (test-build-unified-tree-check-llvm) failure: test (failure)
 TEST 'LLVM-Unit :: Support/./SupportTests/165/208' FAILED 

Script(shard):
--
GTEST_OUTPUT=json:/home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/unittests/Support/./SupportTests-LLVM-Unit-1892456-165-208.json
 GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=208 GTEST_SHARD_INDEX=165 
/home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/unittests/Support/./SupportTests
--


Note: This is test shard 166 of 208.
[==] Running 8 tests from 8 test suites.
[--] Global test environment set-up.
[--] 1 test from CheckedArithmetic
[ RUN  ] CheckedArithmetic.CheckedAddUnsigned
[   OK ] CheckedArithmetic.CheckedAddUnsigned (0 ms)
[--] 1 test from CheckedArithmetic (0 ms total)

[--] 1 test from Error
[ RUN  ] Error.HandleExpectedSuccess
[   OK ] Error.HandleExpectedSuccess (0 ms)
[--] 1 test from Error (0 ms total)

[--] 1 test from JobserverStrategyTest
[ RUN  ] JobserverStrategyTest.ParallelSortIsLimited
[   OK ] JobserverStrategyTest.ParallelSortIsLimited (52 ms)
[--] 1 test from JobserverStrategyTest (52 ms total)

[--] 1 test from MustacheInterpolation
[ RUN  ] MustacheInterpolation.StandaloneAmpersandWithWhitespace
[   OK ] MustacheInterpolation.StandaloneAmpersandWithWhitespace (0 ms)
[--] 1 test from MustacheInterpolation (0 ms total)

[--] 1 test from ProgramEnvTest
[ RUN  ] ProgramEnvTest.TestExecuteEmptyEnvironment
Note: Google Test filter = 
[==] Running 0 tests from 0 test suites.
[==] 0 tests from 0 test suites ran. (0 ms total)
[  PASSED  ] 0 tests.
[   OK ] ProgramEnvTest.TestExecuteEmptyEnvironment (29 ms)
[--] 1 test from ProgramEnvTest (29 ms total)

[--] 1 test from TimeProfiler
[ RUN  ] TimeProfiler.Begin_End_Smoke
[   OK ] TimeProfiler.Begin_End_Smoke (0 ms)
[--] 1 test from TimeProfiler (0 ms total)

[--] 1 test from YAMLIO
[ RUN  ] YAMLIO.TestReadBuiltInTypesint16OverError
[   OK ] YAMLIO.TestReadBuiltInTypesint16OverError (0 ms)
[--] 1 test from YAMLIO (0 ms total)

[--] 1 test from VirtualOutput/BackendTest
...

```



https://github.com/llvm/llvm-project/pull/145131
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][x86] bmi-builtins.c - add i386 test coverage (PR #161171)

2025-10-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Simon Pilgrim (RKSimon)


Changes



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


1 Files Affected:

- (modified) clang/test/CodeGen/X86/bmi-builtins.c (+47-45) 


``diff
diff --git a/clang/test/CodeGen/X86/bmi-builtins.c 
b/clang/test/CodeGen/X86/bmi-builtins.c
index ded40ca59781e..8c9d3a64fb177 100644
--- a/clang/test/CodeGen/X86/bmi-builtins.c
+++ b/clang/test/CodeGen/X86/bmi-builtins.c
@@ -1,7 +1,9 @@
-// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +bmi -emit-llvm -o - -Wall -Werror | FileCheck %s 
--check-prefixes=CHECK,TZCNT
-// RUN: %clang_cc1 -x c -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 -ffreestanding %s -triple=x86_64-windows-msvc 
-emit-llvm -o - -Wall -Werror -DTEST_TZCNT | FileCheck %s --check-prefix=TZCNT
-// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +bmi -emit-llvm -o - -Wall -Werror 
| FileCheck %s --check-prefixes=CHECK,TZCNT
-// RUN: %clang_cc1 -x c++ -std=c++11 -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 -ffreestanding %s -triple=x86_64-windows-msvc 
-emit-llvm -o - -Wall -Werror -DTEST_TZCNT | FileCheck %s --check-prefix=TZCNT
+// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +bmi -emit-llvm -o - -Wall -Werror | FileCheck %s 
--check-prefixes=CHECK,X64,TZCNT,TZCNT64
+// RUN: %clang_cc1 -x c -ffreestanding %s -triple=i386-apple-darwin 
-target-feature +bmi -emit-llvm -o - -Wall -Werror | FileCheck %s 
--check-prefixes=CHECK,TZCNT
+// RUN: %clang_cc1 -x c -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 -ffreestanding %s -triple=x86_64-windows-msvc 
-emit-llvm -o - -Wall -Werror -DTEST_TZCNT | FileCheck %s 
--check-prefixes=TZCNT,TZCNT64
+// RUN: %clang_cc1 -x c++ -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +bmi -emit-llvm -o - -Wall -Werror | FileCheck %s 
--check-prefixes=CHECK,X64,TZCNT,TZCNT64
+// RUN: %clang_cc1 -x c++ -ffreestanding %s -triple=i386-apple-darwin 
-target-feature +bmi -emit-llvm -o - -Wall -Werror | FileCheck %s 
--check-prefixes=CHECK,TZCNT
+// RUN: %clang_cc1 -x c++ -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 -ffreestanding %s -triple=x86_64-windows-msvc 
-emit-llvm -o - -Wall -Werror -DTEST_TZCNT | FileCheck %s 
--check-prefixes=TZCNT,TZCNT64
 
 
 #include 
@@ -48,20 +50,20 @@ unsigned int test_tzcnt_u32(unsigned int __X) {
 
 #ifdef __x86_64__
 unsigned long long test__tzcnt_u64(unsigned long long __X) {
-// TZCNT-LABEL: test__tzcnt_u64
-// TZCNT: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false)
+// TZCNT64-LABEL: test__tzcnt_u64
+// TZCNT64: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false)
   return __tzcnt_u64(__X);
 }
 
 long long test_mm_tzcnt_64(unsigned long long __X) {
-// TZCNT-LABEL: test_mm_tzcnt_64
-// TZCNT: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false)
+// TZCNT64-LABEL: test_mm_tzcnt_64
+// TZCNT64: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false)
   return _mm_tzcnt_64(__X);
 }
 
 unsigned long long test_tzcnt_u64(unsigned long long __X) {
-// TZCNT-LABEL: test_tzcnt_u64
-// TZCNT: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false)
+// TZCNT64-LABEL: test_tzcnt_u64
+// TZCNT64: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false)
   return _tzcnt_u64(__X);
 }
 #endif
@@ -103,36 +105,36 @@ unsigned int test__blsr_u32(unsigned int __X) {
 
 #ifdef __x86_64__
 unsigned long long test__andn_u64(unsigned long __X, unsigned long __Y) {
-// CHECK-LABEL: test__andn_u64
-// CHECK: xor i64 %{{.*}}, -1
-// CHECK: and i64 %{{.*}}, %{{.*}}
+// X64-LABEL: test__andn_u64
+// X64: xor i64 %{{.*}}, -1
+// X64: and i64 %{{.*}}, %{{.*}}
   return __andn_u64(__X, __Y);
 }
 
 unsigned long long test__bextr_u64(unsigned long __X, unsigned long __Y) {
-// CHECK-LABEL: test__bextr_u64
-// CHECK: i64 @llvm.x86.bmi.bextr.64(i64 %{{.*}}, i64 %{{.*}})
+// X64-LABEL: test__bextr_u64
+// X64: i64 @llvm.x86.bmi.bextr.64(i64 %{{.*}}, i64 %{{.*}})
   return __bextr_u64(__X, __Y);
 }
 
 unsigned long long test__blsi_u64(unsigned long long __X) {
-// CHECK-LABEL: test__blsi_u64
-// CHECK: sub i64 0, %{{.*}}
-// CHECK: and i64 %{{.*}}, %{{.*}}
+// X64-LABEL: test__blsi_u64
+// X64: sub i64 0, %{{.*}}
+// X64: and i64 %{{.*}}, %{{.*}}
   return __blsi_u64(__X);
 }
 
 unsigned long long test__blsmsk_u64(unsigned long long __X) {
-// CHECK-LABEL: test__blsmsk_u64
-// CHECK: sub i64 %{{.*}}, 1
-// CHECK: xor i64 %{{.*}}, %{{.*}}
+// X64-LABEL: test__blsmsk_u64
+// X64: sub i64 %{{.*}}, 1
+// X64: xor i64 %{{.*}}, %{{.*}}
   return __blsmsk_u64(__X);
 }
 
 unsigned long long test__blsr_u64(unsigned long long __X) {
-// CHECK-LABEL: test__blsr_u64
-// CHECK: sub i64 %{{.*}}, 1
-// CHECK: and i64 %{{.*}}, %{{.*}}
+// X64-LABEL: test__blsr_u64
+// X64: sub i64 %{{.*}}, 1
+// X64: and i64 %{{.*}}, %{{.*}}
   return __blsr_u64(__X);
 }
 #endif
@@ -186,49 +188,49 @@ unsigned int test_blsr_u32(unsigned int 

[clang] 76cff3b - [clang][Sema] NormalizedConstraint - fix MSVC "not all control paths return a value" warnings. NFC. (#162004)

2025-10-17 Thread via cfe-commits

Author: Simon Pilgrim
Date: 2025-10-05T11:16:31Z
New Revision: 76cff3bcdbe945c053f4c3a7d9c99c7c2ae2bb10

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

LOG: [clang][Sema] NormalizedConstraint - fix MSVC "not all control paths 
return a value" warnings. NFC. (#162004)

Added: 


Modified: 
clang/include/clang/Sema/SemaConcept.h

Removed: 




diff  --git a/clang/include/clang/Sema/SemaConcept.h 
b/clang/include/clang/Sema/SemaConcept.h
index 51ca1e16331f5..bdd997b18cb08 100644
--- a/clang/include/clang/Sema/SemaConcept.h
+++ b/clang/include/clang/Sema/SemaConcept.h
@@ -257,6 +257,7 @@ struct NormalizedConstraint {
 case ConstraintKind::FoldExpanded:
   return FoldExpanded.Pattern->getBeginLoc();
 }
+llvm_unreachable("Unknown ConstraintKind enum");
   }
 
   SourceLocation getEndLoc() const {
@@ -270,6 +271,7 @@ struct NormalizedConstraint {
 case ConstraintKind::FoldExpanded:
   return FoldExpanded.Pattern->getEndLoc();
 }
+llvm_unreachable("Unknown ConstraintKind enum");
   }
 
   SourceRange getSourceRange() const { return {getBeginLoc(), getEndLoc()}; }



___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clangd] Fix off-by-one error in CommandMangler (PR #160029)

2025-10-17 Thread Nathan Ridge via cfe-commits

https://github.com/HighCommander4 closed 
https://github.com/llvm/llvm-project/pull/160029
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [RISCV] Add missing CHECK lines for Zkt to sifive-p450/p470/p670 test. NFC (PR #161393)

2025-10-17 Thread Sam Elliott via cfe-commits

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

LGTM

https://github.com/llvm/llvm-project/pull/161393
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [DirectX] Fix Flags validation to prevent casting into enum (PR #161587)

2025-10-17 Thread Deric C. via cfe-commits

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


https://github.com/llvm/llvm-project/pull/161587
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [OpenMP][docs] Update OpenMP 6.0 OMP_AVAILABLE_DEVICES status (PR #162440)

2025-10-17 Thread Michael Klemm via cfe-commits

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

LGTM

https://github.com/llvm/llvm-project/pull/162440
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Headers][X86] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - allow PALIGNR byte shift intrinsics to be used in constexpr (PR #162005)

2025-10-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-x86

Author: Ye Tian (TianYe717)


Changes

Fixes [issue](https://github.com/llvm/llvm-project/issues/160509)

---

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


8 Files Affected:

- (modified) clang/include/clang/Basic/BuiltinsX86.td (+6-4) 
- (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+77) 
- (modified) clang/lib/AST/ExprConstant.cpp (+62) 
- (modified) clang/test/CodeGen/X86/avx2-builtins.c (+2) 
- (modified) clang/test/CodeGen/X86/avx512bw-builtins.c (+4) 
- (modified) clang/test/CodeGen/X86/avx512vlbw-builtins.c (+6) 
- (modified) clang/test/CodeGen/X86/mmx-builtins.c (+2) 
- (modified) clang/test/CodeGen/X86/ssse3-builtins.c (+2) 


``diff
diff --git a/clang/include/clang/Basic/BuiltinsX86.td 
b/clang/include/clang/Basic/BuiltinsX86.td
index a0181b7ae8f9d..9f361b7613a3d 100644
--- a/clang/include/clang/Basic/BuiltinsX86.td
+++ b/clang/include/clang/Basic/BuiltinsX86.td
@@ -280,7 +280,7 @@ let Features = "sse2", Attributes = [NoThrow, Const, 
RequiredVectorWidth<128>] i
   def psllq128 : X86Builtin<"_Vector<2, long long int>(_Vector<2, long long 
int>, _Vector<2, long long int>)">;
   def pmaddwd128 : X86Builtin<"_Vector<4, int>(_Vector<8, short>, _Vector<8, 
short>)">;
   def pslldqi128_byteshift : X86Builtin<"_Vector<16, char>(_Vector<16, char>, 
_Constant int)">;
-  def psrldqi128_byteshift : X86Builtin<"_Vector<16, char>(_Vector<16, char>, 
_Constant int)">;
+
 }
 
 let Features = "sse2",
@@ -297,6 +297,8 @@ let Features = "sse2",
 
   def psrawi128 : X86Builtin<"_Vector<8, short>(_Vector<8, short>, int)">;
   def psradi128 : X86Builtin<"_Vector<4, int>(_Vector<4, int>, int)">;
+
+  def psrldqi128_byteshift : X86Builtin<"_Vector<16, char>(_Vector<16, char>, 
_Constant int)">;
 }
 
 let Features = "sse3", Attributes = [NoThrow] in {
@@ -308,7 +310,7 @@ let Features = "sse3", Attributes = [NoThrow, 
RequiredVectorWidth<128>] in {
   def lddqu : X86Builtin<"_Vector<16, char>(char const *)">;
 }
 
-let Features = "ssse3", Attributes = [NoThrow, Const, 
RequiredVectorWidth<128>] in {
+let Features = "ssse3", Attributes = [NoThrow, Const, Constexpr, 
RequiredVectorWidth<128>] in {
   def palignr128 : X86Builtin<"_Vector<16, char>(_Vector<16, char>, 
_Vector<16, char>, _Constant int)">;
 }
 
@@ -574,7 +576,6 @@ let Features = "avx", Attributes = [NoThrow, Const, 
Constexpr, RequiredVectorWid
 
 let Features = "avx2", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] 
in {
   def mpsadbw256 : X86Builtin<"_Vector<32, char>(_Vector<32, char>, 
_Vector<32, char>, _Constant char)">;
-  def palignr256 : X86Builtin<"_Vector<32, char>(_Vector<32, char>, 
_Vector<32, char>, _Constant int)">;
   def phaddw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, 
_Vector<16, short>)">;
   def phaddd256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Vector<8, 
int>)">;
   def phaddsw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, 
_Vector<16, short>)">;
@@ -610,6 +611,7 @@ let Features = "avx2", Attributes = [NoThrow, Const, 
RequiredVectorWidth<256>] i
 
 
 let Features = "avx2", Attributes = [NoThrow, Const, Constexpr, 
RequiredVectorWidth<256>] in {
+  def palignr256 : X86Builtin<"_Vector<32, char>(_Vector<32, char>, 
_Vector<32, char>, _Constant int)">;
   def pavgb256 : X86Builtin<"_Vector<32, unsigned char>(_Vector<32, unsigned 
char>, _Vector<32, unsigned char>)">;
   def pavgw256 : X86Builtin<"_Vector<16, unsigned short>(_Vector<16, unsigned 
short>, _Vector<16, unsigned short>)">;
 
@@ -3232,7 +3234,7 @@ let Features = "avx512bw", Attributes = [NoThrow, Const] 
in {
   def kmovq : X86Builtin<"unsigned long long int(unsigned long long int)">;
 }
 
-let Features = "avx512bw", Attributes = [NoThrow, Const, 
RequiredVectorWidth<512>] in {
+let Features = "avx512bw", Attributes = [NoThrow, Const, Constexpr, 
RequiredVectorWidth<512>] in {
   def palignr512 : X86Builtin<"_Vector<64, char>(_Vector<64, char>, 
_Vector<64, char>, _Constant int)">;
 }
 
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 68ebfdf27ba43..1a51b6d3bb802 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -2975,6 +2975,75 @@ static bool interp__builtin_vec_set(InterpState &S, 
CodePtr OpPC,
   return true;
 }
 
+static bool interp__builtin_x86_psrldq_byteshift(InterpState &S, CodePtr OpPC,
+ const CallExpr *Call,
+ unsigned ID) {
+  assert(Call->getNumArgs() == 2);
+
+  APSInt ImmAPS = popToAPSInt(S, Call->getArg(1));
+  uint64_t Shift = ImmAPS.getZExtValue();
+
+  const Pointer &Concat = S.Stk.pop();
+  if (!Concat.getFieldDesc()->isPrimitiveArray())
+return false;
+
+  unsigned NumElems = Concat.getNumElems();
+  const Pointer &Dst = S.Stk.peek();
+  PrimType ElemPT = Concat.getFie

[clang] [clang][Driver][RISCV] Rename `getRISCFeaturesFromMcpu`. NFCI (PR #162545)

2025-10-17 Thread Min-Yih Hsu via cfe-commits

https://github.com/mshockwave created 
https://github.com/llvm/llvm-project/pull/162545

This function, which has a typo in the name btw, is no longer doing what it was 
created to do: instead of deducting non-extension target features from `-mcpu` 
-- a task that was (more or less) subsumed by `riscv::getRISCVTargetFeatures` 
-- it is only checking if the `-mcpu` value is valid or not now. Therefore, 
this patch renames it into `isValidRISCVCPU` and exits early if it's not.

NFCI.

>From 396a0229847546d4058c3f1ade591748e5ddfdf3 Mon Sep 17 00:00:00 2001
From: Min-Yih Hsu 
Date: Wed, 8 Oct 2025 13:22:55 -0700
Subject: [PATCH] [clang][Driver][RISCV] Rename `getRISCFeaturesFromMcpu`. NFCI

---
 clang/lib/Driver/ToolChains/Arch/RISCV.cpp | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index 76dde0da8e849..f2e79e71f93d4 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -49,11 +49,8 @@ static bool getArchFeatures(const Driver &D, StringRef Arch,
   return true;
 }
 
-// Get features except standard extension feature
-static void getRISCFeaturesFromMcpu(const Driver &D, const Arg *A,
-const llvm::Triple &Triple,
-StringRef Mcpu,
-std::vector &Features) {
+static bool isValidRISCVCPU(const Driver &D, const Arg *A,
+const llvm::Triple &Triple, StringRef Mcpu) {
   bool Is64Bit = Triple.isRISCV64();
   if (!llvm::RISCV::parseCPU(Mcpu, Is64Bit)) {
 // Try inverting Is64Bit in case the CPU is valid, but for the wrong 
target.
@@ -63,7 +60,9 @@ static void getRISCFeaturesFromMcpu(const Driver &D, const 
Arg *A,
 else
   D.Diag(clang::diag::err_drv_unsupported_option_argument)
   << A->getSpelling() << Mcpu;
+return false;
   }
+  return true;
 }
 
 void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple,
@@ -84,7 +83,8 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
 if (CPU == "native")
   CPU = llvm::sys::getHostCPUName();
 
-getRISCFeaturesFromMcpu(D, A, Triple, CPU, Features);
+if (!isValidRISCVCPU(D, A, Triple, CPU))
+  return;
 
 if (llvm::RISCV::hasFastScalarUnalignedAccess(CPU))
   CPUFastScalarUnaligned = true;

___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Implement Unary real & imag on scalar expr (PR #159916)

2025-10-17 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/159916

>From c2fd4826027f715829f638c8b1ba67146d3512f9 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 20 Sep 2025 13:03:39 +0200
Subject: [PATCH 1/2] [CIR] Implement Unary real & imag on scalar expr

---
 clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp | 20 -
 clang/test/CIR/CodeGen/complex.cpp | 85 +-
 2 files changed, 100 insertions(+), 5 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
index 85f73fa214eec..3b22c689ecd9f 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
@@ -2140,11 +2140,23 @@ mlir::Value ScalarExprEmitter::VisitRealImag(const 
UnaryOperator *e,
: builder.createComplexImag(loc, complex);
   }
 
-  // __real or __imag on a scalar returns zero. Emit the subexpr to ensure side
+  if (e->getOpcode() == UO_Real) {
+return promotionTy.isNull() ? Visit(op)
+: cgf.emitPromotedScalarExpr(op, promotionTy);
+  }
+
+  // __imag on a scalar returns zero. Emit the subexpr to ensure side
   // effects are evaluated, but not the actual value.
-  cgf.cgm.errorNYI(e->getSourceRange(),
-   "VisitRealImag __real or __imag on a scalar");
-  return {};
+  if (op->isGLValue())
+cgf.emitLValue(op);
+  else if (!promotionTy.isNull())
+cgf.emitPromotedScalarExpr(op, promotionTy);
+  else
+cgf.emitScalarExpr(op);
+
+  mlir::Type valueTy =
+  cgf.convertType(promotionTy.isNull() ? e->getType() : promotionTy);
+  return builder.getNullValue(valueTy, loc);
 }
 
 /// Return the size or alignment of the type of argument of the sizeof
diff --git a/clang/test/CIR/CodeGen/complex.cpp 
b/clang/test/CIR/CodeGen/complex.cpp
index b6fcd5210ad34..1d3c10a9cb5bc 100644
--- a/clang/test/CIR/CodeGen/complex.cpp
+++ b/clang/test/CIR/CodeGen/complex.cpp
@@ -1092,4 +1092,87 @@ void imag_on_non_glvalue() {
 // OGCG: %[[A_REAL:.*]] = load float, ptr %[[A_REAL_PTR]], align 4
 // OGCG: %[[A_IMAG_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr 
%[[A_ADDR]], i32 0, i32 1
 // OGCG: %[[A_IMAG:.*]] = load float, ptr %[[A_IMAG_PTR]], align 4
-// OGCG: store float %[[A_IMAG]], ptr %[[B_ADDR]], align 4
\ No newline at end of file
+// OGCG: store float %[[A_IMAG]], ptr %[[B_ADDR]], align 4
+
+void real_glvalue() {
+  float a;
+  float b = __real__ a;
+}
+
+// CIR: %[[A_ADDR:.*]] = cir.alloca !cir.float, !cir.ptr, ["a"]
+// CIR: %[[B_ADDR:.*]] = cir.alloca !cir.float, !cir.ptr, ["b", 
init]
+// CIR: %[[TMP_A:.*]] = cir.load{{.*}} %[[A_ADDR]] : !cir.ptr, 
!cir.float
+// CIR: cir.store{{.*}} %[[TMP_A]], %[[B_ADDR]] : !cir.float, 
!cir.ptr
+
+// LLVM: %[[A_ADDR:.*]] = alloca float, i64 1, align 4
+// LLVM: %[[B_ADDR:.*]] = alloca float, i64 1, align 4
+// LLVM: %[[TMP_A:.*]] = load float, ptr %[[A_ADDR]], align 4
+// LLVM: store float %[[TMP_A]], ptr %[[B_ADDR]], align 4
+
+// OGCG: %[[A_ADDR:.*]] = alloca float, align 4
+// OGCG: %[[B_ADDR:.*]] = alloca float, align 4
+// OGCG: %[[TMP_A:.*]] = load float, ptr %[[A_ADDR]], align 4
+// OGCG: store float %[[TMP_A]], ptr %[[B_ADDR]], align 4
+
+void imag_glvalue() {
+  float a;
+  float b = __imag__ a;
+}
+
+// CIR: %[[A_ADDR:.*]] = cir.alloca !cir.float, !cir.ptr, ["a"]
+// CIR: %[[B_ADDR:.*]] = cir.alloca !cir.float, !cir.ptr, ["b", 
init]
+// CIR: %[[CONST_ZERO:.*]] = cir.const #cir.fp<0.00e+00> : !cir.float
+// CIR: cir.store{{.*}} %[[CONST_ZERO]], %[[B_ADDR]] : !cir.float, 
!cir.ptr
+
+// LLVM: %[[A_ADDR:.*]] = alloca float, i64 1, align 4
+// LLVM: %[[B_ADDR:.*]] = alloca float, i64 1, align 4
+// LLVM: store float 0.00e+00, ptr %[[B_ADDR]], align 4
+
+// OGCG: %[[A_ADDR:.*]] = alloca float, align 4
+// OGCG: %[[B_ADDR:.*]] = alloca float, align 4
+// OGCG: store float 0.00e+00, ptr %[[B_ADDR]], align 4
+
+void real_glvalue_with_type_promotion() {
+  _Float16 a;
+  _Float16 b = __real__ a;
+}
+
+// CIR: %[[A_ADDR:.*]] = cir.alloca !cir.f16, !cir.ptr, ["a"]
+// CIR: %[[B_ADDR:.*]] = cir.alloca !cir.f16, !cir.ptr, ["b", init]
+// CIR: %[[TMP_A:.*]] = cir.load{{.*}} %[[A_ADDR]] : !cir.ptr, 
!cir.f16
+// CIR: %[[TMP_A_F32:.*]] = cir.cast(floating, %[[TMP_A]] : !cir.f16), 
!cir.float
+// CIR: %[[TMP_A_F16:.*]] = cir.cast(floating, %[[TMP_A_F32]] : !cir.float), 
!cir.f16
+// CIR: cir.store{{.*}} %[[TMP_A_F16]], %[[B_ADDR]] : !cir.f16, 
!cir.ptr
+
+// LLVM: %[[A_ADDR:.*]] = alloca half, i64 1, align 2
+// LLVM: %[[B_ADDR:.*]] = alloca half, i64 1, align 2
+// LLVM: %[[TMP_A:.*]] = load half, ptr %[[A_ADDR]], align 2
+// LLVM: %[[TMP_A_F32:.*]] = fpext half %[[TMP_A]] to float
+// LLVM: %[[TMP_A_F16:.*]] = fptrunc float %[[TMP_A_F32]] to half
+// LLVM: store half %[[TMP_A_F16]], ptr %[[B_ADDR]], align 2
+
+// OGCG: %[[A_ADDR:.*]] = alloca half, align 2
+// OGCG: %[[B_ADDR:.*]] = alloca half, align 2
+// OGCG: %[[TMP_A:.*]] = load half, ptr %[[A_ADDR]], align 2
+

[clang] [CIR][NFC] Fix CIR build (PR #161577)

2025-10-17 Thread Andy Kaylor via cfe-commits

https://github.com/andykaylor created 
https://github.com/llvm/llvm-project/pull/161577

This fixes the CIR build after recent changes to CharUnits.

>From 56c7e1737814515c2cf7992302b1040e043d78af Mon Sep 17 00:00:00 2001
From: Andy Kaylor 
Date: Wed, 1 Oct 2025 13:12:58 -0700
Subject: [PATCH] [CIR][NFC] Fix CIR build

This fixes the CIR build after recent changes to CharUnits.
---
 clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp 
b/clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp
index a7628816089d0..bf812c8a1793b 100644
--- a/clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp
@@ -615,7 +615,7 @@ void CIRRecordLowering::determinePacked(bool nvBaseType) {
   continue;
 // If any member falls at an offset that it not a multiple of its 
alignment,
 // then the entire record must be packed.
-if (member.offset % getAlignment(member.data))
+if (!member.offset.isMultipleOf(getAlignment(member.data)))
   packed = true;
 if (member.offset < nvSize)
   nvAlignment = std::max(nvAlignment, getAlignment(member.data));
@@ -623,12 +623,12 @@ void CIRRecordLowering::determinePacked(bool nvBaseType) {
   }
   // If the size of the record (the capstone's offset) is not a multiple of the
   // record's alignment, it must be packed.
-  if (members.back().offset % alignment)
+  if (!members.back().offset.isMultipleOf(alignment))
 packed = true;
   // If the non-virtual sub-object is not a multiple of the non-virtual
   // sub-object's alignment, it must be packed.  We cannot have a packed
   // non-virtual sub-object and an unpacked complete object or vise versa.
-  if (nvSize % nvAlignment)
+  if (!nvSize.isMultipleOf(nvAlignment))
 packed = true;
   // Update the alignment of the sentinel.
   if (!packed)

___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy][NFC] Update list.rst (PR #162698)

2025-10-17 Thread Davide Cunial via cfe-commits

https://github.com/capitan-davide updated 
https://github.com/llvm/llvm-project/pull/162698

>From fac9b777f3c17ef212cc664cbebf1615b5a72684 Mon Sep 17 00:00:00 2001
From: Davide Cunial 
Date: Thu, 9 Oct 2025 18:51:09 +0200
Subject: [PATCH] [clang-tidy][NFC] Update list.rst

The check 'readability-braces-around-statements' do offer fixes!
---
 clang-tools-extra/docs/clang-tidy/checks/list.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst 
b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index c490d2ece2e0a..7f7857ad39908 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -370,7 +370,7 @@ Clang-Tidy Checks
:doc:`readability-avoid-nested-conditional-operator 
`,
:doc:`readability-avoid-return-with-void-value 
`, "Yes"
:doc:`readability-avoid-unconditional-preprocessor-if 
`,
-   :doc:`readability-braces-around-statements 
`,
+   :doc:`readability-braces-around-statements 
`, "Yes"
:doc:`readability-const-return-type `, "Yes"
:doc:`readability-container-contains `, 
"Yes"
:doc:`readability-container-data-pointer 
`, "Yes"

___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix a crash on BAS_BlockIndent (PR #164047)

2025-10-17 Thread via cfe-commits

https://github.com/owenca created 
https://github.com/llvm/llvm-project/pull/164047

The crash was introduced in commit 413a7cb6e0db96b29bda0dab8541e225193ad139.

Fixes #163355

>From 04b95ad719b5443ee000ff598b10eded14103c29 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Fri, 17 Oct 2025 20:07:23 -0700
Subject: [PATCH] [clang-format] Fix a crash on BAS_BlockIndent

The crash was introduced in commit 413a7cb6e0db96b29bda0dab8541e225193ad139.

Fixes #163355
---
 clang/lib/Format/ContinuationIndenter.cpp|  2 +-
 clang/lib/Format/FormatToken.cpp |  3 ++-
 clang/unittests/Format/AlignBracketsTest.cpp | 13 +
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index cd4c1aabac971..b7d85693b2082 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -411,7 +411,7 @@ bool ContinuationIndenter::mustBreak(const LineState 
&State) {
   }
   if (CurrentState.BreakBeforeClosingBrace &&
   (Current.closesBlockOrBlockTypeList(Style) ||
-   (Current.is(tok::r_brace) &&
+   (Current.is(tok::r_brace) && Current.MatchingParen &&
 Current.isBlockIndentedInitRBrace(Style {
 return true;
   }
diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp
index c2956a179b8ed..222d521d52df9 100644
--- a/clang/lib/Format/FormatToken.cpp
+++ b/clang/lib/Format/FormatToken.cpp
@@ -66,12 +66,13 @@ bool FormatToken::isTypeOrIdentifier(const LangOptions 
&LangOpts) const {
 
 bool FormatToken::isBlockIndentedInitRBrace(const FormatStyle &Style) const {
   assert(is(tok::r_brace));
+  assert(MatchingParen);
+  assert(MatchingParen->is(tok::l_brace));
   if (!Style.Cpp11BracedListStyle ||
   Style.AlignAfterOpenBracket != FormatStyle::BAS_BlockIndent) {
 return false;
   }
   const auto *LBrace = MatchingParen;
-  assert(LBrace && LBrace->is(tok::l_brace));
   if (LBrace->is(BK_BracedInit))
 return true;
   if (LBrace->Previous && LBrace->Previous->is(tok::equal))
diff --git a/clang/unittests/Format/AlignBracketsTest.cpp 
b/clang/unittests/Format/AlignBracketsTest.cpp
index c4380ae415751..ea8db51a4d18e 100644
--- a/clang/unittests/Format/AlignBracketsTest.cpp
+++ b/clang/unittests/Format/AlignBracketsTest.cpp
@@ -778,6 +778,19 @@ TEST_F(AlignBracketsTest, ParenthesesAndOperandAlignment) {
Style);
 }
 
+TEST_F(AlignBracketsTest, BlockIndentAndNamespace) {
+  auto Style = getLLVMStyleWithColumns(120);
+  Style.AllowShortNamespacesOnASingleLine = true;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+
+  verifyNoCrash(
+  "namespace {\n"
+  "void x(n::T const *,\n"
+  "   Y &yy);\n"
+  "} //",
+  Style);
+}
+
 } // namespace
 } // namespace test
 } // namespace format

___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libclc] [libclc] Remove -fno-builtin from compile options (PR #162075)

2025-10-17 Thread Mészáros Gergely via cfe-commits

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


https://github.com/llvm/llvm-project/pull/162075
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [OpenACC][CIR] Reduction combiner lowering for min/max (PR #163656)

2025-10-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Erich Keane (erichkeane)


Changes

These two are lowered as if they are the expression: LHS = (LHS < RHS ) ? 
RHS : LHS;
and
LHS = (LHS < RHS ) ? LHS : RHS;

This patch generates these expressions and ensures they are properly emitted 
into IR.

Note: this is dependent on https://github.com/llvm/llvm-project/pull/163580
and cannot be merged until that one is (or the tests will fail).

---

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


25 Files Affected:

- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+3) 
- (modified) clang/lib/CIR/CodeGen/CIRGenOpenACCRecipe.cpp (+5-2) 
- (modified) clang/lib/Sema/SemaOpenACC.cpp (+80-13) 
- (modified) 
clang/test/CIR/CodeGenOpenACC/combined-reduction-clause-default-ops.cpp 
(+532-4) 
- (modified) clang/test/CIR/CodeGenOpenACC/combined-reduction-clause-float.cpp 
(+158-6) 
- (modified) 
clang/test/CIR/CodeGenOpenACC/combined-reduction-clause-inline-ops.cpp (+136-6) 
- (modified) clang/test/CIR/CodeGenOpenACC/combined-reduction-clause-int.cpp 
(+158-6) 
- (modified) 
clang/test/CIR/CodeGenOpenACC/combined-reduction-clause-outline-ops.cpp 
(+137-7) 
- (modified) 
clang/test/CIR/CodeGenOpenACC/compute-reduction-clause-default-ops.c (+553-4) 
- (modified) 
clang/test/CIR/CodeGenOpenACC/compute-reduction-clause-default-ops.cpp (+532-4) 
- (modified) clang/test/CIR/CodeGenOpenACC/compute-reduction-clause-float.c 
(+159-6) 
- (modified) clang/test/CIR/CodeGenOpenACC/compute-reduction-clause-float.cpp 
(+158-5) 
- (modified) 
clang/test/CIR/CodeGenOpenACC/compute-reduction-clause-inline-ops.cpp (+136-6) 
- (modified) clang/test/CIR/CodeGenOpenACC/compute-reduction-clause-int.c 
(+158-6) 
- (modified) clang/test/CIR/CodeGenOpenACC/compute-reduction-clause-int.cpp 
(+158-6) 
- (modified) 
clang/test/CIR/CodeGenOpenACC/compute-reduction-clause-outline-ops.cpp (+136-6) 
- (modified) 
clang/test/CIR/CodeGenOpenACC/compute-reduction-clause-unsigned-int.c (+158-6) 
- (modified) 
clang/test/CIR/CodeGenOpenACC/loop-reduction-clause-default-ops.cpp (+532-4) 
- (modified) clang/test/CIR/CodeGenOpenACC/loop-reduction-clause-float.cpp 
(+158-6) 
- (modified) clang/test/CIR/CodeGenOpenACC/loop-reduction-clause-inline-ops.cpp 
(+136-6) 
- (modified) clang/test/CIR/CodeGenOpenACC/loop-reduction-clause-int.cpp 
(+158-6) 
- (modified) 
clang/test/CIR/CodeGenOpenACC/loop-reduction-clause-outline-ops.cpp (+136-6) 
- (modified) clang/test/SemaOpenACC/combined-construct-reduction-clause.cpp 
(+5-3) 
- (modified) clang/test/SemaOpenACC/compute-construct-reduction-clause.c 
(+11-7) 
- (modified) clang/test/SemaOpenACC/compute-construct-reduction-clause.cpp 
(+11-6) 


``diff
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 40bc7b9a4e45e..a1f3292715b32 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -13670,6 +13670,9 @@ def err_acc_reduction_recipe_no_op
 "not have a valid operation available">;
 def note_acc_reduction_recipe_noop_field
 : Note<"while forming combiner for compound type %0">;
+def note_acc_reduction_combiner_forming
+: Note<"while forming %select{|binary operator '%1'|conditional "
+   "operator|final assignment operator}0">;
 
 // AMDGCN builtins diagnostics
 def err_amdgcn_load_lds_size_invalid_value : Error<"invalid size value">;
diff --git a/clang/lib/CIR/CodeGen/CIRGenOpenACCRecipe.cpp 
b/clang/lib/CIR/CodeGen/CIRGenOpenACCRecipe.cpp
index f638d391d55cd..be063033ddcfc 100644
--- a/clang/lib/CIR/CodeGen/CIRGenOpenACCRecipe.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenOpenACCRecipe.cpp
@@ -590,15 +590,18 @@ void 
OpenACCRecipeBuilderBase::createReductionRecipeCombiner(
   } else {
 // else we have to handle each individual field after after a
 // get-element.
+const CIRGenRecordLayout &layout =
+cgf.cgm.getTypes().getCIRGenRecordLayout(rd);
 for (const auto &[field, combiner] :
  llvm::zip_equal(rd->fields(), combinerRecipes)) {
   mlir::Type fieldType = cgf.convertType(field->getType());
   auto fieldPtr = cir::PointerType::get(fieldType);
+  unsigned fieldIndex = layout.getCIRFieldNo(field);
 
   mlir::Value lhsField = builder.createGetMember(
-  loc, fieldPtr, lhsArg, field->getName(), field->getFieldIndex());
+  loc, fieldPtr, lhsArg, field->getName(), fieldIndex);
   mlir::Value rhsField = builder.createGetMember(
-  loc, fieldPtr, rhsArg, field->getName(), field->getFieldIndex());
+  loc, fieldPtr, rhsArg, field->getName(), fieldIndex);
 
   emitSingleCombiner(lhsField, rhsField, combiner);
 }
diff --git a/clang/lib/Sema/SemaOpenACC.cpp b/clang/lib/Sema/SemaOpenACC.cpp
index ca99834ce8266..3bb8080f6e72c 

[clang] [Clang] Ensure initialized NTTP expressions when building CTAD for type aliases (PR #161035)

2025-10-17 Thread Younan Zhang via cfe-commits


@@ -1171,17 +1171,46 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
   Args.addOuterTemplateArguments(TransformedDeducedAliasArgs);
   for (unsigned Index = 0; Index < DeduceResults.size(); ++Index) {
 const auto &D = DeduceResults[Index];
+auto *TP = F->getTemplateParameters()->getParam(Index);
 if (IsNonDeducedArgument(D)) {
   // 2): Non-deduced template parameters would be substituted later.
   continue;
 }
 TemplateArgumentLoc Input =
 SemaRef.getTrivialTemplateArgumentLoc(D, QualType(), SourceLocation{});
-TemplateArgumentLoc Output;
-if (!SemaRef.SubstTemplateArgument(Input, Args, Output)) {
-  assert(TemplateArgsForBuildingFPrime[Index].isNull() &&
- "InstantiatedArgs must be null before setting");
-  TemplateArgsForBuildingFPrime[Index] = Output.getArgument();
+TemplateArgumentListInfo Output;
+if (SemaRef.SubstTemplateArguments(Input, Args, Output))
+  return nullptr;
+assert(TemplateArgsForBuildingFPrime[Index].isNull() &&
+   "InstantiatedArgs must be null before setting");
+// CheckTemplateArgument is necessary for NTTP initializations.
+// FIXME: We may want to call CheckTemplateArguments instead, but we cannot
+// match packs as usual, since packs can appear in the middle of the
+// parameter list of a synthesized CTAD guide. See also the FIXME in
+// test/SemaCXX/cxx20-ctad-type-alias.cpp:test25.
+Sema::CheckTemplateArgumentInfo CTAI;
+if (Input.getArgument().getKind() == TemplateArgument::Pack) {
+  for (auto TA : Output.arguments()) {
+if (SemaRef.CheckTemplateArgument(
+TP, TA, F, F->getLocation(), F->getLocation(),
+/*ArgumentPackIndex=*/-1, CTAI,
+Sema::CheckTemplateArgumentKind::CTAK_Specified))
+  return nullptr;
+  }
+  // We will substitute the non-deduced template arguments with these
+  // transformed (unpacked at this point) arguments, where that 
substitution
+  // requires a pack for the corresponding parameter packs.
+  TemplateArgsForBuildingFPrime[Index] =
+  TemplateArgument::CreatePackCopy(Context, CTAI.SugaredConverted);
+} else {
+  assert(Output.arguments().size() == 1);
+  TemplateArgumentLoc Transformed = Output.arguments()[0];
+  if (SemaRef.CheckTemplateArgument(

zyn0217 wrote:

Thanks, I filed https://github.com/llvm/llvm-project/pull/161948

https://github.com/llvm/llvm-project/pull/161035
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [Clang] Normalize constraints before checking for satisfaction (PR #161671)

2025-10-17 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

finally, here's the reduced repro @zyn0217 
```
$ cat /tmp/a.cc
template 
concept a = requires { requires true; };
template 
concept b = a;
template 
concept c = requires { b; };
template 
  requires c
struct s;
template  void f();
template  constexpr bool d = f;
struct s2;
static_assert(d>);
$ clang++ -fsyntax-only /tmp/a.cc -std=c++20
Should not have a NULL template argument
UNREACHABLE executed at ../../clang/lib/AST/TemplateBase.cpp:265!
```

https://github.com/llvm/llvm-project/pull/161671
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][modules-driver] Add dependency scan and dependency graph (PR #152770)

2025-10-17 Thread Michael Spencer via cfe-commits


@@ -0,0 +1,1579 @@
+//===--- Driver.cpp - Clang GCC Compatible Driver 
-===//
+//
+// 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
+//
+//===--===//
+///
+/// \file
+/// This file defines functionality to support driver managed builds for
+/// compilations which use Clang modules or standard C++20 named modules.
+///
+//===--===//
+
+#include "clang/Driver/ModulesDriver.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticDriver.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/Job.h"
+#include "clang/Driver/Options.h"
+#include "clang/Driver/Tool.h"
+#include "clang/Lex/DependencyDirectivesScanner.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Tooling/DependencyScanning/DependencyScanningService.h"
+#include "clang/Tooling/DependencyScanning/DependencyScanningTool.h"
+#include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
+#include "clang/Tooling/DependencyScanning/ModuleDepCollector.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DirectedGraph.h"
+#include "llvm/ADT/GraphTraits.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallBitVector.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/TypeSwitch.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/Option.h"
+#include "llvm/Support/Allocator.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/DOTGraphTraits.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/GraphWriter.h"
+#include "llvm/Support/JSON.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/ThreadPool.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+using namespace llvm::opt;
+
+namespace clang::driver::modules {
+using JobVector = JobList::list_type;
+
+// The tooling::deps namespace has conflicting names with clang::driver, we
+// therefore introduce only the required tooling::deps namespace members into
+// this namespace.
+using tooling::dependencies::DependencyActionController;
+using tooling::dependencies::DependencyScanningService;
+using tooling::dependencies::DependencyScanningWorker;
+using tooling::dependencies::FullDependencyConsumer;
+using tooling::dependencies::ModuleDeps;
+using tooling::dependencies::ModuleDepsGraph;
+using tooling::dependencies::ModuleID;
+using tooling::dependencies::ModuleOutputKind;
+using tooling::dependencies::ScanningMode;
+using tooling::dependencies::ScanningOutputFormat;
+using tooling::dependencies::TranslationUnitDeps;
+
+/// Returns true if any source input is of type c++-module.
+static bool hasCXXNamedModuleInput(const InputList &Inputs) {
+  const auto IsTypeCXXModule = [](const auto &Input) -> bool {
+const auto TypeID = Input.first;
+return (TypeID == types::TY_CXXModule);
+  };
+  return any_of(Inputs, IsTypeCXXModule);
+}
+
+/// Scan the leading lines of each C++ source file until C++20 named module
+/// usage is detected.
+///
+/// \returns true if module usage is detected, false otherwise, or a
+/// llvm::FileError on read failure.
+static Expected scanForCXXNamedModuleUsage(const InputList &Inputs,
+ llvm::vfs::FileSystem &VFS,
+ DiagnosticsEngine &Diags) {
+  const auto CXXInputs = make_filter_range(
+  Inputs, [](const InputTy &Input) { return types::isCXX(Input.first); });
+  for (const auto &Input : CXXInputs) {
+auto Filename = Input.second->getSpelling();
+auto MemBufOrErr = VFS.getBufferForFile(Filename);
+if (!MemBufOrErr)
+  return llvm::createFileError(Filename, MemBufOrErr.getError());
+const auto MemBuf = std::move(*MemBufOrErr);
+
+// Scan the buffer using the dependency directives scanner.
+if (clang::scanInputForCXXNamedModulesUsage(MemBuf->getBuffer())) {
+  Diags.Report(diag::remark_found_cxx20_module_usage) << Filename;
+  return true;
+}
+  }
+  return false;
+}
+
+Expected shouldUseModulesDriver(const InputList &Inputs,
+  llvm::vfs::FileSystem &FS,
+  DiagnosticsEngine &Diags) {
+  if (Inputs.size() < 2)
+return false;
+  if (hasCXXNamedModuleInput(Inputs))
+return true;
+  return scanForCXXNamedModuleUsage(Inputs, FS, Diags);
+}
+
+static bool fromJSON(const llvm::json::Value &Params,
+ StdModuleManifest::LocalModuleArgs &LocalArgs,
+ llvm::json

[clang] [Clang] Do not warn on UTF-16 -> UTF-32 conversions. (PR #163927)

2025-10-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Corentin Jabot (cor3ntin)


Changes

UTF-16 to UTF-16 conversions seems widespread,
and lone surrogate have a distinct representation in UTF-32.

Lets not warn on this case to make the warning easier to adopt. This follows 
SG-16 guideline

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3695r2.html#changes-since-r1

Fixes #163719

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


2 Files Affected:

- (modified) clang/lib/Sema/SemaChecking.cpp (+8-1) 
- (modified) clang/test/SemaCXX/warn-implicit-unicode-conversions.cpp (+4-4) 


``diff
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 4f409ca0f414d..0300d09be0420 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -12309,13 +12309,20 @@ static void 
DiagnoseMixedUnicodeImplicitConversion(Sema &S, const Type *Source,
SourceLocation CC) {
   assert(Source->isUnicodeCharacterType() && Target->isUnicodeCharacterType() 
&&
  Source != Target);
+
+  // Lone surrogates have a distinct representation in UTF-32.
+  // Converting betweem UTF-16 and UTF-32 codepoint seems very widespread,
+  // so don't warn on such conversion.
+  if(Source->isChar16Type() && Target->isChar32Type())
+  return;
+
   Expr::EvalResult Result;
   if (E->EvaluateAsInt(Result, S.getASTContext(), Expr::SE_AllowSideEffects,
S.isConstantEvaluatedContext())) {
 llvm::APSInt Value(32);
 Value = Result.Val.getInt();
 bool IsASCII = Value <= 0x7F;
-bool IsBMP = Value <= 0xD7FF || (Value >= 0xE000 && Value <= 0x);
+bool IsBMP = Value <= 0xDFFF || (Value >= 0xE000 && Value <= 0x);
 bool ConversionPreservesSemantics =
 IsASCII || (!Source->isChar8Type() && !Target->isChar8Type() && IsBMP);
 
diff --git a/clang/test/SemaCXX/warn-implicit-unicode-conversions.cpp 
b/clang/test/SemaCXX/warn-implicit-unicode-conversions.cpp
index fcff006d0e028..f17f20ca25295 100644
--- a/clang/test/SemaCXX/warn-implicit-unicode-conversions.cpp
+++ b/clang/test/SemaCXX/warn-implicit-unicode-conversions.cpp
@@ -14,7 +14,7 @@ void test(char8_t u8, char16_t u16, char32_t u32) {
 c16(u32); // expected-warning {{implicit conversion from 'char32_t' to 
'char16_t' may lose precision and change the meaning of the represented code 
unit}}
 
 c32(u8);  // expected-warning {{implicit conversion from 'char8_t' to 
'char32_t' may change the meaning of the represented code unit}}
-c32(u16); // expected-warning {{implicit conversion from 'char16_t' to 
'char32_t' may change the meaning of the represented code unit}}
+c32(u16);
 c32(u32);
 
 
@@ -30,7 +30,7 @@ void test(char8_t u8, char16_t u16, char32_t u32) {
 c16(char32_t(0x7f));
 c16(char32_t(0x80));
 c16(char32_t(0xD7FF));
-c16(char32_t(0xD800)); // expected-warning {{implicit conversion from 
'char32_t' to 'char16_t' changes the meaning of the code unit '<0xD800>'}}
+c16(char32_t(0xD800));
 c16(char32_t(0xE000));
 c16(char32_t(U'🐉')); // expected-warning {{implicit conversion from 
'char32_t' to 'char16_t' changes the meaning of the code point '🐉'}}
 
@@ -44,8 +44,8 @@ void test(char8_t u8, char16_t u16, char32_t u32) {
 c32(char16_t(0x80));
 
 c32(char16_t(0xD7FF));
-c32(char16_t(0xD800)); // expected-warning {{implicit conversion from 
'char16_t' to 'char32_t' changes the meaning of the code unit '<0xD800>'}}
-c32(char16_t(0xDFFF)); // expected-warning {{implicit conversion from 
'char16_t' to 'char32_t' changes the meaning of the code unit '<0xDFFF>'}}
+c32(char16_t(0xD800));
+c32(char16_t(0xDFFF));
 c32(char16_t(0xE000));
 c32(char16_t(u'☕'));
 

``




https://github.com/llvm/llvm-project/pull/163927
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [IR] Mark vector intrinsics speculatable (PR #162334)

2025-10-17 Thread Florian Hahn via cfe-commits

https://github.com/fhahn commented:

Would be good to test this with a case where we hoist a speculative vector 
intrinsic (and not hoist the remainder/division

https://github.com/llvm/llvm-project/pull/162334
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86][Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - Allow AVX/AVX512 IFMA madd52 intrinsics to be used in constexpr (PR #161056)

2025-10-17 Thread NagaChaitanya Vellanki via cfe-commits

https://github.com/chaitanyav updated 
https://github.com/llvm/llvm-project/pull/161056

>From 76926123db7af4cb83ae478212cd31508035a4d1 Mon Sep 17 00:00:00 2001
From: NagaChaitanya Vellanki 
Date: Sun, 28 Sep 2025 00:29:57 -0700
Subject: [PATCH] [X86][Clang] VectorExprEvaluator::VisitCallExpr /
 InterpretBuiltin - Allow AVX/AVX512 IFMA madd52 intrinsics to be used in
 constexpr

Resolves #160498
---
 clang/include/clang/Basic/BuiltinsX86.td  |  14 +-
 clang/lib/AST/ByteCode/InterpBuiltin.cpp  |  15 ++
 clang/lib/AST/ExprConstant.cpp|  48 +
 clang/lib/Headers/avx512ifmaintrin.h  |  63 +++---
 clang/lib/Headers/avx512ifmavlintrin.h|  43 ++--
 clang/lib/Headers/avxifmaintrin.h |   9 +
 clang/test/CodeGen/X86/avx512ifma-builtins.c  | 199 +-
 .../test/CodeGen/X86/avx512ifmavl-builtins.c  | 182 ++--
 clang/test/CodeGen/X86/avxifma-builtins.c | 138 +---
 9 files changed, 604 insertions(+), 107 deletions(-)

diff --git a/clang/include/clang/Basic/BuiltinsX86.td 
b/clang/include/clang/Basic/BuiltinsX86.td
index a0181b7ae8f9d..7ed1c736e9c95 100644
--- a/clang/include/clang/Basic/BuiltinsX86.td
+++ b/clang/include/clang/Basic/BuiltinsX86.td
@@ -2105,24 +2105,18 @@ let Features = "avx512vl", Attributes = [NoThrow, 
RequiredVectorWidth<256>] in {
   def movdqa64store256_mask : X86Builtin<"void(_Vector<4, long long int *>, 
_Vector<4, long long int>, unsigned char)">;
 }
 
-let Features = "avx512ifma", Attributes = [NoThrow, Const, 
RequiredVectorWidth<512>] in {
+let Features = "avx512ifma", Attributes = [NoThrow, Const, Constexpr, 
RequiredVectorWidth<512>] in {
   def vpmadd52huq512 : X86Builtin<"_Vector<8, long long int>(_Vector<8, long 
long int>, _Vector<8, long long int>, _Vector<8, long long int>)">;
   def vpmadd52luq512 : X86Builtin<"_Vector<8, long long int>(_Vector<8, long 
long int>, _Vector<8, long long int>, _Vector<8, long long int>)">;
 }
 
-let Features = "avx512ifma,avx512vl|avxifma", Attributes = [NoThrow, Const, 
RequiredVectorWidth<128>] in {
+let Features = "avx512ifma,avx512vl|avxifma", Attributes = [NoThrow, Const, 
Constexpr, RequiredVectorWidth<128>] in {
   def vpmadd52huq128 : X86Builtin<"_Vector<2, long long int>(_Vector<2, long 
long int>, _Vector<2, long long int>, _Vector<2, long long int>)">;
-}
-
-let Features = "avx512ifma,avx512vl|avxifma", Attributes = [NoThrow, Const, 
RequiredVectorWidth<256>] in {
-  def vpmadd52huq256 : X86Builtin<"_Vector<4, long long int>(_Vector<4, long 
long int>, _Vector<4, long long int>, _Vector<4, long long int>)">;
-}
-
-let Features = "avx512ifma,avx512vl|avxifma", Attributes = [NoThrow, Const, 
RequiredVectorWidth<128>] in {
   def vpmadd52luq128 : X86Builtin<"_Vector<2, long long int>(_Vector<2, long 
long int>, _Vector<2, long long int>, _Vector<2, long long int>)">;
 }
 
-let Features = "avx512ifma,avx512vl|avxifma", Attributes = [NoThrow, Const, 
RequiredVectorWidth<256>] in {
+let Features = "avx512ifma,avx512vl|avxifma", Attributes = [NoThrow, Const, 
Constexpr, RequiredVectorWidth<256>] in {
+  def vpmadd52huq256 : X86Builtin<"_Vector<4, long long int>(_Vector<4, long 
long int>, _Vector<4, long long int>, _Vector<4, long long int>)">;
   def vpmadd52luq256 : X86Builtin<"_Vector<4, long long int>(_Vector<4, long 
long int>, _Vector<4, long long int>, _Vector<4, long long int>)">;
 }
 
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 6053237b1a261..be7541cba1166 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -3622,6 +3622,21 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, 
const CallExpr *Call,
   return F;
 });
 
+  case X86::BI__builtin_ia32_vpmadd52luq128:
+  case X86::BI__builtin_ia32_vpmadd52luq256:
+  case X86::BI__builtin_ia32_vpmadd52luq512:
+return interp__builtin_elementwise_triop(
+S, OpPC, Call, [](const APSInt &A, const APSInt &B, const APSInt &C) {
+  return A + (B.trunc(52) * C.trunc(52)).zext(64);
+});
+  case X86::BI__builtin_ia32_vpmadd52huq128:
+  case X86::BI__builtin_ia32_vpmadd52huq256:
+  case X86::BI__builtin_ia32_vpmadd52huq512:
+return interp__builtin_elementwise_triop(
+S, OpPC, Call, [](const APSInt &A, const APSInt &B, const APSInt &C) {
+  return A + llvm::APIntOps::mulhu(B.trunc(52), C.trunc(52)).zext(64);
+});
+
   case X86::BI__builtin_ia32_vpshldd128:
   case X86::BI__builtin_ia32_vpshldd256:
   case X86::BI__builtin_ia32_vpshldd512:
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 7bf28d988f405..4a65f279e34d5 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -11922,6 +11922,54 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr 
*E) {
 
 return Success(APValue(ResultElements.data(), ResultElements.size()), E);
   }
+
+  case X86::BI__builtin_ia32_vpmad

[clang] [clang][Diags] Automatically format AP(S)Int values with separators (PR #161047)

2025-10-17 Thread Erich Keane via cfe-commits

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

Oooh, I really like this.  Would be neat/a very appreciated followup to see if 
we could replace all the current places we do the old way, and use this 
instead.  This separators view is way nicer.

https://github.com/llvm/llvm-project/pull/161047
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lld] [llvm] AMDGPU: Use ELF mangling in data layout (PR #163011)

2025-10-17 Thread Joseph Huber via cfe-commits

jhuber6 wrote:

We probably need an exception or something in the IR linker to avoid printing 
warnings for a case like this. I think we do the exact same thing for the CUDA 
device library IR.

https://github.com/llvm/llvm-project/pull/163011
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy][NFC] Clean up and slightly optimize `modernize-use-integer-sign-comparison` (PR #163492)

2025-10-17 Thread Victor Chernyakin via cfe-commits

https://github.com/localspook created 
https://github.com/llvm/llvm-project/pull/163492

None

>From 314636a3bb35d22cc8166a5d8e51527b00f055b5 Mon Sep 17 00:00:00 2001
From: Victor Chernyakin 
Date: Tue, 14 Oct 2025 20:21:25 -0700
Subject: [PATCH] [clang-tidy][NFC] Clean up and slightly optimize
 `modernize-use-integer-sign-comparison`

---
 .../UseIntegerSignComparisonCheck.cpp | 35 +++
 1 file changed, 13 insertions(+), 22 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
index 0003429c62890..a3d3f0fa0ec93 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
@@ -34,13 +34,12 @@ AST_MATCHER(clang::QualType, isActualChar) {
 } // namespace
 
 static BindableMatcher
-intCastExpression(bool IsSigned,
-  const std::string &CastBindName = std::string()) {
+intCastExpression(bool IsSigned, StringRef CastBindName = {}) {
   // std::cmp_{} functions trigger a compile-time error if either LHS or RHS
   // is a non-integer type, char, enum or bool
   // (unsigned char/ signed char are Ok and can be used).
   auto IntTypeExpr = expr(hasType(hasCanonicalType(qualType(
-  isInteger(), IsSigned ? isSignedInteger() : isUnsignedInteger(),
+  IsSigned ? isSignedInteger() : isUnsignedInteger(),
   unless(isActualChar()), unless(booleanType()), unless(enumType());
 
   const auto ImplicitCastExpr =
@@ -71,7 +70,7 @@ static StringRef parseOpCode(BinaryOperator::Opcode Code) {
   case BO_NE:
 return "cmp_not_equal";
   default:
-return "";
+llvm_unreachable("invalid opcode");
   }
 }
 
@@ -119,23 +118,16 @@ void UseIntegerSignComparisonCheck::check(
   Expr::EvalResult EVResult;
   if (!SignedCastExpression->isValueDependent() &&
   SignedCastExpression->getSubExpr()->EvaluateAsInt(EVResult,
-*Result.Context)) {
-const llvm::APSInt SValue = EVResult.Val.getInt();
-if (SValue.isNonNegative())
-  return;
-  }
+*Result.Context) &&
+  EVResult.Val.getInt().isNonNegative())
+return;
 
   const auto *BinaryOp =
   Result.Nodes.getNodeAs("intComparison");
-  if (BinaryOp == nullptr)
-return;
-
-  const BinaryOperator::Opcode OpCode = BinaryOp->getOpcode();
+  assert(BinaryOp);
 
   const Expr *LHS = BinaryOp->getLHS()->IgnoreImpCasts();
   const Expr *RHS = BinaryOp->getRHS()->IgnoreImpCasts();
-  if (LHS == nullptr || RHS == nullptr)
-return;
   const Expr *SubExprLHS = nullptr;
   const Expr *SubExprRHS = nullptr;
   SourceRange R1(LHS->getBeginLoc());
@@ -144,8 +136,7 @@ void UseIntegerSignComparisonCheck::check(
   RHS->getEndLoc(), 0, *Result.SourceManager, getLangOpts()));
   if (const auto *LHSCast = llvm::dyn_cast(LHS)) {
 SubExprLHS = LHSCast->getSubExpr();
-R1 = SourceRange(LHS->getBeginLoc(),
- SubExprLHS->getBeginLoc().getLocWithOffset(-1));
+R1.setEnd(SubExprLHS->getBeginLoc().getLocWithOffset(-1));
 R2.setBegin(Lexer::getLocForEndOfToken(
 SubExprLHS->getEndLoc(), 0, *Result.SourceManager, getLangOpts()));
   }
@@ -156,21 +147,21 @@ void UseIntegerSignComparisonCheck::check(
   DiagnosticBuilder Diag =
   diag(BinaryOp->getBeginLoc(),
"comparison between 'signed' and 'unsigned' integers");
-  std::string CmpNamespace;
-  llvm::StringRef CmpHeader;
+  StringRef CmpNamespace;
+  StringRef CmpHeader;
 
   if (getLangOpts().CPlusPlus20) {
 CmpHeader = "";
-CmpNamespace = llvm::Twine("std::" + parseOpCode(OpCode)).str();
+CmpNamespace = "std::";
   } else if (getLangOpts().CPlusPlus17 && EnableQtSupport) {
 CmpHeader = "";
-CmpNamespace = llvm::Twine("q20::" + parseOpCode(OpCode)).str();
+CmpNamespace = "q20::";
   }
 
   // Prefer modernize-use-integer-sign-comparison when C++20 is available!
   Diag << FixItHint::CreateReplacement(
   CharSourceRange(R1, SubExprLHS != nullptr),
-  llvm::Twine(CmpNamespace + "(").str());
+  Twine(CmpNamespace + parseOpCode(BinaryOp->getOpcode()) + "(").str());
   Diag << FixItHint::CreateReplacement(R2, ",");
   Diag << FixItHint::CreateReplacement(CharSourceRange::getCharRange(R3), ")");
 

___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Fix a broken fix-it provided by `modernize-use-integer-sign-comparison` (PR #163488)

2025-10-17 Thread Victor Chernyakin via cfe-commits

https://github.com/localspook edited 
https://github.com/llvm/llvm-project/pull/163488
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Enable musttail only when tail-call is enabled (PR #163618)

2025-10-17 Thread Jasmine Tang via cfe-commits

https://github.com/badumbatish created 
https://github.com/llvm/llvm-project/pull/163618

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

I'm unsure if this follows closely from the following so reviews are much 
appreciated

> We should add something to TargetInfo.h in Clang that different targets can 
> override and then check that from SemaStmt.cpp. That handles the attribute 
> being accepted at all. Then Attr.td should be modified to make MustTail a 
> TargetSpecificAttr so that __has_attribute support behaves according to the 
> target. This should be pretty straightforward, so marking as a good first 
> issue. However, this might be the first target-specific statement attribute 
> we support, so there could be some extra work involved.

>From f9c22f861739e52e77960ae8083490dfdf62d19e Mon Sep 17 00:00:00 2001
From: Jasmine Tang 
Date: Wed, 15 Oct 2025 12:13:58 -0700
Subject: [PATCH 1/2] Precommit

---
 clang/test/CodeGen/WebAssembly/musttail.c | 20 
 1 file changed, 20 insertions(+)
 create mode 100644 clang/test/CodeGen/WebAssembly/musttail.c

diff --git a/clang/test/CodeGen/WebAssembly/musttail.c 
b/clang/test/CodeGen/WebAssembly/musttail.c
new file mode 100644
index 0..da100484e94f2
--- /dev/null
+++ b/clang/test/CodeGen/WebAssembly/musttail.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -target-feature 
+tail-call -o /dev/null -emit-llvm -verify=good
+// RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -target-feature 
+tail-call -o /dev/null -emit-llvm -verify=good
+// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -o /dev/null -emit-llvm 
-verify=notail
+
+int foo(int x) {
+  return x;
+}
+
+#if __has_attribute(musttail)
+// good-warning@+2 {{HAS IT}}
+// notail-warning@+1 {{HAS IT}}
+#warning HAS IT
+#else
+#warning DOES NOT HAVE
+#endif
+
+int bar(int x)
+{
+ [[clang::musttail]] return foo(1);
+}

>From 26b9025acc1eaecd473196691ed5e23cfbabf88e Mon Sep 17 00:00:00 2001
From: Jasmine Tang 
Date: Wed, 15 Oct 2025 12:14:04 -0700
Subject: [PATCH 2/2] Add must tail support

---
 clang/include/clang/Basic/Attr.td  | 7 ++-
 clang/include/clang/Basic/DiagnosticCommonKinds.td | 2 ++
 clang/include/clang/Basic/TargetInfo.h | 3 +++
 clang/lib/Basic/TargetInfo.cpp | 1 +
 clang/lib/Basic/Targets/WebAssembly.cpp| 3 +++
 clang/lib/Sema/SemaStmt.cpp| 1 -
 clang/lib/Sema/SemaStmtAttr.cpp| 6 ++
 clang/test/CodeGen/WebAssembly/musttail.c  | 8 
 8 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 3cde249e286fa..fab4e1dca024b 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -483,6 +483,7 @@ def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
 def TargetSPIRV : TargetArch<["spirv", "spirv32", "spirv64"]>;
 def TargetWebAssembly : TargetArch<["wasm32", "wasm64"]>;
 def TargetNVPTX : TargetArch<["nvptx", "nvptx64"]>;
+def TargetPowerPC : TargetArch<["ppc", "ppcle", "ppc64", "ppc64le"]>;
 def TargetWindows : TargetSpec {
   let OSes = ["Win32"];
 }
@@ -508,6 +509,10 @@ def TargetMicrosoftRecordLayout : TargetArch<["x86", 
"x86_64", "arm", "thumb",
   let CustomCode = [{ Target.hasMicrosoftRecordLayout() }];
 }
 
+def TargetMustTailAvaiable: TargetArch {
+  let CustomCode = [{ Target.hasMustTail() }];
+}
+
 def TargetELF : TargetSpec {
   let ObjectFormats = ["ELF"];
 }
@@ -1896,7 +1901,7 @@ def NoMerge : DeclOrStmtAttr {
  "functions, statements and variables">;
 }
 
-def MustTail : StmtAttr {
+def MustTail : StmtAttr, TargetSpecificAttr {
   let Spellings = [Clang<"musttail">];
   let Documentation = [MustTailDocs];
   let Subjects = SubjectList<[ReturnStmt], ErrorDiag, "return statements">;
diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td 
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index 6e50e225a8cc1..b0a928018cccd 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -374,6 +374,8 @@ def err_ppc_impossible_musttail: Error<
   >;
 def err_aix_musttail_unsupported: Error<
   "'musttail' attribute is not supported on AIX">;
+def err_wasm_musttail_unsupported: Error<
+  "'musttail' attribute is not supported on this target without tail-call 
feature">;
 
 // Source manager
 def err_cannot_open_file : Error<"cannot open file '%0': %1">, DefaultFatal;
diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index ceb16174e13e7..e2768bea1902e 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -229,6 +229,7 @@ class TargetInfo : public TransferrableTargetInfo,
 protected:
   // Target values set by the ctor of the actual target implementation.  
Default
   // values are specified by the TargetIn

[clang] [HLSL][NFC] Refactor structured buffer methods tests (PR #161908)

2025-10-17 Thread Joshua Batista via cfe-commits

bob80905 wrote:

Your tests don't make use of the SPV filecheck prefix. Is there output that's 
only visible when targeting DXIL? 

https://github.com/llvm/llvm-project/pull/161908
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Upstream pointer subtraction handling (PR #163306)

2025-10-17 Thread Andy Kaylor via cfe-commits

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

Looks good!

https://github.com/llvm/llvm-project/pull/163306
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebKit Checkers] Treat a NS/CF global defined in a system header as a safe pointer origin (PR #161146)

2025-10-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Ryosuke Niwa (rniwa)


Changes



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


7 Files Affected:

- (modified) clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp (+7-2) 
- (modified) clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.h (+1) 
- (modified) 
clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefCallArgsChecker.cpp (+8-1) 
- (modified) 
clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLocalVarsChecker.cpp (+7-1) 
- (modified) clang/test/Analysis/Checkers/WebKit/mock-system-header.h (+6) 
- (modified) clang/test/Analysis/Checkers/WebKit/unretained-local-vars.mm (+26) 
- (added) clang/test/Analysis/Checkers/WebKit/unretained-obj-arg.mm (+18) 


``diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
index 00a1b8b6e7e89..ab9a5b85cf241 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
@@ -26,6 +26,7 @@ bool tryToFindPtrOrigin(
 const Expr *E, bool StopAtFirstRefCountedObj,
 std::function isSafePtr,
 std::function isSafePtrType,
+std::function isSafeGlobalDecl,
 std::function callback) {
   while (E) {
 if (auto *DRE = dyn_cast(E)) {
@@ -34,6 +35,8 @@ bool tryToFindPtrOrigin(
 if (VD->hasGlobalStorage() && QT.isConstQualified()) {
   return callback(E, true);
 }
+if (VD->hasGlobalStorage() && isSafeGlobalDecl(VD))
+  return callback(E, true);
   }
 }
 if (auto *tempExpr = dyn_cast(E)) {
@@ -71,9 +74,11 @@ bool tryToFindPtrOrigin(
 }
 if (auto *Expr = dyn_cast(E)) {
   return tryToFindPtrOrigin(Expr->getTrueExpr(), StopAtFirstRefCountedObj,
-isSafePtr, isSafePtrType, callback) &&
+isSafePtr, isSafePtrType, isSafeGlobalDecl,
+callback) &&
  tryToFindPtrOrigin(Expr->getFalseExpr(), StopAtFirstRefCountedObj,
-isSafePtr, isSafePtrType, callback);
+isSafePtr, isSafePtrType, isSafeGlobalDecl,
+callback);
 }
 if (auto *cast = dyn_cast(E)) {
   if (StopAtFirstRefCountedObj) {
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.h 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.h
index 3a009d65efea6..9fff456b7e8b8 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.h
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.h
@@ -56,6 +56,7 @@ bool tryToFindPtrOrigin(
 const clang::Expr *E, bool StopAtFirstRefCountedObj,
 std::function isSafePtr,
 std::function isSafePtrType,
+std::function isSafeGlobalDecl,
 std::function callback);
 
 /// For \p E referring to a ref-countable/-counted pointer/reference we return
diff --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefCallArgsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefCallArgsChecker.cpp
index 9585ceb40f95e..791e70998477f 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefCallArgsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefCallArgsChecker.cpp
@@ -29,12 +29,12 @@ namespace {
 class RawPtrRefCallArgsChecker
 : public Checker> {
   BugType Bug;
-  mutable BugReporter *BR;
 
   TrivialFunctionAnalysis TFA;
   EnsureFunctionAnalysis EFA;
 
 protected:
+  mutable BugReporter *BR;
   mutable std::optional RTC;
 
 public:
@@ -46,6 +46,7 @@ class RawPtrRefCallArgsChecker
   virtual bool isSafePtr(const CXXRecordDecl *Record) const = 0;
   virtual bool isSafePtrType(const QualType type) const = 0;
   virtual bool isSafeExpr(const Expr *) const { return false; }
+  virtual bool isSafeDecl(const Decl *) const { return false; }
   virtual const char *ptrKind() const = 0;
 
   void checkASTDecl(const TranslationUnitDecl *TUD, AnalysisManager &MGR,
@@ -214,6 +215,7 @@ class RawPtrRefCallArgsChecker
 Arg, /*StopAtFirstRefCountedObj=*/true,
 [&](const clang::CXXRecordDecl *Record) { return isSafePtr(Record); },
 [&](const clang::QualType T) { return isSafePtrType(T); },
+[&](const clang::Decl *D) { return isSafeDecl(D); },
 [&](const clang::Expr *ArgOrigin, bool IsSafe) {
   if (IsSafe)
 return true;
@@ -479,6 +481,11 @@ class UnretainedCallArgsChecker final : public 
RawPtrRefCallArgsChecker {
isa(E);
   }
 
+  bool isSafeDecl(const Decl *D) const final {
+// Treat NS/CF globals in system header as immortal.
+return BR->getSourceManager().isInSystemHeader(D->getLocation());
+  }
+
   const char *ptrKind() const final { return "unretained"; }
 };
 
diff --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLocalVarsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLocalVarsChecker.cpp
index dd9701fbbb017..c13df47920f72 100644
---

[clang] [clang-format] Keep the ObjC selector name and `@selector` together (PR #160739)

2025-10-17 Thread via cfe-commits

https://github.com/sstwcw closed 
https://github.com/llvm/llvm-project/pull/160739
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [IR] Mark vector intrinsics speculatable (PR #162334)

2025-10-17 Thread Ramkumar Ramachandra via cfe-commits

https://github.com/artagnon edited 
https://github.com/llvm/llvm-project/pull/162334
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - add MMX/SSE/AVX/AVX512 PMULHRSW intrinsics to be used in constexpr (PR #160636)

2025-10-17 Thread Simon Pilgrim via cfe-commits


@@ -23,6 +23,9 @@
 
 #define __trunc64(x)   
\
   (__m64) __builtin_shufflevector((__v2di)(x), __extension__(__v2di){}, 0)
+#define __zext128(x)   
\

RKSimon wrote:

undef this at the end of the file

https://github.com/llvm/llvm-project/pull/160636
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] add array out-of-bounds access constraints using llvm.assume (PR #159046)

2025-10-17 Thread Sebastian Pop via cfe-commits

sebpop wrote:

I think we need to generate only one assume per declaration instead of 
littering the IR with assumes for every use and rely on optimizers to fold all 
the assumes to a single one.

The current way is the declarations of arrays also contain the dimensions 
sizes. If this type gets removed from alloca/globals (from what I understood in 
the next ~2 years) a possible way to provide the array dimensions is to 
maintain the info in a symbol table (as meta-data or so.)

https://github.com/llvm/llvm-project/pull/159046
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Upstream Exception CXXTryStmt (PR #162528)

2025-10-17 Thread Andy Kaylor via cfe-commits

https://github.com/andykaylor edited 
https://github.com/llvm/llvm-project/pull/162528
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-scan-deps] Remove const from ModuleDeps loop to enable move. (PR #161109)

2025-10-17 Thread Naveen Seth Hanig via cfe-commits

naveen-seth wrote:

Ah I see, I've moved it to #155523 now (even though that is also NFC). Hope 
that’s fine anyway.
Otherwise I can add them to a more meaningful PR in the future.

https://github.com/llvm/llvm-project/pull/161109
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8dac6e2 - Reapply "[clang] Convert second arg of __builtin_assume_aligned to Co… (#161945)

2025-10-17 Thread via cfe-commits

Author: Timm Baeder
Date: 2025-10-05T08:35:56+02:00
New Revision: 8dac6e28c951b33659f1f1f80e0dd553788abaab

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

LOG: Reapply "[clang] Convert second arg of __builtin_assume_aligned to Co… 
(#161945)

…nstantExpr (#161314)" (#161719)

This reverts commit f1650cf91b01470ce44f47797663d59f00828493.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/SemaCXX/builtin-assume-aligned.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2ac5f4aab75dc..ab536adcd3ba0 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -250,6 +250,8 @@ Non-comprehensive list of changes in this release
 
 - ``__builtin_assume_dereferenceable`` now accepts non-constant size operands.
 
+- Fixed a crash when the second argument to ``__builtin_assume_aligned`` was 
not constant (#GH161314)
+
 New Compiler Flags
 --
 - New option ``-fno-sanitize-debug-trap-reasons`` added to disable emitting 
trap reasons into the debug info when compiling with trapping UBSan (e.g. 
``-fsanitize-trap=undefined``).

diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index f319b176513f8..c961222766475 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -465,11 +465,16 @@ class ScalarExprEmitter
   return nullptr;
 
 if (Value *Result = ConstantEmitter(CGF).tryEmitConstantExpr(E)) {
-  if (E->isGLValue())
+  if (E->isGLValue()) {
+// This was already converted to an rvalue when it was constant
+// evaluated.
+if (E->hasAPValueResult() && !E->getAPValueResult().isLValue())
+  return Result;
 return CGF.EmitLoadOfScalar(
 Address(Result, CGF.convertTypeForLoadStore(E->getType()),
 CGF.getContext().getTypeAlignInChars(E->getType())),
 /*Volatile*/ false, E->getType(), E->getExprLoc());
+  }
   return Result;
 }
 return Visit(E->getSubExpr());

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 7ce3513fe0969..3cc61b167ba98 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -5954,6 +5954,9 @@ bool Sema::BuiltinAssumeAligned(CallExpr *TheCall) {
 if (Result > Sema::MaximumAlignment)
   Diag(TheCall->getBeginLoc(), diag::warn_assume_aligned_too_great)
   << SecondArg->getSourceRange() << Sema::MaximumAlignment;
+
+TheCall->setArg(1,
+ConstantExpr::Create(Context, SecondArg, APValue(Result)));
   }
 
   if (NumArgs > 2) {

diff  --git a/clang/test/SemaCXX/builtin-assume-aligned.cpp 
b/clang/test/SemaCXX/builtin-assume-aligned.cpp
index 48bd8414fc50a..30296c72c6be8 100644
--- a/clang/test/SemaCXX/builtin-assume-aligned.cpp
+++ b/clang/test/SemaCXX/builtin-assume-aligned.cpp
@@ -47,3 +47,16 @@ constexpr void *s1 = __builtin_assume_aligned(x, 32);
 constexpr void *s2 = __builtin_assume_aligned(x, 32, 5);
 constexpr void *s3 = __builtin_assume_aligned(x, 32, -1);
 
+
+constexpr int add(int a, int b) {
+  return a+b;
+}
+constexpr void *c1 = __builtin_assume_aligned(p, add(1,1));
+constexpr void *c2 = __builtin_assume_aligned(p, add(2,1)); // expected-error 
{{not a power of 2}}
+
+constexpr long kAlignment = 128;
+long AllocateAlignedBytes_payload;
+void AllocateAlignedBytes() {
+  void *m = __builtin_assume_aligned(
+  reinterpret_cast(AllocateAlignedBytes_payload), kAlignment);
+}



___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [llvm] [polly] [Unittest][Cygwin] Set $PATH when running unittests (PR #163947)

2025-10-17 Thread Alexander Richardson via cfe-commits


@@ -19,12 +19,12 @@
 
 if platform.system() == "Darwin":
 shlibpath_var = "DYLD_LIBRARY_PATH"
-elif platform.system() == "Windows":
+elif platform.system() == "Windows" or sys.platform == "cygwin":
 shlibpath_var = "PATH"
 else:
 shlibpath_var = "LD_LIBRARY_PATH"
 config.environment[shlibpath_var] = os.path.pathsep.join(
-("@SHLIBDIR@", "@LLVM_LIBS_DIR@", config.environment.get(shlibpath_var, 
""))
+(config.shlibdir, config.llvm_libs_dir, 
config.environment.get(shlibpath_var, ""))

arichardson wrote:

This is odd, how did this code work before? Was it moved here and no one 
noticed that the values are no longer expanded? 

https://github.com/llvm/llvm-project/pull/163947
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Fix -analyze-function debug warning to account for syntax checkers (PR #161664)

2025-10-17 Thread Balazs Benics via cfe-commits

https://github.com/steakhal closed 
https://github.com/llvm/llvm-project/pull/161664
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Add readability-default-lambda-capture (PR #160150)

2025-10-17 Thread JJ Marr via cfe-commits

https://github.com/jjmarr-amd commented:

I like reviewing AI-generated code in the web interface.

https://github.com/llvm/llvm-project/pull/160150
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Allow weak/selectany external definitions in header units. (PR #162713)

2025-10-17 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 commented:

Looks not bad. Let's add a comment for it.

https://github.com/llvm/llvm-project/pull/162713
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add inline function attributes (PR #162866)

2025-10-17 Thread Bruno Cardoso Lopes via cfe-commits


@@ -959,5 +959,31 @@ def CIR_TypeInfoAttr : CIR_Attr<"TypeInfo", "typeinfo", 
[TypedAttrInterface]> {
 `<` custom($data) `>`
   }];
 }
+//===--===//
+// InlineAttr
+//===--===//
+
+def CIR_InlineKind : CIR_I32EnumAttr<"InlineKind", "inlineKind", [
+  I32EnumAttrCase<"NoInline", 1, "no">,
+  I32EnumAttrCase<"AlwaysInline", 2, "always">,
+  I32EnumAttrCase<"InlineHint", 3, "hint">
+]> {
+  let genSpecializedAttr = 0;
+}
+
+def CIR_InlineAttr : CIR_EnumAttr {
+  let summary = "Inline attribute";
+  let description = [{
+Inline attributes represents user directives.

bcardosolopes wrote:

Can you please add an example? Maybe say it can only be used by cir.func and 
add an example there instead?

https://github.com/llvm/llvm-project/pull/162866
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [SPIR-V] Generate SPIR-V instructions when 'enable-maximal-reconvergence' function attribute is set (PR #163682)

2025-10-17 Thread Lucie Choi via cfe-commits


@@ -0,0 +1,20 @@
+; RUN: llc -O0 -verify-machineinstrs 
-mtriple=spirv1.6-unknown-vulkan1.3-compute 
--spirv-ext=+SPV_KHR_maximal_reconvergence %s -o - | FileCheck %s
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv1.6-unknown-vulkan1.3-compute 
--spirv-ext=+SPV_KHR_maximal_reconvergence %s -o - -filetype=obj | spirv-val %}
+
+; CHECK: OpCapability Shader
+; CHECK: OpExtension "SPV_KHR_maximal_reconvergence"
+; CHECK-NOT: OpExtension "SPV_KHR_maximal_reconvergence"
+; CHECK: OpExecutionMode {{.*}} MaximallyReconvergesKHR
+; CHECK-NOT: OpExecutionMode {{.*}} MaximallyReconvergesKHR

luciechoi wrote:

Replaced to match exactly with function name.

https://github.com/llvm/llvm-project/pull/163682
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Upstream `AddressSpace` support for `PointerType` (PR #161028)

2025-10-17 Thread Bruno Cardoso Lopes via cfe-commits


@@ -297,6 +317,20 @@ bool RecordType::isLayoutIdentical(const RecordType 
&other) {
 // Data Layout information for types
 
//===--===//
 
+llvm::TypeSize
+PointerType::getTypeSizeInBits(const ::mlir::DataLayout &dataLayout,
+   ::mlir::DataLayoutEntryListRef params) const {
+  // FIXME: improve this in face of address spaces

bcardosolopes wrote:

Thanks for adding the assert!

https://github.com/llvm/llvm-project/pull/161028
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [OpenMP] Adds omp_target_is_accessible routine (PR #138294)

2025-10-17 Thread via cfe-commits


@@ -3027,6 +3027,29 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, 
AMDGenericDeviceTy {
 return ((IsAPU || OMPX_ApuMaps) && IsXnackEnabled);
   }
 
+  bool isAccessiblePtrImpl(const void *Ptr, size_t Size) override {
+hsa_amd_pointer_info_t Info;
+Info.size = sizeof(hsa_amd_pointer_info_t);
+
+hsa_agent_t *Agents = nullptr;
+uint32_t Count = 0;
+hsa_status_t Status =
+hsa_amd_pointer_info(Ptr, &Info, malloc, &Count, &Agents);
+
+if (Status != HSA_STATUS_SUCCESS)

carlobertolli wrote:

I guess that the two semantically relevant errors here would be:
HSA_EXT_POINTER_TYPE_UNKNOWN 
and
HSA_STATUS_ERROR_INVALID_ARGUMENT (which we should never get because we already 
checked whether ptr is null). The rest of the errors "out of resources, hsa not 
initialized" would have been caught earlier on, is my guess

https://github.com/llvm/llvm-project/pull/138294
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [LLVM] Add GNU make jobserver support (PR #145131)

2025-10-17 Thread Yaxun Liu via cfe-commits


@@ -0,0 +1,160 @@
+//===- llvm/Support/Jobserver.h - Jobserver Client --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file defines a client for the GNU Make jobserver protocol. This allows
+// LLVM tools to coordinate parallel execution with a parent `make` process.
+//
+// The jobserver protocol is a mechanism for GNU Make to share its pool of
+// available "job slots" with the subprocesses it invokes. This is particularly
+// useful for tools that can perform parallel operations themselves (e.g., a
+// multi-threaded linker or compiler). By participating in this protocol, a
+// tool can ensure the total number of concurrent jobs does not exceed the
+// limit specified by the user (e.g., `make -j8`).
+//
+// How it works:
+//
+// 1. Establishment:
+//A child process discovers the jobserver by inspecting the `MAKEFLAGS`
+//environment variable. If a jobserver is active, this variable will
+//contain a `--jobserver-auth=` argument. The format of ``
+//determines how to communicate with the server.
+//
+// 2. The Implicit Slot:
+//Every command invoked by `make` is granted one "implicit" job slot. This
+//means a tool can always perform at least one unit of work without needing
+//to communicate with the jobserver. This implicit slot should NEVER be
+//released back to the jobserver.
+//
+// 3. Acquiring and Releasing Slots:
+//On POSIX systems, the jobserver is implemented as a pipe. The
+//`--jobserver-auth` value specifies either a path to a named pipe
+//(`fifo:PATH`) or a pair of file descriptors (`R,W`). The pipe is
+//pre-loaded with single-character tokens, one for each available job slot.
+//
+//- To acquire an additional slot, a client reads a single-character token
+//  from the pipe.
+//- To release a slot, the client must write the *exact same* character
+//  token back to the pipe.
+//
+//It is critical that a client releases all acquired slots before it exits,
+//even in cases of error, to avoid deadlocking the build.
+//
+// Example:
+//A multi-threaded linker invoked by `make -j8` wants to use multiple
+//threads. It first checks for the jobserver. It knows it has one implicit
+//slot, so it can use one thread. It then tries to acquire 7 more slots by
+//reading 7 tokens from the jobserver pipe. If it only receives 3 tokens,
+//it knows it can use a total of 1 (implicit) + 3 (acquired) = 4 threads.
+//Before exiting, it must write the 3 tokens it read back to the pipe.
+//
+// For more context, see:
+//   - LLVM RFC discussion on jobserver support:

yxsamliu wrote:

will add the link

https://github.com/llvm/llvm-project/pull/145131
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-10-17 Thread Justin Stitt via cfe-commits

JustinStitt wrote:

FYI, I'm meeting with @kees off-thread today to analyze kernel use cases and 
digest @ojhunt's review comments.

https://github.com/llvm/llvm-project/pull/148914
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][RVV][SVE] Cache getScalableVectorType lookups (PR #160108)

2025-10-17 Thread Paul Walker via cfe-commits


@@ -4567,6 +4567,11 @@ QualType ASTContext::getWebAssemblyExternrefType() const 
{
 /// type.
 QualType ASTContext::getScalableVectorType(QualType EltTy, unsigned NumElts,
unsigned NumFields) const {
+  auto K = llvm::ScalableVecTyKey{
+  reinterpret_cast(EltTy.getAsOpaquePtr()), NumElts, NumFields};

paulwalker-arm wrote:

My knowledge here is not great, is it safe to assume the opaque ptr is unique? 
Why not use QualType directly.  I can see this done in other places (e.g. 
NullableQualTypeDenseMapInfo).

https://github.com/llvm/llvm-project/pull/160108
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] Dataflow Sanitizer support for SystemZ. (PR #162195)

2025-10-17 Thread Thurston Dang via cfe-commits

https://github.com/thurstond commented:

It would be nice to land these two improvements in separate patch(es):
- Add support for non-zero shadow base in getShadowAddress()
- Big-endian support for wide shadows in loadShadowFast()

since they are general fixes, used for but not specific to SystemZ support.

https://github.com/llvm/llvm-project/pull/162195
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AMDGPU] Support for type inferring image load/store builtins for AMDGPU (PR #140210)

2025-10-17 Thread Rana Pratap Reddy via cfe-commits


@@ -181,6 +184,92 @@ static Value *EmitAMDGCNBallotForExec(CodeGenFunction 
&CGF, const CallExpr *E,
   return Call;
 }
 
+static bool IsImageSampleBuiltIn(unsigned BuiltinID) {
+  switch (BuiltinID) {
+  case clang::AMDGPU::BI__builtin_amdgcn_image_sample_1d_v4f32_f32:
+  case clang::AMDGPU::BI__builtin_amdgcn_image_sample_1d_v4f16_f32:
+  case clang::AMDGPU::BI__builtin_amdgcn_image_sample_1darray_v4f32_f32:
+  case clang::AMDGPU::BI__builtin_amdgcn_image_sample_1darray_v4f16_f32:
+  case clang::AMDGPU::BI__builtin_amdgcn_image_sample_2d_f32_f32:
+  case clang::AMDGPU::BI__builtin_amdgcn_image_sample_2d_v4f32_f32:
+  case clang::AMDGPU::BI__builtin_amdgcn_image_sample_2d_v4f16_f32:
+  case clang::AMDGPU::BI__builtin_amdgcn_image_sample_2darray_f32_f32:
+  case clang::AMDGPU::BI__builtin_amdgcn_image_sample_2darray_v4f32_f32:
+  case clang::AMDGPU::BI__builtin_amdgcn_image_sample_2darray_v4f16_f32:
+  case clang::AMDGPU::BI__builtin_amdgcn_image_sample_3d_v4f32_f32:
+  case clang::AMDGPU::BI__builtin_amdgcn_image_sample_3d_v4f16_f32:
+  case clang::AMDGPU::BI__builtin_amdgcn_image_sample_cube_v4f32_f32:
+  case clang::AMDGPU::BI__builtin_amdgcn_image_sample_cube_v4f16_f32:
+return true;
+  default:
+return false;
+  }
+}
+
+static llvm::Value *LoadTextureDescPtorAsVec8I32(CodeGenFunction &CGF,
+ llvm::Value *RsrcPtr) {
+  auto &B = CGF.Builder;
+  auto *VecTy = llvm::FixedVectorType::get(B.getInt32Ty(), 8);
+
+  if (RsrcPtr->getType() == VecTy)
+return RsrcPtr;
+
+  if (RsrcPtr->getType()->isIntegerTy(32)) {
+unsigned AS = 8;

ranapratap55 wrote:

Updated.

https://github.com/llvm/llvm-project/pull/140210
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [C2y] Implement WG14 N3622 static used in an inline (PR #162877)

2025-10-17 Thread Erich Keane via cfe-commits


@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -verify=good -pedantic -Wall -std=c2y %s
+// RUN: %clang_cc1 -verify -pedantic -Wall -std=c23 %s
+// RUN: %clang_cc1 -verify -pedantic -Wall -std=c17 %s
+// good-no-diagnostics
+
+/* WG14 N3622: Clang 22
+ * Allow calling static inline within extern inline
+ *
+ * This verifies that a constraint from previous standards is no longer
+ * triggered in C2y mode. The constraint is with calling a statric function

erichkeane wrote:

```suggestion
 * triggered in C2y mode. The constraint is with calling a static function
```

https://github.com/llvm/llvm-project/pull/162877
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Use the VFS to get the OpenMP entry info (PR #160935)

2025-10-17 Thread via cfe-commits

carlobertolli wrote:

here we go:
https://github.com/llvm/llvm-project/pull/161472

https://github.com/llvm/llvm-project/pull/160935
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Instantiate variables referenced in `decltype` with an undeduced type. (PR #161231)

2025-10-17 Thread Corentin Jabot via cfe-commits

https://github.com/cor3ntin updated 
https://github.com/llvm/llvm-project/pull/161231

>From 6c4bd440fb13335cf07ac69ed67890640e5e8323 Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Mon, 29 Sep 2025 18:55:22 +0200
Subject: [PATCH 1/2] [Clang] Instantiate variables referenced in `decltype`
 with an undeduced type.

Fixes #160497
---
 clang/docs/ReleaseNotes.rst |  1 +
 clang/lib/Sema/SemaExpr.cpp |  5 +++--
 clang/test/SemaCXX/decltype.cpp | 30 ++
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 270b5d336eba7..3ff40f98334ca 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -432,6 +432,7 @@ Bug Fixes to C++ Support
 - Fix an assertion failure when taking the address on a non-type template 
parameter argument of
   object type. (#GH151531)
 - Suppress ``-Wdouble-promotion`` when explicitly asked for with C++ list 
initialization (#GH33409).
+- Correctly deduced return types in ``decltype`` expressions. (#GH160497)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 3b267c1b1693d..3302bfce193a2 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -20108,8 +20108,9 @@ static void DoMarkVarDeclReferenced(
   bool NeededForConstantEvaluation =
   isPotentiallyConstantEvaluatedContext(SemaRef) && UsableInConstantExpr;
 
-  bool NeedDefinition =
-  OdrUse == OdrUseContext::Used || NeededForConstantEvaluation;
+  bool NeedDefinition = OdrUse == OdrUseContext::Used ||
+NeededForConstantEvaluation ||
+Var->getType()->isUndeducedType();
 
   assert(!isa(Var) &&
  "Can't instantiate a partial template specialization.");
diff --git a/clang/test/SemaCXX/decltype.cpp b/clang/test/SemaCXX/decltype.cpp
index 739485b57a3ec..971cf5132d4d5 100644
--- a/clang/test/SemaCXX/decltype.cpp
+++ b/clang/test/SemaCXX/decltype.cpp
@@ -170,3 +170,33 @@ class conditional {
 // FIXME: The diagnostics here are produced twice.
 void foo(conditional) {  // expected-note 2 {{to match this 
'('}} expected-error {{expected ')'}} expected-note 2{{to match this '<'}}
 } // expected-error {{expected function body after function declarator}} 
expected-error 2 {{expected '>'}} expected-error {{expected ')'}}
+
+
+namespace GH160497 {
+
+template  struct S {
+template 
+inline static auto mem =
+[] { static_assert(false); // expected-error {{static assertion failed}} \
+// expected-note {{while substituting into a lambda expression here}}
+return 42;
+}();
+};
+
+using T = decltype(S::mem);
+ // expected-note@-1 {{in instantiation of static data member 
'GH160497::S::mem' requested here}}
+
+namespace N1 {
+
+template
+struct S {
+  template
+  inline static auto mem = 42;
+};
+
+using T = decltype(S::mem);
+
+T y = 42;
+
+}
+}

>From 1dd09353d52f6ccd5e7b2d0fa59e484f85940a91 Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Mon, 29 Sep 2025 19:11:21 +0200
Subject: [PATCH 2/2] fix tests

---
 clang/test/SemaCXX/decltype.cpp | 38 +
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/clang/test/SemaCXX/decltype.cpp b/clang/test/SemaCXX/decltype.cpp
index 971cf5132d4d5..7931c6ac45429 100644
--- a/clang/test/SemaCXX/decltype.cpp
+++ b/clang/test/SemaCXX/decltype.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Wno-c99-designator %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify -Wno-c99-designator %s
 
 // PR5290
 int const f0();
@@ -156,27 +157,12 @@ struct A {
   }
 };
 
-// This shouldn't crash.
-static_assert(A().f() == 0, "");
-// The result should not be dependent.
-static_assert(A().f() != 0, ""); // expected-error {{static 
assertion failed due to requirement 'GH99873::A().f() != 0'}}
-   // expected-note@-1 {{expression 
evaluates to '0 != 0'}}
-}
-
-template
-class conditional {
-};
-
-// FIXME: The diagnostics here are produced twice.
-void foo(conditional) {  // expected-note 2 {{to match this 
'('}} expected-error {{expected ')'}} expected-note 2{{to match this '<'}}
-} // expected-error {{expected function body after function declarator}} 
expected-error 2 {{expected '>'}} expected-error {{expected ')'}}
-
-
+#if __cplusplus >= 201703L
 namespace GH160497 {
 
 template  struct S {
 template 
-inline static auto mem =
+static inline auto mem =
 [] { static_assert(false); // expected-error {{static assertion failed}} \
 // expected-note {{while substituting into a lambda expression here}}
 return 42;
@@ -184,7 +170,7 @@ template  struct S {
 };
 
 using T = decltype(S::mem);
- // expected-note@-1 {{in instantiation of static data member 
'GH160497::S::mem' requested here}}
+ // expected-note@-1 {{in instantiation of static data member 
'GH99873::GH1604

[clang] [Clang][CodeGen] Make UnqualPtrTy match llvm::PointerType::getUnqual (PR #163207)

2025-10-17 Thread Eli Friedman via cfe-commits
Juan Manuel Martinez =?utf-8?q?Caamaño?= ,
Juan Manuel Martinez =?utf-8?q?Caamaño?= 
Message-ID:
In-Reply-To: 


efriedma-quic wrote:

I think on the rare occasion where we actually want addrspace 0, regardless of 
the target's addrspace preferences, I'd prefer to change it to explicitly 
request addrspace 0.  `Builder.getPtrTy(/*AddrSpace*/0)` is unambiguous.

https://github.com/llvm/llvm-project/pull/163207
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e573c79 - [clang][x86][bytecode] Replace interp__builtin_rotate with static bool interp__builtin_elementwise_int_binop callback #160289 (#161924)

2025-10-17 Thread via cfe-commits

Author: rdez13
Date: 2025-10-06T07:58:40Z
New Revision: e573c795e4938440aa1ddb0371568be69eb08390

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

LOG: [clang][x86][bytecode] Replace interp__builtin_rotate with static bool 
interp__builtin_elementwise_int_binop callback #160289 (#161924)

Fixes #160289

Added: 


Modified: 
clang/lib/AST/ByteCode/InterpBuiltin.cpp

Removed: 




diff  --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 68ebfdf27ba43..a3c4ba5447250 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -736,25 +736,6 @@ static bool interp__builtin_expect(InterpState &S, CodePtr 
OpPC,
   return true;
 }
 
-/// rotateleft(value, amount)
-static bool interp__builtin_rotate(InterpState &S, CodePtr OpPC,
-   const InterpFrame *Frame,
-   const CallExpr *Call, bool Right) {
-  APSInt Amount = popToAPSInt(S, Call->getArg(1));
-  APSInt Value = popToAPSInt(S, Call->getArg(0));
-
-  APSInt Result;
-  if (Right)
-Result = APSInt(Value.rotr(Amount.urem(Value.getBitWidth())),
-/*IsUnsigned=*/true);
-  else // Left.
-Result = APSInt(Value.rotl(Amount.urem(Value.getBitWidth())),
-/*IsUnsigned=*/true);
-
-  pushInteger(S, Result, Call->getType());
-  return true;
-}
-
 static bool interp__builtin_ffs(InterpState &S, CodePtr OpPC,
 const InterpFrame *Frame,
 const CallExpr *Call) {
@@ -3160,7 +3141,10 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, 
const CallExpr *Call,
   case Builtin::BI_rotl:
   case Builtin::BI_lrotl:
   case Builtin::BI_rotl64:
-return interp__builtin_rotate(S, OpPC, Frame, Call, /*Right=*/false);
+return interp__builtin_elementwise_int_binop(
+S, OpPC, Call, [](const APSInt &Value, const APSInt &Amount) -> APInt {
+  return Value.rotl(Amount);
+});
 
   case Builtin::BI__builtin_rotateright8:
   case Builtin::BI__builtin_rotateright16:
@@ -3171,7 +3155,10 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, 
const CallExpr *Call,
   case Builtin::BI_rotr:
   case Builtin::BI_lrotr:
   case Builtin::BI_rotr64:
-return interp__builtin_rotate(S, OpPC, Frame, Call, /*Right=*/true);
+return interp__builtin_elementwise_int_binop(
+S, OpPC, Call, [](const APSInt &Value, const APSInt &Amount) -> APInt {
+  return Value.rotr(Amount);
+});
 
   case Builtin::BI__builtin_ffs:
   case Builtin::BI__builtin_ffsl:



___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Upstream CIR Dialect TryOp with Catch Attrs (PR #162897)

2025-10-17 Thread Andy Kaylor via cfe-commits


@@ -4296,6 +4296,88 @@ def CIR_AllocExceptionOp : CIR_Op<"alloc.exception"> {
   }];
 }
 
+//===--===//
+// TryOp
+//===--===//
+
+def CIR_TryOp : CIR_Op<"try",[
+  DeclareOpInterfaceMethods,
+  RecursivelySpeculatable, AutomaticAllocationScope, NoRegionArguments
+]> {
+  let summary = "C++ try block";
+  let description = [{
+Holds the lexical scope of `try {}`. Note that resources used on catch
+clauses are usually allocated in the same parent as `cir.try`.
+
+`synthetic`: use `cir.try` to represent try/catches not originally
+present in the source code. For example, a synthetic `cir.try` region
+is created around the constructor call when `operator new` is used
+so that the memory allocated will be freed if the constructor throws
+an exception.
+
+`cleanup`: indicates that there are cleanups that must be performed
+when exiting the try region via exception, even if the exception is not
+caught.
+
+Example:
+
+```mlir
+cir.try {
+  cir.call exception @function() : () -> ()
+  cir.yield
+} catch [type #cir.global_view<@_ZTIPf> : !cir.ptr] {
+  ...
+  cir.yield
+} unwind {
+  cir.resume
+}
+```
+  }];
+
+  let arguments = (ins
+UnitAttr:$synthetic,
+UnitAttr:$cleanup,
+CIR_GlobalViewOrCatchAllOrUnwindArrayAttr:$catch_types
+  );
+
+  let regions = (region
+AnyRegion:$try_region,
+VariadicRegion>:$handlers
+  );
+
+  let assemblyFormat = [{
+(`synthetic` $synthetic^)?
+(`cleanup` $cleanup^)?
+$try_region
+custom($handlers, $catch_types)

andykaylor wrote:

```suggestion
custom($handlers, $handler_types)
```

https://github.com/llvm/llvm-project/pull/162897
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][HIP][CUDA] Add `__cluster_dims__` and `__no_cluster__` attribute (PR #156686)

2025-10-17 Thread Erich Keane via cfe-commits


@@ -402,6 +405,29 @@ void AMDGPUTargetCodeGenInfo::setFunctionDeclAttributes(
 
 F->addFnAttr("amdgpu-max-num-workgroups", AttrVal.str());
   }
+
+  if (auto *Attr = FD->getAttr()) {
+uint32_t X =

erichkeane wrote:

```
auto getVal(const Expr * E) { return 
E->EvaluateKnownConstInt(M.getContext()).getExtValue()' };
```

Then you can just omit all X, Y, and Z (and avoid the problematic type here), 
and make it:

```
llvm::interleaveComma({Attr->getX(), Attr->getY(), Attr->getZ()}, OS, [&](const 
Expr *E){getVal(E); });

```

Instead of the comma stuff.  Perhaps a cast/etc needed to get the init list to 
form correctly though.

https://github.com/llvm/llvm-project/pull/156686
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [llvm][clang] Remove handling of Python2 ConfigParser module name (PR #163727)

2025-10-17 Thread David Spickett via cfe-commits

https://github.com/DavidSpickett edited 
https://github.com/llvm/llvm-project/pull/163727
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clangd] Fix regression regarding new line handling for hover/signature help content (PR #162029)

2025-10-17 Thread via cfe-commits

JWTheDBA wrote:

bump

https://github.com/llvm/llvm-project/pull/162029
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [openmp] [OpenMP] Taskgraph Clang 'record and replay' frontend support (PR #159774)

2025-10-17 Thread Julian Brown via cfe-commits


@@ -2218,7 +2218,11 @@ enum CXCursorKind {
*/
   CXCursor_OpenACCCacheConstruct = 333,
 
-  CXCursor_LastStmt = CXCursor_OpenACCCacheConstruct,
+  /** OpenMP taskgraph directive.
+   */
+  CXCursor_OMPTaskgraphDirective = 334,

jtb20 wrote:

Only that I didn't notice that gap! Thanks. I'll move the definition now, 
that's probably easier than doing it later.

https://github.com/llvm/llvm-project/pull/159774
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [ARM][KCFI] Add backend support for Kernel Control-Flow Integrity (PR #163698)

2025-10-17 Thread Ard Biesheuvel via cfe-commits


@@ -687,7 +687,9 @@ static void addKCFIPass(const Triple &TargetTriple, const 
LangOptions &LangOpts,
 PassBuilder &PB) {
   // If the back-end supports KCFI operand bundle lowering, skip KCFIPass.
   if (TargetTriple.getArch() == llvm::Triple::x86_64 ||
-  TargetTriple.isAArch64(64) || TargetTriple.isRISCV())
+  TargetTriple.isAArch64(64) || TargetTriple.isRISCV() ||
+  TargetTriple.getArch() == llvm::Triple::arm ||

ardbiesheuvel wrote:

We are talking about Thumb2 here right? Any reason we cannot just enable that 
too? Does it have to do with the encoding of the EOR instructions? Because in 
that case, I will reiterate the point I made previously, i.e., that we should 
be able to decode the expected signature in the exception handler by XOR'ing 
with the observed signature, and not look at the opcodes at all.

https://github.com/llvm/llvm-project/pull/163698
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL][NFC] Refactor for structured buffer methods tests (PR #161908)

2025-10-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Helena Kotas (hekota)


Changes

Refactoring methods tests for structured buffers to make it clearer that:
- the test functions call the buffer methods and do not directly call the LLVM 
intrinsic
- the buffer methods are defined after each test function
- show what the buffer methods bodies look like
- use buffers with different element types, not just `float`
- use `llvm-cxxfilt` tool to de-mangle names

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


2 Files Affected:

- (modified) 
clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-lib.hlsl (+82-34) 
- (modified) clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-ps.hlsl 
(+54-20) 


``diff
diff --git 
a/clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-lib.hlsl 
b/clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-lib.hlsl
index 43ddd2e768ea0..a506c2b50b1dc 100644
--- a/clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-lib.hlsl
+++ b/clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-lib.hlsl
@@ -1,64 +1,112 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-DXIL
-// RUN-DISABLED: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-SPIRV
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library 
-finclude-default-header -emit-llvm -disable-llvm-passes -o - %s | llvm-cxxfilt 
| FileCheck %s --check-prefixes=CHECK,DXIL
+// RUN-DISABLED: %clang_cc1 -triple spirv-vulkan-library 
-finclude-default-header -emit-llvm -disable-llvm-passes -o - %s | llvm-cxxfilt 
| FileCheck %s --check-prefixes=CHECK,SPV
 
 // NOTE: SPIRV codegen for resource methods is not yet implemented
 
 StructuredBuffer SB1 : register(t0);
 RWStructuredBuffer RWSB1 : register(u0);
-RWStructuredBuffer RWSB2 : register(u1);
+RWStructuredBuffer RWSB2 : register(u1);
 AppendStructuredBuffer ASB : register(u2);
-ConsumeStructuredBuffer CSB : register(u3);
+ConsumeStructuredBuffer CSB : register(u3);
 
-// CHECK: %"class.hlsl::StructuredBuffer" = type { target("dx.RawBuffer", 
float, 0, 0) }
-// CHECK: %"class.hlsl::RWStructuredBuffer" = type { target("dx.RawBuffer", 
float, 1, 0), target("dx.RawBuffer", float, 1, 0) }
-// CHECK: %"class.hlsl::AppendStructuredBuffer" = type { 
target("dx.RawBuffer", float, 1, 0), target("dx.RawBuffer", float, 1, 0) }
-// CHECK: %"class.hlsl::ConsumeStructuredBuffer" = type { 
target("dx.RawBuffer", float, 1, 0), target("dx.RawBuffer", float, 1, 0) }
+// DXIL: %"class.hlsl::StructuredBuffer" = type { target("dx.RawBuffer", 
float, 0, 0) }
+// DXIL: %"class.hlsl::RWStructuredBuffer" = type { target("dx.RawBuffer", 
float, 1, 0), target("dx.RawBuffer", float, 1, 0) }
+// DXIL: %"class.hlsl::RWStructuredBuffer.0" = type { target("dx.RawBuffer", 
<4 x i32>, 1, 0), target("dx.RawBuffer", <4 x i32>, 1, 0) }
+// DXIL: %"class.hlsl::AppendStructuredBuffer" = type { target("dx.RawBuffer", 
float, 1, 0), target("dx.RawBuffer", float, 1, 0) }
+// DXIL: %"class.hlsl::ConsumeStructuredBuffer" = type { 
target("dx.RawBuffer", double, 1, 0), target("dx.RawBuffer", double, 1, 0) }
 
 export int TestIncrementCounter() {
 return RWSB1.IncrementCounter();
 }
 
-// CHECK: define noundef i32 @_Z20TestIncrementCounterv()
-// CHECK-DXIL: %[[INDEX:.*]] = call i32 
@llvm.dx.resource.updatecounter.tdx.RawBuffer_f32_1_0t(target("dx.RawBuffer", 
float, 1, 0) %{{[0-9]+}}, i8 1)
-// CHECK-DXIL: ret i32 %[[INDEX]]
+// CHECK: define noundef i32 @TestIncrementCounter()()
+// CHECK: call noundef i32 
@hlsl::RWStructuredBuffer::IncrementCounter()(ptr {{.*}} @RWSB1)
+// CHECK: ret
+
+// CHECK: define {{.*}} noundef i32 
@hlsl::RWStructuredBuffer::IncrementCounter()(ptr {{.*}} %this)
+// CHECK: %__handle = getelementptr inbounds nuw 
%"class.hlsl::RWStructuredBuffer", ptr %{{.*}}, i32 0, i32 0
+// DXIL-NEXT: %[[HANDLE:.*]] = load target("dx.RawBuffer", float, 1, 0), ptr 
%__handle, align 4
+// DXIL-NEXT: %[[COUNTER:.*]] = call i32 
@llvm.dx.resource.updatecounter.tdx.RawBuffer_f32_1_0t(target("dx.RawBuffer", 
float, 1, 0) %[[HANDLE]], i8 1)
+// CHECK-NEXT:  ret i32 %[[COUNTER]]
+
 export int TestDecrementCounter() {
 return RWSB2.DecrementCounter();
 }
+// CHECK: define {{.*}} i32 @TestDecrementCounter()()
+// CHECK: call noundef i32 @hlsl::RWStructuredBuffer::DecrementCounter()(ptr {{.*}} @RWSB2)
+// CHECK: ret
 
-// CHECK: define noundef i32 @_Z20TestDecrementCounterv()
-// CHECK-DXIL: %[[INDEX:.*]] = call i32 
@llvm.dx.resource.updatecounter.tdx.RawBuffer_f32_1_0t(target("dx.RawBuffer", 
float, 1, 0) %{{[0-9]+}}, i8 -1)
-// CHECK-DXIL: ret i32 %[[INDEX]]
+// CHECK: define {{.*}} noundef i32 @hlsl::RWStructuredBuffer::DecrementCounter()(ptr {{.*}} %this)
+// CHECK: %__handle = getelementptr inbounds nuw 
%"class.hlsl::RWStructuredBuffer.0", ptr %{{.*}}, i32 0, i32 0
+// 

[clang] [clang] Cleanup docs and code for legacy no_sanitize attributes (NFC). (PR #161311)

2025-10-17 Thread Alexey Samsonov via cfe-commits

vonosmas wrote:

> A release note is a good idea, just 'improved the heck outa sanitize docs' 
> kinda thing.

Done

https://github.com/llvm/llvm-project/pull/161311
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   5   6   7   8   9   10   >