[clang] [llvm] [Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - allow AVX/AVX512 subvector extraction intrinsics to be used in constexpr #157712 (PR #158853)

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


@@ -678,6 +678,30 @@ static bool interp__builtin_popcount(InterpState &S, 
CodePtr OpPC,
   return true;
 }
 
+static bool interp__builtin_parity(InterpState &S, CodePtr OpPC,
+   const InterpFrame *Frame,
+   const CallExpr *Call) {
+  APSInt Val = popToAPSInt(S, Call->getArg(0));
+  pushInteger(S, Val.popcount() % 2, Call->getType());
+  return true;
+}
+
+static bool interp__builtin_clrsb(InterpState &S, CodePtr OpPC,
+  const InterpFrame *Frame,
+  const CallExpr *Call) {
+  APSInt Val = popToAPSInt(S, Call->getArg(0));
+  pushInteger(S, Val.getBitWidth() - Val.getSignificantBits(), 
Call->getType());
+  return true;
+}
+
+static bool interp__builtin_bitreverse(InterpState &S, CodePtr OpPC,
+   const InterpFrame *Frame,
+   const CallExpr *Call) {
+  APSInt Val = popToAPSInt(S, Call->getArg(0));
+  pushInteger(S, Val.reverseBits(), Call->getType());
+  return true;
+}

RKSimon wrote:

remove these - they have been removed from a recent patch

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


[clang] Sort attributes according to source position before printing (PR #162556)

2025-10-13 Thread Giuliano Belinassi via cfe-commits

giulianobelinassi wrote:

> Can we use ~`llvm::partition`~ `llvm::stable_partition` to split `Attrs` into 
> two parts by `.isValid()` so that we can use `llvm::sort`?
> 
> Please add a release note entry to clang/docs/ReleaseNotes.rst so that users 
> can know the improvement.

I am not sure this is a good idea, once that will change the order of 
attributes with invalid source locations, which is something we may not want 
to. But let me try to see the consequences of it.

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


[clang] [llvm] [LifetimeSafety] Reorganize code into modular components (PR #162474)

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

https://github.com/usx95 ready_for_review 
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] [clang][x86][bytecode] Replace interp__builtin_parity/clrsb/bitreverse/ffs with static bool interp__builtin_elementwise_int_unaryop callback (PR #162346)

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

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


[clang-tools-extra] [clang-tidy] add modernize-use-constexpr check (PR #146553)

2025-10-13 Thread Julian Schmidt via cfe-commits

5chmidti wrote:

I've cleaned things up and separated-out the C++-11-only rule-set into a new PR 
for a more incremental review and merge here: #162741

- dropped support for declarations of multiple variables in one statement
- hopefully addressed all outstanding review comments

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


[clang] [X86][Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - add SSE/AVX VPTEST/VTESTPD/VTESTPS intrinsics to be used in constexpr (PR #160428)

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


@@ -2009,90 +2009,136 @@ int test_mm_testc_pd(__m128d A, __m128d B) {
   // CHECK: call {{.*}}i32 @llvm.x86.avx.vtestc.pd(<2 x double> %{{.*}}, <2 x 
double> %{{.*}})
   return _mm_testc_pd(A, B);
 }
+TEST_CONSTEXPR(_mm_testc_pd((__m128d)(__v2df){-1.0, 
-2.0},(__m128d)(__v2df){-3.0,  4.0}) == 1);
+TEST_CONSTEXPR(_mm_testc_pd((__m128d)(__v2df){ 1.0, 
-2.0},(__m128d)(__v2df){-3.0,  4.0}) == 0);
+TEST_CONSTEXPR(_mm_testc_pd((__m128d)(__v2df){ 1.0, -2.0},(__m128d)(__v2df){ 
0.0,  5.0}) == 1);
 
 int test_mm256_testc_pd(__m256d A, __m256d B) {
   // CHECK-LABEL: test_mm256_testc_pd
   // CHECK: call {{.*}}i32 @llvm.x86.avx.vtestc.pd.256(<4 x double> %{{.*}}, 
<4 x double> %{{.*}})
   return _mm256_testc_pd(A, B);
 }
+TEST_CONSTEXPR(_mm256_testc_pd((__m256d)(__v4df){-1.0,  2.0, -3.0,  
4.0},(__m256d)(__v4df){-5.0,  6.0,  7.0,  8.0}) == 1);
+TEST_CONSTEXPR(_mm256_testc_pd((__m256d)(__v4df){ 1.0,  2.0, -3.0,  
4.0},(__m256d)(__v4df){-5.0,  6.0,  7.0,  8.0}) == 0);
+TEST_CONSTEXPR(_mm256_testc_pd((__m256d)(__v4df){-1.0, -2.0, -3.0, 
-4.0},(__m256d)(__v4df){ 5.0,  6.0,  7.0,  8.0}) == 1);
 
 int test_mm_testc_ps(__m128 A, __m128 B) {
   // CHECK-LABEL: test_mm_testc_ps
   // CHECK: call {{.*}}i32 @llvm.x86.avx.vtestc.ps(<4 x float> %{{.*}}, <4 x 
float> %{{.*}})
   return _mm_testc_ps(A, B);
 }
+TEST_CONSTEXPR(_mm_testc_ps((__m128)(__v4sf){-1,-1,-9001.1009,}, 
(__m128)(__v4sf){-1.0,-9001,9001,9000}) == 1);
+TEST_CONSTEXPR(_mm_testc_ps((__m128)(__v4sf){-1,2384.23,-9001.1009,}, 
(__m128)(__v4sf){-1.0,-9001,9001,9000}) == 0);

RKSimon wrote:

missing elements?

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


[libcxx] [libcxxabi] [libunwind] [libcxx] Use %{temp} instead of %T (PR #162323)

2025-10-13 Thread Louis Dionne via cfe-commits

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

LGTM, thanks!

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


[clang] [llvm] [PowerPC][AIX] Specify correct ABI alignment for double (PR #144673)

2025-10-13 Thread Nikita Popov via cfe-commits

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

>From c69372599c7ddccad3db078d17a65d29b3666f95 Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Wed, 11 Jun 2025 11:17:53 +0200
Subject: [PATCH 1/2] [PowerPC][AIX] Specify correct ABI alignment for double

Add `f64:32:64` to the data layout for AIX, to indicate that doubles
have a 32-bit ABI alignment and 64-bit preferred alignment.

Clang was already taking this into account, but it was not reflected
in LLVM's data layout.

Fixes https://github.com/llvm/llvm-project/issues/133599.
---
 clang/lib/Basic/Targets/PPC.h |   4 +-
 clang/lib/CodeGen/CodeGenModule.cpp   |  14 +-
 llvm/lib/IR/AutoUpgrade.cpp   |   8 +-
 llvm/lib/TargetParser/TargetDataLayout.cpp|   4 +
 llvm/test/CodeGen/PowerPC/aix-cc-abi-mir.ll   | 152 +++
 llvm/test/CodeGen/PowerPC/aix-cc-abi.ll   | 174 --
 .../PowerPC/aix-emit-tracebacktable.ll|   2 +-
 llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll   |   4 +-
 .../CodeGen/PowerPC/aix32-cc-abi-vaarg-mir.ll |  59 +++---
 .../CodeGen/PowerPC/aix32-cc-abi-vaarg.ll |  57 +++---
 .../CodeGen/PowerPC/aix64-cc-abi-vaarg-mir.ll |  12 +-
 .../CodeGen/PowerPC/aix64-cc-abi-vaarg.ll |  10 +-
 .../Bitcode/DataLayoutUpgradeTest.cpp |  12 +-
 13 files changed, 239 insertions(+), 273 deletions(-)

diff --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 9f3a4cd2da716..b538ac64e7c42 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -390,7 +390,7 @@ class LLVM_LIBRARY_VISIBILITY PPC32TargetInfo : public 
PPCTargetInfo {
   PPC32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : PPCTargetInfo(Triple, Opts) {
 if (Triple.isOSAIX())
-  resetDataLayout("E-m:a-p:32:32-Fi32-i64:64-n32");
+  resetDataLayout("E-m:a-p:32:32-Fi32-i64:64-n32-f64:32:64");
 else if (Triple.getArch() == llvm::Triple::ppcle)
   resetDataLayout("e-m:e-p:32:32-Fn32-i64:64-n32");
 else
@@ -449,7 +449,7 @@ class LLVM_LIBRARY_VISIBILITY PPC64TargetInfo : public 
PPCTargetInfo {
 
 if (Triple.isOSAIX()) {
   // TODO: Set appropriate ABI for AIX platform.
-  DataLayout = "E-m:a-Fi64-i64:64-i128:128-n32:64";
+  DataLayout = "E-m:a-Fi64-i64:64-i128:128-n32:64-f64:32:64";
   LongDoubleWidth = 64;
   LongDoubleAlign = DoubleAlign = 32;
   LongDoubleFormat = &llvm::APFloat::IEEEdouble();
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 8d019d4b2da25..e0782db6efd50 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -378,15 +378,11 @@ static void checkDataLayoutConsistency(const TargetInfo 
&Target,
 Check("bfloat", llvm::Type::getBFloatTy(Context), Target.BFloat16Align);
   Check("float", llvm::Type::getFloatingPointTy(Context, *Target.FloatFormat),
 Target.FloatAlign);
-  // FIXME: AIX specifies wrong double alignment in DataLayout
-  if (!Triple.isOSAIX()) {
-Check("double",
-  llvm::Type::getFloatingPointTy(Context, *Target.DoubleFormat),
-  Target.DoubleAlign);
-Check("long double",
-  llvm::Type::getFloatingPointTy(Context, *Target.LongDoubleFormat),
-  Target.LongDoubleAlign);
-  }
+  Check("double", llvm::Type::getFloatingPointTy(Context, 
*Target.DoubleFormat),
+Target.DoubleAlign);
+  Check("long double",
+llvm::Type::getFloatingPointTy(Context, *Target.LongDoubleFormat),
+Target.LongDoubleAlign);
   if (Target.hasFloat128Type())
 Check("__float128", llvm::Type::getFP128Ty(Context), Target.Float128Align);
   if (Target.hasIbm128Type())
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index f28b98957cae4..b6d14a8a8d3b9 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -6120,7 +6120,13 @@ std::string llvm::UpgradeDataLayoutString(StringRef DL, 
StringRef TT) {
   if (Pos != size_t(-1))
 Res.insert(Pos + I64.size(), I128);
 }
-return Res;
+  }
+
+  if (T.isPPC() && T.isOSAIX() && !DL.contains("f64:32:64") && !DL.empty()) {
+size_t Pos = Res.find("-S128");
+if (Pos == StringRef::npos)
+  Pos = Res.size();
+Res.insert(Pos, "-f64:32:64");
   }
 
   if (!T.isX86())
diff --git a/llvm/lib/TargetParser/TargetDataLayout.cpp 
b/llvm/lib/TargetParser/TargetDataLayout.cpp
index cea246e9527bd..ca610b58afa67 100644
--- a/llvm/lib/TargetParser/TargetDataLayout.cpp
+++ b/llvm/lib/TargetParser/TargetDataLayout.cpp
@@ -246,6 +246,10 @@ static std::string computePowerDataLayout(const Triple &T) 
{
   else
 Ret += "-n32";
 
+  // The ABI alignment for doubles on AIX is 4 bytes.
+  if (T.isOSAIX())
+Ret += "-f64:32:64";
+
   // Specify the vector alignment explicitly. For v256i1 and v512i1, the
   // calculated alignment would be 256*alignment(i1) and 512*alignment(i1),
   // which is 256 and 512 bytes

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

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


@@ -1474,12 +1474,12 @@ TEST_F(FormatTestComments, 
CommentsInStaticInitializers) {
   verifyFormat("S s = {{a, b, c},  // Group #1\n"
"   {d, e, f},  // Group #2\n"
"   {g, h, i}}; // Group #3");
-  verifyFormat("S s = {{// Group #1\n"
-   "a, b, c},\n"
-   "   {// Group #2\n"
-   "d, e, f},\n"
-   "   {// Group #3\n"
-   "g, h, i}};");
+  verifyFormat("S s = {{ // Group #1\n"
+   " a, b, c},\n"

HazardyKnusperkeks wrote:

It handles `{}` just the same as `()`, as a function call, and as @owenca 
pointed out: "If there is no name, a zero-length name is assumed."

It took so long, because things happen and I did not fine any time to actually 
try to work on this stuff. This is not an issue which happens in my code. 

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


[clang] [clang] Fix inconsistencies with the device_kernel attr on different targets (PR #161905)

2025-10-13 Thread Tom Honermann via cfe-commits

tahonermann wrote:

> Joseph's suggestion seems the best to me, having one of the aliases have 
> totally different semantics is just asking for trouble. If @tahonermann 
> agrees I'll update this PR to implement that.

Yes, please. Enablement of the `sycl_kernel` attribute is already subject to 
use of the `-fsycl` option. Please do revert the prior change to the 
documentation and add appropriate documentation for `device_kernel` and 
friends. I suggest doing this in a separate PR (probably one that lands before 
this one).

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


[clang] [Clang] Add __builtin_bswapg (PR #162433)

2025-10-13 Thread Timm Baeder via cfe-commits


@@ -3288,7 +3288,15 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, 
const CallExpr *Call,
   case Builtin::BI__builtin_elementwise_ctzg:
 return interp__builtin_elementwise_countzeroes(S, OpPC, Frame, Call,
BuiltinID);
-
+  case Builtin::BI__builtin_bswapg: {
+const APSInt &Val = popToAPSInt(S, Call->getArg(0));
+  assert(Val.getActiveBits() <= 64);
+if (Val.getBitWidth() == 8)
+pushInteger(S, Val, Call->getType());
+else
+pushInteger(S, Val.byteSwap(), Call->getType());
+return true;
+  }

tbaederr wrote:

Don't add the implementation in the switch. We already have 
`interp__builtin_swap` which you can just use here, provided the special case 
for 8 doesn't break anything.

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


[clang] [clang][CodeGen] Remove "unsafe-fp-math" attribute support (PR #162779)

2025-10-13 Thread via cfe-commits

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


[clang-tools-extra] [clang-tidy] add modernize-use-constexpr check (PR #162741)

2025-10-13 Thread via cfe-commits


@@ -0,0 +1,72 @@
+.. title:: clang-tidy - modernize-use-constexpr
+
+modernize-use-constexpr
+===
+
+Finds functions and variables that can be declared ``constexpr``.
+
+This check currently supports the ``constexpr`` rule-set of C++11.
+
+The check analyses any function and variable according to the rules defined
+for the language version that the code compiles with.
+Changing to a newer language standard may therefore offer additional
+opportunities to declare a function or variable as ``constexpr``.
+Furthermore, this check can be incremental in terms of its diagnostics. For
+example, declaring a function ``constepxr`` might create new opportunities of
+marking additional variables or function ``constexpr``, which can only be found
+in subsequent runs of this check.
+
+Before C++23, ``static constexpr`` variables could not be declared inside a
+``constexpr`` function. This check prefers adding ``constexpr`` to an enclosing
+function over adding ``constexpr`` to a static local variable inside that
+function.
+
+Limitations
+---
+
+* Only analyzes variables declared ``const``, because this check would have
+  to duplicate the expensive analysis of the 
+  :doc:`misc-const-correctness<../misc/const-correctness>` check.
+  For the best results, enable both `misc-const-correctness` and
+  `modernize-use-constexpr` together.
+
+* Only analyzes variable declarations that declare a single variable
+
+Options
+---
+
+.. option:: ConservativeLiteralType
+
+  With this option enabled, only literal types that can be constructed at
+  compile-time are considered to supoprt ``constexpr``.
+
+  .. code-block:: c++
+
+struct NonLiteral{
+  NonLiteral();
+  ~NonLiteral();
+  int &ref;
+};
+
+  This type is a literal type, but can not be constructed at compile-time.
+  With `ConservativeLiteralType` equal to `true`, variables or funtions

EugeneZelenko wrote:

```suggestion
  With :option:`ConservativeLiteralType` equal to `true`, variables or functions
```

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


[clang] [Driver] Remove special handling for older Ubuntu (PR #162518)

2025-10-13 Thread Brad Smith via cfe-commits

https://github.com/brad0 created 
https://github.com/llvm/llvm-project/pull/162518

Releases of Ubuntu that do not support the GNU hash style
are long unsupported.

>From b93c418279e12131e2368d82df9153f5807ab7ba Mon Sep 17 00:00:00 2001
From: Brad Smith 
Date: Wed, 8 Oct 2025 13:41:08 -0400
Subject: [PATCH] [Driver] Remove special handling for older Ubuntu

Releases of Ubuntu that do not support the GNU hash style
are long unsupported.
---
 clang/lib/Driver/ToolChains/Linux.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index 16e35b08cfbd6..49e7c482afda4 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -303,9 +303,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, 
const ArgList &Args)
   // Android loader does not support .gnu.hash until API 23.
   // Hexagon linker/loader does not support .gnu.hash
   if (!IsMips && !IsHexagon) {
-if (Distro.IsOpenSUSE() || Distro == Distro::UbuntuLucid ||
-Distro == Distro::UbuntuJaunty || Distro == Distro::UbuntuKarmic ||
-(IsAndroid && Triple.isAndroidVersionLT(23)))
+if (Distro.IsOpenSUSE() || (IsAndroid && Triple.isAndroidVersionLT(23)))
   ExtraOpts.push_back("--hash-style=both");
 else
   ExtraOpts.push_back("--hash-style=gnu");

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


[clang] Fix use of funified-lto and save-temps flags together (PR #162763)

2025-10-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Alexey Bader (bader)


Changes

> clang -flto -funified-lto -save-temps test.c

Fails with the following error message:

```bash
module flag identifiers must be unique (or of 'require' type)
!"UnifiedLTO"
fatal error: error in backend: Broken module found, compilation aborted!
clang: error: clang frontend command failed with exit code 70 (use -v to see 
invocation)
```

Here is what the driver does when `-save-temps` flag is set:

> clang -flto -funified-lto -save-temps test.c -ccc-print-phases
>  +- 0: input, "test.c", c
>   +- 1: preprocessor, {0}, cpp-output
>+- 2: compiler, {1}, ir
> +- 3: backend, {2}, lto-bc
> 4: linker, {3}, image

The IR output of "compiler" step has "UnifiedLTO" module flag. "backend"
step adds another module flag with "UnifiedLTO" identifier, which
invalidates the LLVM IR module.

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


1 Files Affected:

- (modified) clang/lib/CodeGen/BackendUtil.cpp (+2-1) 


``diff
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 2d959827d6972..d28d886b3551e 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1199,7 +1199,8 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
   }
 }
 
-if (shouldEmitUnifiedLTOModueFlag())
+if (shouldEmitUnifiedLTOModueFlag() &&
+!TheModule->getModuleFlag("UnifiedLTO"))
   TheModule->addModuleFlag(llvm::Module::Error, "UnifiedLTO", uint32_t(1));
   }
 

``




https://github.com/llvm/llvm-project/pull/162763
___
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-13 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).
+  auto emitCombiner = [&](mlir::Value lhsArg, mlir::Value rhsArg, QualType Ty) 
{
+if (const auto *RD = Ty->getAsRecordDecl()) {
+  if (combinerRecipes.size() == 1 &&
+  cgf.getContext().hasSameType(Ty, combinerRecipes[0].LHS->getType())) 
{
+// If this is a 'top level' operator on the type we can just emit this
+// as a simple one.
+emitSingleCombiner(lhsArg, rhsArg, combinerRecipes[0]);
+  } else {
+// else we have to handle each individual field after after a
+// get-element.
+for (const auto &[field, combiner] :
+ llvm::zip_equal(RD->fields(), combinerRecipes)) {
+  mlir::Type fieldType = cgf.convertType(field->getType());
+  auto fieldPtr = cir::PointerType::get(fieldType);
+
+  mlir::Value lhsField = builder.createGetMember(
+  loc, fieldPtr, lhsArg, field->getName(), field->getFieldIndex());
+  mlir::Value rhsField = builder.createGetMember(
+  loc, fieldPtr, rhsArg, field->getName(), field->getFieldIndex());
+
+  emitSingleCombiner(lhsField, rhsField, combiner);
+}
+  }
+
+} else {
+  // if this is a single-thing (because we should know this isn't an array,
+  // as Sema wouldn't let us get here), we can just do a normal emit call.

andykaylor wrote:

Maybe assert that it's not an array?

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-tools-extra] [NFC][clang-tidy] Fix potential constant overflow (PR #162647)

2025-10-13 Thread Zahira Ammarguellat via cfe-commits

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


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

2025-10-13 Thread Craig Topper via cfe-commits

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

LGTM

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


[clang] 1b627da - [CIR] Call base class destructors (#162562)

2025-10-13 Thread via cfe-commits

Author: Andy Kaylor
Date: 2025-10-09T11:19:57-07:00
New Revision: 1b627da8cfb6188c5bcf3f9a3bd35501387a462b

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

LOG: [CIR] Call base class destructors (#162562)

This adds handling for calling virtual and non-virtual base class
destructors. Non-virtual base class destructors are call from the base
(D2) destructor body for derived classes. Virtual base class destructors
are called only from the complete (D1) destructor.

Added: 


Modified: 
clang/lib/CIR/CodeGen/CIRGenCXXABI.h
clang/lib/CIR/CodeGen/CIRGenClass.cpp
clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp
clang/test/CIR/CodeGen/dtors.cpp

Removed: 




diff  --git a/clang/lib/CIR/CodeGen/CIRGenCXXABI.h 
b/clang/lib/CIR/CodeGen/CIRGenCXXABI.h
index 6030dd2365672..06f41cd8fcfdb 100644
--- a/clang/lib/CIR/CodeGen/CIRGenCXXABI.h
+++ b/clang/lib/CIR/CodeGen/CIRGenCXXABI.h
@@ -155,6 +155,14 @@ class CIRGenCXXABI {
   /// Loads the incoming C++ this pointer as it was passed by the caller.
   mlir::Value loadIncomingCXXThis(CIRGenFunction &cgf);
 
+  /// Get the implicit (second) parameter that comes after the "this" pointer,
+  /// or nullptr if there is isn't one.
+  virtual mlir::Value getCXXDestructorImplicitParam(CIRGenFunction &cgf,
+const CXXDestructorDecl 
*dd,
+CXXDtorType type,
+bool forVirtualBase,
+bool delegating) = 0;
+
   /// Emit constructor variants required by this ABI.
   virtual void emitCXXConstructors(const clang::CXXConstructorDecl *d) = 0;
 

diff  --git a/clang/lib/CIR/CodeGen/CIRGenClass.cpp 
b/clang/lib/CIR/CodeGen/CIRGenClass.cpp
index 599bef7cc6ce7..485b2c86cbc58 100644
--- a/clang/lib/CIR/CodeGen/CIRGenClass.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenClass.cpp
@@ -126,6 +126,30 @@ static bool isInitializerOfDynamicClass(const 
CXXCtorInitializer *baseInit) {
 }
 
 namespace {
+/// Call the destructor for a direct base class.
+struct CallBaseDtor final : EHScopeStack::Cleanup {
+  const CXXRecordDecl *baseClass;
+  bool baseIsVirtual;
+  CallBaseDtor(const CXXRecordDecl *base, bool baseIsVirtual)
+  : baseClass(base), baseIsVirtual(baseIsVirtual) {}
+
+  void emit(CIRGenFunction &cgf) override {
+const CXXRecordDecl *derivedClass =
+cast(cgf.curFuncDecl)->getParent();
+
+const CXXDestructorDecl *d = baseClass->getDestructor();
+// We are already inside a destructor, so presumably the object being
+// destroyed should have the expected type.
+QualType thisTy = d->getFunctionObjectParameterType();
+assert(cgf.currSrcLoc && "expected source location");
+Address addr = cgf.getAddressOfDirectBaseInCompleteClass(
+*cgf.currSrcLoc, cgf.loadCXXThisAddress(), derivedClass, baseClass,
+baseIsVirtual);
+cgf.emitCXXDestructorCall(d, Dtor_Base, baseIsVirtual,
+  /*delegating=*/false, addr, thisTy);
+  }
+};
+
 /// A visitor which checks whether an initializer uses 'this' in a
 /// way which requires the vtable to be properly set.
 struct DynamicThisUseChecker
@@ -922,8 +946,21 @@ void CIRGenFunction::enterDtorCleanups(const 
CXXDestructorDecl *dd,
   if (dtorType == Dtor_Complete) {
 assert(!cir::MissingFeatures::sanitizers());
 
-if (classDecl->getNumVBases())
-  cgm.errorNYI(dd->getSourceRange(), "virtual base destructor cleanups");
+// We push them in the forward order so that they'll be popped in
+// the reverse order.
+for (const CXXBaseSpecifier &base : classDecl->vbases()) {
+  auto *baseClassDecl = base.getType()->castAsCXXRecordDecl();
+
+  if (baseClassDecl->hasTrivialDestructor()) {
+// Under SanitizeMemoryUseAfterDtor, poison the trivial base class
+// memory. For non-trival base classes the same is done in the class
+// destructor.
+assert(!cir::MissingFeatures::sanitizers());
+  } else {
+ehStack.pushCleanup(NormalAndEHCleanup, baseClassDecl,
+  /*baseIsVirtual=*/true);
+  }
+}
 
 return;
   }
@@ -942,8 +979,8 @@ void CIRGenFunction::enterDtorCleanups(const 
CXXDestructorDecl *dd,
 if (baseClassDecl->hasTrivialDestructor())
   assert(!cir::MissingFeatures::sanitizers());
 else
-  cgm.errorNYI(dd->getSourceRange(),
-   "non-trivial base destructor cleanups");
+  ehStack.pushCleanup(NormalAndEHCleanup, baseClassDecl,
+/*baseIsVirtual=*/false);
   }
 
   assert(!cir::MissingFeatures::sanitizers());

diff  --git a/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp 
b/cl

[clang] [llvm] [clang] Introduce CallGraphSection codegen option (PR #117037)

2025-10-13 Thread Prabhu Rajasekaran via cfe-commits

Prabhuk wrote:

@arsenm -- The patches that precede this change in llvm have landed. I am 
planning to land this early next week if there are no objections.

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


[clang-tools-extra] [clang-tidy] add modernize-use-constexpr check (PR #162741)

2025-10-13 Thread via cfe-commits


@@ -0,0 +1,72 @@
+.. title:: clang-tidy - modernize-use-constexpr
+
+modernize-use-constexpr
+===
+
+Finds functions and variables that can be declared ``constexpr``.
+
+This check currently supports the ``constexpr`` rule-set of C++11.
+
+The check analyses any function and variable according to the rules defined
+for the language version that the code compiles with.
+Changing to a newer language standard may therefore offer additional
+opportunities to declare a function or variable as ``constexpr``.
+Furthermore, this check can be incremental in terms of its diagnostics. For
+example, declaring a function ``constepxr`` might create new opportunities of
+marking additional variables or function ``constexpr``, which can only be found
+in subsequent runs of this check.
+
+Before C++23, ``static constexpr`` variables could not be declared inside a
+``constexpr`` function. This check prefers adding ``constexpr`` to an enclosing
+function over adding ``constexpr`` to a static local variable inside that
+function.
+
+Limitations
+---
+
+* Only analyzes variables declared ``const``, because this check would have
+  to duplicate the expensive analysis of the 
+  :doc:`misc-const-correctness<../misc/const-correctness>` check.
+  For the best results, enable both `misc-const-correctness` and
+  `modernize-use-constexpr` together.
+
+* Only analyzes variable declarations that declare a single variable
+
+Options
+---
+
+.. option:: ConservativeLiteralType
+
+  With this option enabled, only literal types that can be constructed at
+  compile-time are considered to supoprt ``constexpr``.
+
+  .. code-block:: c++
+
+struct NonLiteral{
+  NonLiteral();
+  ~NonLiteral();
+  int &ref;
+};
+
+  This type is a literal type, but can not be constructed at compile-time.
+  With `ConservativeLiteralType` equal to `true`, variables or funtions

EugeneZelenko wrote:

This is not code, but option name and value, so should be in single back-ticks.

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


[clang] [C2y] Claim support for WG14 N3623 (PR #162843)

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

https://github.com/AaronBallman created 
https://github.com/llvm/llvm-project/pull/162843

This requires invalid signatures of main to be diagnosed while still allowing 
for common extensions. Clang has always supported this.

>From 67b3435b81d2f0f3c6f1d7bf92eea98e1ee90d02 Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Fri, 10 Oct 2025 09:37:27 -0400
Subject: [PATCH] [C2y] Claim support for WG14 N3623

This requires invalid signatures of main to be diagnosed while still
allowing for common extensions. Clang has always supported this.
---
 clang/test/C/C2y/n3623.c | 74 
 clang/www/c_status.html  |  2 +-
 2 files changed, 75 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/C/C2y/n3623.c

diff --git a/clang/test/C/C2y/n3623.c b/clang/test/C/C2y/n3623.c
new file mode 100644
index 0..a557edadae078
--- /dev/null
+++ b/clang/test/C/C2y/n3623.c
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 -verify -std=c2y -DSTD1 %s
+// RUN: %clang_cc1 -verify -std=c2y -DSTD2 %s
+// RUN: %clang_cc1 -verify=gnu1 -std=gnu2y -DGNU1 %s
+// RUN: %clang_cc1 -verify -std=gnu2y -DGNU2 %s
+// RUN: %clang_cc1 -verify=gnu3 -std=gnu2y -DGNU3 %s
+// RUN: %clang_cc1 -verify -std=gnu2y -DGNU4 %s
+// RUN: %clang_cc1 -verify -std=gnu2y -DGNU5 %s
+// RUN: %clang_cc1 -verify -std=gnu2y -DGNU6 %s
+// RUN: %clang_cc1 -verify=gnu7 -std=gnu2y -DGNU7 %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin12 -verify -std=c2y -DDARWIN1 %s
+// RUN: %clang_cc1 -triple x86_64-pc-win32-mscv -verify -std=c2y 
-fms-compatibility -DMS1 %s
+// RUN: %clang_cc1 -triple x86_64-pc-win32-mscv -verify -std=c2y 
-fms-compatibility -DMS2 %s
+// RUN: %clang_cc1 -verify=invalid -std=c2y -DINVALID1 %s
+// RUN: %clang_cc1 -verify=invalid -std=c2y -DINVALID2 %s
+// expected-no-diagnostics
+
+/* WG14 N3623: Yes
+ * Earthly Demon XV: Definition of Main
+ *
+ * This validates that we accept the standard type definitions of main or some
+ * other implementation-defined type.
+ */
+
+typedef __WCHAR_TYPE__ wchar_t;
+
+// These are the signatures required by the standard.
+#if defined(STD1)
+int main(void) {}
+#elif defined(STD2)
+int main(int argc, char *argv[]) {}
+#endif
+
+// GNU extensions.
+#if defined(GNU1)
+void main(void) {} /* gnu1-warning {{return type of 'main' is not 'int'}}
+  gnu1-note {{change return type to 'int'}}
+*/
+#elif defined(GNU2)
+const int main(void) {}
+#elif defined(GNU3)
+int main(...) {} /* gnu3-warning {{'main' is not allowed to be declared 
variadic}} */
+#elif defined(GNU4)
+int main(int, const char **) {}
+#elif defined(GNU5)
+int main(int, char const * const *) {}
+#elif defined(GNU6)
+int main(int, char * const *) {}
+#elif defined(GNU7)
+int main(int) {} /* gnu7-warning {{only one parameter on 'main' declaration}} 
*/
+#endif
+
+// Darwin extensions.
+#if defined(DARWIN1)
+int main(int argc, char *argv[], char *environ[], char **undocumented) {}
+#endif
+
+// Microsoft extensions.
+#if defined(MS1)
+int wmain(int, wchar_t *[]) {}
+#elif defined(MS2)
+int wmain(int, wchar_t *[], wchar_t *[]) {}
+#endif
+
+// Invalid signatures.
+#if defined(INVALID1)
+inline int main(int, char *[]); /* invalid-error {{'main' is not allowed to be 
declared inline}} */
+int main(int, char *[], char *[], float); /* invalid-error {{too many 
parameters (4) for 'main': must be 0, 2, or 3}} */
+float main(int); /* invalid-error {{'main' must return 'int'}} */
+_Noreturn int main(int, char *[]); /* invalid-warning {{'main' is not allowed 
to be declared _Noreturn}}
+  invalid-note {{remove '_Noreturn'}}
+*/
+#elif defined(INVALID2)
+static int main(void); /* invalid-warning {{'main' should not be declared 
static}} */
+#endif
diff --git a/clang/www/c_status.html b/clang/www/c_status.html
index f16c40202aa21..a6bcd4c197133 100644
--- a/clang/www/c_status.html
+++ b/clang/www/c_status.html
@@ -339,7 +339,7 @@ C2y implementation status
 
   Earthly Demon XV: Definition of Main
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3623.pdf";>N3623
-  Unknown
+  Yes

 
   static_assert without UB

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


[clang] [libcxx] [clang] [libc++] fix _Atomic c11 compare exchange does not update expected results (PR #78707)

2025-10-13 Thread Louis Dionne via cfe-commits




ldionne wrote:

Let's give a real name to this test file.

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


[clang] [llvm] [clang][docs] Update doc and release note for probe instrumentation (PR #162606)

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

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


https://github.com/llvm/llvm-project/pull/162606
___
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-13 Thread Nikita Popov via cfe-commits


@@ -10,30 +10,30 @@
 // CHECK-C-SAME: i32 noundef [[SLICE_BASE:%.*]],  
[[PG:%.*]], ptr noundef [[PTR:%.*]], i64 noundef [[VNUM:%.*]]) 
local_unnamed_addr #[[ATTR0:[0-9]+]] {
 // CHECK-C-NEXT:  entry:
 // CHECK-C-NEXT:[[TMP0:%.*]] = tail call i64 @llvm.vscale.i64()
-// CHECK-C-NEXT:[[TMP1:%.*]] = shl i64 [[VNUM]], 4
-// CHECK-C-NEXT:[[MULVL:%.*]] = mul i64 [[TMP1]], [[TMP0]]
-// CHECK-C-NEXT:[[TMP2:%.*]] = getelementptr i8, ptr [[PTR]], i64 [[MULVL]]
-// CHECK-C-NEXT:[[TMP3:%.*]] = trunc i64 [[VNUM]] to i32
-// CHECK-C-NEXT:[[TMP4:%.*]] = add i32 [[SLICE_BASE]], [[TMP3]]
-// CHECK-C-NEXT:tail call void @llvm.aarch64.sme.ld1b.horiz( [[PG]], ptr [[TMP2]], i32 0, i32 [[TMP4]])
-// CHECK-C-NEXT:[[ADD:%.*]] = add i32 [[SLICE_BASE]], [[TMP3]]
-// CHECK-C-NEXT:[[TMP5:%.*]] = add i32 [[ADD]], 15
-// CHECK-C-NEXT:tail call void @llvm.aarch64.sme.ld1b.horiz( [[PG]], ptr [[TMP2]], i32 0, i32 [[TMP5]])
+// CHECK-C-NEXT:[[SVL:%.*]] = shl nuw nsw i64 [[TMP0]], 4

nikic wrote:

That looks like ptradd canonicalization. But I still don't understand why this 
patch changes anything about the nowrap handling here.

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] [Sema] Compare canonical conversion function (PR #154158)

2025-10-13 Thread Jonas Hahnfeld via cfe-commits

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


[libclc] [libclc] Replace float remquo with Intel IMF version (PR #162643)

2025-10-13 Thread Wenju He via cfe-commits

https://github.com/wenju-he updated 
https://github.com/llvm/llvm-project/pull/162643

>From 4574b973070d237c88f8a951e9a3c0fc9afcaeaf Mon Sep 17 00:00:00 2001
From: Wenju He 
Date: Thu, 9 Oct 2025 14:19:17 +0200
Subject: [PATCH 1/2] [libclc] Replace float remquo with Intel IMF version

Current implementation has two issues:
- unconditionally soft flushes denormal.
- can't pass OpenCL CTS test "test_bruteforce remquo" on intel gpu.

This PR upstreams remquo implementation from Intel Math Functions (IMF)
Device Library. It supports denormal and can pass OpenCL CTS test.
---
 libclc/clc/lib/generic/math/clc_remquo.cl  |   1 +
 libclc/clc/lib/generic/math/clc_remquo.inc | 308 +
 2 files changed, 248 insertions(+), 61 deletions(-)

diff --git a/libclc/clc/lib/generic/math/clc_remquo.cl 
b/libclc/clc/lib/generic/math/clc_remquo.cl
index fd83ead06d89a..4039d39e17c65 100644
--- a/libclc/clc/lib/generic/math/clc_remquo.cl
+++ b/libclc/clc/lib/generic/math/clc_remquo.cl
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/libclc/clc/lib/generic/math/clc_remquo.inc 
b/libclc/clc/lib/generic/math/clc_remquo.inc
index 3a76ffed7f039..d248e770b7560 100644
--- a/libclc/clc/lib/generic/math/clc_remquo.inc
+++ b/libclc/clc/lib/generic/math/clc_remquo.inc
@@ -6,71 +6,257 @@
 //
 
//===--===//
 
+#define _sHighMask 0xf000u
+#define _iMaxQExp 0xbu
+// To prevent YLow to be denormal it should be checked
+// that Exp(Y) <= -127+23 (worst case when only last bit is non zero)
+//  Exp(Y) < -103 -> Y < 0x0C00
+// That value is used to construct _iYSub by setting up first bit to 1.
+// _iYCmp is get from max acceptable value 0x797f:
+//   0x797f - 0x8C00 = 0x(1)ED7F
+#define _iYSub 0x8C00u
+#define _iYCmp 0xED7Fu
+#define _iOne 0x0001u
+
+static _CLC_INLINE _CLC_OVERLOAD int
+internal_remquo(float x, float y, float *r, __CLC_ADDRESS_SPACE uint *q) {
+  uint signif_x, signif_y, rem_bit, quo_bit, tmp_x, tmp_y;
+  int exp_x, exp_y, i, j;
+  uint expabs_diff, special_op = 0, signbit_x, signbit_y, sign = 1;
+  float result, abs_x, abs_y;
+  float zero = 0.0f;
+  int nRet = 0;
+  // Remove sign bits
+  tmp_x = ((*(int *)&x)) & EXSIGNBIT_SP32;
+  tmp_y = ((*(int *)&y)) & EXSIGNBIT_SP32;
+  signbit_x = (uint)((*(int *)&x) >> 31);
+  signbit_y = (uint)((*(int *)&y) >> 31);
+  if (signbit_x ^ signbit_y)
+sign = (-sign);
+  // Get float absolute values
+  abs_x = *(float *)&tmp_x;
+  abs_y = *(float *)&tmp_y;
+  // Remove exponent bias
+  exp_x = (int)((tmp_x & (0x7FF0L)) >> 23) - 127;
+  exp_y = (int)((tmp_y & (0x7FF0L)) >> 23) - 127;
+  // Test for NaNs, Infs, and Zeros
+  if ((exp_x == (0x0080L)) || (exp_y == (0x0080L)) ||
+  (tmp_x == (0xL)) || (tmp_y == (0xL)))
+special_op++;
+  // Get significands
+  signif_x = (tmp_x & (0x007FL));
+  signif_y = (tmp_y & (0x007FL));
+  // Process NaNs, Infs, and Zeros
+  if (special_op) {
+(*q) = 0;
+// x is NaN
+if ((signif_x != (0xL)) && (exp_x == (0x0080L)))
+  result = x * 1.7f;
+// y is NaN
+else if ((signif_y != (0xL)) && (exp_y == (0x0080L)))
+  result = y * 1.7f;
+// y is zero
+else if (abs_y == zero) {
+  result = zero / zero;
+  nRet = 1;
+}
+// x is zero
+else if (abs_x == zero)
+  result = x;
+// x is Inf
+else if ((signif_x == (0xL)) && (exp_x == (0x0080L)))
+  result = zero / zero;
+// y is Inf
+else
+  result = x;
+(*r) = (result);
+return nRet;
+  }
+  // If x < y, fast return
+  if (abs_x <= abs_y) {
+(*q) = 1 * sign;
+if (abs_x == abs_y) {
+  (*r) = (zero * x);
+  return nRet;
+}
+// Is x too big to scale up by 2.0f?
+if (exp_x != 127) {
+  if ((2.0f * abs_x) <= abs_y) {
+(*q) = 0;
+(*r) = x;
+return nRet;
+  }
+}
+result = abs_x - abs_y;
+if (signbit_x) {
+  result = -result;
+}
+(*r) = (result);
+return nRet;
+  }
+  // Check for denormal x and y, adjust and normalize
+  if ((exp_x == -127) && (signif_x != (0xL))) {
+exp_x = -126;
+while (signif_x <= (0x007FL)) {
+  exp_x--;
+  signif_x <<= 1;
+};
+  } else
+signif_x = (signif_x | (0x0080L));
+  if ((exp_y == -127) && (signif_y != (0xL))) {
+exp_y = -126;
+while (signif_y <= (0x007FL)) {
+  exp_y--;
+  signif_y <<= 1;
+};
+  } else
+signif_y = (signif_y | (0x0080L));
+  //
+  // Main computational path
+  //
+  // Calculate exponent difference
+  expabs_diff = (exp_x - exp_y) + 1;
+  rem_bit = signif_x;
+  quo_bit = 0;
+  for (i = 0; i < expabs_diff; i++) {
+quo_bit = quo_bit << 1;
+if (rem_bit >= signif_y) {
+  rem_bit -= signif_y;
+  quo_bit++;
+}
+rem_bit <<= 1;
+  }
+  // Zero remquo .

[clang] [Sema] Keep attribute lists in the order the attributes were parsed (PR #162714)

2025-10-13 Thread Saleem Abdulrasool via cfe-commits


@@ -20,7 +20,7 @@ struct __attribute__((internal_linkage)) S { // 
expected-warning{{'internal_link
 __attribute__((internal_linkage("foo"))) int g(void) {} // 
expected-error{{'internal_linkage' attribute takes no arguments}}
 
 int var6 [[clang::internal_linkage]];
-int var7 [[clang::internal_linkage]] __attribute__((common)); // 
expected-error{{'clang::internal_linkage' and 'common' attributes are not 
compatible}} \
+int var7 [[clang::internal_linkage]] __attribute__((common)); // 
expected-error{{'common' and 'clang::internal_linkage' attributes are not 
compatible}} \

compnerd wrote:

Yeah, I think that the rephrasing of the warning would absolutely help!

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


[clang] [Clang] Add __builtin_bswapg (PR #162433)

2025-10-13 Thread Oliver Hunt via cfe-commits

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


[libcxx] [libcxxabi] [libunwind] [runtimes][NFC] Consistently declare main() functions in tests (PR #162548)

2025-10-13 Thread via cfe-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff origin/main HEAD --extensions cpp -- 
libcxx/test/std/localization/codecvt_unicode.pass.cpp 
libcxx/test/std/ranges/range.access/include.iterator.pass.cpp 
libcxxabi/test/forced_unwind4.pass.cpp 
libcxxabi/test/native/AArch64/ra_sign_state.pass.cpp 
libunwind/test/aarch64_vg_unwind.pass.cpp 
libunwind/test/bad_unwind_info.pass.cpp 
libunwind/test/eh_frame_fde_pc_range.pass.cpp 
libunwind/test/floatregister.pass.cpp libunwind/test/forceunwind.pass.cpp 
libunwind/test/unw_resume.pass.cpp 
libunwind/test/unwind_scalable_vectors.pass.cpp
``

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:





View the diff from clang-format here.


``diff
diff --git a/libcxxabi/test/forced_unwind4.pass.cpp 
b/libcxxabi/test/forced_unwind4.pass.cpp
index 241bc2982..fbc8128af 100644
--- a/libcxxabi/test/forced_unwind4.pass.cpp
+++ b/libcxxabi/test/forced_unwind4.pass.cpp
@@ -17,9 +17,7 @@
 
 // Android/Bionic does not support pthread_cancel.
 #ifdef __BIONIC__
-int main(int, char**) {
-  return 0;
-}
+int main(int, char**) { return 0; }
 #else
 
 #include 
diff --git a/libunwind/test/bad_unwind_info.pass.cpp 
b/libunwind/test/bad_unwind_info.pass.cpp
index 95fdb282d..272a83f64 100644
--- a/libunwind/test/bad_unwind_info.pass.cpp
+++ b/libunwind/test/bad_unwind_info.pass.cpp
@@ -77,7 +77,7 @@ extern "C" void stepper() {
   assert(unw_step(&cursor) <= 0);
 }
 
-int main(int, char**) {
+int main(int, char **) {
   bad_unwind_info();
   return 0;
 }
diff --git a/libunwind/test/eh_frame_fde_pc_range.pass.cpp 
b/libunwind/test/eh_frame_fde_pc_range.pass.cpp
index c28a2759c..795ce6680 100644
--- a/libunwind/test/eh_frame_fde_pc_range.pass.cpp
+++ b/libunwind/test/eh_frame_fde_pc_range.pass.cpp
@@ -53,7 +53,7 @@ void f() {
   assert(fde_fpc == fde_fpc1);
 }
 
-int main(int, char**) {
+int main(int, char **) {
   f();
   return 0;
 }
diff --git a/libunwind/test/unw_resume.pass.cpp 
b/libunwind/test/unw_resume.pass.cpp
index 17c3e8a4f..e1f40b4a4 100644
--- a/libunwind/test/unw_resume.pass.cpp
+++ b/libunwind/test/unw_resume.pass.cpp
@@ -25,7 +25,7 @@ __attribute__((noinline)) void test_unw_resume() {
   unw_resume(&cursor);
 }
 
-int main(int, char**) {
+int main(int, char **) {
   test_unw_resume();
   return 0;
 }

``




https://github.com/llvm/llvm-project/pull/162548
___
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-13 Thread Simon Pilgrim via cfe-commits

https://github.com/RKSimon auto_merge_enabled 
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] [Driver] Remove special handling for older Ubuntu (PR #162518)

2025-10-13 Thread Brad Smith via cfe-commits

https://github.com/brad0 updated 
https://github.com/llvm/llvm-project/pull/162518

>From 5ed713889daa8bf71f11c96398b23567d5382488 Mon Sep 17 00:00:00 2001
From: Brad Smith 
Date: Wed, 8 Oct 2025 13:41:08 -0400
Subject: [PATCH] [Driver] Remove special handling for older Ubuntu

Releases of Ubuntu that do not support the GNU hash style
are long unsupported.
---
 clang/lib/Driver/ToolChains/Linux.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index 16e35b08cfbd6..aa53418b2efdd 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -302,10 +302,9 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, 
const ArgList &Args)
   // ABI requires a mapping between the GOT and the symbol table.
   // Android loader does not support .gnu.hash until API 23.
   // Hexagon linker/loader does not support .gnu.hash
+  // SUSE SLES 11 will stop being supported Mar 28.
   if (!IsMips && !IsHexagon) {
-if (Distro.IsOpenSUSE() || Distro == Distro::UbuntuLucid ||
-Distro == Distro::UbuntuJaunty || Distro == Distro::UbuntuKarmic ||
-(IsAndroid && Triple.isAndroidVersionLT(23)))
+if (Distro.IsOpenSUSE() || (IsAndroid && Triple.isAndroidVersionLT(23)))
   ExtraOpts.push_back("--hash-style=both");
 else
   ExtraOpts.push_back("--hash-style=gnu");

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


[clang] a9dafc9 - [Sema] Compare canonical conversion function (#154158)

2025-10-13 Thread via cfe-commits

Author: Jonas Hahnfeld
Date: 2025-10-06T10:34:49+02:00
New Revision: a9dafc9bdcfc1090d0744d0c708c5d133bc0fd84

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

LOG: [Sema] Compare canonical conversion function (#154158)

With lazy template loading, it is possible to find non-canonical
FunctionDecls, depending on when redecl chains are completed. This
is a problem for templated conversion operators that would allow to
call either the copy assignment or the move assignment operator.
This ambiguity is resolved by isBetterReferenceBindingKind (called
from CompareStandardConversionSequences) ranking rvalue refs over
lvalue refs.

Unfortunately, this fix is hard to test in isolation without the
changes in https://github.com/llvm/llvm-project/pull/133057 that
make lazy template loading more likely to complete redecl chains
at "inconvenient" times. The added reproducer passes before and
after this commit, but would have failed with the proposed changes
of the linked PR.

Kudos to Maksim Ivanov for providing an initial version of the
reproducer that I further simplified.

Added: 
clang/test/Modules/pr133057.cpp

Modified: 
clang/lib/Sema/SemaOverload.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index b8701147ae7d4..5657dfe0b9553 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -4413,14 +4413,23 @@ CompareImplicitConversionSequences(Sema &S, 
SourceLocation Loc,
 Result = CompareStandardConversionSequences(S, Loc,
 ICS1.Standard, ICS2.Standard);
   else if (ICS1.isUserDefined()) {
+// With lazy template loading, it is possible to find non-canonical
+// FunctionDecls, depending on when redecl chains are completed. Make sure
+// to compare the canonical decls of conversion functions. This avoids
+// ambiguity problems for templated conversion operators.
+const FunctionDecl *ConvFunc1 = ICS1.UserDefined.ConversionFunction;
+if (ConvFunc1)
+  ConvFunc1 = ConvFunc1->getCanonicalDecl();
+const FunctionDecl *ConvFunc2 = ICS2.UserDefined.ConversionFunction;
+if (ConvFunc2)
+  ConvFunc2 = ConvFunc2->getCanonicalDecl();
 // User-defined conversion sequence U1 is a better conversion
 // sequence than another user-defined conversion sequence U2 if
 // they contain the same user-defined conversion function or
 // constructor and if the second standard conversion sequence of
 // U1 is better than the second standard conversion sequence of
 // U2 (C++ 13.3.3.2p3).
-if (ICS1.UserDefined.ConversionFunction ==
-  ICS2.UserDefined.ConversionFunction)
+if (ConvFunc1 == ConvFunc2)
   Result = CompareStandardConversionSequences(S, Loc,
   ICS1.UserDefined.After,
   ICS2.UserDefined.After);

diff  --git a/clang/test/Modules/pr133057.cpp b/clang/test/Modules/pr133057.cpp
new file mode 100644
index 0..b273fc318058e
--- /dev/null
+++ b/clang/test/Modules/pr133057.cpp
@@ -0,0 +1,143 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -xc++ -std=c++20 -emit-module -fmodule-name=hf 
-fno-cxx-modules -fmodules -fno-implicit-modules %t/CMO.cppmap -o %t/WI9.pcm
+// RUN: %clang_cc1 -xc++ -std=c++20 -emit-module -fmodule-name=g 
-fno-cxx-modules -fmodules -fno-implicit-modules -fmodule-file=%t/WI9.pcm 
%t/E6H.cppmap -o %t/4BK.pcm
+// RUN: %clang_cc1 -xc++ -std=c++20 -emit-module -fmodule-name=r 
-fno-cxx-modules -fmodules -fno-implicit-modules -fmodule-file=%t/WI9.pcm 
%t/HMT.cppmap -o %t/LUM.pcm
+// RUN: %clang_cc1 -xc++ -std=c++20 -emit-module -fmodule-name=q 
-fno-cxx-modules -fmodules -fno-implicit-modules -fmodule-file=%t/LUM.pcm 
-fmodule-file=%t/4BK.pcm %t/JOV.cppmap -o %t/9VX.pcm
+// RUN: %clang_cc1 -xc++ -std=c++20 -verify -fsyntax-only -fno-cxx-modules 
-fmodules -fno-implicit-modules -fmodule-file=%t/9VX.pcm %t/XFD.cc
+
+//--- 2OT.h
+#include "LQ1.h"
+
+namespace ciy {
+namespace xqk {
+template 
+class vum {
+ public:
+  using sc = std::C::wmd;
+  friend bool operator==(vum, vum);
+};
+template 
+class me {
+ public:
+  using vbh = vum;
+  using sc = std::C::vy::sc;
+  template 
+  operator db() { return {}; }
+};
+}  // namespace xqk
+template 
+xqk::me uvo(std::C::wmd, vus);
+}  // namespace ciy
+
+class ua {
+  std::C::wmd kij() {
+ciy::uvo(kij(), '-');
+return {};
+  }
+};
+
+//--- 9KF.h
+#include "LQ1.h"
+#include "2OT.h"
+namespace {
+void al(std::C::wmd lou) { std::C::jv yt = ciy::uvo(lou, '/'); }
+}  // namespace
+
+//--- CMO.cppmap
+module "hf" {
+header "LQ1.h"
+}
+
+
+//--- E6H.cppmap
+module "g" {
+export *
+head