[llvm-branch-commits] MC: Refactor FT_Align fragments when linker relaxation is enabled (PR #149465)
https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/149465 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] MC: Refactor FT_Align fragments when linker relaxation is enabled (PR #149465)
@@ -992,7 +965,30 @@ void MCAssembler::layoutSection(MCSection &Sec) { uint64_t Offset = 0; for (MCFragment &F : Sec) { F.Offset = Offset; -Offset += computeFragmentSize(F); +if (F.getKind() == MCFragment::FT_Align) { + Offset += F.getFixedSize(); + unsigned Size = offsetToAlignment(Offset, F.getAlignment()); + // In the nops mode, RISC-V style linker relaxation might adjust the size + // and add a fixup, even if `Size` is originally 0. + bool AlignFixup = false; + if (F.hasAlignEmitNops()) { +AlignFixup = getBackend().relaxAlign(F, Size); +// If the backend does not handle the fragment specially, pad with nops, +// but ensure that the padding is larger than the minimum nop size. +if (!AlignFixup) + while (Size % getBackend().getMinimumNopSize()) +Size += F.getAlignment().value(); + } + if (!AlignFixup && Size > F.getAlignMaxBytesToEmit()) +Size = 0; + // Update the variable tail size. The content is ignored. + F.VarContentEnd = F.VarContentStart + Size; MaskRay wrote: Agree! Let me try `assert(F.VarContentStart == 0);` https://github.com/llvm/llvm-project/pull/149465 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] MC: Refactor FT_Align fragments when linker relaxation is enabled (PR #149465)
MaskRay wrote: Next steps: * Allocate the fixed content as trailing data of the MCFragment by utilizing a special bump allocator (gnulib obstack) * Delete MCFixup member variables from MCFragment. Instead, add a MCFragment pointer to MCFixup. https://github.com/llvm/llvm-project/pull/149465 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] MC: Refactor FT_Align fragments when linker relaxation is enabled (PR #149465)
https://github.com/MaskRay edited https://github.com/llvm/llvm-project/pull/149465 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] MC: Refactor FT_Align fragments when linker relaxation is enabled (PR #149465)
https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/149465 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [mlir] Nominate Tensor Compiler maintainers (PR #149488)
javedabsar1 wrote: is this the right place to volunteer? https://github.com/llvm/llvm-project/pull/149488 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [LifetimeSafety] Implement a basic use-after-free diagnostic (PR #149731)
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/149731 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [LoongArch] Optimize general fp build_vector lowering (PR #149486)
https://github.com/tangaac approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/149486 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libclc] [libclc] Revert the recent breaking changes from CMake from the 21.x release branch (PR #149711)
=?utf-8?q?Micha=C5=82_G=C3=B3rny?= , =?utf-8?q?Micha=C5=82_G=C3=B3rny?= , =?utf-8?q?Micha=C5=82_G=C3=B3rny?= , =?utf-8?q?Micha=C5=82_G=C3=B3rny?= Message-ID: In-Reply-To: https://github.com/thesamesam approved this pull request. https://github.com/llvm/llvm-project/pull/149711 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [flang] release/21.x: [SPARC][Driver] Move feature mode selection to Arch/Sparc.cpp (#149652) (PR #149756)
llvmbot wrote: @llvm/pr-subscribers-clang Author: None (llvmbot) Changes Backport 38fc453afdb6a4511b7c8e189f12a92559ecc396 Requested by: @brad0 --- Full diff: https://github.com/llvm/llvm-project/pull/149756.diff 6 Files Affected: - (modified) clang/lib/Driver/ToolChains/Arch/Sparc.cpp (+10-1) - (modified) clang/lib/Driver/ToolChains/Arch/Sparc.h (+2-1) - (modified) clang/lib/Driver/ToolChains/Clang.cpp (-10) - (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+1-1) - (modified) clang/lib/Driver/ToolChains/Flang.cpp (+1) - (modified) flang/test/Driver/target-cpu-features.f90 (+7) ``diff diff --git a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp index 9595ee8383c85..504f110eac87c 100644 --- a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp +++ b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp @@ -130,7 +130,8 @@ std::string sparc::getSparcTargetCPU(const Driver &D, const ArgList &Args, return ""; } -void sparc::getSparcTargetFeatures(const Driver &D, const ArgList &Args, +void sparc::getSparcTargetFeatures(const Driver &D, const llvm::Triple &Triple, + const ArgList &Args, std::vector &Features) { sparc::FloatABI FloatABI = sparc::getSparcFloatABI(D, Args); if (FloatABI == sparc::FloatABI::Soft) @@ -150,11 +151,19 @@ void sparc::getSparcTargetFeatures(const Driver &D, const ArgList &Args, Features.push_back("-popc"); } + // Those OSes default to enabling VIS on 64-bit SPARC. + // See also the corresponding code for external assemblers in + // sparc::getSparcAsmModeForCPU(). + bool IsSparcV9ATarget = + (Triple.getArch() == llvm::Triple::sparcv9) && + (Triple.isOSLinux() || Triple.isOSFreeBSD() || Triple.isOSOpenBSD()); if (Arg *A = Args.getLastArg(options::OPT_mvis, options::OPT_mno_vis)) { if (A->getOption().matches(options::OPT_mvis)) Features.push_back("+vis"); else Features.push_back("-vis"); + } else if (IsSparcV9ATarget) { +Features.push_back("+vis"); } if (Arg *A = Args.getLastArg(options::OPT_mvis2, options::OPT_mno_vis2)) { diff --git a/clang/lib/Driver/ToolChains/Arch/Sparc.h b/clang/lib/Driver/ToolChains/Arch/Sparc.h index 2b178d9df1ee3..fa25b4992cc8b 100644 --- a/clang/lib/Driver/ToolChains/Arch/Sparc.h +++ b/clang/lib/Driver/ToolChains/Arch/Sparc.h @@ -31,7 +31,8 @@ FloatABI getSparcFloatABI(const Driver &D, const llvm::opt::ArgList &Args); std::string getSparcTargetCPU(const Driver &D, const llvm::opt::ArgList &Args, const llvm::Triple &Triple); -void getSparcTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, +void getSparcTargetFeatures(const Driver &D, const llvm::Triple &Triple, +const llvm::opt::ArgList &Args, std::vector &Features); const char *getSparcAsmModeForCPU(llvm::StringRef Name, const llvm::Triple &Triple); diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 456bfe885f354..bf5f427fbfbb4 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2731,16 +2731,6 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, CmdArgs.push_back(MipsTargetFeature); } - // Those OSes default to enabling VIS on 64-bit SPARC. - // See also the corresponding code for external assemblers in - // sparc::getSparcAsmModeForCPU(). - bool IsSparcV9ATarget = - (C.getDefaultToolChain().getArch() == llvm::Triple::sparcv9) && - (Triple.isOSLinux() || Triple.isOSFreeBSD() || Triple.isOSOpenBSD()); - if (IsSparcV9ATarget && SparcTargetFeatures.empty()) { -CmdArgs.push_back("-target-feature"); -CmdArgs.push_back("+vis"); - } for (const char *Feature : SparcTargetFeatures) { CmdArgs.push_back("-target-feature"); CmdArgs.push_back(Feature); diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 097d186ad8ea4..069fd877bd7f8 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -856,7 +856,7 @@ void tools::getTargetFeatures(const Driver &D, const llvm::Triple &Triple, case llvm::Triple::sparc: case llvm::Triple::sparcel: case llvm::Triple::sparcv9: -sparc::getSparcTargetFeatures(D, Args, Features); +sparc::getSparcTargetFeatures(D, Triple, Args, Features); break; case llvm::Triple::r600: case llvm::Triple::amdgcn: diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index 1edb83f7255eb..7ab41e9b85a04 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -447,6 +447,7 @@ void Flang::addTargetOptions(const ArgList &Args, // Add the target features. switch (TC.getArch()) { default: +getTargetFeat
[llvm-branch-commits] [clang] [flang] release/21.x: [SPARC][Driver] Move feature mode selection to Arch/Sparc.cpp (#149652) (PR #149756)
llvmbot wrote: @llvm/pr-subscribers-backend-sparc Author: None (llvmbot) Changes Backport 38fc453afdb6a4511b7c8e189f12a92559ecc396 Requested by: @brad0 --- Full diff: https://github.com/llvm/llvm-project/pull/149756.diff 6 Files Affected: - (modified) clang/lib/Driver/ToolChains/Arch/Sparc.cpp (+10-1) - (modified) clang/lib/Driver/ToolChains/Arch/Sparc.h (+2-1) - (modified) clang/lib/Driver/ToolChains/Clang.cpp (-10) - (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+1-1) - (modified) clang/lib/Driver/ToolChains/Flang.cpp (+1) - (modified) flang/test/Driver/target-cpu-features.f90 (+7) ``diff diff --git a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp index 9595ee8383c85..504f110eac87c 100644 --- a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp +++ b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp @@ -130,7 +130,8 @@ std::string sparc::getSparcTargetCPU(const Driver &D, const ArgList &Args, return ""; } -void sparc::getSparcTargetFeatures(const Driver &D, const ArgList &Args, +void sparc::getSparcTargetFeatures(const Driver &D, const llvm::Triple &Triple, + const ArgList &Args, std::vector &Features) { sparc::FloatABI FloatABI = sparc::getSparcFloatABI(D, Args); if (FloatABI == sparc::FloatABI::Soft) @@ -150,11 +151,19 @@ void sparc::getSparcTargetFeatures(const Driver &D, const ArgList &Args, Features.push_back("-popc"); } + // Those OSes default to enabling VIS on 64-bit SPARC. + // See also the corresponding code for external assemblers in + // sparc::getSparcAsmModeForCPU(). + bool IsSparcV9ATarget = + (Triple.getArch() == llvm::Triple::sparcv9) && + (Triple.isOSLinux() || Triple.isOSFreeBSD() || Triple.isOSOpenBSD()); if (Arg *A = Args.getLastArg(options::OPT_mvis, options::OPT_mno_vis)) { if (A->getOption().matches(options::OPT_mvis)) Features.push_back("+vis"); else Features.push_back("-vis"); + } else if (IsSparcV9ATarget) { +Features.push_back("+vis"); } if (Arg *A = Args.getLastArg(options::OPT_mvis2, options::OPT_mno_vis2)) { diff --git a/clang/lib/Driver/ToolChains/Arch/Sparc.h b/clang/lib/Driver/ToolChains/Arch/Sparc.h index 2b178d9df1ee3..fa25b4992cc8b 100644 --- a/clang/lib/Driver/ToolChains/Arch/Sparc.h +++ b/clang/lib/Driver/ToolChains/Arch/Sparc.h @@ -31,7 +31,8 @@ FloatABI getSparcFloatABI(const Driver &D, const llvm::opt::ArgList &Args); std::string getSparcTargetCPU(const Driver &D, const llvm::opt::ArgList &Args, const llvm::Triple &Triple); -void getSparcTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, +void getSparcTargetFeatures(const Driver &D, const llvm::Triple &Triple, +const llvm::opt::ArgList &Args, std::vector &Features); const char *getSparcAsmModeForCPU(llvm::StringRef Name, const llvm::Triple &Triple); diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 456bfe885f354..bf5f427fbfbb4 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2731,16 +2731,6 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, CmdArgs.push_back(MipsTargetFeature); } - // Those OSes default to enabling VIS on 64-bit SPARC. - // See also the corresponding code for external assemblers in - // sparc::getSparcAsmModeForCPU(). - bool IsSparcV9ATarget = - (C.getDefaultToolChain().getArch() == llvm::Triple::sparcv9) && - (Triple.isOSLinux() || Triple.isOSFreeBSD() || Triple.isOSOpenBSD()); - if (IsSparcV9ATarget && SparcTargetFeatures.empty()) { -CmdArgs.push_back("-target-feature"); -CmdArgs.push_back("+vis"); - } for (const char *Feature : SparcTargetFeatures) { CmdArgs.push_back("-target-feature"); CmdArgs.push_back(Feature); diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 097d186ad8ea4..069fd877bd7f8 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -856,7 +856,7 @@ void tools::getTargetFeatures(const Driver &D, const llvm::Triple &Triple, case llvm::Triple::sparc: case llvm::Triple::sparcel: case llvm::Triple::sparcv9: -sparc::getSparcTargetFeatures(D, Args, Features); +sparc::getSparcTargetFeatures(D, Triple, Args, Features); break; case llvm::Triple::r600: case llvm::Triple::amdgcn: diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index 1edb83f7255eb..7ab41e9b85a04 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -447,6 +447,7 @@ void Flang::addTargetOptions(const ArgList &Args, // Add the target features. switch (TC.getArch()) { default: +getTa
[llvm-branch-commits] [clang] [flang] release/21.x: [SPARC][Driver] Move feature mode selection to Arch/Sparc.cpp (#149652) (PR #149756)
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/149756 Backport 38fc453afdb6a4511b7c8e189f12a92559ecc396 Requested by: @brad0 >From 5ce2a6e7c86ed4b3a5283ae081ae2c0697ab2548 Mon Sep 17 00:00:00 2001 From: Koakuma Date: Mon, 21 Jul 2025 08:33:06 +0700 Subject: [PATCH] [SPARC][Driver] Move feature mode selection to Arch/Sparc.cpp (#149652) This is so that it's performed also for flang and not just for clang. This should fix https://github.com/llvm/llvm-project/issues/138494. (cherry picked from commit 38fc453afdb6a4511b7c8e189f12a92559ecc396) --- clang/lib/Driver/ToolChains/Arch/Sparc.cpp | 11 ++- clang/lib/Driver/ToolChains/Arch/Sparc.h | 3 ++- clang/lib/Driver/ToolChains/Clang.cpp | 10 -- clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 +- clang/lib/Driver/ToolChains/Flang.cpp | 1 + flang/test/Driver/target-cpu-features.f90 | 7 +++ 6 files changed, 21 insertions(+), 13 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp index 9595ee8383c85..504f110eac87c 100644 --- a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp +++ b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp @@ -130,7 +130,8 @@ std::string sparc::getSparcTargetCPU(const Driver &D, const ArgList &Args, return ""; } -void sparc::getSparcTargetFeatures(const Driver &D, const ArgList &Args, +void sparc::getSparcTargetFeatures(const Driver &D, const llvm::Triple &Triple, + const ArgList &Args, std::vector &Features) { sparc::FloatABI FloatABI = sparc::getSparcFloatABI(D, Args); if (FloatABI == sparc::FloatABI::Soft) @@ -150,11 +151,19 @@ void sparc::getSparcTargetFeatures(const Driver &D, const ArgList &Args, Features.push_back("-popc"); } + // Those OSes default to enabling VIS on 64-bit SPARC. + // See also the corresponding code for external assemblers in + // sparc::getSparcAsmModeForCPU(). + bool IsSparcV9ATarget = + (Triple.getArch() == llvm::Triple::sparcv9) && + (Triple.isOSLinux() || Triple.isOSFreeBSD() || Triple.isOSOpenBSD()); if (Arg *A = Args.getLastArg(options::OPT_mvis, options::OPT_mno_vis)) { if (A->getOption().matches(options::OPT_mvis)) Features.push_back("+vis"); else Features.push_back("-vis"); + } else if (IsSparcV9ATarget) { +Features.push_back("+vis"); } if (Arg *A = Args.getLastArg(options::OPT_mvis2, options::OPT_mno_vis2)) { diff --git a/clang/lib/Driver/ToolChains/Arch/Sparc.h b/clang/lib/Driver/ToolChains/Arch/Sparc.h index 2b178d9df1ee3..fa25b4992cc8b 100644 --- a/clang/lib/Driver/ToolChains/Arch/Sparc.h +++ b/clang/lib/Driver/ToolChains/Arch/Sparc.h @@ -31,7 +31,8 @@ FloatABI getSparcFloatABI(const Driver &D, const llvm::opt::ArgList &Args); std::string getSparcTargetCPU(const Driver &D, const llvm::opt::ArgList &Args, const llvm::Triple &Triple); -void getSparcTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, +void getSparcTargetFeatures(const Driver &D, const llvm::Triple &Triple, +const llvm::opt::ArgList &Args, std::vector &Features); const char *getSparcAsmModeForCPU(llvm::StringRef Name, const llvm::Triple &Triple); diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 456bfe885f354..bf5f427fbfbb4 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2731,16 +2731,6 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, CmdArgs.push_back(MipsTargetFeature); } - // Those OSes default to enabling VIS on 64-bit SPARC. - // See also the corresponding code for external assemblers in - // sparc::getSparcAsmModeForCPU(). - bool IsSparcV9ATarget = - (C.getDefaultToolChain().getArch() == llvm::Triple::sparcv9) && - (Triple.isOSLinux() || Triple.isOSFreeBSD() || Triple.isOSOpenBSD()); - if (IsSparcV9ATarget && SparcTargetFeatures.empty()) { -CmdArgs.push_back("-target-feature"); -CmdArgs.push_back("+vis"); - } for (const char *Feature : SparcTargetFeatures) { CmdArgs.push_back("-target-feature"); CmdArgs.push_back(Feature); diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 097d186ad8ea4..069fd877bd7f8 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -856,7 +856,7 @@ void tools::getTargetFeatures(const Driver &D, const llvm::Triple &Triple, case llvm::Triple::sparc: case llvm::Triple::sparcel: case llvm::Triple::sparcv9: -sparc::getSparcTargetFeatures(D, Args, Features); +sparc::getSparcTargetFeatures(D, Triple, Args, Features); break; case llvm::Triple::r600: case llvm::Triple::amdgcn: diff --git a/clang/lib/Driver/Too
[llvm-branch-commits] [clang] [flang] release/21.x: [SPARC][Driver] Move feature mode selection to Arch/Sparc.cpp (#149652) (PR #149756)
llvmbot wrote: @MaskRay What do you think about merging this PR to the release branch? https://github.com/llvm/llvm-project/pull/149756 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [flang] release/21.x: [SPARC][Driver] Move feature mode selection to Arch/Sparc.cpp (#149652) (PR #149756)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/149756 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [flang] release/21.x: [SPARC][Driver] Move feature mode selection to Arch/Sparc.cpp (#149652) (PR #149756)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/149756 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libclc] [libclc] Revert the recent breaking changes from CMake from the 21.x release branch (PR #149711)
https://github.com/mgorny created https://github.com/llvm/llvm-project/pull/149711 Revert the recent batch of changes to the CMake build of libclc that introduced significant breakage, notably: - standalone builds no longer working - broken symlinks being installed These changes are nontrivial and were made shortly prior to the branching point, so it's better to defer them to 22.x and fix properly than attempt to apply more ad hoc fixes. Fixes #149659 Fixes #149437 From 92b937eb336d235b981b4beaae2c9cabe02914be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sun, 20 Jul 2025 16:07:23 +0200 Subject: [PATCH 1/5] Revert "[libclc] Move CMake for prepare_builtins to a subdirectory (#148815)" This reverts commit 8a7a64873b13e6fd931b748fbf50b3da26fe7fca. It broke standalone builds since the necessary variables are now limited in scope to `libclc/utils` while they are used in the top-level CMakeLists. --- libclc/CMakeLists.txt | 24 ++-- libclc/utils/CMakeLists.txt | 24 2 files changed, 22 insertions(+), 26 deletions(-) delete mode 100644 libclc/utils/CMakeLists.txt diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index 2570d1a106d21..e2871d1b01a16 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -164,14 +164,34 @@ endif() list( SORT LIBCLC_TARGETS_TO_BUILD ) +# Construct LLVM version define +set( LLVM_VERSION_DEFINE "-DHAVE_LLVM=0x${LLVM_VERSION_MAJOR}0${LLVM_VERSION_MINOR}" ) + # This needs to be set before any target that needs it # We need to use LLVM_INCLUDE_DIRS here, because if we are linking to an # llvm build directory, this includes $src/llvm/include which is where all the # headers are not $build/include/ which is what LLVM_INCLUDE_DIR is set to. include_directories( ${LLVM_INCLUDE_DIRS} ) -# Configure prepare_builtins -add_subdirectory( utils ) +# Setup prepare_builtins tools +set(LLVM_LINK_COMPONENTS + BitReader + BitWriter + Core + IRReader + Support +) +if( LIBCLC_STANDALONE_BUILD ) + add_llvm_executable( prepare_builtins utils/prepare-builtins.cpp ) + set( prepare_builtins_exe prepare_builtins ) + set( prepare_builtins_target prepare_builtins ) +else() + add_llvm_utility( prepare_builtins utils/prepare-builtins.cpp ) + setup_host_tool( prepare_builtins PREPARE_BUILTINS prepare_builtins_exe prepare_builtins_target ) +endif() +target_compile_definitions( prepare_builtins PRIVATE ${LLVM_VERSION_DEFINE} ) +# These were not properly reported in early LLVM and we don't need them +target_compile_options( prepare_builtins PRIVATE -fno-rtti -fno-exceptions ) # Setup arch devices set( r600--_devices cedar cypress barts cayman ) diff --git a/libclc/utils/CMakeLists.txt b/libclc/utils/CMakeLists.txt deleted file mode 100644 index ea1d9e9c8ef5f..0 --- a/libclc/utils/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -# Construct LLVM version define -set( LLVM_VERSION_DEFINE "-DHAVE_LLVM=0x${LLVM_VERSION_MAJOR}0${LLVM_VERSION_MINOR}" ) - -# Setup prepare_builtins tools -set( LLVM_LINK_COMPONENTS - BitReader - BitWriter - Core - IRReader - Support -) - -if( LIBCLC_STANDALONE_BUILD ) - add_llvm_executable( prepare_builtins prepare-builtins.cpp ) - set( prepare_builtins_exe prepare_builtins ) - set( prepare_builtins_target prepare_builtins ) -else() - add_llvm_utility( prepare_builtins prepare-builtins.cpp ) - setup_host_tool( prepare_builtins PREPARE_BUILTINS prepare_builtins_exe prepare_builtins_target ) -endif() - -target_compile_definitions( prepare_builtins PRIVATE ${LLVM_VERSION_DEFINE} ) -# These were not properly reported in early LLVM and we don't need them -target_compile_options( prepare_builtins PRIVATE -fno-rtti -fno-exceptions ) From 3f12831601fcbdc1c610c2d7131661b9990de1b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sun, 20 Jul 2025 16:07:59 +0200 Subject: [PATCH 2/5] Revert "[libclc] Change symlinks to copies on Windows (#147759)" This reverts commit 9b5959dd9a0eb0fc005b92be7ef7f3a5e3377b81. --- libclc/cmake/modules/AddLibclc.cmake | 10 ++ 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 056706ee629cd..a8160e04d46a0 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -425,17 +425,11 @@ function(add_libclc_builtin_set) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) endif() - if(CMAKE_HOST_UNIX OR LLVM_USE_SYMLINKS) -set(LIBCLC_LINK_OR_COPY create_symlink) - else() -set(LIBCLC_LINK_OR_COPY copy) - endif() - - foreach( a IN LISTS ARG_ALIASES ) + foreach( a ${ARG_ALIASES} ) set( alias_suffix "${a}-${ARG_TRIPLE}.bc" ) add_custom_command( OUTPUT ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix} - COMMAND ${CMAKE_COMMAND} -E ${LIBCLC_LINK_OR_COPY} ${libclc_builtins_lib} ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix} +
[llvm-branch-commits] [libclc] [libclc] Revert the recent breaking changes from CMake from the 21.x release branch (PR #149711)
https://github.com/mgorny milestoned https://github.com/llvm/llvm-project/pull/149711 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] basic error report for use after free (PR #149731)
https://github.com/usx95 created https://github.com/llvm/llvm-project/pull/149731 None >From 250f9d4735503dcd6eba12e500deca91342d9f48 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Sun, 20 Jul 2025 18:33:56 + Subject: [PATCH] basic error report for use after free --- .../clang/Analysis/Analyses/LifetimeSafety.h | 52 +++- clang/include/clang/Basic/DiagnosticGroups.td | 5 +- .../clang/Basic/DiagnosticSemaKinds.td| 11 +- clang/lib/Analysis/LifetimeSafety.cpp | 248 ++ clang/lib/Sema/AnalysisBasedWarnings.cpp | 35 ++- clang/test/Sema/warn-lifetime-safety.cpp | 204 ++ .../unittests/Analysis/LifetimeSafetyTest.cpp | 15 +- 7 files changed, 505 insertions(+), 65 deletions(-) create mode 100644 clang/test/Sema/warn-lifetime-safety.cpp diff --git a/clang/include/clang/Analysis/Analyses/LifetimeSafety.h b/clang/include/clang/Analysis/Analyses/LifetimeSafety.h index 1c00558d32f63..bd7e76b1bc238 100644 --- a/clang/include/clang/Analysis/Analyses/LifetimeSafety.h +++ b/clang/include/clang/Analysis/Analyses/LifetimeSafety.h @@ -19,14 +19,35 @@ #define LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMESAFETY_H #include "clang/Analysis/AnalysisDeclContext.h" #include "clang/Analysis/CFG.h" +#include "clang/Basic/SourceLocation.h" +#include "llvm/ADT/DenseMapInfo.h" +#include "llvm/ADT/ImmutableMap.h" #include "llvm/ADT/ImmutableSet.h" #include "llvm/ADT/StringMap.h" #include namespace clang::lifetimes { +/// Enum to track the confidence level of a potential error. +enum class Confidence { + None, + Maybe, // Reported as a potential error (-Wlifetime-safety-strict) + Definite // Reported as a definite error (-Wlifetime-safety-permissive) +}; + +class LifetimeSafetyReporter { +public: + LifetimeSafetyReporter() = default; + virtual ~LifetimeSafetyReporter() = default; + + virtual void reportUseAfterFree(const Expr *IssueExpr, const Expr *UseExpr, + SourceLocation FreeLoc, + Confidence Confidence) {} +}; + /// The main entry point for the analysis. -void runLifetimeSafetyAnalysis(AnalysisDeclContext &AC); +void runLifetimeSafetyAnalysis(AnalysisDeclContext &AC, + LifetimeSafetyReporter *Reporter); namespace internal { // Forward declarations of internal types. @@ -53,6 +74,7 @@ template struct ID { IDBuilder.AddInteger(Value); } }; + template inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, ID ID) { return OS << ID.Value; @@ -66,6 +88,7 @@ using OriginID = ID; // TODO(opt): Consider using a bitset to represent the set of loans. using LoanSet = llvm::ImmutableSet; using OriginSet = llvm::ImmutableSet; +using ExpiredLoanMap = llvm::ImmutableMap; /// A `ProgramPoint` identifies a location in the CFG by pointing to a specific /// `Fact`. identified by a lifetime-related event (`Fact`). @@ -78,7 +101,8 @@ using ProgramPoint = const Fact *; /// encapsulates the various dataflow analyses. class LifetimeSafetyAnalysis { public: - LifetimeSafetyAnalysis(AnalysisDeclContext &AC); + LifetimeSafetyAnalysis(AnalysisDeclContext &AC, + LifetimeSafetyReporter *Reporter); ~LifetimeSafetyAnalysis(); void run(); @@ -87,7 +111,7 @@ class LifetimeSafetyAnalysis { LoanSet getLoansAtPoint(OriginID OID, ProgramPoint PP) const; /// Returns the set of loans that have expired at a specific program point. - LoanSet getExpiredLoansAtPoint(ProgramPoint PP) const; + ExpiredLoanMap getExpiredLoansAtPoint(ProgramPoint PP) const; /// Finds the OriginID for a given declaration. /// Returns a null optional if not found. @@ -110,6 +134,7 @@ class LifetimeSafetyAnalysis { private: AnalysisDeclContext &AC; + LifetimeSafetyReporter *Reporter; std::unique_ptr Factory; std::unique_ptr FactMgr; std::unique_ptr LoanPropagation; @@ -118,4 +143,25 @@ class LifetimeSafetyAnalysis { } // namespace internal } // namespace clang::lifetimes +namespace llvm { +template +struct DenseMapInfo> { + using ID = clang::lifetimes::internal::ID; + + static inline ID getEmptyKey() { +return {DenseMapInfo::getEmptyKey()}; + } + + static inline ID getTombstoneKey() { +return {DenseMapInfo::getTombstoneKey()}; + } + + static unsigned getHashValue(const ID &Val) { +return DenseMapInfo::getHashValue(Val.Value); + } + + static bool isEqual(const ID &LHS, const ID &RHS) { return LHS == RHS; } +}; +} // namespace llvm + #endif // LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMESAFETY_H diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index c28a919e35d08..257823e4664d0 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -533,7 +533,10 @@ def Dangling : DiagGroup<"dangling", [DanglingAssignment, DanglingGsl,
[llvm-branch-commits] [llvm] release/21.x: [LV] Vectorize maxnum/minnum w/o fast-math flags. (#148239) (PR #149736)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/149736 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/21.x: [LV] Vectorize maxnum/minnum w/o fast-math flags. (#148239) (PR #149736)
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/149736 Backport 004c67ea257039e4e98abc26dd4ac6e8f3d7a171 Requested by: @fhahn >From 104183777e3a6bd14f209c74da53e6f592b72d9f Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Fri, 18 Jul 2025 22:58:19 +0200 Subject: [PATCH] [LV] Vectorize maxnum/minnum w/o fast-math flags. (#148239) Update LV to vectorize maxnum/minnum reductions without fast-math flags, by adding an extra check in the loop if any inputs to maxnum/minnum are NaN, due to maxnum/minnum behavior w.r.t to signaling NaNs. Signed-zeros are already handled consistently by maxnum/minnum. If any input is NaN, *exit the vector loop, *compute the reduction result up to the vector iteration that contained NaN inputs and * resume in the scalar loop New recurrence kinds are added for reductions using maxnum/minnum without fast-math flags. PR: https://github.com/llvm/llvm-project/pull/148239 (cherry picked from commit 004c67ea257039e4e98abc26dd4ac6e8f3d7a171) --- llvm/include/llvm/Analysis/IVDescriptors.h| 3 + llvm/lib/Analysis/IVDescriptors.cpp | 26 +- llvm/lib/Transforms/Utils/LoopUtils.cpp | 10 +- .../Vectorize/LoopVectorizationPlanner.h | 12 +- .../Transforms/Vectorize/LoopVectorize.cpp| 18 +- .../Transforms/Vectorize/SLPVectorizer.cpp| 6 + .../Transforms/Vectorize/VPlanAnalysis.cpp| 1 + .../Vectorize/VPlanConstruction.cpp | 160 +++ .../lib/Transforms/Vectorize/VPlanRecipes.cpp | 8 +- .../Transforms/Vectorize/VPlanTransforms.h| 6 + .../AArch64/fmax-without-fast-math-flags.ll | 55 +++- .../AArch64/fmin-without-fast-math-flags.ll | 55 +++- ...fmax-without-fast-math-flags-interleave.ll | 55 +++- .../fmax-without-fast-math-flags.ll | 272 +- .../fmin-without-fast-math-flags.ll | 94 +- .../LoopVectorize/minmax_reduction.ll | 8 +- 16 files changed, 731 insertions(+), 58 deletions(-) diff --git a/llvm/include/llvm/Analysis/IVDescriptors.h b/llvm/include/llvm/Analysis/IVDescriptors.h index b985292ccee40..1dc73205a0ebb 100644 --- a/llvm/include/llvm/Analysis/IVDescriptors.h +++ b/llvm/include/llvm/Analysis/IVDescriptors.h @@ -47,6 +47,8 @@ enum class RecurKind { FMul, ///< Product of floats. FMin, ///< FP min implemented in terms of select(cmp()). FMax, ///< FP max implemented in terms of select(cmp()). + FMinNum, ///< FP min with llvm.minnum semantics including NaNs. + FMaxNum, ///< FP max with llvm.maxnum semantics including NaNs. FMinimum, ///< FP min with llvm.minimum semantics FMaximum, ///< FP max with llvm.maximum semantics FMinimumNum, ///< FP min with llvm.minimumnum semantics @@ -250,6 +252,7 @@ class RecurrenceDescriptor { /// Returns true if the recurrence kind is a floating-point min/max kind. static bool isFPMinMaxRecurrenceKind(RecurKind Kind) { return Kind == RecurKind::FMin || Kind == RecurKind::FMax || + Kind == RecurKind::FMinNum || Kind == RecurKind::FMaxNum || Kind == RecurKind::FMinimum || Kind == RecurKind::FMaximum || Kind == RecurKind::FMinimumNum || Kind == RecurKind::FMaximumNum; } diff --git a/llvm/lib/Analysis/IVDescriptors.cpp b/llvm/lib/Analysis/IVDescriptors.cpp index 39f74beca082f..8be5de3bf356f 100644 --- a/llvm/lib/Analysis/IVDescriptors.cpp +++ b/llvm/lib/Analysis/IVDescriptors.cpp @@ -941,10 +941,30 @@ RecurrenceDescriptor::InstDesc RecurrenceDescriptor::isRecurrenceInstr( m_Intrinsic(m_Value(), m_Value())) || match(I, m_Intrinsic(m_Value(), m_Value())); }; -if (isIntMinMaxRecurrenceKind(Kind) || -(HasRequiredFMF() && isFPMinMaxRecurrenceKind(Kind))) +if (isIntMinMaxRecurrenceKind(Kind)) return isMinMaxPattern(I, Kind, Prev); -else if (isFMulAddIntrinsic(I)) +if (isFPMinMaxRecurrenceKind(Kind)) { + InstDesc Res = isMinMaxPattern(I, Kind, Prev); + if (!Res.isRecurrence()) +return InstDesc(false, I); + if (HasRequiredFMF()) +return Res; + // We may be able to vectorize FMax/FMin reductions using maxnum/minnum + // intrinsics with extra checks ensuring the vector loop handles only + // non-NaN inputs. + if (match(I, m_Intrinsic(m_Value(), m_Value( { +assert(Kind == RecurKind::FMax && + "unexpected recurrence kind for maxnum"); +return InstDesc(I, RecurKind::FMaxNum); + } + if (match(I, m_Intrinsic(m_Value(), m_Value( { +assert(Kind == RecurKind::FMin && + "unexpected recurrence kind for minnum"); +return InstDesc(I, RecurKind::FMinNum); + } + return InstDesc(false, I); +} +if (isFMulAddIntrinsic(I)) return InstDesc(Kind == RecurKind::FMulAdd, I, I->hasAllowReassoc() ? nullptr : I); return InstDesc(false, I); diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp
[llvm-branch-commits] [llvm] release/21.x: [LV] Vectorize maxnum/minnum w/o fast-math flags. (#148239) (PR #149736)
llvmbot wrote: @ayalz What do you think about merging this PR to the release branch? https://github.com/llvm/llvm-project/pull/149736 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/21.x: [LV] Vectorize maxnum/minnum w/o fast-math flags. (#148239) (PR #149736)
llvmbot wrote: @llvm/pr-subscribers-llvm-analysis Author: None (llvmbot) Changes Backport 004c67ea257039e4e98abc26dd4ac6e8f3d7a171 Requested by: @fhahn --- Patch is 66.35 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/149736.diff 16 Files Affected: - (modified) llvm/include/llvm/Analysis/IVDescriptors.h (+3) - (modified) llvm/lib/Analysis/IVDescriptors.cpp (+23-3) - (modified) llvm/lib/Transforms/Utils/LoopUtils.cpp (+8-2) - (modified) llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h (+11-1) - (modified) llvm/lib/Transforms/Vectorize/LoopVectorize.cpp (+14-4) - (modified) llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp (+6) - (modified) llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp (+1) - (modified) llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp (+160) - (modified) llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp (+6-2) - (modified) llvm/lib/Transforms/Vectorize/VPlanTransforms.h (+6) - (modified) llvm/test/Transforms/LoopVectorize/AArch64/fmax-without-fast-math-flags.ll (+48-7) - (modified) llvm/test/Transforms/LoopVectorize/AArch64/fmin-without-fast-math-flags.ll (+48-7) - (modified) llvm/test/Transforms/LoopVectorize/fmax-without-fast-math-flags-interleave.ll (+48-7) - (modified) llvm/test/Transforms/LoopVectorize/fmax-without-fast-math-flags.ll (+263-9) - (modified) llvm/test/Transforms/LoopVectorize/fmin-without-fast-math-flags.ll (+80-14) - (modified) llvm/test/Transforms/LoopVectorize/minmax_reduction.ll (+6-2) ``diff diff --git a/llvm/include/llvm/Analysis/IVDescriptors.h b/llvm/include/llvm/Analysis/IVDescriptors.h index b985292ccee40..1dc73205a0ebb 100644 --- a/llvm/include/llvm/Analysis/IVDescriptors.h +++ b/llvm/include/llvm/Analysis/IVDescriptors.h @@ -47,6 +47,8 @@ enum class RecurKind { FMul, ///< Product of floats. FMin, ///< FP min implemented in terms of select(cmp()). FMax, ///< FP max implemented in terms of select(cmp()). + FMinNum, ///< FP min with llvm.minnum semantics including NaNs. + FMaxNum, ///< FP max with llvm.maxnum semantics including NaNs. FMinimum, ///< FP min with llvm.minimum semantics FMaximum, ///< FP max with llvm.maximum semantics FMinimumNum, ///< FP min with llvm.minimumnum semantics @@ -250,6 +252,7 @@ class RecurrenceDescriptor { /// Returns true if the recurrence kind is a floating-point min/max kind. static bool isFPMinMaxRecurrenceKind(RecurKind Kind) { return Kind == RecurKind::FMin || Kind == RecurKind::FMax || + Kind == RecurKind::FMinNum || Kind == RecurKind::FMaxNum || Kind == RecurKind::FMinimum || Kind == RecurKind::FMaximum || Kind == RecurKind::FMinimumNum || Kind == RecurKind::FMaximumNum; } diff --git a/llvm/lib/Analysis/IVDescriptors.cpp b/llvm/lib/Analysis/IVDescriptors.cpp index 39f74beca082f..8be5de3bf356f 100644 --- a/llvm/lib/Analysis/IVDescriptors.cpp +++ b/llvm/lib/Analysis/IVDescriptors.cpp @@ -941,10 +941,30 @@ RecurrenceDescriptor::InstDesc RecurrenceDescriptor::isRecurrenceInstr( m_Intrinsic(m_Value(), m_Value())) || match(I, m_Intrinsic(m_Value(), m_Value())); }; -if (isIntMinMaxRecurrenceKind(Kind) || -(HasRequiredFMF() && isFPMinMaxRecurrenceKind(Kind))) +if (isIntMinMaxRecurrenceKind(Kind)) return isMinMaxPattern(I, Kind, Prev); -else if (isFMulAddIntrinsic(I)) +if (isFPMinMaxRecurrenceKind(Kind)) { + InstDesc Res = isMinMaxPattern(I, Kind, Prev); + if (!Res.isRecurrence()) +return InstDesc(false, I); + if (HasRequiredFMF()) +return Res; + // We may be able to vectorize FMax/FMin reductions using maxnum/minnum + // intrinsics with extra checks ensuring the vector loop handles only + // non-NaN inputs. + if (match(I, m_Intrinsic(m_Value(), m_Value( { +assert(Kind == RecurKind::FMax && + "unexpected recurrence kind for maxnum"); +return InstDesc(I, RecurKind::FMaxNum); + } + if (match(I, m_Intrinsic(m_Value(), m_Value( { +assert(Kind == RecurKind::FMin && + "unexpected recurrence kind for minnum"); +return InstDesc(I, RecurKind::FMinNum); + } + return InstDesc(false, I); +} +if (isFMulAddIntrinsic(I)) return InstDesc(Kind == RecurKind::FMulAdd, I, I->hasAllowReassoc() ? nullptr : I); return InstDesc(false, I); diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp index 200d1fb854155..e7623aaff105d 100644 --- a/llvm/lib/Transforms/Utils/LoopUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp @@ -938,8 +938,10 @@ constexpr Intrinsic::ID llvm::getReductionIntrinsicID(RecurKind RK) { case RecurKind::UMin: return Intrinsic::vector_reduce_umin; case RecurKind::FMax: + case RecurKind::FMaxNum: return Intrinsic::vector_reduce_fmax; case RecurKi
[llvm-branch-commits] [clang] [PATCH 2/4] [clang] Improve nested name specifier AST representation (PR #148012)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- clang/include/clang/ASTMatchers/ASTMatchers.h clang/include/clang/ASTMatchers/ASTMatchersInternal.h clang/include/clang/Analysis/FlowSensitive/ASTOps.h clang/include/clang/Sema/DeclSpec.h clang/include/clang/Sema/ParsedTemplate.h clang/include/clang/Sema/Sema.h clang/include/clang/Serialization/ASTRecordWriter.h clang/lib/ASTMatchers/ASTMatchFinder.cpp clang/lib/ASTMatchers/ASTMatchersInternal.cpp clang/lib/ASTMatchers/Dynamic/Registry.cpp clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp clang/lib/Analysis/UnsafeBufferUsage.cpp clang/lib/CodeGen/CGCXXABI.cpp clang/lib/CodeGen/CGCall.cpp clang/lib/CodeGen/CGClass.cpp clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGDecl.cpp clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CGExprCXX.cpp clang/lib/CodeGen/CGHLSLRuntime.cpp clang/lib/CodeGen/CGNonTrivialStruct.cpp clang/lib/CodeGen/CGObjCMac.cpp clang/lib/CodeGen/CGOpenMPRuntime.cpp clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp clang/lib/CodeGen/CGPointerAuth.cpp clang/lib/CodeGen/CGStmt.cpp clang/lib/CodeGen/CGStmtOpenMP.cpp clang/lib/CodeGen/CGVTables.cpp clang/lib/CodeGen/CodeGenFunction.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenTypes.cpp clang/lib/CodeGen/ItaniumCXXABI.cpp clang/lib/CodeGen/MicrosoftCXXABI.cpp clang/lib/CodeGen/Targets/X86.cpp clang/lib/ExtractAPI/DeclarationFragments.cpp clang/lib/Frontend/ASTConsumers.cpp clang/lib/Frontend/ASTUnit.cpp clang/lib/Index/IndexTypeSourceInfo.cpp clang/lib/Index/USRGeneration.cpp clang/lib/InstallAPI/Visitor.cpp clang/lib/Parse/ParseExprCXX.cpp clang/lib/Parse/ParseTemplate.cpp clang/lib/Parse/Parser.cpp clang/lib/Sema/DeclSpec.cpp clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.h clang/lib/Sema/HeuristicResolver.cpp clang/lib/Sema/SemaAccess.cpp clang/lib/Sema/SemaCXXScopeSpec.cpp clang/lib/Sema/SemaCast.cpp clang/lib/Sema/SemaChecking.cpp clang/lib/Sema/SemaCodeComplete.cpp clang/lib/Sema/SemaCoroutine.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclAttr.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/lib/Sema/SemaDeclObjC.cpp clang/lib/Sema/SemaExceptionSpec.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaExprCXX.cpp clang/lib/Sema/SemaExprMember.cpp clang/lib/Sema/SemaExprObjC.cpp clang/lib/Sema/SemaFunctionEffects.cpp clang/lib/Sema/SemaHLSL.cpp clang/lib/Sema/SemaInit.cpp clang/lib/Sema/SemaLambda.cpp clang/lib/Sema/SemaLookup.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/Sema/SemaStmt.cpp clang/lib/Sema/SemaStmtAsm.cpp clang/lib/Sema/SemaTemplate.cpp clang/lib/Sema/SemaTemplateDeduction.cpp clang/lib/Sema/SemaTemplateDeductionGuide.cpp clang/lib/Sema/SemaTemplateInstantiate.cpp clang/lib/Sema/SemaTemplateInstantiateDecl.cpp clang/lib/Sema/SemaTemplateVariadic.cpp clang/lib/Sema/SemaType.cpp clang/lib/Sema/SemaTypeTraits.cpp clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTReaderDecl.cpp clang/lib/Serialization/ASTWriter.cpp clang/lib/Serialization/ASTWriterDecl.cpp clang/lib/Serialization/TemplateArgumentHasher.cpp clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp clang/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp clang/lib/StaticAnalyzer/Core/CallEvent.cpp clang/lib/StaticAnalyzer/Core/MemRegion.cpp clang/lib/StaticAnalyzer/Core/SValBuilder.cpp clang/lib/Tooling/ASTDiff/ASTDiff.cpp clang/lib/Tooling/Refactoring/Lookup.cpp clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp clang/lib/Tooling/Syntax/BuildTree.cpp clang/lib/Tooling/Transformer/RangeSelector.cpp clang/tools/libclang/CIndex.cpp clang/tools/libclang/CXCursor.cpp clang/tools/libclang/CXIndexDataConsumer.cpp clang/tools/libclang/CXType.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 345a23ae9..c262b8f72 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -9224,8 +9224,7 @@ bool InitializationSequence::Diagnose(Sema &S, if (const RecordType *Record = Entity.getType()->getAs()) - S.Diag(Record->getDecl()->getLocation(), - diag::note_previous_decl) + S.Diag(Record->getDecl()->getLocation(), diag::note_previous_decl) << S.Co
[llvm-branch-commits] [clang-tools-extra] [PATCH 4/6] [clang] Improve nested name specifier AST representation (PR #148015)
https://github.com/mizvekov updated https://github.com/llvm/llvm-project/pull/148015 >From 6f7eb76bbbf50ce88e2d92a5ab919c74c777f4b7 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Thu, 10 Jul 2025 14:07:34 -0300 Subject: [PATCH] [PATCH 4/6] [clang] Improve nested name specifier AST representation clang tools extra changes --- .../find-all-symbols/FindAllSymbols.cpp | 3 +- .../CrtpConstructorAccessibilityCheck.cpp | 6 ++- .../EasilySwappableParametersCheck.cpp| 14 ++--- .../ForwardDeclarationNamespaceCheck.cpp | 11 ++-- .../bugprone/IncorrectEnableIfCheck.cpp | 19 +++ .../bugprone/SizeofExpressionCheck.cpp| 10 ++-- .../NoSuspendWithLockCheck.cpp| 4 +- .../google/AvoidCStyleCastsCheck.cpp | 31 --- .../google/UpgradeGoogletestCaseCheck.cpp | 9 +++- .../clang-tidy/misc/ConstCorrectnessCheck.cpp | 11 ++-- .../clang-tidy/misc/MisplacedConstCheck.cpp | 14 ++--- .../misc/RedundantExpressionCheck.cpp | 5 +- .../clang-tidy/misc/UnusedUsingDeclsCheck.cpp | 6 +-- .../DeprecatedIosBaseAliasesCheck.cpp | 11 ++-- .../clang-tidy/modernize/PassByValueCheck.cpp | 3 +- .../modernize/ReplaceAutoPtrCheck.cpp | 15 +++--- .../clang-tidy/modernize/TypeTraitsCheck.cpp | 34 .../clang-tidy/modernize/UseAutoCheck.cpp | 18 +++ .../modernize/UseConstraintsCheck.cpp | 7 ++- .../clang-tidy/modernize/UseEmplaceCheck.cpp | 53 +-- .../modernize/UseScopedLockCheck.cpp | 41 +- .../modernize/UseTransparentFunctorsCheck.cpp | 16 +++--- .../performance/NoAutomaticMoveCheck.cpp | 8 +-- .../portability/StdAllocatorConstCheck.cpp| 11 ++-- .../readability/UseStdMinMaxCheck.cpp | 6 +-- .../clang-tidy/utils/Matchers.cpp | 2 +- .../utils/RenamerClangTidyCheck.cpp | 30 +++ clang-tools-extra/clangd/AST.cpp | 11 ++-- clang-tools-extra/clangd/AST.h| 3 +- clang-tools-extra/clangd/DumpAST.cpp | 6 ++- clang-tools-extra/clangd/FindTarget.cpp | 36 ++--- clang-tools-extra/clangd/Hover.cpp| 18 --- clang-tools-extra/clangd/InlayHints.cpp | 28 +- clang-tools-extra/clangd/Selection.cpp| 15 +++--- clang-tools-extra/clangd/XRefs.cpp| 13 +++-- .../refactor/tweaks/ExtractFunction.cpp | 5 +- .../clangd/unittests/ASTTests.cpp | 7 +-- .../clangd/unittests/DumpASTTests.cpp | 15 +++--- .../clangd/unittests/HoverTests.cpp | 10 ++-- .../clangd/unittests/InlayHintTests.cpp | 9 +--- .../clangd/unittests/QualityTests.cpp | 14 +++-- .../include-cleaner/lib/WalkAST.cpp | 6 +-- .../bugprone/copy-constructor-init.cpp| 1 - .../unused-local-non-trivial-variable.cpp | 6 +-- .../portability/std-allocator-const.cpp | 22 45 files changed, 289 insertions(+), 334 deletions(-) diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp index bb48883f88815..1f30d27c0a54f 100644 --- a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp +++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp @@ -216,8 +216,7 @@ void FindAllSymbols::registerMatchers(MatchFinder *MatchFinder) { // Uses of most types: just look at what the typeLoc refers to. MatchFinder->addMatcher( typeLoc(isExpansionInMainFile(), - loc(qualType(allOf(unless(elaboratedType()), - hasDeclaration(Types.bind("use")), + loc(qualType(hasDeclaration(Types.bind("use"), this); // Uses of typedefs: these are often transparent to hasDeclaration, so we need // to handle them explicitly. diff --git a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp index 6565fa3f7c85b..0625468d9da88 100644 --- a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp @@ -43,7 +43,8 @@ static bool isDerivedClassBefriended(const CXXRecordDecl *CRTP, return false; } -return FriendType->getType()->getAsCXXRecordDecl() == Derived; +return declaresSameEntity(FriendType->getType()->getAsCXXRecordDecl(), + Derived); }); } @@ -55,7 +56,8 @@ getDerivedParameter(const ClassTemplateSpecializationDecl *CRTP, CRTP->getTemplateArgs().asArray(), [&](const TemplateArgument &Arg) { ++Idx; return Arg.getKind() == TemplateArgument::Type && - Arg.getAsType()->getAsCXXRecordDecl() == Derived; + declaresSameEntity(Arg.getAsType()->getAsCXXRecordDecl(
[llvm-branch-commits] [clang-tools-extra] [PATCH 4/6] [clang] Improve nested name specifier AST representation (PR #148015)
https://github.com/mizvekov updated https://github.com/llvm/llvm-project/pull/148015 >From 6f7eb76bbbf50ce88e2d92a5ab919c74c777f4b7 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Thu, 10 Jul 2025 14:07:34 -0300 Subject: [PATCH] [PATCH 4/6] [clang] Improve nested name specifier AST representation clang tools extra changes --- .../find-all-symbols/FindAllSymbols.cpp | 3 +- .../CrtpConstructorAccessibilityCheck.cpp | 6 ++- .../EasilySwappableParametersCheck.cpp| 14 ++--- .../ForwardDeclarationNamespaceCheck.cpp | 11 ++-- .../bugprone/IncorrectEnableIfCheck.cpp | 19 +++ .../bugprone/SizeofExpressionCheck.cpp| 10 ++-- .../NoSuspendWithLockCheck.cpp| 4 +- .../google/AvoidCStyleCastsCheck.cpp | 31 --- .../google/UpgradeGoogletestCaseCheck.cpp | 9 +++- .../clang-tidy/misc/ConstCorrectnessCheck.cpp | 11 ++-- .../clang-tidy/misc/MisplacedConstCheck.cpp | 14 ++--- .../misc/RedundantExpressionCheck.cpp | 5 +- .../clang-tidy/misc/UnusedUsingDeclsCheck.cpp | 6 +-- .../DeprecatedIosBaseAliasesCheck.cpp | 11 ++-- .../clang-tidy/modernize/PassByValueCheck.cpp | 3 +- .../modernize/ReplaceAutoPtrCheck.cpp | 15 +++--- .../clang-tidy/modernize/TypeTraitsCheck.cpp | 34 .../clang-tidy/modernize/UseAutoCheck.cpp | 18 +++ .../modernize/UseConstraintsCheck.cpp | 7 ++- .../clang-tidy/modernize/UseEmplaceCheck.cpp | 53 +-- .../modernize/UseScopedLockCheck.cpp | 41 +- .../modernize/UseTransparentFunctorsCheck.cpp | 16 +++--- .../performance/NoAutomaticMoveCheck.cpp | 8 +-- .../portability/StdAllocatorConstCheck.cpp| 11 ++-- .../readability/UseStdMinMaxCheck.cpp | 6 +-- .../clang-tidy/utils/Matchers.cpp | 2 +- .../utils/RenamerClangTidyCheck.cpp | 30 +++ clang-tools-extra/clangd/AST.cpp | 11 ++-- clang-tools-extra/clangd/AST.h| 3 +- clang-tools-extra/clangd/DumpAST.cpp | 6 ++- clang-tools-extra/clangd/FindTarget.cpp | 36 ++--- clang-tools-extra/clangd/Hover.cpp| 18 --- clang-tools-extra/clangd/InlayHints.cpp | 28 +- clang-tools-extra/clangd/Selection.cpp| 15 +++--- clang-tools-extra/clangd/XRefs.cpp| 13 +++-- .../refactor/tweaks/ExtractFunction.cpp | 5 +- .../clangd/unittests/ASTTests.cpp | 7 +-- .../clangd/unittests/DumpASTTests.cpp | 15 +++--- .../clangd/unittests/HoverTests.cpp | 10 ++-- .../clangd/unittests/InlayHintTests.cpp | 9 +--- .../clangd/unittests/QualityTests.cpp | 14 +++-- .../include-cleaner/lib/WalkAST.cpp | 6 +-- .../bugprone/copy-constructor-init.cpp| 1 - .../unused-local-non-trivial-variable.cpp | 6 +-- .../portability/std-allocator-const.cpp | 22 45 files changed, 289 insertions(+), 334 deletions(-) diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp index bb48883f88815..1f30d27c0a54f 100644 --- a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp +++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp @@ -216,8 +216,7 @@ void FindAllSymbols::registerMatchers(MatchFinder *MatchFinder) { // Uses of most types: just look at what the typeLoc refers to. MatchFinder->addMatcher( typeLoc(isExpansionInMainFile(), - loc(qualType(allOf(unless(elaboratedType()), - hasDeclaration(Types.bind("use")), + loc(qualType(hasDeclaration(Types.bind("use"), this); // Uses of typedefs: these are often transparent to hasDeclaration, so we need // to handle them explicitly. diff --git a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp index 6565fa3f7c85b..0625468d9da88 100644 --- a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp @@ -43,7 +43,8 @@ static bool isDerivedClassBefriended(const CXXRecordDecl *CRTP, return false; } -return FriendType->getType()->getAsCXXRecordDecl() == Derived; +return declaresSameEntity(FriendType->getType()->getAsCXXRecordDecl(), + Derived); }); } @@ -55,7 +56,8 @@ getDerivedParameter(const ClassTemplateSpecializationDecl *CRTP, CRTP->getTemplateArgs().asArray(), [&](const TemplateArgument &Arg) { ++Idx; return Arg.getKind() == TemplateArgument::Type && - Arg.getAsType()->getAsCXXRecordDecl() == Derived; + declaresSameEntity(Arg.getAsType()->getAsCXXRecordDecl(
[llvm-branch-commits] [clang] [clang-tools-extra] [PATCH 6/6] [clang] improve NestedNameSpecifier (PR #149748)
llvmbot wrote: @llvm/pr-subscribers-clangd @llvm/pr-subscribers-clang-tidy Author: Matheus Izvekov (mizvekov) Changes This contains the NestedNameSpecifier representation changes originally from: https://github.com/llvm/llvm-project/pull/147835 --- Patch is 465.84 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/149748.diff 124 Files Affected: - (modified) clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp (+17-36) - (modified) clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp (+2-1) - (modified) clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp (+7-11) - (modified) clang-tools-extra/clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp (+12-5) - (modified) clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp (-8) - (modified) clang-tools-extra/clang-tidy/misc/UnusedAliasDeclsCheck.cpp (+5-5) - (modified) clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp (+12-17) - (modified) clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp (+46-47) - (modified) clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp (+16-10) - (modified) clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp (+3-2) - (modified) clang-tools-extra/clangd/AST.cpp (+51-32) - (modified) clang-tools-extra/clangd/CodeComplete.cpp (+6-10) - (modified) clang-tools-extra/clangd/DumpAST.cpp (+14-19) - (modified) clang-tools-extra/clangd/FindTarget.cpp (+42-43) - (modified) clang-tools-extra/clangd/IncludeFixer.cpp (+25-25) - (modified) clang-tools-extra/clangd/Selection.cpp (+1-1) - (modified) clang-tools-extra/clangd/SemanticHighlighting.cpp (-15) - (modified) clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp (+77-44) - (modified) clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp (+1-1) - (modified) clang-tools-extra/clangd/unittests/FindTargetTests.cpp (+2-2) - (modified) clang-tools-extra/clangd/unittests/SelectionTests.cpp (+2-2) - (modified) clang-tools-extra/include-cleaner/lib/WalkAST.cpp (+7-9) - (modified) clang/include/clang/AST/ASTConcept.h (+2-7) - (modified) clang/include/clang/AST/ASTContext.h (+6-32) - (modified) clang/include/clang/AST/ASTImporter.h (+1-1) - (modified) clang/include/clang/AST/ASTNodeTraverser.h (+7-5) - (modified) clang/include/clang/AST/ASTTypeTraits.h (+7-6) - (modified) clang/include/clang/AST/AbstractBasicReader.h (+16-21) - (modified) clang/include/clang/AST/AbstractBasicWriter.h (+17-16) - (modified) clang/include/clang/AST/CanonicalType.h (+1-1) - (modified) clang/include/clang/AST/Decl.h (+5-5) - (modified) clang/include/clang/AST/DeclCXX.h (+7-9) - (modified) clang/include/clang/AST/DependenceFlags.h (+1-1) - (modified) clang/include/clang/AST/DynamicRecursiveASTVisitor.h (+1-2) - (modified) clang/include/clang/AST/Expr.h (+2-2) - (modified) clang/include/clang/AST/ExprCXX.h (+4-4) - (modified) clang/include/clang/AST/NestedNameSpecifier.h (+212-453) - (added) clang/include/clang/AST/NestedNameSpecifierBase.h (+586) - (modified) clang/include/clang/AST/ODRHash.h (+1-1) - (modified) clang/include/clang/AST/PropertiesBase.td (+2-3) - (modified) clang/include/clang/AST/RecursiveASTVisitor.h (+37-37) - (modified) clang/include/clang/AST/TemplateBase.h (+13-23) - (modified) clang/include/clang/AST/TemplateName.h (+19-11) - (modified) clang/include/clang/AST/TextNodeDumper.h (+1-1) - (modified) clang/include/clang/AST/Type.h (+18-13) - (modified) clang/include/clang/AST/TypeLoc.h (+17-2) - (modified) clang/include/clang/ASTMatchers/ASTMatchers.h (+33-9) - (modified) clang/include/clang/ASTMatchers/ASTMatchersInternal.h (+1-1) - (modified) clang/include/clang/ExtractAPI/DeclarationFragments.h (+2-3) - (modified) clang/include/clang/Sema/CodeCompleteConsumer.h (+4-3) - (modified) clang/include/clang/Sema/DeclSpec.h (+6-6) - (modified) clang/include/clang/Sema/HeuristicResolver.h (+1-2) - (modified) clang/include/clang/Sema/Sema.h (+7-6) - (modified) clang/include/clang/Sema/SemaInternal.h (+4-4) - (modified) clang/include/clang/Sema/TypoCorrection.h (+15-14) - (modified) clang/include/clang/Serialization/ASTRecordReader.h (+1-1) - (modified) clang/include/clang/Serialization/ASTRecordWriter.h (+1-1) - (modified) clang/include/clang/Tooling/Refactoring/Lookup.h (+1-2) - (modified) clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h (+9-7) - (modified) clang/lib/AST/ASTConcept.cpp (+9-2) - (modified) clang/lib/AST/ASTContext.cpp (+94-214) - (modified) clang/lib/AST/ASTDiagnostic.cpp (+3-4) - (modified) clang/lib/AST/ASTImporter.cpp (+42-56) - (modified) clang/lib/AST/ASTStructuralEquivalence.cpp (+26-33) - (modified) clang/lib/AST/ASTTypeTraits.cpp (+31-5) - (modified) clang/lib/AST/ComputeDependence.cpp (+8-12) - (modified) clang/lib/AST/Decl.cpp (+7-12) - (modified) clang/lib/AST/DeclPrinter.cpp (+2-5) - (modified) clang/lib/AST/DynamicRec
[llvm-branch-commits] [clang] [PATCH 3/6] [clang] Improve nested name specifier AST representation (PR #148014)
https://github.com/mizvekov edited https://github.com/llvm/llvm-project/pull/148014 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [PATCH 4/6] [clang] Improve nested name specifier AST representation (PR #148015)
https://github.com/mizvekov edited https://github.com/llvm/llvm-project/pull/148015 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [PATCH 2/6] [clang] Improve nested name specifier AST representation (PR #148012)
https://github.com/mizvekov edited https://github.com/llvm/llvm-project/pull/148012 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] release/21.x: [lld] Add thunks for hexagon (#111217) (PR #149723)
llvmbot wrote: @llvm/pr-subscribers-lld @llvm/pr-subscribers-lld-elf Author: None (llvmbot) Changes Backport b42f96bc057fd9e31572069b241ba130c21144e5 Requested by: @androm3da --- Patch is 27.54 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/149723.diff 9 Files Affected: - (modified) lld/ELF/Arch/Hexagon.cpp (+47) - (modified) lld/ELF/Relocations.cpp (+40-13) - (modified) lld/ELF/Thunks.cpp (+71-1) - (removed) lld/test/ELF/hexagon-jump-error.s (-32) - (added) lld/test/ELF/hexagon-thunk-range-b22rel.s (+115) - (added) lld/test/ELF/hexagon-thunk-range-gdplt.s (+95) - (added) lld/test/ELF/hexagon-thunk-range-plt.s (+75) - (added) lld/test/ELF/hexagon-thunks-packets.s (+122) - (added) lld/test/ELF/hexagon-thunks.s (+53) ``diff diff --git a/lld/ELF/Arch/Hexagon.cpp b/lld/ELF/Arch/Hexagon.cpp index 479131a24dcfc..9b33e78731c97 100644 --- a/lld/ELF/Arch/Hexagon.cpp +++ b/lld/ELF/Arch/Hexagon.cpp @@ -11,6 +11,7 @@ #include "Symbols.h" #include "SyntheticSections.h" #include "Target.h" +#include "Thunks.h" #include "lld/Common/ErrorHandler.h" #include "llvm/ADT/SmallVector.h" #include "llvm/BinaryFormat/ELF.h" @@ -36,6 +37,10 @@ class Hexagon final : public TargetInfo { const uint8_t *loc) const override; RelType getDynRel(RelType type) const override; int64_t getImplicitAddend(const uint8_t *buf, RelType type) const override; + bool needsThunk(RelExpr expr, RelType type, const InputFile *file, + uint64_t branchAddr, const Symbol &s, + int64_t a) const override; + bool inBranchRange(RelType type, uint64_t src, uint64_t dst) const override; void relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const override; void writePltHeader(uint8_t *buf) const override; @@ -63,6 +68,8 @@ Hexagon::Hexagon(Ctx &ctx) : TargetInfo(ctx) { tlsGotRel = R_HEX_TPREL_32; tlsModuleIndexRel = R_HEX_DTPMOD_32; tlsOffsetRel = R_HEX_DTPREL_32; + + needsThunks = true; } uint32_t Hexagon::calcEFlags() const { @@ -258,6 +265,46 @@ static uint32_t findMaskR16(Ctx &ctx, uint32_t insn) { static void or32le(uint8_t *p, int32_t v) { write32le(p, read32le(p) | v); } +bool Hexagon::inBranchRange(RelType type, uint64_t src, uint64_t dst) const { + int64_t offset = dst - src; + switch (type) { + case llvm::ELF::R_HEX_B22_PCREL: + case llvm::ELF::R_HEX_PLT_B22_PCREL: + case llvm::ELF::R_HEX_GD_PLT_B22_PCREL: + case llvm::ELF::R_HEX_LD_PLT_B22_PCREL: +return llvm::isInt<22>(offset >> 2); + case llvm::ELF::R_HEX_B15_PCREL: +return llvm::isInt<15>(offset >> 2); +break; + case llvm::ELF::R_HEX_B13_PCREL: +return llvm::isInt<13>(offset >> 2); +break; + case llvm::ELF::R_HEX_B9_PCREL: +return llvm::isInt<9>(offset >> 2); + default: +return true; + } + llvm_unreachable("unsupported relocation"); +} + +bool Hexagon::needsThunk(RelExpr expr, RelType type, const InputFile *file, + uint64_t branchAddr, const Symbol &s, + int64_t a) const { + // Only check branch range for supported branch relocation types + switch (type) { + case R_HEX_B22_PCREL: + case R_HEX_PLT_B22_PCREL: + case R_HEX_GD_PLT_B22_PCREL: + case R_HEX_LD_PLT_B22_PCREL: + case R_HEX_B15_PCREL: + case R_HEX_B13_PCREL: + case R_HEX_B9_PCREL: +return !ctx.target->inBranchRange(type, branchAddr, s.getVA(ctx, a)); + default: +return false; + } +} + void Hexagon::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const { switch (rel.type) { diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index cebd564036b2c..41f153e97de77 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -2139,17 +2139,44 @@ void ThunkCreator::mergeThunks(ArrayRef outputSections) { }); } -static int64_t getPCBias(Ctx &ctx, RelType type) { - if (ctx.arg.emachine != EM_ARM) -return 0; - switch (type) { - case R_ARM_THM_JUMP19: - case R_ARM_THM_JUMP24: - case R_ARM_THM_CALL: -return 4; - default: -return 8; +constexpr uint32_t HEXAGON_MASK_END_PACKET = 3 << 14; +constexpr uint32_t HEXAGON_END_OF_PACKET = 3 << 14; +constexpr uint32_t HEXAGON_END_OF_DUPLEX = 0 << 14; + +// Return the distance between the packet start and the instruction in the +// relocation. +static int getHexagonPacketOffset(const InputSection &isec, + const Relocation &rel) { + const ArrayRef data = isec.content(); + + // Search back as many as 3 instructions. + for (unsigned i = 0;; i++) { +if (i == 3 || rel.offset < (i + 1) * 4) + return i * 4; +uint32_t instWord = 0; +const ArrayRef instWordContents = +data.drop_front(rel.offset - (i + 1) * 4); +memcpy(&instWord, instWordContents.data(), sizeof(instWord)); +if (((instWord & HEXAGON_MASK_END_PACKET) == HEXAGON_END_OF_PACKET) || +((instWord & HEXAGO
[llvm-branch-commits] [lld] release/21.x: [lld] Add thunks for hexagon (#111217) (PR #149723)
llvmbot wrote: @llvm/pr-subscribers-backend-hexagon Author: None (llvmbot) Changes Backport b42f96bc057fd9e31572069b241ba130c21144e5 Requested by: @androm3da --- Patch is 27.54 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/149723.diff 9 Files Affected: - (modified) lld/ELF/Arch/Hexagon.cpp (+47) - (modified) lld/ELF/Relocations.cpp (+40-13) - (modified) lld/ELF/Thunks.cpp (+71-1) - (removed) lld/test/ELF/hexagon-jump-error.s (-32) - (added) lld/test/ELF/hexagon-thunk-range-b22rel.s (+115) - (added) lld/test/ELF/hexagon-thunk-range-gdplt.s (+95) - (added) lld/test/ELF/hexagon-thunk-range-plt.s (+75) - (added) lld/test/ELF/hexagon-thunks-packets.s (+122) - (added) lld/test/ELF/hexagon-thunks.s (+53) ``diff diff --git a/lld/ELF/Arch/Hexagon.cpp b/lld/ELF/Arch/Hexagon.cpp index 479131a24dcfc..9b33e78731c97 100644 --- a/lld/ELF/Arch/Hexagon.cpp +++ b/lld/ELF/Arch/Hexagon.cpp @@ -11,6 +11,7 @@ #include "Symbols.h" #include "SyntheticSections.h" #include "Target.h" +#include "Thunks.h" #include "lld/Common/ErrorHandler.h" #include "llvm/ADT/SmallVector.h" #include "llvm/BinaryFormat/ELF.h" @@ -36,6 +37,10 @@ class Hexagon final : public TargetInfo { const uint8_t *loc) const override; RelType getDynRel(RelType type) const override; int64_t getImplicitAddend(const uint8_t *buf, RelType type) const override; + bool needsThunk(RelExpr expr, RelType type, const InputFile *file, + uint64_t branchAddr, const Symbol &s, + int64_t a) const override; + bool inBranchRange(RelType type, uint64_t src, uint64_t dst) const override; void relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const override; void writePltHeader(uint8_t *buf) const override; @@ -63,6 +68,8 @@ Hexagon::Hexagon(Ctx &ctx) : TargetInfo(ctx) { tlsGotRel = R_HEX_TPREL_32; tlsModuleIndexRel = R_HEX_DTPMOD_32; tlsOffsetRel = R_HEX_DTPREL_32; + + needsThunks = true; } uint32_t Hexagon::calcEFlags() const { @@ -258,6 +265,46 @@ static uint32_t findMaskR16(Ctx &ctx, uint32_t insn) { static void or32le(uint8_t *p, int32_t v) { write32le(p, read32le(p) | v); } +bool Hexagon::inBranchRange(RelType type, uint64_t src, uint64_t dst) const { + int64_t offset = dst - src; + switch (type) { + case llvm::ELF::R_HEX_B22_PCREL: + case llvm::ELF::R_HEX_PLT_B22_PCREL: + case llvm::ELF::R_HEX_GD_PLT_B22_PCREL: + case llvm::ELF::R_HEX_LD_PLT_B22_PCREL: +return llvm::isInt<22>(offset >> 2); + case llvm::ELF::R_HEX_B15_PCREL: +return llvm::isInt<15>(offset >> 2); +break; + case llvm::ELF::R_HEX_B13_PCREL: +return llvm::isInt<13>(offset >> 2); +break; + case llvm::ELF::R_HEX_B9_PCREL: +return llvm::isInt<9>(offset >> 2); + default: +return true; + } + llvm_unreachable("unsupported relocation"); +} + +bool Hexagon::needsThunk(RelExpr expr, RelType type, const InputFile *file, + uint64_t branchAddr, const Symbol &s, + int64_t a) const { + // Only check branch range for supported branch relocation types + switch (type) { + case R_HEX_B22_PCREL: + case R_HEX_PLT_B22_PCREL: + case R_HEX_GD_PLT_B22_PCREL: + case R_HEX_LD_PLT_B22_PCREL: + case R_HEX_B15_PCREL: + case R_HEX_B13_PCREL: + case R_HEX_B9_PCREL: +return !ctx.target->inBranchRange(type, branchAddr, s.getVA(ctx, a)); + default: +return false; + } +} + void Hexagon::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const { switch (rel.type) { diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index cebd564036b2c..41f153e97de77 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -2139,17 +2139,44 @@ void ThunkCreator::mergeThunks(ArrayRef outputSections) { }); } -static int64_t getPCBias(Ctx &ctx, RelType type) { - if (ctx.arg.emachine != EM_ARM) -return 0; - switch (type) { - case R_ARM_THM_JUMP19: - case R_ARM_THM_JUMP24: - case R_ARM_THM_CALL: -return 4; - default: -return 8; +constexpr uint32_t HEXAGON_MASK_END_PACKET = 3 << 14; +constexpr uint32_t HEXAGON_END_OF_PACKET = 3 << 14; +constexpr uint32_t HEXAGON_END_OF_DUPLEX = 0 << 14; + +// Return the distance between the packet start and the instruction in the +// relocation. +static int getHexagonPacketOffset(const InputSection &isec, + const Relocation &rel) { + const ArrayRef data = isec.content(); + + // Search back as many as 3 instructions. + for (unsigned i = 0;; i++) { +if (i == 3 || rel.offset < (i + 1) * 4) + return i * 4; +uint32_t instWord = 0; +const ArrayRef instWordContents = +data.drop_front(rel.offset - (i + 1) * 4); +memcpy(&instWord, instWordContents.data(), sizeof(instWord)); +if (((instWord & HEXAGON_MASK_END_PACKET) == HEXAGON_END_OF_PACKET) || +((instWord & HEXAGON_MASK_END_PACKET
[llvm-branch-commits] [lld] release/21.x: [lld] Add thunks for hexagon (#111217) (PR #149723)
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/149723 Backport b42f96bc057fd9e31572069b241ba130c21144e5 Requested by: @androm3da >From 7e8727bcf0f31986137e74b4df8ed6556f89612f Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Sun, 20 Jul 2025 11:46:31 -0500 Subject: [PATCH] [lld] Add thunks for hexagon (#111217) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without thunks, programs will encounter link errors complaining that the branch target is out of range. Thunks will extend the range of branch targets, which is a critical need for large programs. Thunks provide this flexibility at a cost of some modest code size increase. When configured with the maximal feature set, the hexagon port of the linux kernel would often encounter these limitations when linking with `lld`. The relocations which will be extended by thunks are: * R_HEX_B22_PCREL, R_HEX_{G,L}D_PLT_B22_PCREL, R_HEX_PLT_B22_PCREL relocations have a range of ± 8MiB on the baseline * R_HEX_B15_PCREL: ±65,532 bytes * R_HEX_B13_PCREL: ±16,380 bytes * R_HEX_B9_PCREL: ±1,020 bytes Fixes #149689 Co-authored-by: Alexey Karyakin - Co-authored-by: Alexey Karyakin (cherry picked from commit b42f96bc057fd9e31572069b241ba130c21144e5) --- lld/ELF/Arch/Hexagon.cpp | 47 + lld/ELF/Relocations.cpp | 53 +++--- lld/ELF/Thunks.cpp| 72 - lld/test/ELF/hexagon-jump-error.s | 32 -- lld/test/ELF/hexagon-thunk-range-b22rel.s | 115 lld/test/ELF/hexagon-thunk-range-gdplt.s | 95 + lld/test/ELF/hexagon-thunk-range-plt.s| 75 + lld/test/ELF/hexagon-thunks-packets.s | 122 ++ lld/test/ELF/hexagon-thunks.s | 53 ++ 9 files changed, 618 insertions(+), 46 deletions(-) delete mode 100644 lld/test/ELF/hexagon-jump-error.s create mode 100644 lld/test/ELF/hexagon-thunk-range-b22rel.s create mode 100644 lld/test/ELF/hexagon-thunk-range-gdplt.s create mode 100644 lld/test/ELF/hexagon-thunk-range-plt.s create mode 100644 lld/test/ELF/hexagon-thunks-packets.s create mode 100644 lld/test/ELF/hexagon-thunks.s diff --git a/lld/ELF/Arch/Hexagon.cpp b/lld/ELF/Arch/Hexagon.cpp index 479131a24dcfc..9b33e78731c97 100644 --- a/lld/ELF/Arch/Hexagon.cpp +++ b/lld/ELF/Arch/Hexagon.cpp @@ -11,6 +11,7 @@ #include "Symbols.h" #include "SyntheticSections.h" #include "Target.h" +#include "Thunks.h" #include "lld/Common/ErrorHandler.h" #include "llvm/ADT/SmallVector.h" #include "llvm/BinaryFormat/ELF.h" @@ -36,6 +37,10 @@ class Hexagon final : public TargetInfo { const uint8_t *loc) const override; RelType getDynRel(RelType type) const override; int64_t getImplicitAddend(const uint8_t *buf, RelType type) const override; + bool needsThunk(RelExpr expr, RelType type, const InputFile *file, + uint64_t branchAddr, const Symbol &s, + int64_t a) const override; + bool inBranchRange(RelType type, uint64_t src, uint64_t dst) const override; void relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const override; void writePltHeader(uint8_t *buf) const override; @@ -63,6 +68,8 @@ Hexagon::Hexagon(Ctx &ctx) : TargetInfo(ctx) { tlsGotRel = R_HEX_TPREL_32; tlsModuleIndexRel = R_HEX_DTPMOD_32; tlsOffsetRel = R_HEX_DTPREL_32; + + needsThunks = true; } uint32_t Hexagon::calcEFlags() const { @@ -258,6 +265,46 @@ static uint32_t findMaskR16(Ctx &ctx, uint32_t insn) { static void or32le(uint8_t *p, int32_t v) { write32le(p, read32le(p) | v); } +bool Hexagon::inBranchRange(RelType type, uint64_t src, uint64_t dst) const { + int64_t offset = dst - src; + switch (type) { + case llvm::ELF::R_HEX_B22_PCREL: + case llvm::ELF::R_HEX_PLT_B22_PCREL: + case llvm::ELF::R_HEX_GD_PLT_B22_PCREL: + case llvm::ELF::R_HEX_LD_PLT_B22_PCREL: +return llvm::isInt<22>(offset >> 2); + case llvm::ELF::R_HEX_B15_PCREL: +return llvm::isInt<15>(offset >> 2); +break; + case llvm::ELF::R_HEX_B13_PCREL: +return llvm::isInt<13>(offset >> 2); +break; + case llvm::ELF::R_HEX_B9_PCREL: +return llvm::isInt<9>(offset >> 2); + default: +return true; + } + llvm_unreachable("unsupported relocation"); +} + +bool Hexagon::needsThunk(RelExpr expr, RelType type, const InputFile *file, + uint64_t branchAddr, const Symbol &s, + int64_t a) const { + // Only check branch range for supported branch relocation types + switch (type) { + case R_HEX_B22_PCREL: + case R_HEX_PLT_B22_PCREL: + case R_HEX_GD_PLT_B22_PCREL: + case R_HEX_LD_PLT_B22_PCREL: + case R_HEX_B15_PCREL: + case R_HEX_B13_PCREL: + case R_HEX_B9_PCREL: +return !ctx.target->inBranchRange(type, branchAddr, s.getVA(ctx, a)); + default: +return false; + } +} + void Hexagon::relocate(uin
[llvm-branch-commits] [lld] release/21.x: [lld] Add thunks for hexagon (#111217) (PR #149723)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/149723 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] release/21.x: [lld] Add thunks for hexagon (#111217) (PR #149723)
llvmbot wrote: @MaskRay What do you think about merging this PR to the release branch? https://github.com/llvm/llvm-project/pull/149723 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libclc] [libclc] Revert the recent breaking changes from CMake from the 21.x release branch (PR #149711)
=?utf-8?q?Micha=C5=82_G=C3=B3rny?= , =?utf-8?q?Micha=C5=82_G=C3=B3rny?= , =?utf-8?q?Micha=C5=82_G=C3=B3rny?= , =?utf-8?q?Micha=C5=82_G=C3=B3rny?= Message-ID: In-Reply-To: https://github.com/sylvestre approved this pull request. Agreed https://github.com/llvm/llvm-project/pull/149711 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [PATCH 4/6] [clang] Improve nested name specifier AST representation (PR #148015)
https://github.com/mizvekov updated https://github.com/llvm/llvm-project/pull/148015 >From 07134c3a595386732fb7c7b86d725bfccf885820 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Thu, 10 Jul 2025 14:07:34 -0300 Subject: [PATCH] [PATCH 4/6] [clang] Improve nested name specifier AST representation clang tools extra changes --- .../find-all-symbols/FindAllSymbols.cpp | 3 +- .../CrtpConstructorAccessibilityCheck.cpp | 6 ++- .../EasilySwappableParametersCheck.cpp| 14 ++--- .../ForwardDeclarationNamespaceCheck.cpp | 11 ++-- .../bugprone/IncorrectEnableIfCheck.cpp | 19 +++ .../bugprone/SizeofExpressionCheck.cpp| 10 ++-- .../NoSuspendWithLockCheck.cpp| 4 +- .../google/AvoidCStyleCastsCheck.cpp | 31 --- .../google/UpgradeGoogletestCaseCheck.cpp | 9 +++- .../clang-tidy/misc/ConstCorrectnessCheck.cpp | 11 ++-- .../clang-tidy/misc/MisplacedConstCheck.cpp | 14 ++--- .../misc/RedundantExpressionCheck.cpp | 5 +- .../clang-tidy/misc/UnusedUsingDeclsCheck.cpp | 6 +-- .../DeprecatedIosBaseAliasesCheck.cpp | 11 ++-- .../clang-tidy/modernize/PassByValueCheck.cpp | 3 +- .../modernize/ReplaceAutoPtrCheck.cpp | 15 +++--- .../clang-tidy/modernize/TypeTraitsCheck.cpp | 34 .../clang-tidy/modernize/UseAutoCheck.cpp | 18 +++ .../modernize/UseConstraintsCheck.cpp | 7 ++- .../clang-tidy/modernize/UseEmplaceCheck.cpp | 53 +-- .../modernize/UseScopedLockCheck.cpp | 41 +- .../modernize/UseTransparentFunctorsCheck.cpp | 16 +++--- .../performance/NoAutomaticMoveCheck.cpp | 8 +-- .../portability/StdAllocatorConstCheck.cpp| 11 ++-- .../readability/UseStdMinMaxCheck.cpp | 6 +-- .../clang-tidy/utils/Matchers.cpp | 2 +- .../utils/RenamerClangTidyCheck.cpp | 30 +++ clang-tools-extra/clangd/AST.cpp | 11 ++-- clang-tools-extra/clangd/AST.h| 3 +- clang-tools-extra/clangd/DumpAST.cpp | 6 ++- clang-tools-extra/clangd/FindTarget.cpp | 36 ++--- clang-tools-extra/clangd/Hover.cpp| 18 --- clang-tools-extra/clangd/InlayHints.cpp | 28 +- clang-tools-extra/clangd/Selection.cpp| 15 +++--- clang-tools-extra/clangd/XRefs.cpp| 13 +++-- .../refactor/tweaks/ExtractFunction.cpp | 5 +- .../clangd/unittests/ASTTests.cpp | 7 +-- .../clangd/unittests/DumpASTTests.cpp | 15 +++--- .../clangd/unittests/HoverTests.cpp | 10 ++-- .../clangd/unittests/InlayHintTests.cpp | 9 +--- .../clangd/unittests/QualityTests.cpp | 14 +++-- .../include-cleaner/lib/WalkAST.cpp | 6 +-- .../bugprone/copy-constructor-init.cpp| 1 - .../unused-local-non-trivial-variable.cpp | 6 +-- .../portability/std-allocator-const.cpp | 22 45 files changed, 289 insertions(+), 334 deletions(-) diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp index bb48883f88815..1f30d27c0a54f 100644 --- a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp +++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp @@ -216,8 +216,7 @@ void FindAllSymbols::registerMatchers(MatchFinder *MatchFinder) { // Uses of most types: just look at what the typeLoc refers to. MatchFinder->addMatcher( typeLoc(isExpansionInMainFile(), - loc(qualType(allOf(unless(elaboratedType()), - hasDeclaration(Types.bind("use")), + loc(qualType(hasDeclaration(Types.bind("use"), this); // Uses of typedefs: these are often transparent to hasDeclaration, so we need // to handle them explicitly. diff --git a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp index 6565fa3f7c85b..0625468d9da88 100644 --- a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp @@ -43,7 +43,8 @@ static bool isDerivedClassBefriended(const CXXRecordDecl *CRTP, return false; } -return FriendType->getType()->getAsCXXRecordDecl() == Derived; +return declaresSameEntity(FriendType->getType()->getAsCXXRecordDecl(), + Derived); }); } @@ -55,7 +56,8 @@ getDerivedParameter(const ClassTemplateSpecializationDecl *CRTP, CRTP->getTemplateArgs().asArray(), [&](const TemplateArgument &Arg) { ++Idx; return Arg.getKind() == TemplateArgument::Type && - Arg.getAsType()->getAsCXXRecordDecl() == Derived; + declaresSameEntity(Arg.getAsType()->getAsCXXRecordDecl(
[llvm-branch-commits] [clang-tools-extra] [PATCH 4/6] [clang] Improve nested name specifier AST representation (PR #148015)
https://github.com/mizvekov updated https://github.com/llvm/llvm-project/pull/148015 >From 07134c3a595386732fb7c7b86d725bfccf885820 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Thu, 10 Jul 2025 14:07:34 -0300 Subject: [PATCH] [PATCH 4/6] [clang] Improve nested name specifier AST representation clang tools extra changes --- .../find-all-symbols/FindAllSymbols.cpp | 3 +- .../CrtpConstructorAccessibilityCheck.cpp | 6 ++- .../EasilySwappableParametersCheck.cpp| 14 ++--- .../ForwardDeclarationNamespaceCheck.cpp | 11 ++-- .../bugprone/IncorrectEnableIfCheck.cpp | 19 +++ .../bugprone/SizeofExpressionCheck.cpp| 10 ++-- .../NoSuspendWithLockCheck.cpp| 4 +- .../google/AvoidCStyleCastsCheck.cpp | 31 --- .../google/UpgradeGoogletestCaseCheck.cpp | 9 +++- .../clang-tidy/misc/ConstCorrectnessCheck.cpp | 11 ++-- .../clang-tidy/misc/MisplacedConstCheck.cpp | 14 ++--- .../misc/RedundantExpressionCheck.cpp | 5 +- .../clang-tidy/misc/UnusedUsingDeclsCheck.cpp | 6 +-- .../DeprecatedIosBaseAliasesCheck.cpp | 11 ++-- .../clang-tidy/modernize/PassByValueCheck.cpp | 3 +- .../modernize/ReplaceAutoPtrCheck.cpp | 15 +++--- .../clang-tidy/modernize/TypeTraitsCheck.cpp | 34 .../clang-tidy/modernize/UseAutoCheck.cpp | 18 +++ .../modernize/UseConstraintsCheck.cpp | 7 ++- .../clang-tidy/modernize/UseEmplaceCheck.cpp | 53 +-- .../modernize/UseScopedLockCheck.cpp | 41 +- .../modernize/UseTransparentFunctorsCheck.cpp | 16 +++--- .../performance/NoAutomaticMoveCheck.cpp | 8 +-- .../portability/StdAllocatorConstCheck.cpp| 11 ++-- .../readability/UseStdMinMaxCheck.cpp | 6 +-- .../clang-tidy/utils/Matchers.cpp | 2 +- .../utils/RenamerClangTidyCheck.cpp | 30 +++ clang-tools-extra/clangd/AST.cpp | 11 ++-- clang-tools-extra/clangd/AST.h| 3 +- clang-tools-extra/clangd/DumpAST.cpp | 6 ++- clang-tools-extra/clangd/FindTarget.cpp | 36 ++--- clang-tools-extra/clangd/Hover.cpp| 18 --- clang-tools-extra/clangd/InlayHints.cpp | 28 +- clang-tools-extra/clangd/Selection.cpp| 15 +++--- clang-tools-extra/clangd/XRefs.cpp| 13 +++-- .../refactor/tweaks/ExtractFunction.cpp | 5 +- .../clangd/unittests/ASTTests.cpp | 7 +-- .../clangd/unittests/DumpASTTests.cpp | 15 +++--- .../clangd/unittests/HoverTests.cpp | 10 ++-- .../clangd/unittests/InlayHintTests.cpp | 9 +--- .../clangd/unittests/QualityTests.cpp | 14 +++-- .../include-cleaner/lib/WalkAST.cpp | 6 +-- .../bugprone/copy-constructor-init.cpp| 1 - .../unused-local-non-trivial-variable.cpp | 6 +-- .../portability/std-allocator-const.cpp | 22 45 files changed, 289 insertions(+), 334 deletions(-) diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp index bb48883f88815..1f30d27c0a54f 100644 --- a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp +++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp @@ -216,8 +216,7 @@ void FindAllSymbols::registerMatchers(MatchFinder *MatchFinder) { // Uses of most types: just look at what the typeLoc refers to. MatchFinder->addMatcher( typeLoc(isExpansionInMainFile(), - loc(qualType(allOf(unless(elaboratedType()), - hasDeclaration(Types.bind("use")), + loc(qualType(hasDeclaration(Types.bind("use"), this); // Uses of typedefs: these are often transparent to hasDeclaration, so we need // to handle them explicitly. diff --git a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp index 6565fa3f7c85b..0625468d9da88 100644 --- a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp @@ -43,7 +43,8 @@ static bool isDerivedClassBefriended(const CXXRecordDecl *CRTP, return false; } -return FriendType->getType()->getAsCXXRecordDecl() == Derived; +return declaresSameEntity(FriendType->getType()->getAsCXXRecordDecl(), + Derived); }); } @@ -55,7 +56,8 @@ getDerivedParameter(const ClassTemplateSpecializationDecl *CRTP, CRTP->getTemplateArgs().asArray(), [&](const TemplateArgument &Arg) { ++Idx; return Arg.getKind() == TemplateArgument::Type && - Arg.getAsType()->getAsCXXRecordDecl() == Derived; + declaresSameEntity(Arg.getAsType()->getAsCXXRecordDecl(
[llvm-branch-commits] [clang] [flang] release/21.x: [SPARC][Driver] Move feature mode selection to Arch/Sparc.cpp (#149652) (PR #149756)
https://github.com/llvmbot updated https://github.com/llvm/llvm-project/pull/149756 >From 2c0293255994d2df56f0cfe636f551bea6bf1e62 Mon Sep 17 00:00:00 2001 From: Koakuma Date: Mon, 21 Jul 2025 08:33:06 +0700 Subject: [PATCH] [SPARC][Driver] Move feature mode selection to Arch/Sparc.cpp (#149652) This is so that it's performed also for flang and not just for clang. This should fix https://github.com/llvm/llvm-project/issues/138494. (cherry picked from commit 38fc453afdb6a4511b7c8e189f12a92559ecc396) --- clang/lib/Driver/ToolChains/Arch/Sparc.cpp | 11 ++- clang/lib/Driver/ToolChains/Arch/Sparc.h | 3 ++- clang/lib/Driver/ToolChains/Clang.cpp | 10 -- clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 +- clang/lib/Driver/ToolChains/Flang.cpp | 1 + flang/test/Driver/target-cpu-features.f90 | 7 +++ 6 files changed, 21 insertions(+), 13 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp index 9595ee8383c85..504f110eac87c 100644 --- a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp +++ b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp @@ -130,7 +130,8 @@ std::string sparc::getSparcTargetCPU(const Driver &D, const ArgList &Args, return ""; } -void sparc::getSparcTargetFeatures(const Driver &D, const ArgList &Args, +void sparc::getSparcTargetFeatures(const Driver &D, const llvm::Triple &Triple, + const ArgList &Args, std::vector &Features) { sparc::FloatABI FloatABI = sparc::getSparcFloatABI(D, Args); if (FloatABI == sparc::FloatABI::Soft) @@ -150,11 +151,19 @@ void sparc::getSparcTargetFeatures(const Driver &D, const ArgList &Args, Features.push_back("-popc"); } + // Those OSes default to enabling VIS on 64-bit SPARC. + // See also the corresponding code for external assemblers in + // sparc::getSparcAsmModeForCPU(). + bool IsSparcV9ATarget = + (Triple.getArch() == llvm::Triple::sparcv9) && + (Triple.isOSLinux() || Triple.isOSFreeBSD() || Triple.isOSOpenBSD()); if (Arg *A = Args.getLastArg(options::OPT_mvis, options::OPT_mno_vis)) { if (A->getOption().matches(options::OPT_mvis)) Features.push_back("+vis"); else Features.push_back("-vis"); + } else if (IsSparcV9ATarget) { +Features.push_back("+vis"); } if (Arg *A = Args.getLastArg(options::OPT_mvis2, options::OPT_mno_vis2)) { diff --git a/clang/lib/Driver/ToolChains/Arch/Sparc.h b/clang/lib/Driver/ToolChains/Arch/Sparc.h index 2b178d9df1ee3..fa25b4992cc8b 100644 --- a/clang/lib/Driver/ToolChains/Arch/Sparc.h +++ b/clang/lib/Driver/ToolChains/Arch/Sparc.h @@ -31,7 +31,8 @@ FloatABI getSparcFloatABI(const Driver &D, const llvm::opt::ArgList &Args); std::string getSparcTargetCPU(const Driver &D, const llvm::opt::ArgList &Args, const llvm::Triple &Triple); -void getSparcTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, +void getSparcTargetFeatures(const Driver &D, const llvm::Triple &Triple, +const llvm::opt::ArgList &Args, std::vector &Features); const char *getSparcAsmModeForCPU(llvm::StringRef Name, const llvm::Triple &Triple); diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 456bfe885f354..bf5f427fbfbb4 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2731,16 +2731,6 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, CmdArgs.push_back(MipsTargetFeature); } - // Those OSes default to enabling VIS on 64-bit SPARC. - // See also the corresponding code for external assemblers in - // sparc::getSparcAsmModeForCPU(). - bool IsSparcV9ATarget = - (C.getDefaultToolChain().getArch() == llvm::Triple::sparcv9) && - (Triple.isOSLinux() || Triple.isOSFreeBSD() || Triple.isOSOpenBSD()); - if (IsSparcV9ATarget && SparcTargetFeatures.empty()) { -CmdArgs.push_back("-target-feature"); -CmdArgs.push_back("+vis"); - } for (const char *Feature : SparcTargetFeatures) { CmdArgs.push_back("-target-feature"); CmdArgs.push_back(Feature); diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 097d186ad8ea4..069fd877bd7f8 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -856,7 +856,7 @@ void tools::getTargetFeatures(const Driver &D, const llvm::Triple &Triple, case llvm::Triple::sparc: case llvm::Triple::sparcel: case llvm::Triple::sparcv9: -sparc::getSparcTargetFeatures(D, Args, Features); +sparc::getSparcTargetFeatures(D, Triple, Args, Features); break; case llvm::Triple::r600: case llvm::Triple::amdgcn: diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index 1edb83f7
[llvm-branch-commits] [clang-tools-extra] [PATCH 4/4] [clang] Improve nested name specifier AST representation (PR #148015)
https://github.com/mizvekov updated https://github.com/llvm/llvm-project/pull/148015 >From 58408083dc31297fba96aa9127dce07aee2f Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Thu, 10 Jul 2025 14:07:34 -0300 Subject: [PATCH] [PATCH 4/6] [clang] Improve nested name specifier AST representation clang tools extra changes --- .../find-all-symbols/FindAllSymbols.cpp | 3 +- .../CrtpConstructorAccessibilityCheck.cpp | 6 ++- .../EasilySwappableParametersCheck.cpp| 14 ++--- .../ForwardDeclarationNamespaceCheck.cpp | 11 ++-- .../bugprone/IncorrectEnableIfCheck.cpp | 19 +++ .../bugprone/SizeofExpressionCheck.cpp| 10 ++-- .../NoSuspendWithLockCheck.cpp| 4 +- .../google/AvoidCStyleCastsCheck.cpp | 31 --- .../google/UpgradeGoogletestCaseCheck.cpp | 9 +++- .../clang-tidy/misc/ConstCorrectnessCheck.cpp | 11 ++-- .../clang-tidy/misc/MisplacedConstCheck.cpp | 14 ++--- .../misc/RedundantExpressionCheck.cpp | 5 +- .../clang-tidy/misc/UnusedUsingDeclsCheck.cpp | 6 +-- .../DeprecatedIosBaseAliasesCheck.cpp | 11 ++-- .../clang-tidy/modernize/PassByValueCheck.cpp | 3 +- .../modernize/ReplaceAutoPtrCheck.cpp | 15 +++--- .../clang-tidy/modernize/TypeTraitsCheck.cpp | 34 .../clang-tidy/modernize/UseAutoCheck.cpp | 18 +++ .../modernize/UseConstraintsCheck.cpp | 7 ++- .../clang-tidy/modernize/UseEmplaceCheck.cpp | 53 +-- .../modernize/UseScopedLockCheck.cpp | 41 +- .../modernize/UseTransparentFunctorsCheck.cpp | 16 +++--- .../performance/NoAutomaticMoveCheck.cpp | 8 +-- .../portability/StdAllocatorConstCheck.cpp| 11 ++-- .../readability/UseStdMinMaxCheck.cpp | 6 +-- .../clang-tidy/utils/Matchers.cpp | 2 +- .../utils/RenamerClangTidyCheck.cpp | 30 +++ clang-tools-extra/clangd/AST.cpp | 11 ++-- clang-tools-extra/clangd/AST.h| 3 +- clang-tools-extra/clangd/DumpAST.cpp | 6 ++- clang-tools-extra/clangd/FindTarget.cpp | 36 ++--- clang-tools-extra/clangd/Hover.cpp| 18 --- clang-tools-extra/clangd/InlayHints.cpp | 28 +- clang-tools-extra/clangd/Selection.cpp| 15 +++--- clang-tools-extra/clangd/XRefs.cpp| 13 +++-- .../refactor/tweaks/ExtractFunction.cpp | 5 +- .../clangd/unittests/ASTTests.cpp | 7 +-- .../clangd/unittests/DumpASTTests.cpp | 15 +++--- .../clangd/unittests/HoverTests.cpp | 10 ++-- .../clangd/unittests/InlayHintTests.cpp | 9 +--- .../clangd/unittests/QualityTests.cpp | 14 +++-- .../include-cleaner/lib/WalkAST.cpp | 6 +-- .../bugprone/copy-constructor-init.cpp| 1 - .../unused-local-non-trivial-variable.cpp | 6 +-- .../portability/std-allocator-const.cpp | 22 45 files changed, 289 insertions(+), 334 deletions(-) diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp index bb48883f88815..1f30d27c0a54f 100644 --- a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp +++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp @@ -216,8 +216,7 @@ void FindAllSymbols::registerMatchers(MatchFinder *MatchFinder) { // Uses of most types: just look at what the typeLoc refers to. MatchFinder->addMatcher( typeLoc(isExpansionInMainFile(), - loc(qualType(allOf(unless(elaboratedType()), - hasDeclaration(Types.bind("use")), + loc(qualType(hasDeclaration(Types.bind("use"), this); // Uses of typedefs: these are often transparent to hasDeclaration, so we need // to handle them explicitly. diff --git a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp index 6565fa3f7c85b..0625468d9da88 100644 --- a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp @@ -43,7 +43,8 @@ static bool isDerivedClassBefriended(const CXXRecordDecl *CRTP, return false; } -return FriendType->getType()->getAsCXXRecordDecl() == Derived; +return declaresSameEntity(FriendType->getType()->getAsCXXRecordDecl(), + Derived); }); } @@ -55,7 +56,8 @@ getDerivedParameter(const ClassTemplateSpecializationDecl *CRTP, CRTP->getTemplateArgs().asArray(), [&](const TemplateArgument &Arg) { ++Idx; return Arg.getKind() == TemplateArgument::Type && - Arg.getAsType()->getAsCXXRecordDecl() == Derived; + declaresSameEntity(Arg.getAsType()->getAsCXXRecordDecl(
[llvm-branch-commits] [clang-tools-extra] [PATCH 4/4] [clang] Improve nested name specifier AST representation (PR #148015)
https://github.com/mizvekov updated https://github.com/llvm/llvm-project/pull/148015 >From 58408083dc31297fba96aa9127dce07aee2f Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Thu, 10 Jul 2025 14:07:34 -0300 Subject: [PATCH] [PATCH 4/6] [clang] Improve nested name specifier AST representation clang tools extra changes --- .../find-all-symbols/FindAllSymbols.cpp | 3 +- .../CrtpConstructorAccessibilityCheck.cpp | 6 ++- .../EasilySwappableParametersCheck.cpp| 14 ++--- .../ForwardDeclarationNamespaceCheck.cpp | 11 ++-- .../bugprone/IncorrectEnableIfCheck.cpp | 19 +++ .../bugprone/SizeofExpressionCheck.cpp| 10 ++-- .../NoSuspendWithLockCheck.cpp| 4 +- .../google/AvoidCStyleCastsCheck.cpp | 31 --- .../google/UpgradeGoogletestCaseCheck.cpp | 9 +++- .../clang-tidy/misc/ConstCorrectnessCheck.cpp | 11 ++-- .../clang-tidy/misc/MisplacedConstCheck.cpp | 14 ++--- .../misc/RedundantExpressionCheck.cpp | 5 +- .../clang-tidy/misc/UnusedUsingDeclsCheck.cpp | 6 +-- .../DeprecatedIosBaseAliasesCheck.cpp | 11 ++-- .../clang-tidy/modernize/PassByValueCheck.cpp | 3 +- .../modernize/ReplaceAutoPtrCheck.cpp | 15 +++--- .../clang-tidy/modernize/TypeTraitsCheck.cpp | 34 .../clang-tidy/modernize/UseAutoCheck.cpp | 18 +++ .../modernize/UseConstraintsCheck.cpp | 7 ++- .../clang-tidy/modernize/UseEmplaceCheck.cpp | 53 +-- .../modernize/UseScopedLockCheck.cpp | 41 +- .../modernize/UseTransparentFunctorsCheck.cpp | 16 +++--- .../performance/NoAutomaticMoveCheck.cpp | 8 +-- .../portability/StdAllocatorConstCheck.cpp| 11 ++-- .../readability/UseStdMinMaxCheck.cpp | 6 +-- .../clang-tidy/utils/Matchers.cpp | 2 +- .../utils/RenamerClangTidyCheck.cpp | 30 +++ clang-tools-extra/clangd/AST.cpp | 11 ++-- clang-tools-extra/clangd/AST.h| 3 +- clang-tools-extra/clangd/DumpAST.cpp | 6 ++- clang-tools-extra/clangd/FindTarget.cpp | 36 ++--- clang-tools-extra/clangd/Hover.cpp| 18 --- clang-tools-extra/clangd/InlayHints.cpp | 28 +- clang-tools-extra/clangd/Selection.cpp| 15 +++--- clang-tools-extra/clangd/XRefs.cpp| 13 +++-- .../refactor/tweaks/ExtractFunction.cpp | 5 +- .../clangd/unittests/ASTTests.cpp | 7 +-- .../clangd/unittests/DumpASTTests.cpp | 15 +++--- .../clangd/unittests/HoverTests.cpp | 10 ++-- .../clangd/unittests/InlayHintTests.cpp | 9 +--- .../clangd/unittests/QualityTests.cpp | 14 +++-- .../include-cleaner/lib/WalkAST.cpp | 6 +-- .../bugprone/copy-constructor-init.cpp| 1 - .../unused-local-non-trivial-variable.cpp | 6 +-- .../portability/std-allocator-const.cpp | 22 45 files changed, 289 insertions(+), 334 deletions(-) diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp index bb48883f88815..1f30d27c0a54f 100644 --- a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp +++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp @@ -216,8 +216,7 @@ void FindAllSymbols::registerMatchers(MatchFinder *MatchFinder) { // Uses of most types: just look at what the typeLoc refers to. MatchFinder->addMatcher( typeLoc(isExpansionInMainFile(), - loc(qualType(allOf(unless(elaboratedType()), - hasDeclaration(Types.bind("use")), + loc(qualType(hasDeclaration(Types.bind("use"), this); // Uses of typedefs: these are often transparent to hasDeclaration, so we need // to handle them explicitly. diff --git a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp index 6565fa3f7c85b..0625468d9da88 100644 --- a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp @@ -43,7 +43,8 @@ static bool isDerivedClassBefriended(const CXXRecordDecl *CRTP, return false; } -return FriendType->getType()->getAsCXXRecordDecl() == Derived; +return declaresSameEntity(FriendType->getType()->getAsCXXRecordDecl(), + Derived); }); } @@ -55,7 +56,8 @@ getDerivedParameter(const ClassTemplateSpecializationDecl *CRTP, CRTP->getTemplateArgs().asArray(), [&](const TemplateArgument &Arg) { ++Idx; return Arg.getKind() == TemplateArgument::Type && - Arg.getAsType()->getAsCXXRecordDecl() == Derived; + declaresSameEntity(Arg.getAsType()->getAsCXXRecordDecl(
[llvm-branch-commits] [clang] [clang-tools-extra] [PATCH 5/6] [clang] NNS improvement: getOriginalDecl changes (PR #149747)
llvmbot wrote: @llvm/pr-subscribers-clang-modules @llvm/pr-subscribers-backend-hexagon Author: Matheus Izvekov (mizvekov) Changes --- Patch is 330.74 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/149747.diff 167 Files Affected: - (modified) clang-tools-extra/clang-doc/Serialize.cpp (+2-2) - (modified) clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp (+1-1) - (modified) clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp (+1-1) - (modified) clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp (+5-3) - (modified) clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp (+1-1) - (modified) clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp (+1-1) - (modified) clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp (+1-1) - (modified) clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp (+2-2) - (modified) clang-tools-extra/clang-tidy/utils/ExceptionSpecAnalyzer.cpp (+2-1) - (modified) clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp (+3-2) - (modified) clang-tools-extra/clang-tidy/utils/TypeTraits.cpp (+2-1) - (modified) clang-tools-extra/clangd/DumpAST.cpp (+1-1) - (modified) clang-tools-extra/clangd/FindTarget.cpp (+1-1) - (modified) clang-tools-extra/clangd/Hover.cpp (+1-1) - (modified) clang-tools-extra/clangd/IncludeFixer.cpp (+1-1) - (modified) clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp (+1-1) - (modified) clang-tools-extra/include-cleaner/lib/WalkAST.cpp (+3-3) - (modified) clang/include/clang/AST/Type.h (+4-4) - (modified) clang/lib/AST/APValue.cpp (+2-1) - (modified) clang/lib/AST/ASTContext.cpp (+54-37) - (modified) clang/lib/AST/ASTDiagnostic.cpp (+3-2) - (modified) clang/lib/AST/ASTImporter.cpp (+8-7) - (modified) clang/lib/AST/ASTStructuralEquivalence.cpp (+3-3) - (modified) clang/lib/AST/ByteCode/Compiler.cpp (+5-4) - (modified) clang/lib/AST/ByteCode/Context.cpp (+1-1) - (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+4-3) - (modified) clang/lib/AST/ByteCode/Pointer.cpp (+1-1) - (modified) clang/lib/AST/ByteCode/Program.cpp (+4-3) - (modified) clang/lib/AST/ByteCode/Record.cpp (+1-1) - (modified) clang/lib/AST/CXXInheritance.cpp (+10-6) - (modified) clang/lib/AST/Decl.cpp (+20-12) - (modified) clang/lib/AST/DeclCXX.cpp (+14-9) - (modified) clang/lib/AST/DeclarationName.cpp (+3-3) - (modified) clang/lib/AST/Expr.cpp (+14-7) - (modified) clang/lib/AST/ExprConstant.cpp (+32-16) - (modified) clang/lib/AST/FormatString.cpp (+6-4) - (modified) clang/lib/AST/InheritViz.cpp (+2-2) - (modified) clang/lib/AST/ItaniumCXXABI.cpp (+4-4) - (modified) clang/lib/AST/ItaniumMangle.cpp (+14-9) - (modified) clang/lib/AST/JSONNodeDumper.cpp (+3-3) - (modified) clang/lib/AST/MicrosoftMangle.cpp (+2-2) - (modified) clang/lib/AST/ODRHash.cpp (+1-1) - (modified) clang/lib/AST/PrintfFormatString.cpp (+1-1) - (modified) clang/lib/AST/RecordLayoutBuilder.cpp (+4-5) - (modified) clang/lib/AST/ScanfFormatString.cpp (+3-2) - (modified) clang/lib/AST/TemplateBase.cpp (+1-1) - (modified) clang/lib/AST/TextNodeDumper.cpp (+3-3) - (modified) clang/lib/AST/Type.cpp (+123-71) - (modified) clang/lib/AST/TypeLoc.cpp (+2-3) - (modified) clang/lib/AST/TypePrinter.cpp (+4-2) - (modified) clang/lib/AST/VTTBuilder.cpp (+9-3) - (modified) clang/lib/AST/VTableBuilder.cpp (+5-3) - (modified) clang/lib/Analysis/ThreadSafety.cpp (+3-1) - (modified) clang/lib/Analysis/ThreadSafetyCommon.cpp (+2-2) - (modified) clang/lib/CodeGen/ABIInfo.cpp (+1-1) - (modified) clang/lib/CodeGen/ABIInfoImpl.cpp (+18-18) - (modified) clang/lib/CodeGen/CGBlocks.cpp (+2-1) - (modified) clang/lib/CodeGen/CGCUDANV.cpp (+2-1) - (modified) clang/lib/CodeGen/CGCXX.cpp (+5-3) - (modified) clang/lib/CodeGen/CGCall.cpp (+13-7) - (modified) clang/lib/CodeGen/CGClass.cpp (+29-14) - (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+18-14) - (modified) clang/lib/CodeGen/CGDecl.cpp (+5-2) - (modified) clang/lib/CodeGen/CGExpr.cpp (+20-9) - (modified) clang/lib/CodeGen/CGExprAgg.cpp (+17-8) - (modified) clang/lib/CodeGen/CGExprCXX.cpp (+12-8) - (modified) clang/lib/CodeGen/CGExprConstant.cpp (+21-8) - (modified) clang/lib/CodeGen/CGExprScalar.cpp (+7-4) - (modified) clang/lib/CodeGen/CGNonTrivialStruct.cpp (+4-2) - (modified) clang/lib/CodeGen/CGObjC.cpp (+3-1) - (modified) clang/lib/CodeGen/CGObjCMac.cpp (+4-3) - (modified) clang/lib/CodeGen/CGObjCRuntime.cpp (+3-1) - (modified) clang/lib/CodeGen/CGOpenMPRuntime.cpp (+9-3) - (modified) clang/lib/CodeGen/CodeGenFunction.cpp (+3-1) - (modified) clang/lib/CodeGen/CodeGenFunction.h (+1-1) - (modified) clang/lib/CodeGen/CodeGenModule.cpp (+4-2) - (modified) clang/lib/CodeGen/CodeGenTBAA.cpp (+7-6) - (modified) clang/lib/CodeGen/CodeGenTypes.cpp (+10-6) - (modified) clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp (+2-1) - (modified) clang/lib/CodeGen/ItaniumCXXABI.c
[llvm-branch-commits] [lld] release/21.x: [lld] Add thunks for hexagon (#111217) (PR #149723)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/149723 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] release/21.x: [lld] [hexagon] guard allocateAux: only if idx nonzero (#149690) (PR #149733)
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/149733 Backport 3e9ceae29f39456508eef5b4af4d3c895048706a Requested by: @androm3da >From 509762342205a992823e64c087401d232520b7ac Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Sun, 20 Jul 2025 14:39:03 -0500 Subject: [PATCH] [lld] [hexagon] guard allocateAux: only if idx nonzero (#149690) While building libclang_rt.asan-hexagon.so, lld would assert in lld::elf::hexagonTLSSymbolUpdate(). Fixes #132766 (cherry picked from commit 3e9ceae29f39456508eef5b4af4d3c895048706a) --- lld/ELF/Relocations.cpp | 3 +- .../ELF/hexagon-tls-allocateaux-multiple.s| 36 +++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 lld/test/ELF/hexagon-tls-allocateaux-multiple.s diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index cebd564036b2c..c6dba7558396f 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -2525,7 +2525,8 @@ void elf::hexagonTLSSymbolUpdate(Ctx &ctx) { for (Relocation &rel : isec->relocs()) if (rel.sym->type == llvm::ELF::STT_TLS && rel.expr == R_PLT_PC) { if (needEntry) { -sym->allocateAux(ctx); +if (sym->auxIdx == 0) + sym->allocateAux(ctx); addPltEntry(ctx, *ctx.in.plt, *ctx.in.gotPlt, *ctx.in.relaPlt, ctx.target->pltRel, *sym); needEntry = false; diff --git a/lld/test/ELF/hexagon-tls-allocateaux-multiple.s b/lld/test/ELF/hexagon-tls-allocateaux-multiple.s new file mode 100644 index 0..a77cc822e67d4 --- /dev/null +++ b/lld/test/ELF/hexagon-tls-allocateaux-multiple.s @@ -0,0 +1,36 @@ +# REQUIRES: hexagon +# RUN: rm -rf %t && split-file %s %t && cd %t +# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf a.s -o a.o +# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf b.s -o b.o +# RUN: ld.lld -shared a.o b.o -o out.so +# RUN: llvm-readobj -r out.so | FileCheck --check-prefix=RELOC %s + +#--- a.s +.globl _start +.type _start, @function + +_start: + r2 = add(pc,##_GLOBAL_OFFSET_TABLE_@PCREL) + r0 = add(r2,##tls_var@GDGOT) + call tls_var@GDPLT + jumpr r31 + +.section .tdata,"awT",@progbits +.globl tls_var +.type tls_var, @object +tls_var: + .word 0x1234 + +#--- b.s +.globl other_func +.type other_func, @function + +other_func: + ## Direct call to __tls_get_addr - this creates another path that may + ## try to allocate auxiliary data for the same symbol + call __tls_get_addr + jumpr r31 + +# RELOC: Section ({{.*}}) .rela.plt { +# RELOC:R_HEX_JMP_SLOT __tls_get_addr 0x0 +# RELOC: } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] release/21.x: [lld] [hexagon] guard allocateAux: only if idx nonzero (#149690) (PR #149733)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/149733 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] release/21.x: [lld] [hexagon] guard allocateAux: only if idx nonzero (#149690) (PR #149733)
llvmbot wrote: @MaskRay What do you think about merging this PR to the release branch? https://github.com/llvm/llvm-project/pull/149733 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] release/21.x: [lld] [hexagon] guard allocateAux: only if idx nonzero (#149690) (PR #149733)
llvmbot wrote: @llvm/pr-subscribers-lld @llvm/pr-subscribers-lld-elf Author: None (llvmbot) Changes Backport 3e9ceae29f39456508eef5b4af4d3c895048706a Requested by: @androm3da --- Full diff: https://github.com/llvm/llvm-project/pull/149733.diff 2 Files Affected: - (modified) lld/ELF/Relocations.cpp (+2-1) - (added) lld/test/ELF/hexagon-tls-allocateaux-multiple.s (+36) ``diff diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index cebd564036b2c..c6dba7558396f 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -2525,7 +2525,8 @@ void elf::hexagonTLSSymbolUpdate(Ctx &ctx) { for (Relocation &rel : isec->relocs()) if (rel.sym->type == llvm::ELF::STT_TLS && rel.expr == R_PLT_PC) { if (needEntry) { -sym->allocateAux(ctx); +if (sym->auxIdx == 0) + sym->allocateAux(ctx); addPltEntry(ctx, *ctx.in.plt, *ctx.in.gotPlt, *ctx.in.relaPlt, ctx.target->pltRel, *sym); needEntry = false; diff --git a/lld/test/ELF/hexagon-tls-allocateaux-multiple.s b/lld/test/ELF/hexagon-tls-allocateaux-multiple.s new file mode 100644 index 0..a77cc822e67d4 --- /dev/null +++ b/lld/test/ELF/hexagon-tls-allocateaux-multiple.s @@ -0,0 +1,36 @@ +# REQUIRES: hexagon +# RUN: rm -rf %t && split-file %s %t && cd %t +# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf a.s -o a.o +# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf b.s -o b.o +# RUN: ld.lld -shared a.o b.o -o out.so +# RUN: llvm-readobj -r out.so | FileCheck --check-prefix=RELOC %s + +#--- a.s +.globl _start +.type _start, @function + +_start: + r2 = add(pc,##_GLOBAL_OFFSET_TABLE_@PCREL) + r0 = add(r2,##tls_var@GDGOT) + call tls_var@GDPLT + jumpr r31 + +.section .tdata,"awT",@progbits +.globl tls_var +.type tls_var, @object +tls_var: + .word 0x1234 + +#--- b.s +.globl other_func +.type other_func, @function + +other_func: + ## Direct call to __tls_get_addr - this creates another path that may + ## try to allocate auxiliary data for the same symbol + call __tls_get_addr + jumpr r31 + +# RELOC: Section ({{.*}}) .rela.plt { +# RELOC:R_HEX_JMP_SLOT __tls_get_addr 0x0 +# RELOC: } `` https://github.com/llvm/llvm-project/pull/149733 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] basic error report for use after free (PR #149731)
usx95 wrote: > [!WARNING] > This pull request is not mergeable via GitHub because a downstack PR is > open. Once all requirements are satisfied, merge this PR as a stack href="https://app.graphite.dev/github/pr/llvm/llvm-project/149731?utm_source=stack-comment-downstack-mergeability-warning"; > >on Graphite. > https://graphite.dev/docs/merge-pull-requests";>Learn more * **#149731** https://app.graphite.dev/github/pr/llvm/llvm-project/149731?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/149731?utm_source=stack-comment-view-in-graphite"; target="_blank">(View in Graphite) * **#148712** https://app.graphite.dev/github/pr/llvm/llvm-project/148712?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/>: 1 other dependent PR ([#148976](https://github.com/llvm/llvm-project/pull/148976) https://app.graphite.dev/github/pr/llvm/llvm-project/148976?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/>) * **#149158** https://app.graphite.dev/github/pr/llvm/llvm-project/149158?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#149199** https://app.graphite.dev/github/pr/llvm/llvm-project/149199?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * `main` This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn more about https://stacking.dev/?utm_source=stack-comment";>stacking. https://github.com/llvm/llvm-project/pull/149731 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [LifetimeSafety] Implement a basic use-after-free diagnostic (PR #149731)
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/149731 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/21.x: [LV] Vectorize maxnum/minnum w/o fast-math flags. (#148239) (PR #149736)
https://github.com/ayalz approved this pull request. https://github.com/llvm/llvm-project/pull/149736 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/21.x: [LV] Vectorize maxnum/minnum w/o fast-math flags. (#148239) (PR #149736)
ayalz wrote: > @ayalz What do you think about merging this PR to the release branch? Sure, fine w/ me, looks profitable and stable enough. Nit: name could be shortened from `handleMaxMinNumReductionsWithoutFastMath()` to `handleMaxMinNumReductions()` https://github.com/llvm/llvm-project/pull/149736 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [LifetimeSafety] Implement a basic use-after-free diagnostic (PR #149731)
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/149731 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/21.x: [LV] Vectorize maxnum/minnum w/o fast-math flags. (#148239) (PR #149736)
https://github.com/fhahn updated https://github.com/llvm/llvm-project/pull/149736 >From 104183777e3a6bd14f209c74da53e6f592b72d9f Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Fri, 18 Jul 2025 22:58:19 +0200 Subject: [PATCH 1/2] [LV] Vectorize maxnum/minnum w/o fast-math flags. (#148239) Update LV to vectorize maxnum/minnum reductions without fast-math flags, by adding an extra check in the loop if any inputs to maxnum/minnum are NaN, due to maxnum/minnum behavior w.r.t to signaling NaNs. Signed-zeros are already handled consistently by maxnum/minnum. If any input is NaN, *exit the vector loop, *compute the reduction result up to the vector iteration that contained NaN inputs and * resume in the scalar loop New recurrence kinds are added for reductions using maxnum/minnum without fast-math flags. PR: https://github.com/llvm/llvm-project/pull/148239 (cherry picked from commit 004c67ea257039e4e98abc26dd4ac6e8f3d7a171) --- llvm/include/llvm/Analysis/IVDescriptors.h| 3 + llvm/lib/Analysis/IVDescriptors.cpp | 26 +- llvm/lib/Transforms/Utils/LoopUtils.cpp | 10 +- .../Vectorize/LoopVectorizationPlanner.h | 12 +- .../Transforms/Vectorize/LoopVectorize.cpp| 18 +- .../Transforms/Vectorize/SLPVectorizer.cpp| 6 + .../Transforms/Vectorize/VPlanAnalysis.cpp| 1 + .../Vectorize/VPlanConstruction.cpp | 160 +++ .../lib/Transforms/Vectorize/VPlanRecipes.cpp | 8 +- .../Transforms/Vectorize/VPlanTransforms.h| 6 + .../AArch64/fmax-without-fast-math-flags.ll | 55 +++- .../AArch64/fmin-without-fast-math-flags.ll | 55 +++- ...fmax-without-fast-math-flags-interleave.ll | 55 +++- .../fmax-without-fast-math-flags.ll | 272 +- .../fmin-without-fast-math-flags.ll | 94 +- .../LoopVectorize/minmax_reduction.ll | 8 +- 16 files changed, 731 insertions(+), 58 deletions(-) diff --git a/llvm/include/llvm/Analysis/IVDescriptors.h b/llvm/include/llvm/Analysis/IVDescriptors.h index b985292ccee40..1dc73205a0ebb 100644 --- a/llvm/include/llvm/Analysis/IVDescriptors.h +++ b/llvm/include/llvm/Analysis/IVDescriptors.h @@ -47,6 +47,8 @@ enum class RecurKind { FMul, ///< Product of floats. FMin, ///< FP min implemented in terms of select(cmp()). FMax, ///< FP max implemented in terms of select(cmp()). + FMinNum, ///< FP min with llvm.minnum semantics including NaNs. + FMaxNum, ///< FP max with llvm.maxnum semantics including NaNs. FMinimum, ///< FP min with llvm.minimum semantics FMaximum, ///< FP max with llvm.maximum semantics FMinimumNum, ///< FP min with llvm.minimumnum semantics @@ -250,6 +252,7 @@ class RecurrenceDescriptor { /// Returns true if the recurrence kind is a floating-point min/max kind. static bool isFPMinMaxRecurrenceKind(RecurKind Kind) { return Kind == RecurKind::FMin || Kind == RecurKind::FMax || + Kind == RecurKind::FMinNum || Kind == RecurKind::FMaxNum || Kind == RecurKind::FMinimum || Kind == RecurKind::FMaximum || Kind == RecurKind::FMinimumNum || Kind == RecurKind::FMaximumNum; } diff --git a/llvm/lib/Analysis/IVDescriptors.cpp b/llvm/lib/Analysis/IVDescriptors.cpp index 39f74beca082f..8be5de3bf356f 100644 --- a/llvm/lib/Analysis/IVDescriptors.cpp +++ b/llvm/lib/Analysis/IVDescriptors.cpp @@ -941,10 +941,30 @@ RecurrenceDescriptor::InstDesc RecurrenceDescriptor::isRecurrenceInstr( m_Intrinsic(m_Value(), m_Value())) || match(I, m_Intrinsic(m_Value(), m_Value())); }; -if (isIntMinMaxRecurrenceKind(Kind) || -(HasRequiredFMF() && isFPMinMaxRecurrenceKind(Kind))) +if (isIntMinMaxRecurrenceKind(Kind)) return isMinMaxPattern(I, Kind, Prev); -else if (isFMulAddIntrinsic(I)) +if (isFPMinMaxRecurrenceKind(Kind)) { + InstDesc Res = isMinMaxPattern(I, Kind, Prev); + if (!Res.isRecurrence()) +return InstDesc(false, I); + if (HasRequiredFMF()) +return Res; + // We may be able to vectorize FMax/FMin reductions using maxnum/minnum + // intrinsics with extra checks ensuring the vector loop handles only + // non-NaN inputs. + if (match(I, m_Intrinsic(m_Value(), m_Value( { +assert(Kind == RecurKind::FMax && + "unexpected recurrence kind for maxnum"); +return InstDesc(I, RecurKind::FMaxNum); + } + if (match(I, m_Intrinsic(m_Value(), m_Value( { +assert(Kind == RecurKind::FMin && + "unexpected recurrence kind for minnum"); +return InstDesc(I, RecurKind::FMinNum); + } + return InstDesc(false, I); +} +if (isFMulAddIntrinsic(I)) return InstDesc(Kind == RecurKind::FMulAdd, I, I->hasAllowReassoc() ? nullptr : I); return InstDesc(false, I); diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp index 200d1fb854155..e7623a
[llvm-branch-commits] [llvm] release/21.x: [LV] Vectorize maxnum/minnum w/o fast-math flags. (#148239) (PR #149736)
https://github.com/fhahn commented: > Nit: name could be shortened from > `handleMaxMinNumReductionsWithoutFastMath()` to > `handleMaxMinNumReductions()` Ah yes thanks! done on main in 3813567e08e202280546dd9fd5ae891d067cbda9 and also adjusted in this PR. https://github.com/llvm/llvm-project/pull/149736 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/21.x: [LV] Vectorize maxnum/minnum w/o fast-math flags. (#148239) (PR #149736)
https://github.com/fhahn updated https://github.com/llvm/llvm-project/pull/149736 >From 104183777e3a6bd14f209c74da53e6f592b72d9f Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Fri, 18 Jul 2025 22:58:19 +0200 Subject: [PATCH 1/4] [LV] Vectorize maxnum/minnum w/o fast-math flags. (#148239) Update LV to vectorize maxnum/minnum reductions without fast-math flags, by adding an extra check in the loop if any inputs to maxnum/minnum are NaN, due to maxnum/minnum behavior w.r.t to signaling NaNs. Signed-zeros are already handled consistently by maxnum/minnum. If any input is NaN, *exit the vector loop, *compute the reduction result up to the vector iteration that contained NaN inputs and * resume in the scalar loop New recurrence kinds are added for reductions using maxnum/minnum without fast-math flags. PR: https://github.com/llvm/llvm-project/pull/148239 (cherry picked from commit 004c67ea257039e4e98abc26dd4ac6e8f3d7a171) --- llvm/include/llvm/Analysis/IVDescriptors.h| 3 + llvm/lib/Analysis/IVDescriptors.cpp | 26 +- llvm/lib/Transforms/Utils/LoopUtils.cpp | 10 +- .../Vectorize/LoopVectorizationPlanner.h | 12 +- .../Transforms/Vectorize/LoopVectorize.cpp| 18 +- .../Transforms/Vectorize/SLPVectorizer.cpp| 6 + .../Transforms/Vectorize/VPlanAnalysis.cpp| 1 + .../Vectorize/VPlanConstruction.cpp | 160 +++ .../lib/Transforms/Vectorize/VPlanRecipes.cpp | 8 +- .../Transforms/Vectorize/VPlanTransforms.h| 6 + .../AArch64/fmax-without-fast-math-flags.ll | 55 +++- .../AArch64/fmin-without-fast-math-flags.ll | 55 +++- ...fmax-without-fast-math-flags-interleave.ll | 55 +++- .../fmax-without-fast-math-flags.ll | 272 +- .../fmin-without-fast-math-flags.ll | 94 +- .../LoopVectorize/minmax_reduction.ll | 8 +- 16 files changed, 731 insertions(+), 58 deletions(-) diff --git a/llvm/include/llvm/Analysis/IVDescriptors.h b/llvm/include/llvm/Analysis/IVDescriptors.h index b985292ccee40..1dc73205a0ebb 100644 --- a/llvm/include/llvm/Analysis/IVDescriptors.h +++ b/llvm/include/llvm/Analysis/IVDescriptors.h @@ -47,6 +47,8 @@ enum class RecurKind { FMul, ///< Product of floats. FMin, ///< FP min implemented in terms of select(cmp()). FMax, ///< FP max implemented in terms of select(cmp()). + FMinNum, ///< FP min with llvm.minnum semantics including NaNs. + FMaxNum, ///< FP max with llvm.maxnum semantics including NaNs. FMinimum, ///< FP min with llvm.minimum semantics FMaximum, ///< FP max with llvm.maximum semantics FMinimumNum, ///< FP min with llvm.minimumnum semantics @@ -250,6 +252,7 @@ class RecurrenceDescriptor { /// Returns true if the recurrence kind is a floating-point min/max kind. static bool isFPMinMaxRecurrenceKind(RecurKind Kind) { return Kind == RecurKind::FMin || Kind == RecurKind::FMax || + Kind == RecurKind::FMinNum || Kind == RecurKind::FMaxNum || Kind == RecurKind::FMinimum || Kind == RecurKind::FMaximum || Kind == RecurKind::FMinimumNum || Kind == RecurKind::FMaximumNum; } diff --git a/llvm/lib/Analysis/IVDescriptors.cpp b/llvm/lib/Analysis/IVDescriptors.cpp index 39f74beca082f..8be5de3bf356f 100644 --- a/llvm/lib/Analysis/IVDescriptors.cpp +++ b/llvm/lib/Analysis/IVDescriptors.cpp @@ -941,10 +941,30 @@ RecurrenceDescriptor::InstDesc RecurrenceDescriptor::isRecurrenceInstr( m_Intrinsic(m_Value(), m_Value())) || match(I, m_Intrinsic(m_Value(), m_Value())); }; -if (isIntMinMaxRecurrenceKind(Kind) || -(HasRequiredFMF() && isFPMinMaxRecurrenceKind(Kind))) +if (isIntMinMaxRecurrenceKind(Kind)) return isMinMaxPattern(I, Kind, Prev); -else if (isFMulAddIntrinsic(I)) +if (isFPMinMaxRecurrenceKind(Kind)) { + InstDesc Res = isMinMaxPattern(I, Kind, Prev); + if (!Res.isRecurrence()) +return InstDesc(false, I); + if (HasRequiredFMF()) +return Res; + // We may be able to vectorize FMax/FMin reductions using maxnum/minnum + // intrinsics with extra checks ensuring the vector loop handles only + // non-NaN inputs. + if (match(I, m_Intrinsic(m_Value(), m_Value( { +assert(Kind == RecurKind::FMax && + "unexpected recurrence kind for maxnum"); +return InstDesc(I, RecurKind::FMaxNum); + } + if (match(I, m_Intrinsic(m_Value(), m_Value( { +assert(Kind == RecurKind::FMin && + "unexpected recurrence kind for minnum"); +return InstDesc(I, RecurKind::FMinNum); + } + return InstDesc(false, I); +} +if (isFMulAddIntrinsic(I)) return InstDesc(Kind == RecurKind::FMulAdd, I, I->hasAllowReassoc() ? nullptr : I); return InstDesc(false, I); diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp index 200d1fb854155..e7623a
[llvm-branch-commits] [llvm] release/21.x: [LV] Vectorize maxnum/minnum w/o fast-math flags. (#148239) (PR #149736)
https://github.com/fhahn updated https://github.com/llvm/llvm-project/pull/149736 >From 104183777e3a6bd14f209c74da53e6f592b72d9f Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Fri, 18 Jul 2025 22:58:19 +0200 Subject: [PATCH 1/3] [LV] Vectorize maxnum/minnum w/o fast-math flags. (#148239) Update LV to vectorize maxnum/minnum reductions without fast-math flags, by adding an extra check in the loop if any inputs to maxnum/minnum are NaN, due to maxnum/minnum behavior w.r.t to signaling NaNs. Signed-zeros are already handled consistently by maxnum/minnum. If any input is NaN, *exit the vector loop, *compute the reduction result up to the vector iteration that contained NaN inputs and * resume in the scalar loop New recurrence kinds are added for reductions using maxnum/minnum without fast-math flags. PR: https://github.com/llvm/llvm-project/pull/148239 (cherry picked from commit 004c67ea257039e4e98abc26dd4ac6e8f3d7a171) --- llvm/include/llvm/Analysis/IVDescriptors.h| 3 + llvm/lib/Analysis/IVDescriptors.cpp | 26 +- llvm/lib/Transforms/Utils/LoopUtils.cpp | 10 +- .../Vectorize/LoopVectorizationPlanner.h | 12 +- .../Transforms/Vectorize/LoopVectorize.cpp| 18 +- .../Transforms/Vectorize/SLPVectorizer.cpp| 6 + .../Transforms/Vectorize/VPlanAnalysis.cpp| 1 + .../Vectorize/VPlanConstruction.cpp | 160 +++ .../lib/Transforms/Vectorize/VPlanRecipes.cpp | 8 +- .../Transforms/Vectorize/VPlanTransforms.h| 6 + .../AArch64/fmax-without-fast-math-flags.ll | 55 +++- .../AArch64/fmin-without-fast-math-flags.ll | 55 +++- ...fmax-without-fast-math-flags-interleave.ll | 55 +++- .../fmax-without-fast-math-flags.ll | 272 +- .../fmin-without-fast-math-flags.ll | 94 +- .../LoopVectorize/minmax_reduction.ll | 8 +- 16 files changed, 731 insertions(+), 58 deletions(-) diff --git a/llvm/include/llvm/Analysis/IVDescriptors.h b/llvm/include/llvm/Analysis/IVDescriptors.h index b985292ccee40..1dc73205a0ebb 100644 --- a/llvm/include/llvm/Analysis/IVDescriptors.h +++ b/llvm/include/llvm/Analysis/IVDescriptors.h @@ -47,6 +47,8 @@ enum class RecurKind { FMul, ///< Product of floats. FMin, ///< FP min implemented in terms of select(cmp()). FMax, ///< FP max implemented in terms of select(cmp()). + FMinNum, ///< FP min with llvm.minnum semantics including NaNs. + FMaxNum, ///< FP max with llvm.maxnum semantics including NaNs. FMinimum, ///< FP min with llvm.minimum semantics FMaximum, ///< FP max with llvm.maximum semantics FMinimumNum, ///< FP min with llvm.minimumnum semantics @@ -250,6 +252,7 @@ class RecurrenceDescriptor { /// Returns true if the recurrence kind is a floating-point min/max kind. static bool isFPMinMaxRecurrenceKind(RecurKind Kind) { return Kind == RecurKind::FMin || Kind == RecurKind::FMax || + Kind == RecurKind::FMinNum || Kind == RecurKind::FMaxNum || Kind == RecurKind::FMinimum || Kind == RecurKind::FMaximum || Kind == RecurKind::FMinimumNum || Kind == RecurKind::FMaximumNum; } diff --git a/llvm/lib/Analysis/IVDescriptors.cpp b/llvm/lib/Analysis/IVDescriptors.cpp index 39f74beca082f..8be5de3bf356f 100644 --- a/llvm/lib/Analysis/IVDescriptors.cpp +++ b/llvm/lib/Analysis/IVDescriptors.cpp @@ -941,10 +941,30 @@ RecurrenceDescriptor::InstDesc RecurrenceDescriptor::isRecurrenceInstr( m_Intrinsic(m_Value(), m_Value())) || match(I, m_Intrinsic(m_Value(), m_Value())); }; -if (isIntMinMaxRecurrenceKind(Kind) || -(HasRequiredFMF() && isFPMinMaxRecurrenceKind(Kind))) +if (isIntMinMaxRecurrenceKind(Kind)) return isMinMaxPattern(I, Kind, Prev); -else if (isFMulAddIntrinsic(I)) +if (isFPMinMaxRecurrenceKind(Kind)) { + InstDesc Res = isMinMaxPattern(I, Kind, Prev); + if (!Res.isRecurrence()) +return InstDesc(false, I); + if (HasRequiredFMF()) +return Res; + // We may be able to vectorize FMax/FMin reductions using maxnum/minnum + // intrinsics with extra checks ensuring the vector loop handles only + // non-NaN inputs. + if (match(I, m_Intrinsic(m_Value(), m_Value( { +assert(Kind == RecurKind::FMax && + "unexpected recurrence kind for maxnum"); +return InstDesc(I, RecurKind::FMaxNum); + } + if (match(I, m_Intrinsic(m_Value(), m_Value( { +assert(Kind == RecurKind::FMin && + "unexpected recurrence kind for minnum"); +return InstDesc(I, RecurKind::FMinNum); + } + return InstDesc(false, I); +} +if (isFMulAddIntrinsic(I)) return InstDesc(Kind == RecurKind::FMulAdd, I, I->hasAllowReassoc() ? nullptr : I); return InstDesc(false, I); diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp index 200d1fb854155..e7623a
[llvm-branch-commits] [clang] [PATCH 2/6] [clang] Improve nested name specifier AST representation (PR #148012)
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/148012 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [PATCH 2/6] [clang] Improve nested name specifier AST representation (PR #148012)
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/148012 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [PATCH 2/6] [clang] Improve nested name specifier AST representation (PR #148012)
@@ -63,7 +63,7 @@ def test_a_struct(self): self.assertIsNotNone(fields[1].translation_unit) self.assertEqual(fields[1].spelling, "b") self.assertFalse(fields[1].type.is_const_qualified()) -self.assertEqual(fields[1].type.kind, TypeKind.ELABORATED) +self.assertEqual(fields[1].type.kind, TypeKind.TYPEDEF) DeinAlptraum wrote: If I understand the changes correctly, the `ELABORATED` TypeKind is removed, right? If so, shouldn't that enum variant also be removed from the TypeKind enum in the Python bindings? I.e. variant 119 of `TypeKind` in `cindex.py`: https://github.com/llvm/llvm-project/blob/6ebc42322ca7bd0261c1faa6e2d785057ab95c5f/clang/bindings/python/clang/cindex.py#L2505 https://github.com/llvm/llvm-project/pull/148012 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [PATCH 2/6] [clang] Improve nested name specifier AST representation (PR #148012)
https://github.com/DeinAlptraum commented: Re: Python bindings changes. The tests currently fail because the libclang.so cannot even be built. Is this expected, as in, can it only be built after the last patch again? (I see that the tests passed on patch 6/6). This should also probably get an entry in the bindings' breaking changes section of the release notes. https://github.com/llvm/llvm-project/pull/148012 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [PATCH 2/6] [clang] Improve nested name specifier AST representation (PR #148012)
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/148012 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] release/21.x: [lld] [hexagon] guard allocateAux: only if idx nonzero (#149690) (PR #149733)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/149733 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits