[llvm-branch-commits] [NFC][ELF] Don't duplicate DynamicReloc constructor (PR #150811)

2025-07-27 Thread Alexander Richardson via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/150811
___
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] [NFC][ELF] Don't duplicate DynamicReloc constructor (PR #150811)

2025-07-27 Thread Fangrui Song via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/150811
___
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] [NFC][ELF] Replace DynamicReloc::Kind with the equivalent bool in APIs (PR #150813)

2025-07-27 Thread Alexander Richardson via llvm-branch-commits

https://github.com/arichardson commented:

Thanks for cleaning up my ugly https://reviews.llvm.org/D100490 in the previous 
commits :)

I think having names for the boolean parameters makes the code calling this 
function easier to read than a magic true/false. So I'd have a slight 
preference for keeping an enum parameter but I'll leave that decision to 
@MaskRay.

https://github.com/llvm/llvm-project/pull/150813
___
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] [NFCI][ELF] Merge AgainstSymbol and AgainstSymbolWithTargetVA (PR #150798)

2025-07-27 Thread Alexander Richardson via llvm-branch-commits

arichardson wrote:

Thanks for cleaning up https://reviews.llvm.org/D100490. It looks like I 
originally started that with a single boolean parameter for "sym/no sym" but it 
was quite confusing that way.

I think all the cleanups that have happened since now makes this a feasible 
approach.

https://github.com/llvm/llvm-project/pull/150798
___
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] [NFC][ELF] Replace DynamicReloc::Kind with the equivalent bool in APIs (PR #150813)

2025-07-27 Thread Jessica Clarke via llvm-branch-commits

jrtc27 wrote:

> Thanks for cleaning up my ugly https://reviews.llvm.org/D100490 in the 
> previous commits :)
> 
> I think having names for the boolean parameters makes the code calling this 
> function easier to read than a magic true/false. So I'd have a slight 
> preference for keeping an enum parameter but I'll leave that decision to 
> @MaskRay.

There's always /*isAgainstSymbol=*/ if you want to name it, I suppose. The 
existence of the enum just encourages people to do things like MIPS and Morello 
have both done in the past, so I want to make sure that everything ends up 
being done via RelExpr instead.

https://github.com/llvm/llvm-project/pull/150813
___
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] [NFCI][ELF] Introduce explicit Computed state for DynamicReloc (PR #150799)

2025-07-27 Thread Alexander Richardson via llvm-branch-commits

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

This is much better.

https://github.com/llvm/llvm-project/pull/150799
___
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] [NFCI][ELF] Store DynamicReloc Kind as two bools (PR #150812)

2025-07-27 Thread Alexander Richardson via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/150812
___
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] [NFCI][ELF] Merge AddendOnly and AddendOnlyWithTargetVA (PR #150797)

2025-07-27 Thread Alexander Richardson via llvm-branch-commits


@@ -422,13 +422,10 @@ class DynamicReloc {
 /// The resulting dynamic relocation has already had its addend computed.
 /// Calling computeAddend() is an error. Only for internal use.
 Computed,
-/// The resulting dynamic relocation does not reference a symbol (#sym must
-/// be nullptr) and uses #addend as the result of computeAddend(ctx).
-AddendOnly,
 /// The resulting dynamic relocation will not reference a symbol: #sym is
 /// only used to compute the addend with InputSection::getRelocTargetVA().
 /// Useful for various relative and TLS relocations (e.g. 
R_X86_64_TPOFF64).
-AddendOnlyWithTargetVA,
+AddendOnly,

arichardson wrote:

Could add a comment such as "#sym can be NULL to record a constant addend"?

https://github.com/llvm/llvm-project/pull/150797
___
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] [NFCI][ELF] Merge AddendOnly and AddendOnlyWithTargetVA (PR #150797)

2025-07-27 Thread Alexander Richardson via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/150797
___
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] [NFCI][ELF][Mips] Replace MipsMultiGotPage with new RE_MIPS_OSEC_LOCAL_PAGE (PR #150810)

2025-07-27 Thread Fangrui Song via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/150810
___
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] [NFCI][ELF][Mips] Replace MipsMultiGotPage with new RE_MIPS_OSEC_LOCAL_PAGE (PR #150810)

2025-07-27 Thread Fangrui Song via llvm-branch-commits


@@ -470,7 +461,6 @@ class DynamicReloc {
   void computeRaw(Ctx &, SymbolTableBaseSection *symt);
 
   Symbol *sym;
-  const OutputSection *outputSec = nullptr;

MaskRay wrote:

Thanks for removing `outputSec`!

https://github.com/llvm/llvm-project/pull/150810
___
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] [NFC][ELF] Replace DynamicReloc::Kind with the equivalent bool in APIs (PR #150813)

2025-07-27 Thread Fangrui Song via llvm-branch-commits

MaskRay wrote:

Is this the last change in the patch series? The use of booleans is a good move 
to prevent the complexity of MIPS-style dynamic relocations (which I haven’t 
fully analyzed). Thanks for tidying this up!

https://github.com/llvm/llvm-project/pull/150813
___
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] [NFC][ELF] Replace DynamicReloc::Kind with the equivalent bool in APIs (PR #150813)

2025-07-27 Thread Fangrui Song via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/150813
___
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] [NFC][ELF] Replace DynamicReloc::Kind with the equivalent bool in APIs (PR #150813)

2025-07-27 Thread Jessica Clarke via llvm-branch-commits

jrtc27 wrote:

> Is this the last change in the patch series? The use of booleans is a good 
> move to prevent the complexity of MIPS-style dynamic relocations (which I 
> haven’t fully analyzed). Thanks for tidying this up!

Yes, though #150729 and #150730 are based on this patch series (as a 
logically-separate series that conflicts due to the refactoring so I linearised 
that way).

https://github.com/llvm/llvm-project/pull/150813
___
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] [lldb] [PATCH 7/7] [clang] improve NestedNameSpecifier: LLDB changes (PR #149949)

2025-07-27 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/149949

>From 1ee69180a1e5d90242b5c33d78371b7a7b8eefbd Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Mon, 21 Jul 2025 22:00:01 -0300
Subject: [PATCH] [PATCH 7/7] [clang] improve NestedNameSpecifier: LLDB changes

Patch series starting at https://github.com/llvm/llvm-project/pull/147835
---
 clang/include/clang/AST/QualTypeNames.h   |  10 +
 clang/lib/AST/QualTypeNames.cpp   |   7 +
 .../Clang/ClangASTImporter.cpp|  31 +--
 .../ExpressionParser/Clang/ClangASTSource.cpp |   5 +-
 .../Clang/ClangExpressionDeclMap.cpp  |   4 +-
 .../Clang/ClangPersistentVariables.cpp|   6 +-
 .../Clang/NameSearchContext.cpp   |   2 +-
 .../Plugins/Language/ObjC/NSDictionary.cpp|   3 +-
 .../RegisterTypeBuilderClang.cpp  |   4 +-
 .../SymbolFile/NativePDB/PdbAstBuilder.cpp|  11 +-
 .../Plugins/SymbolFile/PDB/PDBASTParser.cpp   |  11 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 243 +-
 .../TypeSystem/Clang/TypeSystemClang.h|   9 +-
 .../TestDataFormatterStdSharedPtr.py  |   2 +-
 .../string/TestDataFormatterStdString.py  |  41 ++-
 .../TestDataFormatterStdStringView.py |  64 +++--
 .../TestDataFormatterStdUniquePtr.py  |   2 +-
 .../TestClassLoadingViaMemberTypedef.py   |   4 +-
 .../x86/DW_AT_declaration-with-children.s |   4 +-
 .../DWARF/x86/dwp-foreign-type-units.cpp  |   8 +-
 .../DWARF/x86/typedef-in-incomplete-type.cpp  |   2 +-
 .../lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp|   5 +-
 22 files changed, 233 insertions(+), 245 deletions(-)

diff --git a/clang/include/clang/AST/QualTypeNames.h 
b/clang/include/clang/AST/QualTypeNames.h
index daa86cda2d992..9f5cf045d1d4c 100644
--- a/clang/include/clang/AST/QualTypeNames.h
+++ b/clang/include/clang/AST/QualTypeNames.h
@@ -87,6 +87,16 @@ std::string getFullyQualifiedName(QualType QT, const 
ASTContext &Ctx,
 /// specifier "::" should be prepended or not.
 QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx,
bool WithGlobalNsPrefix = false);
+
+/// Get the fully qualified name for the declared context of a declaration.
+///
+/// \param[in] Ctx - the ASTContext to be used.
+/// \param[in] Decl - the declaration for which to get the fully qualified 
name.
+/// \param[in] WithGlobalNsPrefix - If true, then the global namespace
+/// specifier "::" will be prepended to the fully qualified name.
+NestedNameSpecifier
+getFullyQualifiedDeclaredContext(const ASTContext &Ctx, const Decl *Decl,
+ bool WithGlobalNsPrefix = false);
 } // end namespace TypeName
 } // end namespace clang
 #endif // LLVM_CLANG_AST_QUALTYPENAMES_H
diff --git a/clang/lib/AST/QualTypeNames.cpp b/clang/lib/AST/QualTypeNames.cpp
index 319becd8a5a98..086450e790541 100644
--- a/clang/lib/AST/QualTypeNames.cpp
+++ b/clang/lib/AST/QualTypeNames.cpp
@@ -491,5 +491,12 @@ std::string getFullyQualifiedName(QualType QT,
   return FQQT.getAsString(Policy);
 }
 
+NestedNameSpecifier getFullyQualifiedDeclaredContext(const ASTContext &Ctx,
+ const Decl *Decl,
+ bool WithGlobalNsPrefix) {
+  return createNestedNameSpecifierForScopeOf(Ctx, Decl, 
/*FullyQualified=*/true,
+ WithGlobalNsPrefix);
+}
+
 }  // end namespace TypeName
 }  // end namespace clang
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index 2529e78f78bca..7ba8b730c6e9b 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -320,7 +320,8 @@ CompilerType ClangASTImporter::DeportType(TypeSystemClang 
&dst,
   DeclContextOverride decl_context_override;
 
   if (auto *t = ClangUtil::GetQualType(src_type)->getAs())
-decl_context_override.OverrideAllDeclsFromContainingFunction(t->getDecl());
+decl_context_override.OverrideAllDeclsFromContainingFunction(
+t->getOriginalDecl());
 
   CompleteTagDeclsScope complete_scope(*this, &dst.getASTContext(),
&src_ctxt->getASTContext());
@@ -377,8 +378,7 @@ bool ClangASTImporter::CanImport(const CompilerType &type) {
   } break;
 
   case clang::Type::Enum: {
-clang::EnumDecl *enum_decl =
-llvm::cast(qual_type)->getDecl();
+auto *enum_decl = 
llvm::cast(qual_type)->getOriginalDecl();
 if (enum_decl) {
   if (GetDeclOrigin(enum_decl).Valid())
 return true;
@@ -414,12 +414,6 @@ bool ClangASTImporter::CanImport(const CompilerType &type) 
{
   ->getDeducedType()
   .getAsOpaquePtr()));
 
-  case clang::Type::Elaborated:
-return CanI

[llvm-branch-commits] [libc] [llvm] [libc][math] Refactor asinhf16 implementation to header-only in src/__support/math folder. (PR #150849)

2025-07-27 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libc

Author: Muhammad Bassiouni (bassiounix)


Changes

Part of #147386

in preparation for: 
https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450

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


10 Files Affected:

- (modified) libc/shared/math.h (+1) 
- (modified) libc/shared/math/asinf16.h (+1-1) 
- (added) libc/shared/math/asinhf16.h (+28) 
- (modified) libc/src/__support/math/CMakeLists.txt (+18) 
- (added) libc/src/__support/math/asinhf16.h (+123) 
- (modified) libc/src/math/generic/CMakeLists.txt (+1-12) 
- (modified) libc/src/math/generic/asinhf16.cpp (+2-94) 
- (modified) libc/test/shared/CMakeLists.txt (+1) 
- (modified) libc/test/shared/shared_math_test.cpp (+1) 
- (modified) utils/bazel/llvm-project-overlay/libc/BUILD.bazel (+25) 


``diff
diff --git a/libc/shared/math.h b/libc/shared/math.h
index e0f00f52e9dc3..26e33ecd45d73 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -21,6 +21,7 @@
 #include "math/asinf.h"
 #include "math/asinf16.h"
 #include "math/asinhf.h"
+#include "math/asinhf16.h"
 #include "math/erff.h"
 #include "math/exp.h"
 #include "math/exp10.h"
diff --git a/libc/shared/math/asinf16.h b/libc/shared/math/asinf16.h
index d545e269a6402..af5b2ec179233 100644
--- a/libc/shared/math/asinf16.h
+++ b/libc/shared/math/asinf16.h
@@ -25,4 +25,4 @@ using math::asinf16;
 
 #endif // LIBC_TYPES_HAS_FLOAT16
 
-#endif // LLVM_LIBC_SHARED_MATH_ASINF_H
+#endif // LLVM_LIBC_SHARED_MATH_ASINF16_H
diff --git a/libc/shared/math/asinhf16.h b/libc/shared/math/asinhf16.h
new file mode 100644
index 0..1a0525b6a9b8b
--- /dev/null
+++ b/libc/shared/math/asinhf16.h
@@ -0,0 +1,28 @@
+//===-- Shared asinhf16 function -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_ASINHF16_H
+#define LLVM_LIBC_SHARED_MATH_ASINHF16_H
+
+#include "shared/libc_common.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/asinhf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::asinhf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_ASINHF16_H
diff --git a/libc/src/__support/math/CMakeLists.txt 
b/libc/src/__support/math/CMakeLists.txt
index 13f46a13fe0d7..be208f946024a 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -154,6 +154,24 @@ add_header_library(
 libc.src.__support.macros.optimization
 )
 
+add_header_library(
+  asinhf16
+  HDRS
+asinhf16.h
+DEPENDS
+.acoshf_utils
+libc.src.__support.FPUtil.fenv_impl
+libc.src.__support.FPUtil.fp_bits
+libc.src.__support.FPUtil.polyeval
+libc.src.__support.FPUtil.cast
+libc.src.__support.FPUtil.except_value_utils
+libc.src.__support.FPUtil.multiply_add
+libc.src.__support.FPUtil.rounding_mode
+libc.src.__support.FPUtil.sqrt
+libc.src.__support.macros.config
+libc.src.__support.macros.optimization
+)
+
 add_header_library(
   asinf
   HDRS
diff --git a/libc/src/__support/math/asinhf16.h 
b/libc/src/__support/math/asinhf16.h
new file mode 100644
index 0..81657b8db97b0
--- /dev/null
+++ b/libc/src/__support/math/asinhf16.h
@@ -0,0 +1,123 @@
+//===-- Implementation header for asinhf16 --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ASINHF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_ASINHF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "acoshf_utils.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/PolyEval.h"
+#include "src/__support/FPUtil/cast.h"
+#include "src/__support/FPUtil/except_value_utils.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/FPUtil/rounding_mode.h"
+#include "src/__support/FPUtil/sqrt.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE static constexpr float16 asinhf16(float16 x) {
+
+#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+  constexpr size_t N_EXCEPTS = 8;
+
+  constexpr fputil::ExceptValues ASINHF16_EXCEPTS{{
+// (input, RZ output, RU offset,

[llvm-branch-commits] [libc] [llvm] [libc][math] Refactor asinhf16 implementation to header-only in src/__support/math folder. (PR #150849)

2025-07-27 Thread via llvm-branch-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- 
libc/shared/math/asinhf16.h libc/src/__support/math/asinhf16.h 
libc/shared/math.h libc/shared/math/asinf16.h 
libc/src/math/generic/asinhf16.cpp libc/test/shared/shared_math_test.cpp
``





View the diff from clang-format here.


``diff
diff --git a/libc/shared/math/asinhf16.h b/libc/shared/math/asinhf16.h
index 1a0525b6a..b063a5b80 100644
--- a/libc/shared/math/asinhf16.h
+++ b/libc/shared/math/asinhf16.h
@@ -1,4 +1,5 @@
-//===-- Shared asinhf16 function -*- C++ 
-*-===//
+//===-- Shared asinhf16 function -*- C++
+//-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/src/__support/math/asinhf16.h 
b/libc/src/__support/math/asinhf16.h
index 81657b8db..3c5171e59 100644
--- a/libc/src/__support/math/asinhf16.h
+++ b/libc/src/__support/math/asinhf16.h
@@ -35,25 +35,25 @@ LIBC_INLINE static constexpr float16 asinhf16(float16 x) {
   constexpr size_t N_EXCEPTS = 8;
 
   constexpr fputil::ExceptValues ASINHF16_EXCEPTS{{
-// (input, RZ output, RU offset, RD offset, RN offset)
-
-// x = 0x1.da4p-2, asinhf16(x) = 0x1.ca8p-2 (RZ)
-{0x3769, 0x372a, 1, 0, 1},
-// x = 0x1.d6cp-1, asinhf16(x) = 0x1.a58p-1 (RZ)
-{0x3b5b, 0x3a96, 1, 0, 0},
-// x = 0x1.c7cp+3, asinhf16(x) = 0x1.accp+1 (RZ)
-{0x4b1f, 0x42b3, 1, 0, 0},
-// x = 0x1.26cp+4, asinhf16(x) = 0x1.cd8p+1 (RZ)
-{0x4c9b, 0x4336, 1, 0, 1},
-// x = -0x1.da4p-2, asinhf16(x) = -0x1.ca8p-2 (RZ)
-{0xb769, 0xb72a, 0, 1, 1},
-// x = -0x1.d6cp-1, asinhf16(x) = -0x1.a58p-1 (RZ)
-{0xbb5b, 0xba96, 0, 1, 0},
-// x = -0x1.c7cp+3, asinhf16(x) = -0x1.accp+1 (RZ)
-{0xcb1f, 0xc2b3, 0, 1, 0},
-// x = -0x1.26cp+4, asinhf16(x) = -0x1.cd8p+1 (RZ)
-{0xcc9b, 0xc336, 0, 1, 1},
-}};
+  // (input, RZ output, RU offset, RD offset, RN offset)
+
+  // x = 0x1.da4p-2, asinhf16(x) = 0x1.ca8p-2 (RZ)
+  {0x3769, 0x372a, 1, 0, 1},
+  // x = 0x1.d6cp-1, asinhf16(x) = 0x1.a58p-1 (RZ)
+  {0x3b5b, 0x3a96, 1, 0, 0},
+  // x = 0x1.c7cp+3, asinhf16(x) = 0x1.accp+1 (RZ)
+  {0x4b1f, 0x42b3, 1, 0, 0},
+  // x = 0x1.26cp+4, asinhf16(x) = 0x1.cd8p+1 (RZ)
+  {0x4c9b, 0x4336, 1, 0, 1},
+  // x = -0x1.da4p-2, asinhf16(x) = -0x1.ca8p-2 (RZ)
+  {0xb769, 0xb72a, 0, 1, 1},
+  // x = -0x1.d6cp-1, asinhf16(x) = -0x1.a58p-1 (RZ)
+  {0xbb5b, 0xba96, 0, 1, 0},
+  // x = -0x1.c7cp+3, asinhf16(x) = -0x1.accp+1 (RZ)
+  {0xcb1f, 0xc2b3, 0, 1, 0},
+  // x = -0x1.26cp+4, asinhf16(x) = -0x1.cd8p+1 (RZ)
+  {0xcc9b, 0xc336, 0, 1, 1},
+  }};
 #endif // !LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
   using namespace acoshf_internal;
@@ -110,8 +110,6 @@ LIBC_INLINE static constexpr float16 asinhf16(float16 x) {
   float sqrt_term = fputil::sqrt(fputil::multiply_add(xf, xf, 1.0f));
   return fputil::cast(
   x_sign * log_eval(fputil::multiply_add(xf, x_sign, sqrt_term)));
-
-
 }
 
 } // namespace math

``




https://github.com/llvm/llvm-project/pull/150849
___
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] [libc] [llvm] [libc][math] Refactor asinhf16 implementation to header-only in src/__support/math folder. (PR #150849)

2025-07-27 Thread Muhammad Bassiouni via llvm-branch-commits

https://github.com/bassiounix created 
https://github.com/llvm/llvm-project/pull/150849

None

>From 7be3b70ef8d3c8f39006dbee302fe5291491cb77 Mon Sep 17 00:00:00 2001
From: bassiounix 
Date: Sun, 27 Jul 2025 22:21:00 +0300
Subject: [PATCH] [libc][math] Refactor asinhf16 implementation to header-only
 in src/__support/math folder.

---
 libc/shared/math.h|   1 +
 libc/shared/math/asinf16.h|   2 +-
 libc/shared/math/asinhf16.h   |  28 
 libc/src/__support/math/CMakeLists.txt|  18 +++
 libc/src/__support/math/asinhf16.h| 123 ++
 libc/src/math/generic/CMakeLists.txt  |  13 +-
 libc/src/math/generic/asinhf16.cpp|  96 +-
 libc/test/shared/CMakeLists.txt   |   1 +
 libc/test/shared/shared_math_test.cpp |   1 +
 .../llvm-project-overlay/libc/BUILD.bazel |  25 
 10 files changed, 201 insertions(+), 107 deletions(-)
 create mode 100644 libc/shared/math/asinhf16.h
 create mode 100644 libc/src/__support/math/asinhf16.h

diff --git a/libc/shared/math.h b/libc/shared/math.h
index e0f00f52e9dc3..26e33ecd45d73 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -21,6 +21,7 @@
 #include "math/asinf.h"
 #include "math/asinf16.h"
 #include "math/asinhf.h"
+#include "math/asinhf16.h"
 #include "math/erff.h"
 #include "math/exp.h"
 #include "math/exp10.h"
diff --git a/libc/shared/math/asinf16.h b/libc/shared/math/asinf16.h
index d545e269a6402..af5b2ec179233 100644
--- a/libc/shared/math/asinf16.h
+++ b/libc/shared/math/asinf16.h
@@ -25,4 +25,4 @@ using math::asinf16;
 
 #endif // LIBC_TYPES_HAS_FLOAT16
 
-#endif // LLVM_LIBC_SHARED_MATH_ASINF_H
+#endif // LLVM_LIBC_SHARED_MATH_ASINF16_H
diff --git a/libc/shared/math/asinhf16.h b/libc/shared/math/asinhf16.h
new file mode 100644
index 0..1a0525b6a9b8b
--- /dev/null
+++ b/libc/shared/math/asinhf16.h
@@ -0,0 +1,28 @@
+//===-- Shared asinhf16 function -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_ASINHF16_H
+#define LLVM_LIBC_SHARED_MATH_ASINHF16_H
+
+#include "shared/libc_common.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/asinhf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::asinhf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_ASINHF16_H
diff --git a/libc/src/__support/math/CMakeLists.txt 
b/libc/src/__support/math/CMakeLists.txt
index 13f46a13fe0d7..be208f946024a 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -154,6 +154,24 @@ add_header_library(
 libc.src.__support.macros.optimization
 )
 
+add_header_library(
+  asinhf16
+  HDRS
+asinhf16.h
+DEPENDS
+.acoshf_utils
+libc.src.__support.FPUtil.fenv_impl
+libc.src.__support.FPUtil.fp_bits
+libc.src.__support.FPUtil.polyeval
+libc.src.__support.FPUtil.cast
+libc.src.__support.FPUtil.except_value_utils
+libc.src.__support.FPUtil.multiply_add
+libc.src.__support.FPUtil.rounding_mode
+libc.src.__support.FPUtil.sqrt
+libc.src.__support.macros.config
+libc.src.__support.macros.optimization
+)
+
 add_header_library(
   asinf
   HDRS
diff --git a/libc/src/__support/math/asinhf16.h 
b/libc/src/__support/math/asinhf16.h
new file mode 100644
index 0..81657b8db97b0
--- /dev/null
+++ b/libc/src/__support/math/asinhf16.h
@@ -0,0 +1,123 @@
+//===-- Implementation header for asinhf16 --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ASINHF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_ASINHF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "acoshf_utils.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/PolyEval.h"
+#include "src/__support/FPUtil/cast.h"
+#include "src/__support/FPUtil/except_value_utils.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/FPUtil/rounding_mode.h"
+#include "src/__support/FPUtil/sqrt.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE static constexpr float16 asinhf16(float16 x) {
+
+#i

[llvm-branch-commits] [libc] [llvm] [libc][math] Refactor asinhf16 implementation to header-only in src/__support/math folder. (PR #150849)

2025-07-27 Thread Muhammad Bassiouni via llvm-branch-commits

https://github.com/bassiounix edited 
https://github.com/llvm/llvm-project/pull/150849
___
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] [libc] [llvm] [libc][math] Refactor asinhf16 implementation to header-only in src/__support/math folder. (PR #150849)

2025-07-27 Thread Muhammad Bassiouni via llvm-branch-commits

bassiounix 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/150849?utm_source=stack-comment-downstack-mergeability-warning";
>  >on Graphite.
> https://graphite.dev/docs/merge-pull-requests";>Learn more

* **#150849** https://app.graphite.dev/github/pr/llvm/llvm-project/150849?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/150849?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#150843** https://app.graphite.dev/github/pr/llvm/llvm-project/150843?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/150849
___
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] [libc] [llvm] [libc][math] Refactor asinhf16 implementation to header-only in src/__support/math folder. (PR #150849)

2025-07-27 Thread Muhammad Bassiouni via llvm-branch-commits

https://github.com/bassiounix ready_for_review 
https://github.com/llvm/llvm-project/pull/150849
___
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: Align f128 and i128 to 16 bytes when passing on x86-32 (PR #150746)

2025-07-27 Thread Simon Pilgrim via llvm-branch-commits

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

LGTM 

https://github.com/llvm/llvm-project/pull/150746
___
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] 6004880 - Revert "[MemProf] Ensure all callsite clones are assigned a function clone (#…"

2025-07-27 Thread via llvm-branch-commits

Author: Teresa Johnson
Date: 2025-07-27T15:43:47-07:00
New Revision: 600488062856b2ec4cf33e040dbf242c559842c8

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

LOG: Revert "[MemProf] Ensure all callsite clones are assigned a function clone 
(#…"

This reverts commit 0f2484a7408eb4a14dc9bb231e56e8dbfddbc5bc.

Added: 


Modified: 
llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp

Removed: 
llvm/test/ThinLTO/X86/memprof_func_assign_fix.ll
llvm/test/Transforms/MemProfContextDisambiguation/func_assign_fix.ll



diff  --git a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp 
b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
index 81de0a59321d3..0164fcd71419e 100644
--- a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
+++ b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
@@ -97,8 +97,6 @@ STATISTIC(MissingAllocForContextId,
   "Number of missing alloc nodes for context ids");
 STATISTIC(SkippedCallsCloning,
   "Number of calls skipped during cloning due to unexpected operand");
-STATISTIC(MismatchedCloneAssignments,
-  "Number of callsites assigned to call multiple non-matching clones");
 
 static cl::opt DotFilePathPrefix(
 "memprof-dot-file-path-prefix", cl::init(""), cl::Hidden,
@@ -2062,20 +2060,6 @@ static bool isMemProfClone(const Function &F) {
   return F.getName().contains(MemProfCloneSuffix);
 }
 
-// Return the clone number of the given function by extracting it from the
-// memprof suffix. Assumes the caller has already confirmed it is a memprof
-// clone.
-static unsigned getMemProfCloneNum(const Function &F) {
-  assert(isMemProfClone(F));
-  auto Pos = F.getName().find_last_of('.');
-  assert(Pos > 0);
-  unsigned CloneNo;
-  bool Err = F.getName().drop_front(Pos + 1).getAsInteger(10, CloneNo);
-  assert(!Err);
-  (void)Err;
-  return CloneNo;
-}
-
 std::string ModuleCallsiteContextGraph::getLabel(const Function *Func,
  const Instruction *Call,
  unsigned CloneNo) const {
@@ -3995,22 +3979,7 @@ IndexCallsiteContextGraph::getAllocationCallType(const 
CallInfo &Call) const {
 
 void ModuleCallsiteContextGraph::updateCall(CallInfo &CallerCall,
 FuncInfo CalleeFunc) {
-  auto *CurF = cast(CallerCall.call())->getCalledFunction();
-  auto NewCalleeCloneNo = CalleeFunc.cloneNo();
-  if (isMemProfClone(*CurF)) {
-// If we already assigned this callsite to call a specific non-default
-// clone (i.e. not the original function which is clone 0), ensure that we
-// aren't trying to now update it to call a 
diff erent clone, which is
-// indicative of a bug in the graph or function assignment.
-auto CurCalleeCloneNo = getMemProfCloneNum(*CurF);
-if (CurCalleeCloneNo != NewCalleeCloneNo) {
-  LLVM_DEBUG(dbgs() << "Mismatch in call clone assignment: was "
-<< CurCalleeCloneNo << " now " << NewCalleeCloneNo
-<< "\n");
-  MismatchedCloneAssignments++;
-}
-  }
-  if (NewCalleeCloneNo > 0)
+  if (CalleeFunc.cloneNo() > 0)
 cast(CallerCall.call())->setCalledFunction(CalleeFunc.func());
   OREGetter(CallerCall.call()->getFunction())
   .emit(OptimizationRemark(DEBUG_TYPE, "MemprofCall", CallerCall.call())
@@ -4026,19 +3995,7 @@ void IndexCallsiteContextGraph::updateCall(CallInfo 
&CallerCall,
   assert(CI &&
  "Caller cannot be an allocation which should not have profiled 
calls");
   assert(CI->Clones.size() > CallerCall.cloneNo());
-  auto NewCalleeCloneNo = CalleeFunc.cloneNo();
-  auto &CurCalleeCloneNo = CI->Clones[CallerCall.cloneNo()];
-  // If we already assigned this callsite to call a specific non-default
-  // clone (i.e. not the original function which is clone 0), ensure that we
-  // aren't trying to now update it to call a 
diff erent clone, which is
-  // indicative of a bug in the graph or function assignment.
-  if (CurCalleeCloneNo != 0 && CurCalleeCloneNo != NewCalleeCloneNo) {
-LLVM_DEBUG(dbgs() << "Mismatch in call clone assignment: was "
-  << CurCalleeCloneNo << " now " << NewCalleeCloneNo
-  << "\n");
-MismatchedCloneAssignments++;
-  }
-  CurCalleeCloneNo = NewCalleeCloneNo;
+  CI->Clones[CallerCall.cloneNo()] = CalleeFunc.cloneNo();
 }
 
 // Update the debug information attached to NewFunc to use the clone Name. Note
@@ -4746,19 +4703,6 @@ bool CallsiteContextGraph::assignFunctions() {
   // where the callers were assigned to 
diff erent clones of a function.
 }
 
-auto FindFirstAvailFuncClone = [&]() {
-  // Find first function in FuncClonesToCallMap without an assigned
-  

[llvm-branch-commits] [llvm] AMDGPU: Remove -stress-regalloc arguments from mfma selection tests (PR #150890)

2025-07-27 Thread Matt Arsenault via llvm-branch-commits

https://github.com/arsenm created 
https://github.com/llvm/llvm-project/pull/150890

I'm not really sure what the point of these was, but they originated
in the base support commit for gfx942 mfma support. These don't impact
the selection at all, so don't belong in this test. These were causing
allocation failure depending on whether or not the AGPR or VGPR form
was used.

>From 29fc34e1c7794595e72b44312c5b372dc14d785b Mon Sep 17 00:00:00 2001
From: Matt Arsenault 
Date: Mon, 28 Jul 2025 15:14:33 +0900
Subject: [PATCH] AMDGPU: Remove -stress-regalloc arguments from mfma selection
 tests

I'm not really sure what the point of these was, but they originated
in the base support commit for gfx942 mfma support. These don't impact
the selection at all, so don't belong in this test. These were causing
allocation failure depending on whether or not the AGPR or VGPR form
was used.
---
 .../CodeGen/AMDGPU/llvm.amdgcn.mfma.gfx942.ll |   4 -
 .../AMDGPU/llvm.amdgcn.mfma.xf32.gfx942.ll| 123 --
 2 files changed, 127 deletions(-)

diff --git a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.gfx942.ll 
b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.gfx942.ll
index 7d85d3439eed9..beda16c17a5c9 100644
--- a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.gfx942.ll
+++ b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.gfx942.ll
@@ -1,13 +1,9 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 5
 ; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx942 < %s | FileCheck 
--check-prefixes=GFX942,GFX942-VGPRCD,GFX942-SDAG,GFX942-VGPRCD-SDAG %s
 ; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx942 < %s | FileCheck 
--check-prefixes=GFX942,GFX942-VGPRCD,GFX942-GISEL,GFX942-VGPRCD-GISEL %s
-; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx942 -stress-regalloc=10 < 
%s | FileCheck 
--check-prefixes=GFX942,GFX942-AGPRCD,GFX942-SDAG,GFX942-AGPRCD-SDAG %s
-; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx942 -stress-regalloc=10 < %s 
| FileCheck 
--check-prefixes=GFX942,GFX942-AGPRCD,GFX942-GISEL,GFX942-AGPRCD-GISEL %s
 
 ; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx950 < %s | FileCheck 
--check-prefixes=GFX950,GFX950-VGPRCD,GFX950-SDAG,GFX950-VGPRCD-SDAG %s
 ; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx950 < %s | FileCheck 
--check-prefixes=GFX950,GFX950-VGPRCD,GFX950-GISEL,GFX950-VGPRCD-GISEL %s
-; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx950 -stress-regalloc=10 < 
%s | FileCheck 
--check-prefixes=GFX950,GFX950-AGPRCD,GFX950-SDAG,GFX950-AGPRCD-SDAG %s
-; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx950 -stress-regalloc=10 < %s 
| FileCheck 
--check-prefixes=GFX950,GFX950-AGPRCD,GFX950-GISEL,GFX950-AGPRCD-GISEL %s
 
 declare <4 x i32> @llvm.amdgcn.mfma.i32.16x16x32.i8(i64, i64, <4 x i32>, i32, 
i32, i32)
 declare <16 x i32> @llvm.amdgcn.mfma.i32.32x32x16.i8(i64, i64, <16 x i32>, 
i32, i32, i32)
diff --git a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.xf32.gfx942.ll 
b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.xf32.gfx942.ll
index ea9334a6c74d3..31a48de4133ac 100644
--- a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.xf32.gfx942.ll
+++ b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.xf32.gfx942.ll
@@ -1,8 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 5
 ; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx942 < %s | FileCheck 
--check-prefixes=GFX942,GFX942-SDAG %s
 ; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx942 < %s | FileCheck 
--check-prefixes=GFX942,GFX942-GISEL %s
-; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx942 -stress-regalloc=10 < 
%s | FileCheck --check-prefixes=GFX942-STRESS,GFX942-SDAG-STRESS %s
-; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx942 -stress-regalloc=10 < %s 
| FileCheck --check-prefixes=GFX942-STRESS,GFX942-GISEL-STRESS %s
 
 declare <4 x float> @llvm.amdgcn.mfma.f32.16x16x8.xf32(<2 x float>, <2 x 
float>, <4 x float>, i32, i32, i32)
 declare <16 x float> @llvm.amdgcn.mfma.f32.32x32x4.xf32(<2 x float>, <2 x 
float>, <16 x float>, i32, i32, i32)
@@ -51,50 +49,6 @@ define amdgpu_kernel void @test_mfma_f32_16x16x8xf32(ptr 
addrspace(1) %arg) #0 {
 ; GFX942-GISEL-NEXT:s_nop 5
 ; GFX942-GISEL-NEXT:global_store_dwordx4 v0, a[0:3], s[6:7]
 ; GFX942-GISEL-NEXT:s_endpgm
-;
-; GFX942-SDAG-STRESS-LABEL: test_mfma_f32_16x16x8xf32:
-; GFX942-SDAG-STRESS:   ; %bb.0: ; %bb
-; GFX942-SDAG-STRESS-NEXT:s_load_dwordx2 s[6:7], s[4:5], 0x24
-; GFX942-SDAG-STRESS-NEXT:v_mov_b32_e32 v0, 1.0
-; GFX942-SDAG-STRESS-NEXT:v_mov_b32_e32 v1, 2.0
-; GFX942-SDAG-STRESS-NEXT:v_mov_b32_e32 v2, 0x4040
-; GFX942-SDAG-STRESS-NEXT:v_mov_b32_e32 v3, 4.0
-; GFX942-SDAG-STRESS-NEXT:s_waitcnt lgkmcnt(0)
-; GFX942-SDAG-STRESS-NEXT:s_load_dwordx4 s[0:3], s[6:7], 0x0
-; GFX942-SDAG-STRESS-NEXT:v_mov_b32_e32 v4, 0
-; GFX942-SDAG-STRESS-NEXT:s_waitcnt lgkmcnt(0)
-; GFX942-SDAG-STRESS-NEXT:v_accvgpr_write_b32 a0, s0
-; GFX942-SDAG-STRESS-NEXT:v_accvgpr_write_b32

[llvm-branch-commits] [llvm] AMDGPU: Test VGPR and AGPR case for xf32 mfmas (PR #150891)

2025-07-27 Thread Matt Arsenault via llvm-branch-commits

https://github.com/arsenm created 
https://github.com/llvm/llvm-project/pull/150891

None

>From c6f8acd00757091207a20254473e5c58b0be317e Mon Sep 17 00:00:00 2001
From: Matt Arsenault 
Date: Mon, 28 Jul 2025 15:19:37 +0900
Subject: [PATCH] AMDGPU: Test VGPR and AGPR case for xf32 mfmas

---
 .../AMDGPU/llvm.amdgcn.mfma.xf32.gfx942.ll| 115 ++
 1 file changed, 115 insertions(+)

diff --git a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.xf32.gfx942.ll 
b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.xf32.gfx942.ll
index 31a48de4133ac..aebb24d98d1a7 100644
--- a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.xf32.gfx942.ll
+++ b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.xf32.gfx942.ll
@@ -55,6 +55,52 @@ bb:
   store <4 x float> %mai.1, ptr addrspace(1) %arg
   ret void
 }
+define amdgpu_kernel void @test_mfma_f32_16x16x8xf32_vgprcd(ptr addrspace(1) 
%arg) #1 {
+; GFX942-SDAG-LABEL: test_mfma_f32_16x16x8xf32_vgprcd:
+; GFX942-SDAG:   ; %bb.0: ; %bb
+; GFX942-SDAG-NEXT:s_load_dwordx2 s[6:7], s[4:5], 0x24
+; GFX942-SDAG-NEXT:v_mov_b32_e32 v4, 1.0
+; GFX942-SDAG-NEXT:v_mov_b32_e32 v5, 2.0
+; GFX942-SDAG-NEXT:v_mov_b32_e32 v6, 0x4040
+; GFX942-SDAG-NEXT:v_mov_b32_e32 v7, 4.0
+; GFX942-SDAG-NEXT:s_waitcnt lgkmcnt(0)
+; GFX942-SDAG-NEXT:s_load_dwordx4 s[0:3], s[6:7], 0x0
+; GFX942-SDAG-NEXT:v_mov_b32_e32 v8, 0
+; GFX942-SDAG-NEXT:s_waitcnt lgkmcnt(0)
+; GFX942-SDAG-NEXT:v_mov_b64_e32 v[0:1], s[0:1]
+; GFX942-SDAG-NEXT:v_mov_b64_e32 v[2:3], s[2:3]
+; GFX942-SDAG-NEXT:s_nop 1
+; GFX942-SDAG-NEXT:v_mfma_f32_16x16x8_xf32 v[0:3], v[4:5], v[6:7], v[0:3] 
cbsz:1 abid:2 blgp:3
+; GFX942-SDAG-NEXT:s_nop 6
+; GFX942-SDAG-NEXT:global_store_dwordx4 v8, v[0:3], s[6:7]
+; GFX942-SDAG-NEXT:s_endpgm
+;
+; GFX942-GISEL-LABEL: test_mfma_f32_16x16x8xf32_vgprcd:
+; GFX942-GISEL:   ; %bb.0: ; %bb
+; GFX942-GISEL-NEXT:s_load_dwordx2 s[6:7], s[4:5], 0x24
+; GFX942-GISEL-NEXT:s_mov_b32 s4, 1.0
+; GFX942-GISEL-NEXT:s_mov_b32 s5, 2.0
+; GFX942-GISEL-NEXT:v_mov_b64_e32 v[4:5], s[4:5]
+; GFX942-GISEL-NEXT:s_mov_b32 s4, 0x4040
+; GFX942-GISEL-NEXT:s_waitcnt lgkmcnt(0)
+; GFX942-GISEL-NEXT:s_load_dwordx4 s[0:3], s[6:7], 0x0
+; GFX942-GISEL-NEXT:s_mov_b32 s5, 4.0
+; GFX942-GISEL-NEXT:v_mov_b64_e32 v[6:7], s[4:5]
+; GFX942-GISEL-NEXT:s_waitcnt lgkmcnt(0)
+; GFX942-GISEL-NEXT:v_mov_b64_e32 v[0:1], s[0:1]
+; GFX942-GISEL-NEXT:v_mov_b64_e32 v[2:3], s[2:3]
+; GFX942-GISEL-NEXT:s_nop 1
+; GFX942-GISEL-NEXT:v_mfma_f32_16x16x8_xf32 v[0:3], v[4:5], v[6:7], v[0:3] 
cbsz:1 abid:2 blgp:3
+; GFX942-GISEL-NEXT:v_mov_b32_e32 v4, 0
+; GFX942-GISEL-NEXT:s_nop 5
+; GFX942-GISEL-NEXT:global_store_dwordx4 v4, v[0:3], s[6:7]
+; GFX942-GISEL-NEXT:s_endpgm
+bb:
+  %in.1 = load <4 x float>, ptr addrspace(1) %arg
+  %mai.1 = tail call <4 x float> @llvm.amdgcn.mfma.f32.16x16x8.xf32(<2 x 
float> , <2 x float> , <4 x float> 
%in.1, i32 1, i32 2, i32 3)
+  store <4 x float> %mai.1, ptr addrspace(1) %arg
+  ret void
+}
 
 define amdgpu_kernel void @test_mfma_f32_32x32x4xf32(ptr addrspace(1) %arg) #0 
{
 ; GFX942-SDAG-LABEL: test_mfma_f32_32x32x4xf32:
@@ -139,6 +185,75 @@ bb:
   ret void
 }
 
+define amdgpu_kernel void @test_mfma_f32_32x32x4xf32_vgprcd(ptr addrspace(1) 
%arg) #1 {
+; GFX942-SDAG-LABEL: test_mfma_f32_32x32x4xf32_vgprcd:
+; GFX942-SDAG:   ; %bb.0: ; %bb
+; GFX942-SDAG-NEXT:s_load_dwordx2 s[16:17], s[4:5], 0x24
+; GFX942-SDAG-NEXT:v_mov_b32_e32 v16, 1.0
+; GFX942-SDAG-NEXT:v_mov_b32_e32 v17, 2.0
+; GFX942-SDAG-NEXT:v_mov_b32_e32 v18, 0x4040
+; GFX942-SDAG-NEXT:v_mov_b32_e32 v19, 4.0
+; GFX942-SDAG-NEXT:s_waitcnt lgkmcnt(0)
+; GFX942-SDAG-NEXT:s_load_dwordx16 s[0:15], s[16:17], 0x0
+; GFX942-SDAG-NEXT:s_waitcnt lgkmcnt(0)
+; GFX942-SDAG-NEXT:v_mov_b64_e32 v[0:1], s[0:1]
+; GFX942-SDAG-NEXT:v_mov_b64_e32 v[2:3], s[2:3]
+; GFX942-SDAG-NEXT:v_mov_b64_e32 v[4:5], s[4:5]
+; GFX942-SDAG-NEXT:v_mov_b64_e32 v[6:7], s[6:7]
+; GFX942-SDAG-NEXT:v_mov_b64_e32 v[8:9], s[8:9]
+; GFX942-SDAG-NEXT:v_mov_b64_e32 v[10:11], s[10:11]
+; GFX942-SDAG-NEXT:v_mov_b64_e32 v[12:13], s[12:13]
+; GFX942-SDAG-NEXT:v_mov_b64_e32 v[14:15], s[14:15]
+; GFX942-SDAG-NEXT:s_nop 1
+; GFX942-SDAG-NEXT:v_mfma_f32_32x32x4_xf32 v[0:15], v[16:17], v[18:19], 
v[0:15] cbsz:1 abid:2 blgp:3
+; GFX942-SDAG-NEXT:v_mov_b32_e32 v16, 0
+; GFX942-SDAG-NEXT:s_nop 7
+; GFX942-SDAG-NEXT:s_nop 1
+; GFX942-SDAG-NEXT:global_store_dwordx4 v16, v[12:15], s[16:17] offset:48
+; GFX942-SDAG-NEXT:global_store_dwordx4 v16, v[8:11], s[16:17] offset:32
+; GFX942-SDAG-NEXT:global_store_dwordx4 v16, v[4:7], s[16:17] offset:16
+; GFX942-SDAG-NEXT:global_store_dwordx4 v16, v[0:3], s[16:17]
+; GFX942-SDAG-NEXT:s_endpgm
+;
+; GFX942-GISEL-LABEL: test_mfma_f32_32x32x4xf32_vgprcd:
+; GFX942-GISEL:   ; %bb.0: ; %bb
+; GFX942-GISEL-NEXT:s_load_dwordx2 s[16:17], s[

[llvm-branch-commits] [llvm] AMDGPU: Remove -stress-regalloc arguments from mfma selection tests (PR #150890)

2025-07-27 Thread Matt Arsenault via llvm-branch-commits

arsenm 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/150890?utm_source=stack-comment-downstack-mergeability-warning";
>  >on Graphite.
> https://graphite.dev/docs/merge-pull-requests";>Learn more

* **#150891** https://app.graphite.dev/github/pr/llvm/llvm-project/150891?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#150890** https://app.graphite.dev/github/pr/llvm/llvm-project/150890?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/150890?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#150873** https://app.graphite.dev/github/pr/llvm/llvm-project/150873?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/150890
___
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] AMDGPU: Remove -stress-regalloc arguments from mfma selection tests (PR #150890)

2025-07-27 Thread Matt Arsenault via llvm-branch-commits

https://github.com/arsenm ready_for_review 
https://github.com/llvm/llvm-project/pull/150890
___
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] AMDGPU: Test VGPR and AGPR case for xf32 mfmas (PR #150891)

2025-07-27 Thread Matt Arsenault via llvm-branch-commits

arsenm 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/150891?utm_source=stack-comment-downstack-mergeability-warning";
>  >on Graphite.
> https://graphite.dev/docs/merge-pull-requests";>Learn more

* **#150891** https://app.graphite.dev/github/pr/llvm/llvm-project/150891?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/150891?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#150890** https://app.graphite.dev/github/pr/llvm/llvm-project/150890?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#150873** https://app.graphite.dev/github/pr/llvm/llvm-project/150873?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/150891
___
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] AMDGPU: Remove -stress-regalloc arguments from mfma selection tests (PR #150890)

2025-07-27 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-amdgpu

Author: Matt Arsenault (arsenm)


Changes

I'm not really sure what the point of these was, but they originated
in the base support commit for gfx942 mfma support. These don't impact
the selection at all, so don't belong in this test. These were causing
allocation failure depending on whether or not the AGPR or VGPR form
was used.

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


2 Files Affected:

- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.gfx942.ll (-4) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.xf32.gfx942.ll (-123) 


``diff
diff --git a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.gfx942.ll 
b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.gfx942.ll
index 7d85d3439eed9..beda16c17a5c9 100644
--- a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.gfx942.ll
+++ b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.gfx942.ll
@@ -1,13 +1,9 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 5
 ; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx942 < %s | FileCheck 
--check-prefixes=GFX942,GFX942-VGPRCD,GFX942-SDAG,GFX942-VGPRCD-SDAG %s
 ; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx942 < %s | FileCheck 
--check-prefixes=GFX942,GFX942-VGPRCD,GFX942-GISEL,GFX942-VGPRCD-GISEL %s
-; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx942 -stress-regalloc=10 < 
%s | FileCheck 
--check-prefixes=GFX942,GFX942-AGPRCD,GFX942-SDAG,GFX942-AGPRCD-SDAG %s
-; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx942 -stress-regalloc=10 < %s 
| FileCheck 
--check-prefixes=GFX942,GFX942-AGPRCD,GFX942-GISEL,GFX942-AGPRCD-GISEL %s
 
 ; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx950 < %s | FileCheck 
--check-prefixes=GFX950,GFX950-VGPRCD,GFX950-SDAG,GFX950-VGPRCD-SDAG %s
 ; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx950 < %s | FileCheck 
--check-prefixes=GFX950,GFX950-VGPRCD,GFX950-GISEL,GFX950-VGPRCD-GISEL %s
-; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx950 -stress-regalloc=10 < 
%s | FileCheck 
--check-prefixes=GFX950,GFX950-AGPRCD,GFX950-SDAG,GFX950-AGPRCD-SDAG %s
-; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx950 -stress-regalloc=10 < %s 
| FileCheck 
--check-prefixes=GFX950,GFX950-AGPRCD,GFX950-GISEL,GFX950-AGPRCD-GISEL %s
 
 declare <4 x i32> @llvm.amdgcn.mfma.i32.16x16x32.i8(i64, i64, <4 x i32>, i32, 
i32, i32)
 declare <16 x i32> @llvm.amdgcn.mfma.i32.32x32x16.i8(i64, i64, <16 x i32>, 
i32, i32, i32)
diff --git a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.xf32.gfx942.ll 
b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.xf32.gfx942.ll
index ea9334a6c74d3..31a48de4133ac 100644
--- a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.xf32.gfx942.ll
+++ b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.xf32.gfx942.ll
@@ -1,8 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 5
 ; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx942 < %s | FileCheck 
--check-prefixes=GFX942,GFX942-SDAG %s
 ; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx942 < %s | FileCheck 
--check-prefixes=GFX942,GFX942-GISEL %s
-; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx942 -stress-regalloc=10 < 
%s | FileCheck --check-prefixes=GFX942-STRESS,GFX942-SDAG-STRESS %s
-; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx942 -stress-regalloc=10 < %s 
| FileCheck --check-prefixes=GFX942-STRESS,GFX942-GISEL-STRESS %s
 
 declare <4 x float> @llvm.amdgcn.mfma.f32.16x16x8.xf32(<2 x float>, <2 x 
float>, <4 x float>, i32, i32, i32)
 declare <16 x float> @llvm.amdgcn.mfma.f32.32x32x4.xf32(<2 x float>, <2 x 
float>, <16 x float>, i32, i32, i32)
@@ -51,50 +49,6 @@ define amdgpu_kernel void @test_mfma_f32_16x16x8xf32(ptr 
addrspace(1) %arg) #0 {
 ; GFX942-GISEL-NEXT:s_nop 5
 ; GFX942-GISEL-NEXT:global_store_dwordx4 v0, a[0:3], s[6:7]
 ; GFX942-GISEL-NEXT:s_endpgm
-;
-; GFX942-SDAG-STRESS-LABEL: test_mfma_f32_16x16x8xf32:
-; GFX942-SDAG-STRESS:   ; %bb.0: ; %bb
-; GFX942-SDAG-STRESS-NEXT:s_load_dwordx2 s[6:7], s[4:5], 0x24
-; GFX942-SDAG-STRESS-NEXT:v_mov_b32_e32 v0, 1.0
-; GFX942-SDAG-STRESS-NEXT:v_mov_b32_e32 v1, 2.0
-; GFX942-SDAG-STRESS-NEXT:v_mov_b32_e32 v2, 0x4040
-; GFX942-SDAG-STRESS-NEXT:v_mov_b32_e32 v3, 4.0
-; GFX942-SDAG-STRESS-NEXT:s_waitcnt lgkmcnt(0)
-; GFX942-SDAG-STRESS-NEXT:s_load_dwordx4 s[0:3], s[6:7], 0x0
-; GFX942-SDAG-STRESS-NEXT:v_mov_b32_e32 v4, 0
-; GFX942-SDAG-STRESS-NEXT:s_waitcnt lgkmcnt(0)
-; GFX942-SDAG-STRESS-NEXT:v_accvgpr_write_b32 a0, s0
-; GFX942-SDAG-STRESS-NEXT:v_accvgpr_write_b32 a1, s1
-; GFX942-SDAG-STRESS-NEXT:v_accvgpr_write_b32 a2, s2
-; GFX942-SDAG-STRESS-NEXT:v_accvgpr_write_b32 a3, s3
-; GFX942-SDAG-STRESS-NEXT:s_nop 1
-; GFX942-SDAG-STRESS-NEXT:v_mfma_f32_16x16x8_xf32 a[0:3], v[0:1], v[2:3], 
a[0:3] cbsz:1 abid:2 blgp:3
-; GFX942-SDAG-STRESS-NEXT:s_nop 6
-; GFX942-SDAG-STRESS-NEXT:global_store_dwordx4 v4, a[0:3], s[6:7]
-; GFX942-SDAG-STRESS-NEX

[llvm-branch-commits] [llvm] AMDGPU: Test VGPR and AGPR case for xf32 mfmas (PR #150891)

2025-07-27 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-amdgpu

Author: Matt Arsenault (arsenm)


Changes



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


1 Files Affected:

- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.xf32.gfx942.ll (+115) 


``diff
diff --git a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.xf32.gfx942.ll 
b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.xf32.gfx942.ll
index 31a48de4133ac..aebb24d98d1a7 100644
--- a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.xf32.gfx942.ll
+++ b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.xf32.gfx942.ll
@@ -55,6 +55,52 @@ bb:
   store <4 x float> %mai.1, ptr addrspace(1) %arg
   ret void
 }
+define amdgpu_kernel void @test_mfma_f32_16x16x8xf32_vgprcd(ptr addrspace(1) 
%arg) #1 {
+; GFX942-SDAG-LABEL: test_mfma_f32_16x16x8xf32_vgprcd:
+; GFX942-SDAG:   ; %bb.0: ; %bb
+; GFX942-SDAG-NEXT:s_load_dwordx2 s[6:7], s[4:5], 0x24
+; GFX942-SDAG-NEXT:v_mov_b32_e32 v4, 1.0
+; GFX942-SDAG-NEXT:v_mov_b32_e32 v5, 2.0
+; GFX942-SDAG-NEXT:v_mov_b32_e32 v6, 0x4040
+; GFX942-SDAG-NEXT:v_mov_b32_e32 v7, 4.0
+; GFX942-SDAG-NEXT:s_waitcnt lgkmcnt(0)
+; GFX942-SDAG-NEXT:s_load_dwordx4 s[0:3], s[6:7], 0x0
+; GFX942-SDAG-NEXT:v_mov_b32_e32 v8, 0
+; GFX942-SDAG-NEXT:s_waitcnt lgkmcnt(0)
+; GFX942-SDAG-NEXT:v_mov_b64_e32 v[0:1], s[0:1]
+; GFX942-SDAG-NEXT:v_mov_b64_e32 v[2:3], s[2:3]
+; GFX942-SDAG-NEXT:s_nop 1
+; GFX942-SDAG-NEXT:v_mfma_f32_16x16x8_xf32 v[0:3], v[4:5], v[6:7], v[0:3] 
cbsz:1 abid:2 blgp:3
+; GFX942-SDAG-NEXT:s_nop 6
+; GFX942-SDAG-NEXT:global_store_dwordx4 v8, v[0:3], s[6:7]
+; GFX942-SDAG-NEXT:s_endpgm
+;
+; GFX942-GISEL-LABEL: test_mfma_f32_16x16x8xf32_vgprcd:
+; GFX942-GISEL:   ; %bb.0: ; %bb
+; GFX942-GISEL-NEXT:s_load_dwordx2 s[6:7], s[4:5], 0x24
+; GFX942-GISEL-NEXT:s_mov_b32 s4, 1.0
+; GFX942-GISEL-NEXT:s_mov_b32 s5, 2.0
+; GFX942-GISEL-NEXT:v_mov_b64_e32 v[4:5], s[4:5]
+; GFX942-GISEL-NEXT:s_mov_b32 s4, 0x4040
+; GFX942-GISEL-NEXT:s_waitcnt lgkmcnt(0)
+; GFX942-GISEL-NEXT:s_load_dwordx4 s[0:3], s[6:7], 0x0
+; GFX942-GISEL-NEXT:s_mov_b32 s5, 4.0
+; GFX942-GISEL-NEXT:v_mov_b64_e32 v[6:7], s[4:5]
+; GFX942-GISEL-NEXT:s_waitcnt lgkmcnt(0)
+; GFX942-GISEL-NEXT:v_mov_b64_e32 v[0:1], s[0:1]
+; GFX942-GISEL-NEXT:v_mov_b64_e32 v[2:3], s[2:3]
+; GFX942-GISEL-NEXT:s_nop 1
+; GFX942-GISEL-NEXT:v_mfma_f32_16x16x8_xf32 v[0:3], v[4:5], v[6:7], v[0:3] 
cbsz:1 abid:2 blgp:3
+; GFX942-GISEL-NEXT:v_mov_b32_e32 v4, 0
+; GFX942-GISEL-NEXT:s_nop 5
+; GFX942-GISEL-NEXT:global_store_dwordx4 v4, v[0:3], s[6:7]
+; GFX942-GISEL-NEXT:s_endpgm
+bb:
+  %in.1 = load <4 x float>, ptr addrspace(1) %arg
+  %mai.1 = tail call <4 x float> @llvm.amdgcn.mfma.f32.16x16x8.xf32(<2 x 
float> , <2 x float> , <4 x float> 
%in.1, i32 1, i32 2, i32 3)
+  store <4 x float> %mai.1, ptr addrspace(1) %arg
+  ret void
+}
 
 define amdgpu_kernel void @test_mfma_f32_32x32x4xf32(ptr addrspace(1) %arg) #0 
{
 ; GFX942-SDAG-LABEL: test_mfma_f32_32x32x4xf32:
@@ -139,6 +185,75 @@ bb:
   ret void
 }
 
+define amdgpu_kernel void @test_mfma_f32_32x32x4xf32_vgprcd(ptr addrspace(1) 
%arg) #1 {
+; GFX942-SDAG-LABEL: test_mfma_f32_32x32x4xf32_vgprcd:
+; GFX942-SDAG:   ; %bb.0: ; %bb
+; GFX942-SDAG-NEXT:s_load_dwordx2 s[16:17], s[4:5], 0x24
+; GFX942-SDAG-NEXT:v_mov_b32_e32 v16, 1.0
+; GFX942-SDAG-NEXT:v_mov_b32_e32 v17, 2.0
+; GFX942-SDAG-NEXT:v_mov_b32_e32 v18, 0x4040
+; GFX942-SDAG-NEXT:v_mov_b32_e32 v19, 4.0
+; GFX942-SDAG-NEXT:s_waitcnt lgkmcnt(0)
+; GFX942-SDAG-NEXT:s_load_dwordx16 s[0:15], s[16:17], 0x0
+; GFX942-SDAG-NEXT:s_waitcnt lgkmcnt(0)
+; GFX942-SDAG-NEXT:v_mov_b64_e32 v[0:1], s[0:1]
+; GFX942-SDAG-NEXT:v_mov_b64_e32 v[2:3], s[2:3]
+; GFX942-SDAG-NEXT:v_mov_b64_e32 v[4:5], s[4:5]
+; GFX942-SDAG-NEXT:v_mov_b64_e32 v[6:7], s[6:7]
+; GFX942-SDAG-NEXT:v_mov_b64_e32 v[8:9], s[8:9]
+; GFX942-SDAG-NEXT:v_mov_b64_e32 v[10:11], s[10:11]
+; GFX942-SDAG-NEXT:v_mov_b64_e32 v[12:13], s[12:13]
+; GFX942-SDAG-NEXT:v_mov_b64_e32 v[14:15], s[14:15]
+; GFX942-SDAG-NEXT:s_nop 1
+; GFX942-SDAG-NEXT:v_mfma_f32_32x32x4_xf32 v[0:15], v[16:17], v[18:19], 
v[0:15] cbsz:1 abid:2 blgp:3
+; GFX942-SDAG-NEXT:v_mov_b32_e32 v16, 0
+; GFX942-SDAG-NEXT:s_nop 7
+; GFX942-SDAG-NEXT:s_nop 1
+; GFX942-SDAG-NEXT:global_store_dwordx4 v16, v[12:15], s[16:17] offset:48
+; GFX942-SDAG-NEXT:global_store_dwordx4 v16, v[8:11], s[16:17] offset:32
+; GFX942-SDAG-NEXT:global_store_dwordx4 v16, v[4:7], s[16:17] offset:16
+; GFX942-SDAG-NEXT:global_store_dwordx4 v16, v[0:3], s[16:17]
+; GFX942-SDAG-NEXT:s_endpgm
+;
+; GFX942-GISEL-LABEL: test_mfma_f32_32x32x4xf32_vgprcd:
+; GFX942-GISEL:   ; %bb.0: ; %bb
+; GFX942-GISEL-NEXT:s_load_dwordx2 s[16:17], s[4:5], 0x24
+; GFX942-GISEL-NEXT:s_mov_b32 s18, 1.0
+; GFX942-GISEL-NEXT:s_mov_b32 s19, 2.0
+; GFX942-GISEL

[llvm-branch-commits] [llvm] AMDGPU: Test VGPR and AGPR case for xf32 mfmas (PR #150891)

2025-07-27 Thread Matt Arsenault via llvm-branch-commits

https://github.com/arsenm ready_for_review 
https://github.com/llvm/llvm-project/pull/150891
___
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: [Sparc] Remove bogus stack adjustment for LD/GD TLS (#149890) (PR #150048)

2025-07-27 Thread Brad Smith via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/150048
___
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/20.x: Backport [LLD][COFF] Disallow importing DllMain from import libraries (#146610) (PR #146699)

2025-07-27 Thread Alexandre Ganea via llvm-branch-commits

https://github.com/aganea closed 
https://github.com/llvm/llvm-project/pull/146699
___
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] [lldb] [PATCH 7/7] [clang] improve NestedNameSpecifier: LLDB changes (PR #149949)

2025-07-27 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/149949

>From 9d8c830ef0ff10e72020dd76e0a0a07b83ed460c Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Mon, 21 Jul 2025 22:00:01 -0300
Subject: [PATCH] [PATCH 7/7] [clang] improve NestedNameSpecifier: LLDB changes

Patch series starting at https://github.com/llvm/llvm-project/pull/147835
---
 clang/include/clang/AST/QualTypeNames.h   |  10 +
 clang/lib/AST/QualTypeNames.cpp   |   7 +
 .../Clang/ClangASTImporter.cpp|  31 +--
 .../ExpressionParser/Clang/ClangASTSource.cpp |   5 +-
 .../Clang/ClangExpressionDeclMap.cpp  |   4 +-
 .../Clang/ClangPersistentVariables.cpp|  13 +-
 .../Clang/NameSearchContext.cpp   |   2 +-
 .../Plugins/Language/ObjC/NSDictionary.cpp|   3 +-
 .../RegisterTypeBuilderClang.cpp  |   4 +-
 .../SymbolFile/NativePDB/PdbAstBuilder.cpp|  11 +-
 .../Plugins/SymbolFile/PDB/PDBASTParser.cpp   |  11 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 240 +-
 .../TypeSystem/Clang/TypeSystemClang.h|   9 +-
 .../TestDataFormatterStdSharedPtr.py  |   2 +-
 .../string/TestDataFormatterStdString.py  |  41 ++-
 .../TestDataFormatterStdStringView.py |  64 +++--
 .../TestDataFormatterStdUniquePtr.py  |   2 +-
 .../TestClassLoadingViaMemberTypedef.py   |   4 +-
 .../x86/DW_AT_declaration-with-children.s |   4 +-
 .../DWARF/x86/dwp-foreign-type-units.cpp  |   8 +-
 .../DWARF/x86/typedef-in-incomplete-type.cpp  |   2 +-
 .../lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp|   5 +-
 22 files changed, 237 insertions(+), 245 deletions(-)

diff --git a/clang/include/clang/AST/QualTypeNames.h 
b/clang/include/clang/AST/QualTypeNames.h
index daa86cda2d992..9f5cf045d1d4c 100644
--- a/clang/include/clang/AST/QualTypeNames.h
+++ b/clang/include/clang/AST/QualTypeNames.h
@@ -87,6 +87,16 @@ std::string getFullyQualifiedName(QualType QT, const 
ASTContext &Ctx,
 /// specifier "::" should be prepended or not.
 QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx,
bool WithGlobalNsPrefix = false);
+
+/// Get the fully qualified name for the declared context of a declaration.
+///
+/// \param[in] Ctx - the ASTContext to be used.
+/// \param[in] Decl - the declaration for which to get the fully qualified 
name.
+/// \param[in] WithGlobalNsPrefix - If true, then the global namespace
+/// specifier "::" will be prepended to the fully qualified name.
+NestedNameSpecifier
+getFullyQualifiedDeclaredContext(const ASTContext &Ctx, const Decl *Decl,
+ bool WithGlobalNsPrefix = false);
 } // end namespace TypeName
 } // end namespace clang
 #endif // LLVM_CLANG_AST_QUALTYPENAMES_H
diff --git a/clang/lib/AST/QualTypeNames.cpp b/clang/lib/AST/QualTypeNames.cpp
index 319becd8a5a98..086450e790541 100644
--- a/clang/lib/AST/QualTypeNames.cpp
+++ b/clang/lib/AST/QualTypeNames.cpp
@@ -491,5 +491,12 @@ std::string getFullyQualifiedName(QualType QT,
   return FQQT.getAsString(Policy);
 }
 
+NestedNameSpecifier getFullyQualifiedDeclaredContext(const ASTContext &Ctx,
+ const Decl *Decl,
+ bool WithGlobalNsPrefix) {
+  return createNestedNameSpecifierForScopeOf(Ctx, Decl, 
/*FullyQualified=*/true,
+ WithGlobalNsPrefix);
+}
+
 }  // end namespace TypeName
 }  // end namespace clang
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index 2529e78f78bca..7ba8b730c6e9b 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -320,7 +320,8 @@ CompilerType ClangASTImporter::DeportType(TypeSystemClang 
&dst,
   DeclContextOverride decl_context_override;
 
   if (auto *t = ClangUtil::GetQualType(src_type)->getAs())
-decl_context_override.OverrideAllDeclsFromContainingFunction(t->getDecl());
+decl_context_override.OverrideAllDeclsFromContainingFunction(
+t->getOriginalDecl());
 
   CompleteTagDeclsScope complete_scope(*this, &dst.getASTContext(),
&src_ctxt->getASTContext());
@@ -377,8 +378,7 @@ bool ClangASTImporter::CanImport(const CompilerType &type) {
   } break;
 
   case clang::Type::Enum: {
-clang::EnumDecl *enum_decl =
-llvm::cast(qual_type)->getDecl();
+auto *enum_decl = 
llvm::cast(qual_type)->getOriginalDecl();
 if (enum_decl) {
   if (GetDeclOrigin(enum_decl).Valid())
 return true;
@@ -414,12 +414,6 @@ bool ClangASTImporter::CanImport(const CompilerType &type) 
{
   ->getDeducedType()
   .getAsOpaquePtr()));
 
-  case clang::Type::Elaborated:
-return CanI

[llvm-branch-commits] [llvm] release/21.x: [Mips] Fix wrong ELF FP ABI info when inline asm was empty (#146457) (PR #150866)

2025-07-27 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/150866

>From 88c4bdd522c5278cff1859e9ee22c601abc6baad Mon Sep 17 00:00:00 2001
From: yingopq <115543042+ying...@users.noreply.github.com>
Date: Mon, 28 Jul 2025 09:07:51 +0800
Subject: [PATCH] [Mips] Fix wrong ELF FP ABI info when inline asm was empty
 (#146457)

When Mips process emitStartOfAsmFile and updateABIInfo, it did not know
the real value of IsSoftFloat and STI.useSoftFloat(). And when inline
asm instruction was empty, Mips did not process asm parser, so it would
not do TS.updateABIInfo(STI) again and at this time the value of
IsSoftFloat is correct.

Fix #135283.

(cherry picked from commit 778fb76e6308534a63239a91b98f5dad055f6fdb)
---
 llvm/lib/Target/Mips/MipsAsmPrinter.cpp   |  8 ++--
 llvm/test/CodeGen/Mips/abiflags-soft-float.ll | 12 
 2 files changed, 18 insertions(+), 2 deletions(-)
 create mode 100644 llvm/test/CodeGen/Mips/abiflags-soft-float.ll

diff --git a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp 
b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
index 87e06a6d3c08a..2903ff75475cf 100644
--- a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -747,14 +747,18 @@ void MipsAsmPrinter::emitStartOfAsmFile(Module &M) {
 if (FS.empty() && M.size() && F->hasFnAttribute("target-features"))
   FS = F->getFnAttribute("target-features").getValueAsString();
 
+std::string strFS = FS.str();
+if (M.size() && F->getFnAttribute("use-soft-float").getValueAsBool())
+  strFS += strFS.empty() ? "+soft-float" : ",+soft-float";
+
 // Compute MIPS architecture attributes based on the default subtarget
 // that we'd have constructed.
 // FIXME: For ifunc related functions we could iterate over and look
 // for a feature string that doesn't match the default one.
 StringRef CPU = MIPS_MC::selectMipsCPU(TT, TM.getTargetCPU());
 const MipsTargetMachine &MTM = static_cast(TM);
-const MipsSubtarget STI(TT, CPU, FS, MTM.isLittleEndian(), MTM,
-std::nullopt);
+const MipsSubtarget STI(TT, CPU, StringRef(strFS), MTM.isLittleEndian(),
+MTM, std::nullopt);
 
 bool IsABICalls = STI.isABICalls();
 const MipsABIInfo &ABI = MTM.getABI();
diff --git a/llvm/test/CodeGen/Mips/abiflags-soft-float.ll 
b/llvm/test/CodeGen/Mips/abiflags-soft-float.ll
new file mode 100644
index 0..01821f2d9b6c6
--- /dev/null
+++ b/llvm/test/CodeGen/Mips/abiflags-soft-float.ll
@@ -0,0 +1,12 @@
+; RUN: llc -filetype=obj -mtriple mipsel-unknown-linux -mcpu=mips32 %s -o tmp.o
+; RUN: llvm-readobj -A tmp.o | FileCheck %s -check-prefix=OBJ
+; RUN: llc -filetype=asm -mtriple mipsel-unknown-linux -mcpu=mips32 %s -o - | \
+; RUN: FileCheck %s -check-prefix=ASM
+
+; OBJ: FP ABI: Soft float
+; ASM: .module softfloat 
+
+define dso_local void @asm_is_null() "use-soft-float"="true" {
+  call void asm sideeffect "", ""()
+  ret void
+}

___
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] [IR] Introduce the `ptrtoaddr` instruction (PR #139357)

2025-07-27 Thread Alexander Richardson via llvm-branch-commits

https://github.com/arichardson updated 
https://github.com/llvm/llvm-project/pull/139357

>From 25dc175562349410f161ef0e80246301d9a7ba79 Mon Sep 17 00:00:00 2001
From: Alex Richardson 
Date: Fri, 9 May 2025 22:43:37 -0700
Subject: [PATCH] fix docs build

Created using spr 1.3.6-beta.1
---
 llvm/docs/LangRef.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 2d18d0d97aaee..38be6918ff73c 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -12435,7 +12435,7 @@ Example:
 .. _i_ptrtoaddr:
 
 '``ptrtoaddr .. to``' Instruction
-
+^
 
 Syntax:
 """

___
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] [IR] Introduce the `ptrtoaddr` instruction (PR #139357)

2025-07-27 Thread Alexander Richardson via llvm-branch-commits

https://github.com/arichardson updated 
https://github.com/llvm/llvm-project/pull/139357

>From 25dc175562349410f161ef0e80246301d9a7ba79 Mon Sep 17 00:00:00 2001
From: Alex Richardson 
Date: Fri, 9 May 2025 22:43:37 -0700
Subject: [PATCH] fix docs build

Created using spr 1.3.6-beta.1
---
 llvm/docs/LangRef.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 2d18d0d97aaee..38be6918ff73c 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -12435,7 +12435,7 @@ Example:
 .. _i_ptrtoaddr:
 
 '``ptrtoaddr .. to``' Instruction
-
+^
 
 Syntax:
 """

___
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] [IR] Introduce the `ptrtoaddr` instruction (PR #139357)

2025-07-27 Thread Alexander Richardson via llvm-branch-commits

https://github.com/arichardson commented:

Updated based on @nikic's feedback. Now the type needs to match and constant 
expressions are supported.

Thanks for all the review - I'll wait another week for any further comments in 
case I missed something.

https://github.com/llvm/llvm-project/pull/139357
___
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] [IR] Introduce the `ptrtoaddr` instruction (PR #139357)

2025-07-27 Thread Alexander Richardson via llvm-branch-commits


@@ -320,11 +320,13 @@ TEST_F(IR2VecTestFixture, GetInstVecMap) {
   EXPECT_TRUE(InstMap.count(AddInst));
   EXPECT_TRUE(InstMap.count(RetInst));
 
-  EXPECT_EQ(InstMap.at(AddInst).size(), 2u);
-  EXPECT_EQ(InstMap.at(RetInst).size(), 2u);
+  const auto &AddEmb = InstMap.at(AddInst);
+  const auto &RetEmb = InstMap.at(RetInst);
+  EXPECT_EQ(AddEmb.size(), 2u);
+  EXPECT_EQ(RetEmb.size(), 2u);
 
-  EXPECT_TRUE(InstMap.at(AddInst).approximatelyEquals(Embedding(2, 27.6)));
-  EXPECT_TRUE(InstMap.at(RetInst).approximatelyEquals(Embedding(2, 16.8)));
+  EXPECT_TRUE(AddEmb.approximatelyEquals(Embedding(2, 27.9)));
+  EXPECT_TRUE(RetEmb.approximatelyEquals(Embedding(2, 17.0)));

arichardson wrote:

@svkeerthy are these changes expected? Are these values at all meaningful? It 
would probably be good to have some local constants here instead of hardcoding 
values.

https://github.com/llvm/llvm-project/pull/139357
___
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] [IR] Introduce the `ptrtoaddr` instruction (PR #139357)

2025-07-27 Thread Alexander Richardson via llvm-branch-commits

https://github.com/arichardson edited 
https://github.com/llvm/llvm-project/pull/139357
___
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] [IR] Introduce the `ptrtoaddr` instruction (PR #139357)

2025-07-27 Thread Alexander Richardson via llvm-branch-commits


@@ -66,7 +66,8 @@
 "ExtractValue": [127, 128],
 "InsertValue": [129, 130],
 "LandingPad": [131, 132],
-"Freeze": [133, 134]
+"Freeze": [133, 134],
+"PtrToAddr": [135, 136]

arichardson wrote:

@svkeerthy I have no idea what this file does, I just added a new entry for the 
new instruction. Should it be sorted in enum order instead? I tried to reduce 
the number of changes to passes I don't understand.

https://github.com/llvm/llvm-project/pull/139357
___
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] 191030f - Revert "[OMPIRBuilder] Don't use invalid debug loc in reduction functions. (#…"

2025-07-27 Thread via llvm-branch-commits

Author: Abid Qadeer
Date: 2025-07-27T15:56:50+01:00
New Revision: 191030f8eecc0cb3f58c664736fc2ac8c726ab1a

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

LOG: Revert "[OMPIRBuilder] Don't use invalid debug loc in reduction functions. 
(#…"

This reverts commit 7b91df386820aaf84b30c09d48fba110a42bdc56.

Added: 


Modified: 
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Removed: 
mlir/test/Target/LLVMIR/omptarget-debug-reduc-fn-loc.mlir



diff  --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp 
b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 840ca8364e218..79287729fbfd1 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -2617,7 +2617,7 @@ void OpenMPIRBuilder::emitReductionListCopy(
 Expected OpenMPIRBuilder::emitInterWarpCopyFunction(
 const LocationDescription &Loc, ArrayRef ReductionInfos,
 AttributeList FuncAttrs) {
-  IRBuilder<>::InsertPointGuard IPG(Builder);
+  InsertPointTy SavedIP = Builder.saveIP();
   LLVMContext &Ctx = M.getContext();
   FunctionType *FuncTy = FunctionType::get(
   Builder.getVoidTy(), {Builder.getPtrTy(), Builder.getInt32Ty()},
@@ -2630,7 +2630,6 @@ Expected 
OpenMPIRBuilder::emitInterWarpCopyFunction(
   WcFunc->addParamAttr(1, Attribute::NoUndef);
   BasicBlock *EntryBB = BasicBlock::Create(M.getContext(), "entry", WcFunc);
   Builder.SetInsertPoint(EntryBB);
-  Builder.SetCurrentDebugLocation(llvm::DebugLoc());
 
   // ReduceList: thread local Reduce list.
   // At the stage of the computation when this function is called, partially
@@ -2845,6 +2844,7 @@ Expected 
OpenMPIRBuilder::emitInterWarpCopyFunction(
   }
 
   Builder.CreateRetVoid();
+  Builder.restoreIP(SavedIP);
 
   return WcFunc;
 }
@@ -2853,7 +2853,6 @@ Function *OpenMPIRBuilder::emitShuffleAndReduceFunction(
 ArrayRef ReductionInfos, Function *ReduceFn,
 AttributeList FuncAttrs) {
   LLVMContext &Ctx = M.getContext();
-  IRBuilder<>::InsertPointGuard IPG(Builder);
   FunctionType *FuncTy =
   FunctionType::get(Builder.getVoidTy(),
 {Builder.getPtrTy(), Builder.getInt16Ty(),
@@ -2872,7 +2871,6 @@ Function *OpenMPIRBuilder::emitShuffleAndReduceFunction(
   SarFunc->addParamAttr(3, Attribute::SExt);
   BasicBlock *EntryBB = BasicBlock::Create(M.getContext(), "entry", SarFunc);
   Builder.SetInsertPoint(EntryBB);
-  Builder.SetCurrentDebugLocation(llvm::DebugLoc());
 
   // Thread local Reduce list used to host the values of data to be reduced.
   Argument *ReduceListArg = SarFunc->getArg(0);
@@ -3019,7 +3017,7 @@ Function *OpenMPIRBuilder::emitShuffleAndReduceFunction(
 Function *OpenMPIRBuilder::emitListToGlobalCopyFunction(
 ArrayRef ReductionInfos, Type *ReductionsBufferTy,
 AttributeList FuncAttrs) {
-  IRBuilder<>::InsertPointGuard IPG(Builder);
+  OpenMPIRBuilder::InsertPointTy OldIP = Builder.saveIP();
   LLVMContext &Ctx = M.getContext();
   FunctionType *FuncTy = FunctionType::get(
   Builder.getVoidTy(),
@@ -3035,7 +3033,6 @@ Function *OpenMPIRBuilder::emitListToGlobalCopyFunction(
 
   BasicBlock *EntryBlock = BasicBlock::Create(Ctx, "entry", LtGCFunc);
   Builder.SetInsertPoint(EntryBlock);
-  Builder.SetCurrentDebugLocation(llvm::DebugLoc());
 
   // Buffer: global reduction buffer.
   Argument *BufferArg = LtGCFunc->getArg(0);
@@ -3123,13 +3120,14 @@ Function *OpenMPIRBuilder::emitListToGlobalCopyFunction(
   }
 
   Builder.CreateRetVoid();
+  Builder.restoreIP(OldIP);
   return LtGCFunc;
 }
 
 Function *OpenMPIRBuilder::emitListToGlobalReduceFunction(
 ArrayRef ReductionInfos, Function *ReduceFn,
 Type *ReductionsBufferTy, AttributeList FuncAttrs) {
-  IRBuilder<>::InsertPointGuard IPG(Builder);
+  OpenMPIRBuilder::InsertPointTy OldIP = Builder.saveIP();
   LLVMContext &Ctx = M.getContext();
   FunctionType *FuncTy = FunctionType::get(
   Builder.getVoidTy(),
@@ -3145,7 +3143,6 @@ Function *OpenMPIRBuilder::emitListToGlobalReduceFunction(
 
   BasicBlock *EntryBlock = BasicBlock::Create(Ctx, "entry", LtGRFunc);
   Builder.SetInsertPoint(EntryBlock);
-  Builder.SetCurrentDebugLocation(llvm::DebugLoc());
 
   // Buffer: global reduction buffer.
   Argument *BufferArg = LtGRFunc->getArg(0);
@@ -3206,13 +3203,14 @@ Function 
*OpenMPIRBuilder::emitListToGlobalReduceFunction(
   Builder.CreateCall(ReduceFn, {LocalReduceListAddrCast, ReduceList})
   ->addFnAttr(Attribute::NoUnwind);
   Builder.CreateRetVoid();
+  Builder.restoreIP(OldIP);
   return LtGRFunc;
 }
 
 Function *OpenMPIRBuilder::emitGlobalToListCopyFunction(
 ArrayRef ReductionInfos, Type *ReductionsBufferTy,
 AttributeList FuncAttrs) {
-  IRBuilder<>::InsertPointGuard IPG(Builder);
+  OpenMPIRBuilder::InsertPointTy OldIP = Builder.saveIP();
   LLVMContext &Ctx = M.getContext(

[llvm-branch-commits] [NFCI][ELF] Introduce explicit Computed state for DynamicReloc (PR #150799)

2025-07-27 Thread Fangrui Song via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/150799
___
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] [libc] [llvm] [libc][math] Refactor atanf implementation to header-only in src/__support/math folder. (PR #150854)

2025-07-27 Thread Muhammad Bassiouni via llvm-branch-commits

https://github.com/bassiounix created 
https://github.com/llvm/llvm-project/pull/150854

None

>From 19f366d6545cb91b34e5222c2b714abe88103748 Mon Sep 17 00:00:00 2001
From: bassiounix 
Date: Mon, 28 Jul 2025 00:37:42 +0300
Subject: [PATCH] [libc][math] Refactor atanf implementation to header-only in
 src/__support/math folder.

---
 libc/shared/math.h|   1 +
 libc/shared/math/atanf.h  |  23 
 libc/src/__support/math/CMakeLists.txt|  15 ++
 libc/src/__support/math/atanf.h   | 129 ++
 libc/src/math/generic/CMakeLists.txt  |   9 +-
 libc/src/math/generic/atanf.cpp   | 110 +--
 libc/test/shared/CMakeLists.txt   |   1 +
 libc/test/shared/shared_math_test.cpp |   1 +
 .../llvm-project-overlay/libc/BUILD.bazel |  22 ++-
 9 files changed, 188 insertions(+), 123 deletions(-)
 create mode 100644 libc/shared/math/atanf.h
 create mode 100644 libc/src/__support/math/atanf.h

diff --git a/libc/shared/math.h b/libc/shared/math.h
index 70b1b7b0bef09..21536647948f4 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -23,6 +23,7 @@
 #include "math/asinhf.h"
 #include "math/asinhf16.h"
 #include "math/atan.h"
+#include "math/atanf.h"
 #include "math/erff.h"
 #include "math/exp.h"
 #include "math/exp10.h"
diff --git a/libc/shared/math/atanf.h b/libc/shared/math/atanf.h
new file mode 100644
index 0..858d727bd6698
--- /dev/null
+++ b/libc/shared/math/atanf.h
@@ -0,0 +1,23 @@
+//===-- Shared atanf function ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_ATANF_H
+#define LLVM_LIBC_SHARED_MATH_ATANF_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/atanf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::atanf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_ATANF_H
diff --git a/libc/src/__support/math/CMakeLists.txt 
b/libc/src/__support/math/CMakeLists.txt
index cc02920c2a1ef..95acc962cc885 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -199,6 +199,21 @@ DEPENDS
 libc.src.__support.macros.optimization
 )
 
+add_header_library(
+  atanf
+  HDRS
+atanf.h
+  DEPENDS
+.inv_trigf_utils
+libc.src.__support.FPUtil.except_value_utils
+libc.src.__support.FPUtil.fp_bits
+libc.src.__support.FPUtil.multiply_add
+libc.src.__support.FPUtil.nearest_integer
+libc.src.__support.FPUtil.polyeval
+libc.src.__support.FPUtil.rounding_mode
+libc.src.__support.macros.optimization
+)
+
 add_header_library(
   asinf
   HDRS
diff --git a/libc/src/__support/math/atanf.h b/libc/src/__support/math/atanf.h
new file mode 100644
index 0..92799dc8db3cc
--- /dev/null
+++ b/libc/src/__support/math/atanf.h
@@ -0,0 +1,129 @@
+//===-- Implementation header for atanf -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ATANF_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_ATANF_H
+
+#include "inv_trigf_utils.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/PolyEval.h"
+#include "src/__support/FPUtil/except_value_utils.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/FPUtil/nearest_integer.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE static constexpr float atanf(float x) {
+  using namespace inv_trigf_utils_internal;
+  using FPBits = typename fputil::FPBits;
+
+  constexpr double FINAL_SIGN[2] = {1.0, -1.0};
+  constexpr double SIGNED_PI_OVER_2[2] = {0x1.921fb54442d18p0,
+  -0x1.921fb54442d18p0};
+
+  FPBits x_bits(x);
+  Sign sign = x_bits.sign();
+  x_bits.set_sign(Sign::POS);
+  uint32_t x_abs = x_bits.uintval();
+
+  // x is inf or nan, |x| < 2^-4 or |x|= > 16.
+  if (LIBC_UNLIKELY(x_abs <= 0x3d80'U || x_abs >= 0x4180'U)) {
+double x_d = static_cast(x);
+double const_term = 0.0;
+if (LIBC_UNLIKELY(x_abs >= 0x4180')) {
+  // atan(+-Inf) = +-pi/2.
+  if (x_bits.is_inf()) {
+volatile double sign_pi_over_2 = SIGNED_PI_OVER_2[sign.is_neg()];
+return static_cast(sign_pi_over_2);
+  }
+  if (x_bits.is_nan

[llvm-branch-commits] [libc] [llvm] [libc][math] Refactor atanf implementation to header-only in src/__support/math folder. (PR #150854)

2025-07-27 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libc

Author: Muhammad Bassiouni (bassiounix)


Changes

Part of #147386

in preparation for: 
https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450

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


9 Files Affected:

- (modified) libc/shared/math.h (+1) 
- (added) libc/shared/math/atanf.h (+23) 
- (modified) libc/src/__support/math/CMakeLists.txt (+15) 
- (added) libc/src/__support/math/atanf.h (+129) 
- (modified) libc/src/math/generic/CMakeLists.txt (+1-8) 
- (modified) libc/src/math/generic/atanf.cpp (+2-108) 
- (modified) libc/test/shared/CMakeLists.txt (+1) 
- (modified) libc/test/shared/shared_math_test.cpp (+1) 
- (modified) utils/bazel/llvm-project-overlay/libc/BUILD.bazel (+15-7) 


``diff
diff --git a/libc/shared/math.h b/libc/shared/math.h
index 70b1b7b0bef09..21536647948f4 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -23,6 +23,7 @@
 #include "math/asinhf.h"
 #include "math/asinhf16.h"
 #include "math/atan.h"
+#include "math/atanf.h"
 #include "math/erff.h"
 #include "math/exp.h"
 #include "math/exp10.h"
diff --git a/libc/shared/math/atanf.h b/libc/shared/math/atanf.h
new file mode 100644
index 0..858d727bd6698
--- /dev/null
+++ b/libc/shared/math/atanf.h
@@ -0,0 +1,23 @@
+//===-- Shared atanf function ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_ATANF_H
+#define LLVM_LIBC_SHARED_MATH_ATANF_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/atanf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::atanf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_ATANF_H
diff --git a/libc/src/__support/math/CMakeLists.txt 
b/libc/src/__support/math/CMakeLists.txt
index cc02920c2a1ef..95acc962cc885 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -199,6 +199,21 @@ DEPENDS
 libc.src.__support.macros.optimization
 )
 
+add_header_library(
+  atanf
+  HDRS
+atanf.h
+  DEPENDS
+.inv_trigf_utils
+libc.src.__support.FPUtil.except_value_utils
+libc.src.__support.FPUtil.fp_bits
+libc.src.__support.FPUtil.multiply_add
+libc.src.__support.FPUtil.nearest_integer
+libc.src.__support.FPUtil.polyeval
+libc.src.__support.FPUtil.rounding_mode
+libc.src.__support.macros.optimization
+)
+
 add_header_library(
   asinf
   HDRS
diff --git a/libc/src/__support/math/atanf.h b/libc/src/__support/math/atanf.h
new file mode 100644
index 0..92799dc8db3cc
--- /dev/null
+++ b/libc/src/__support/math/atanf.h
@@ -0,0 +1,129 @@
+//===-- Implementation header for atanf -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ATANF_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_ATANF_H
+
+#include "inv_trigf_utils.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/PolyEval.h"
+#include "src/__support/FPUtil/except_value_utils.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/FPUtil/nearest_integer.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE static constexpr float atanf(float x) {
+  using namespace inv_trigf_utils_internal;
+  using FPBits = typename fputil::FPBits;
+
+  constexpr double FINAL_SIGN[2] = {1.0, -1.0};
+  constexpr double SIGNED_PI_OVER_2[2] = {0x1.921fb54442d18p0,
+  -0x1.921fb54442d18p0};
+
+  FPBits x_bits(x);
+  Sign sign = x_bits.sign();
+  x_bits.set_sign(Sign::POS);
+  uint32_t x_abs = x_bits.uintval();
+
+  // x is inf or nan, |x| < 2^-4 or |x|= > 16.
+  if (LIBC_UNLIKELY(x_abs <= 0x3d80'U || x_abs >= 0x4180'U)) {
+double x_d = static_cast(x);
+double const_term = 0.0;
+if (LIBC_UNLIKELY(x_abs >= 0x4180')) {
+  // atan(+-Inf) = +-pi/2.
+  if (x_bits.is_inf()) {
+volatile double sign_pi_over_2 = SIGNED_PI_OVER_2[sign.is_neg()];
+return static_cast(sign_pi_over_2);
+  }
+  if (x_bits.is_nan())
+return x;
+  // x >= 16
+  x_d = -1.0 / x_d;
+  const_term = SIGNED_PI_OVER_2[sign.is_neg()];
+}
+// 0 <= x < 1/16;
+i

[llvm-branch-commits] [libc] [llvm] [libc][math] Refactor atanf implementation to header-only in src/__support/math folder. (PR #150854)

2025-07-27 Thread Muhammad Bassiouni via llvm-branch-commits

bassiounix 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/150854?utm_source=stack-comment-downstack-mergeability-warning";
>  >on Graphite.
> https://graphite.dev/docs/merge-pull-requests";>Learn more

* **#150854** https://app.graphite.dev/github/pr/llvm/llvm-project/150854?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/150854?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#150852** https://app.graphite.dev/github/pr/llvm/llvm-project/150852?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#150849** https://app.graphite.dev/github/pr/llvm/llvm-project/150849?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#150843** https://app.graphite.dev/github/pr/llvm/llvm-project/150843?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/150854
___
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] [libc] [llvm] [libc][math] Refactor atanf implementation to header-only in src/__support/math folder. (PR #150854)

2025-07-27 Thread Muhammad Bassiouni via llvm-branch-commits

https://github.com/bassiounix edited 
https://github.com/llvm/llvm-project/pull/150854
___
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] [libc] [llvm] [libc][math] Refactor atanf implementation to header-only in src/__support/math folder. (PR #150854)

2025-07-27 Thread Muhammad Bassiouni via llvm-branch-commits

https://github.com/bassiounix ready_for_review 
https://github.com/llvm/llvm-project/pull/150854
___
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] [lldb] [PATCH 7/7] [clang] improve NestedNameSpecifier: LLDB changes (PR #149949)

2025-07-27 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/149949

>From ba9b546d750203605af2bb0a955aff157421c834 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Mon, 21 Jul 2025 22:00:01 -0300
Subject: [PATCH] [PATCH 7/7] [clang] improve NestedNameSpecifier: LLDB changes

Patch series starting at https://github.com/llvm/llvm-project/pull/147835
---
 clang/include/clang/AST/QualTypeNames.h   |  10 +
 clang/lib/AST/QualTypeNames.cpp   |   7 +
 .../Clang/ClangASTImporter.cpp|  31 +--
 .../ExpressionParser/Clang/ClangASTSource.cpp |   5 +-
 .../Clang/ClangExpressionDeclMap.cpp  |   4 +-
 .../Clang/ClangPersistentVariables.cpp|   6 +-
 .../Clang/NameSearchContext.cpp   |   2 +-
 .../Plugins/Language/ObjC/NSDictionary.cpp|   3 +-
 .../RegisterTypeBuilderClang.cpp  |   4 +-
 .../SymbolFile/NativePDB/PdbAstBuilder.cpp|  11 +-
 .../Plugins/SymbolFile/PDB/PDBASTParser.cpp   |  11 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 240 +-
 .../TypeSystem/Clang/TypeSystemClang.h|  18 +-
 .../TestDataFormatterStdSharedPtr.py  |   2 +-
 .../string/TestDataFormatterStdString.py  |  41 ++-
 .../TestDataFormatterStdStringView.py |  64 +++--
 .../TestDataFormatterStdUniquePtr.py  |   2 +-
 .../TestClassLoadingViaMemberTypedef.py   |   4 +-
 .../x86/DW_AT_declaration-with-children.s |   4 +-
 .../DWARF/x86/dwp-foreign-type-units.cpp  |   8 +-
 .../DWARF/x86/typedef-in-incomplete-type.cpp  |   2 +-
 .../lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp|   5 +-
 22 files changed, 238 insertions(+), 246 deletions(-)

diff --git a/clang/include/clang/AST/QualTypeNames.h 
b/clang/include/clang/AST/QualTypeNames.h
index daa86cda2d992..9f5cf045d1d4c 100644
--- a/clang/include/clang/AST/QualTypeNames.h
+++ b/clang/include/clang/AST/QualTypeNames.h
@@ -87,6 +87,16 @@ std::string getFullyQualifiedName(QualType QT, const 
ASTContext &Ctx,
 /// specifier "::" should be prepended or not.
 QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx,
bool WithGlobalNsPrefix = false);
+
+/// Get the fully qualified name for the declared context of a declaration.
+///
+/// \param[in] Ctx - the ASTContext to be used.
+/// \param[in] Decl - the declaration for which to get the fully qualified 
name.
+/// \param[in] WithGlobalNsPrefix - If true, then the global namespace
+/// specifier "::" will be prepended to the fully qualified name.
+NestedNameSpecifier
+getFullyQualifiedDeclaredContext(const ASTContext &Ctx, const Decl *Decl,
+ bool WithGlobalNsPrefix = false);
 } // end namespace TypeName
 } // end namespace clang
 #endif // LLVM_CLANG_AST_QUALTYPENAMES_H
diff --git a/clang/lib/AST/QualTypeNames.cpp b/clang/lib/AST/QualTypeNames.cpp
index 319becd8a5a98..086450e790541 100644
--- a/clang/lib/AST/QualTypeNames.cpp
+++ b/clang/lib/AST/QualTypeNames.cpp
@@ -491,5 +491,12 @@ std::string getFullyQualifiedName(QualType QT,
   return FQQT.getAsString(Policy);
 }
 
+NestedNameSpecifier getFullyQualifiedDeclaredContext(const ASTContext &Ctx,
+ const Decl *Decl,
+ bool WithGlobalNsPrefix) {
+  return createNestedNameSpecifierForScopeOf(Ctx, Decl, 
/*FullyQualified=*/true,
+ WithGlobalNsPrefix);
+}
+
 }  // end namespace TypeName
 }  // end namespace clang
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index 2529e78f78bca..7ba8b730c6e9b 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -320,7 +320,8 @@ CompilerType ClangASTImporter::DeportType(TypeSystemClang 
&dst,
   DeclContextOverride decl_context_override;
 
   if (auto *t = ClangUtil::GetQualType(src_type)->getAs())
-decl_context_override.OverrideAllDeclsFromContainingFunction(t->getDecl());
+decl_context_override.OverrideAllDeclsFromContainingFunction(
+t->getOriginalDecl());
 
   CompleteTagDeclsScope complete_scope(*this, &dst.getASTContext(),
&src_ctxt->getASTContext());
@@ -377,8 +378,7 @@ bool ClangASTImporter::CanImport(const CompilerType &type) {
   } break;
 
   case clang::Type::Enum: {
-clang::EnumDecl *enum_decl =
-llvm::cast(qual_type)->getDecl();
+auto *enum_decl = 
llvm::cast(qual_type)->getOriginalDecl();
 if (enum_decl) {
   if (GetDeclOrigin(enum_decl).Valid())
 return true;
@@ -414,12 +414,6 @@ bool ClangASTImporter::CanImport(const CompilerType &type) 
{
   ->getDeducedType()
   .getAsOpaquePtr()));
 
-  case clang::Type::Elaborated:
-return CanI

[llvm-branch-commits] [clang] [lldb] [PATCH 7/7] [clang] improve NestedNameSpecifier: LLDB changes (PR #149949)

2025-07-27 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/149949

>From ea99ebf3ed17456ba5b69ae71766048bae0f02fd Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Mon, 21 Jul 2025 22:00:01 -0300
Subject: [PATCH] [PATCH 7/7] [clang] improve NestedNameSpecifier: LLDB changes

Patch series starting at https://github.com/llvm/llvm-project/pull/147835
---
 clang/include/clang/AST/QualTypeNames.h   |  10 +
 clang/lib/AST/QualTypeNames.cpp   |   7 +
 .../Clang/ClangASTImporter.cpp|  31 +--
 .../ExpressionParser/Clang/ClangASTSource.cpp |   5 +-
 .../Clang/ClangExpressionDeclMap.cpp  |   4 +-
 .../Clang/ClangPersistentVariables.cpp|   6 +-
 .../Clang/NameSearchContext.cpp   |   2 +-
 .../Plugins/Language/ObjC/NSDictionary.cpp|   3 +-
 .../RegisterTypeBuilderClang.cpp  |   4 +-
 .../SymbolFile/NativePDB/PdbAstBuilder.cpp|  11 +-
 .../Plugins/SymbolFile/PDB/PDBASTParser.cpp   |  11 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 240 +-
 .../TypeSystem/Clang/TypeSystemClang.h|  18 +-
 .../TestDataFormatterStdSharedPtr.py  |   2 +-
 .../string/TestDataFormatterStdString.py  |  41 ++-
 .../TestDataFormatterStdStringView.py |  64 +++--
 .../TestDataFormatterStdUniquePtr.py  |   2 +-
 .../TestClassLoadingViaMemberTypedef.py   |   4 +-
 .../x86/DW_AT_declaration-with-children.s |   4 +-
 .../DWARF/x86/dwp-foreign-type-units.cpp  |   8 +-
 .../DWARF/x86/typedef-in-incomplete-type.cpp  |   2 +-
 .../lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp|   5 +-
 22 files changed, 238 insertions(+), 246 deletions(-)

diff --git a/clang/include/clang/AST/QualTypeNames.h 
b/clang/include/clang/AST/QualTypeNames.h
index daa86cda2d992..9f5cf045d1d4c 100644
--- a/clang/include/clang/AST/QualTypeNames.h
+++ b/clang/include/clang/AST/QualTypeNames.h
@@ -87,6 +87,16 @@ std::string getFullyQualifiedName(QualType QT, const 
ASTContext &Ctx,
 /// specifier "::" should be prepended or not.
 QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx,
bool WithGlobalNsPrefix = false);
+
+/// Get the fully qualified name for the declared context of a declaration.
+///
+/// \param[in] Ctx - the ASTContext to be used.
+/// \param[in] Decl - the declaration for which to get the fully qualified 
name.
+/// \param[in] WithGlobalNsPrefix - If true, then the global namespace
+/// specifier "::" will be prepended to the fully qualified name.
+NestedNameSpecifier
+getFullyQualifiedDeclaredContext(const ASTContext &Ctx, const Decl *Decl,
+ bool WithGlobalNsPrefix = false);
 } // end namespace TypeName
 } // end namespace clang
 #endif // LLVM_CLANG_AST_QUALTYPENAMES_H
diff --git a/clang/lib/AST/QualTypeNames.cpp b/clang/lib/AST/QualTypeNames.cpp
index 319becd8a5a98..086450e790541 100644
--- a/clang/lib/AST/QualTypeNames.cpp
+++ b/clang/lib/AST/QualTypeNames.cpp
@@ -491,5 +491,12 @@ std::string getFullyQualifiedName(QualType QT,
   return FQQT.getAsString(Policy);
 }
 
+NestedNameSpecifier getFullyQualifiedDeclaredContext(const ASTContext &Ctx,
+ const Decl *Decl,
+ bool WithGlobalNsPrefix) {
+  return createNestedNameSpecifierForScopeOf(Ctx, Decl, 
/*FullyQualified=*/true,
+ WithGlobalNsPrefix);
+}
+
 }  // end namespace TypeName
 }  // end namespace clang
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index 2529e78f78bca..7ba8b730c6e9b 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -320,7 +320,8 @@ CompilerType ClangASTImporter::DeportType(TypeSystemClang 
&dst,
   DeclContextOverride decl_context_override;
 
   if (auto *t = ClangUtil::GetQualType(src_type)->getAs())
-decl_context_override.OverrideAllDeclsFromContainingFunction(t->getDecl());
+decl_context_override.OverrideAllDeclsFromContainingFunction(
+t->getOriginalDecl());
 
   CompleteTagDeclsScope complete_scope(*this, &dst.getASTContext(),
&src_ctxt->getASTContext());
@@ -377,8 +378,7 @@ bool ClangASTImporter::CanImport(const CompilerType &type) {
   } break;
 
   case clang::Type::Enum: {
-clang::EnumDecl *enum_decl =
-llvm::cast(qual_type)->getDecl();
+auto *enum_decl = 
llvm::cast(qual_type)->getOriginalDecl();
 if (enum_decl) {
   if (GetDeclOrigin(enum_decl).Valid())
 return true;
@@ -414,12 +414,6 @@ bool ClangASTImporter::CanImport(const CompilerType &type) 
{
   ->getDeducedType()
   .getAsOpaquePtr()));
 
-  case clang::Type::Elaborated:
-return CanI

[llvm-branch-commits] [clang] [lldb] [PATCH 7/7] [clang] improve NestedNameSpecifier: LLDB changes (PR #149949)

2025-07-27 Thread via llvm-branch-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- 
clang/include/clang/AST/QualTypeNames.h clang/lib/AST/QualTypeNames.cpp 
lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp 
lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp 
lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp 
lldb/source/Plugins/Language/ObjC/NSDictionary.cpp 
lldb/source/Plugins/RegisterTypeBuilder/RegisterTypeBuilderClang.cpp 
lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp 
lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 
lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp 
lldb/test/Shell/SymbolFile/DWARF/x86/typedef-in-incomplete-type.cpp 
lldb/tools/lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index 86b58eacb..bb633b194 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -288,7 +288,7 @@ public:
Ctx.getTypeDeclType(clang::ElaboratedTypeKeyword::None,
Qualifier, type_decl)
.getAsOpaquePtr());
-  }
+}
 
 return compiler_type;
   }

``




https://github.com/llvm/llvm-project/pull/149949
___
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] [libc] [llvm] [libc][math] Refactor atan implementation to header-only in src/__support/math folder. (PR #150852)

2025-07-27 Thread Muhammad Bassiouni via llvm-branch-commits

https://github.com/bassiounix created 
https://github.com/llvm/llvm-project/pull/150852

None

>From 8f3f2866eb6656784827084b7e1e1922ee0c8a56 Mon Sep 17 00:00:00 2001
From: bassiounix 
Date: Sun, 27 Jul 2025 23:44:37 +0300
Subject: [PATCH] [libc][math] Refactor atan implementation to header-only in
 src/__support/math folder.

---
 libc/shared/math.h|   1 +
 libc/shared/math/atan.h   |  23 +++
 libc/src/__support/math/CMakeLists.txt|  27 +++
 libc/src/__support/math/atan.h| 190 ++
 .../generic => __support/math}/atan_utils.h   |  14 +-
 libc/src/math/generic/CMakeLists.txt  |  25 +--
 libc/src/math/generic/atan.cpp| 167 +--
 libc/src/math/generic/atan2.cpp   |   3 +-
 libc/src/math/generic/atan2f128.cpp   |   3 +-
 libc/test/shared/CMakeLists.txt   |   1 +
 libc/test/shared/shared_math_test.cpp |   1 +
 .../llvm-project-overlay/libc/BUILD.bazel |  44 ++--
 12 files changed, 285 insertions(+), 214 deletions(-)
 create mode 100644 libc/shared/math/atan.h
 create mode 100644 libc/src/__support/math/atan.h
 rename libc/src/{math/generic => __support/math}/atan_utils.h (96%)

diff --git a/libc/shared/math.h b/libc/shared/math.h
index 26e33ecd45d73..70b1b7b0bef09 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -22,6 +22,7 @@
 #include "math/asinf16.h"
 #include "math/asinhf.h"
 #include "math/asinhf16.h"
+#include "math/atan.h"
 #include "math/erff.h"
 #include "math/exp.h"
 #include "math/exp10.h"
diff --git a/libc/shared/math/atan.h b/libc/shared/math/atan.h
new file mode 100644
index 0..b9ba89b7e6225
--- /dev/null
+++ b/libc/shared/math/atan.h
@@ -0,0 +1,23 @@
+//===-- Shared atan function *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_ATAN_H
+#define LLVM_LIBC_SHARED_MATH_ATAN_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/atan.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::atan;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_ATAN_H
diff --git a/libc/src/__support/math/CMakeLists.txt 
b/libc/src/__support/math/CMakeLists.txt
index be208f946024a..cc02920c2a1ef 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -172,6 +172,33 @@ DEPENDS
 libc.src.__support.macros.optimization
 )
 
+add_header_library(
+  atan_utils
+  HDRS
+atan_utils.h
+DEPENDS
+libc.src.__support.integer_literals
+libc.src.__support.FPUtil.double_double
+libc.src.__support.FPUtil.dyadic_float
+libc.src.__support.FPUtil.multiply_add
+libc.src.__support.FPUtil.polyeval
+libc.src.__support.macros.optimization
+)
+
+add_header_library(
+  atan
+  HDRS
+atan.h
+DEPENDS
+.atan_utils
+libc.src.__support.FPUtil.double_double
+libc.src.__support.FPUtil.fenv_impl
+libc.src.__support.FPUtil.fp_bits
+libc.src.__support.FPUtil.multiply_add
+libc.src.__support.FPUtil.nearest_integer
+libc.src.__support.macros.optimization
+)
+
 add_header_library(
   asinf
   HDRS
diff --git a/libc/src/__support/math/atan.h b/libc/src/__support/math/atan.h
new file mode 100644
index 0..4f42b2948aea8
--- /dev/null
+++ b/libc/src/__support/math/atan.h
@@ -0,0 +1,190 @@
+//===-- Implementation header for atan --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ATAN_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_ATAN_H
+
+#include "atan_utils.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/double_double.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/FPUtil/nearest_integer.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+// To compute atan(x), we divided it into the following cases:
+// * |x| < 2^-26:
+//  Since |x| > atan(|x|) > |x| - |x|^3/3, and |x|^3/3 < ulp(x)/2, we 
simply
+//  return atan(x) = x - sign(x) * epsilon.
+// * 2^-26 <= |x| < 1:
+//  We perform range reduction mod 2^-6 = 1/64 as follow:
+//  Let k = 2^(-6) * round(|x| * 2^6), then
+//atan(x) = sign(x) * atan(|x|)
+//   

[llvm-branch-commits] [libc] [llvm] [libc][math] Refactor atan implementation to header-only in src/__support/math folder. (PR #150852)

2025-07-27 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libc

Author: Muhammad Bassiouni (bassiounix)


Changes

Part of #147386

in preparation for: 
https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450

---

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


12 Files Affected:

- (modified) libc/shared/math.h (+1) 
- (added) libc/shared/math/atan.h (+23) 
- (modified) libc/src/__support/math/CMakeLists.txt (+27) 
- (added) libc/src/__support/math/atan.h (+190) 
- (renamed) libc/src/__support/math/atan_utils.h (+7-7) 
- (modified) libc/src/math/generic/CMakeLists.txt (+3-22) 
- (modified) libc/src/math/generic/atan.cpp (+2-165) 
- (modified) libc/src/math/generic/atan2.cpp (+2-1) 
- (modified) libc/src/math/generic/atan2f128.cpp (+2-1) 
- (modified) libc/test/shared/CMakeLists.txt (+1) 
- (modified) libc/test/shared/shared_math_test.cpp (+1) 
- (modified) utils/bazel/llvm-project-overlay/libc/BUILD.bazel (+26-18) 


``diff
diff --git a/libc/shared/math.h b/libc/shared/math.h
index 26e33ecd45d73..70b1b7b0bef09 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -22,6 +22,7 @@
 #include "math/asinf16.h"
 #include "math/asinhf.h"
 #include "math/asinhf16.h"
+#include "math/atan.h"
 #include "math/erff.h"
 #include "math/exp.h"
 #include "math/exp10.h"
diff --git a/libc/shared/math/atan.h b/libc/shared/math/atan.h
new file mode 100644
index 0..b9ba89b7e6225
--- /dev/null
+++ b/libc/shared/math/atan.h
@@ -0,0 +1,23 @@
+//===-- Shared atan function *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_ATAN_H
+#define LLVM_LIBC_SHARED_MATH_ATAN_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/atan.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::atan;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_ATAN_H
diff --git a/libc/src/__support/math/CMakeLists.txt 
b/libc/src/__support/math/CMakeLists.txt
index be208f946024a..cc02920c2a1ef 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -172,6 +172,33 @@ DEPENDS
 libc.src.__support.macros.optimization
 )
 
+add_header_library(
+  atan_utils
+  HDRS
+atan_utils.h
+DEPENDS
+libc.src.__support.integer_literals
+libc.src.__support.FPUtil.double_double
+libc.src.__support.FPUtil.dyadic_float
+libc.src.__support.FPUtil.multiply_add
+libc.src.__support.FPUtil.polyeval
+libc.src.__support.macros.optimization
+)
+
+add_header_library(
+  atan
+  HDRS
+atan.h
+DEPENDS
+.atan_utils
+libc.src.__support.FPUtil.double_double
+libc.src.__support.FPUtil.fenv_impl
+libc.src.__support.FPUtil.fp_bits
+libc.src.__support.FPUtil.multiply_add
+libc.src.__support.FPUtil.nearest_integer
+libc.src.__support.macros.optimization
+)
+
 add_header_library(
   asinf
   HDRS
diff --git a/libc/src/__support/math/atan.h b/libc/src/__support/math/atan.h
new file mode 100644
index 0..4f42b2948aea8
--- /dev/null
+++ b/libc/src/__support/math/atan.h
@@ -0,0 +1,190 @@
+//===-- Implementation header for atan --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ATAN_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_ATAN_H
+
+#include "atan_utils.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/double_double.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/FPUtil/nearest_integer.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+// To compute atan(x), we divided it into the following cases:
+// * |x| < 2^-26:
+//  Since |x| > atan(|x|) > |x| - |x|^3/3, and |x|^3/3 < ulp(x)/2, we 
simply
+//  return atan(x) = x - sign(x) * epsilon.
+// * 2^-26 <= |x| < 1:
+//  We perform range reduction mod 2^-6 = 1/64 as follow:
+//  Let k = 2^(-6) * round(|x| * 2^6), then
+//atan(x) = sign(x) * atan(|x|)
+//= sign(x) * (atan(k) + atan((|x| - k) / (1 + |x|*k)).
+//  We store atan(k) in a look up table, and perform intermediate steps in
+//  double-double.
+//

[llvm-branch-commits] [libc] [llvm] [libc][math] Refactor atan implementation to header-only in src/__support/math folder. (PR #150852)

2025-07-27 Thread via llvm-branch-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- 
libc/shared/math/atan.h libc/src/__support/math/atan.h libc/shared/math.h 
libc/src/math/generic/atan.cpp libc/src/math/generic/atan2.cpp 
libc/src/math/generic/atan2f128.cpp libc/test/shared/shared_math_test.cpp 
libc/src/__support/math/atan_utils.h
``





View the diff from clang-format here.


``diff
diff --git a/libc/src/__support/math/atan.h b/libc/src/__support/math/atan.h
index 4f42b2948..62190b092 100644
--- a/libc/src/__support/math/atan.h
+++ b/libc/src/__support/math/atan.h
@@ -180,7 +180,6 @@ LIBC_INLINE static constexpr double atan(double x) {
 
   return r;
 #endif
-
 }
 
 } // namespace math
diff --git a/libc/src/__support/math/atan_utils.h 
b/libc/src/__support/math/atan_utils.h
index 95613d38c..9e8d7d656 100644
--- a/libc/src/__support/math/atan_utils.h
+++ b/libc/src/__support/math/atan_utils.h
@@ -110,7 +110,8 @@ static constexpr DoubleDouble ATAN_I[65] = {
 //+ x_lo * (1 - x_hi^2 + x_hi^4)
 // Since p.lo is ~ x^3/3, the relative error from rounding is bounded by:
 //   |(atan(x) - P(x))/atan(x)| < ulp(x^2) <= 2^(-14-52) = 2^-66.
-[[maybe_unused]] LIBC_INLINE static DoubleDouble atan_eval(const DoubleDouble 
&x) {
+[[maybe_unused]] LIBC_INLINE static DoubleDouble
+atan_eval(const DoubleDouble &x) {
   DoubleDouble p;
   p.hi = x.hi;
   double x_hi_sq = x.hi * x.hi;
@@ -225,7 +226,8 @@ static constexpr Float128 ATAN_POLY_F128[] = {
 };
 
 // Approximate atan for |x| <= 2^-7.
-[[maybe_unused]] LIBC_INLINE static constexpr Float128 atan_eval(const 
Float128 &x) {
+[[maybe_unused]] LIBC_INLINE static constexpr Float128
+atan_eval(const Float128 &x) {
   Float128 x_sq = fputil::quick_mul(x, x);
   Float128 x3 = fputil::quick_mul(x, x_sq);
   Float128 p = fputil::polyeval(x_sq, ATAN_POLY_F128[0], ATAN_POLY_F128[1],
diff --git a/libc/src/math/generic/atan2.cpp b/libc/src/math/generic/atan2.cpp
index f60c30fc2..58042d3bc 100644
--- a/libc/src/math/generic/atan2.cpp
+++ b/libc/src/math/generic/atan2.cpp
@@ -7,7 +7,6 @@
 
//===--===//
 
 #include "src/math/atan2.h"
-#include "src/__support/math/atan_utils.h"
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/FPUtil/double_double.h"
@@ -15,6 +14,7 @@
 #include "src/__support/FPUtil/nearest_integer.h"
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+#include "src/__support/math/atan_utils.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
diff --git a/libc/src/math/generic/atan2f128.cpp 
b/libc/src/math/generic/atan2f128.cpp
index a3e0dbf21..8838d94c2 100644
--- a/libc/src/math/generic/atan2f128.cpp
+++ b/libc/src/math/generic/atan2f128.cpp
@@ -7,7 +7,6 @@
 
//===--===//
 
 #include "src/math/atan2f128.h"
-#include "src/__support/math/atan_utils.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/FPUtil/dyadic_float.h"
 #include "src/__support/FPUtil/multiply_add.h"
@@ -16,6 +15,7 @@
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 #include "src/__support/macros/properties/types.h"
+#include "src/__support/math/atan_utils.h"
 #include "src/__support/uint128.h"
 
 namespace LIBC_NAMESPACE_DECL {

``




https://github.com/llvm/llvm-project/pull/150852
___
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] [libc] [llvm] [libc][math] Refactor atan implementation to header-only in src/__support/math folder. (PR #150852)

2025-07-27 Thread Muhammad Bassiouni via llvm-branch-commits

https://github.com/bassiounix edited 
https://github.com/llvm/llvm-project/pull/150852
___
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] [libc] [llvm] [libc][math] Refactor atan implementation to header-only in src/__support/math folder. (PR #150852)

2025-07-27 Thread Muhammad Bassiouni via llvm-branch-commits

https://github.com/bassiounix ready_for_review 
https://github.com/llvm/llvm-project/pull/150852
___
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] [libc] [llvm] [libc][math] Refactor atan implementation to header-only in src/__support/math folder. (PR #150852)

2025-07-27 Thread Muhammad Bassiouni via llvm-branch-commits

bassiounix 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/150852?utm_source=stack-comment-downstack-mergeability-warning";
>  >on Graphite.
> https://graphite.dev/docs/merge-pull-requests";>Learn more

* **#150852** https://app.graphite.dev/github/pr/llvm/llvm-project/150852?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/150852?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#150849** https://app.graphite.dev/github/pr/llvm/llvm-project/150849?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#150843** https://app.graphite.dev/github/pr/llvm/llvm-project/150843?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/150852
___
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] [libc] [llvm] [libc][math] Refactor atan implementation to header-only in src/__support/math folder. (PR #150852)

2025-07-27 Thread Muhammad Bassiouni via llvm-branch-commits

https://github.com/bassiounix updated 
https://github.com/llvm/llvm-project/pull/150852

>From 743428ec2ac87dd01da07be4a47199b7cbbec156 Mon Sep 17 00:00:00 2001
From: bassiounix 
Date: Sun, 27 Jul 2025 23:44:37 +0300
Subject: [PATCH] [libc][math] Refactor atan implementation to header-only in
 src/__support/math folder.

---
 libc/shared/math.h|   1 +
 libc/shared/math/atan.h   |  23 +++
 libc/src/__support/math/CMakeLists.txt|  27 +++
 libc/src/__support/math/atan.h| 189 ++
 .../generic => __support/math}/atan_utils.h   |  16 +-
 libc/src/math/generic/CMakeLists.txt  |  25 +--
 libc/src/math/generic/atan.cpp| 167 +---
 libc/src/math/generic/atan2.cpp   |   3 +-
 libc/src/math/generic/atan2f128.cpp   |   3 +-
 libc/test/shared/CMakeLists.txt   |   1 +
 libc/test/shared/shared_math_test.cpp |   1 +
 .../llvm-project-overlay/libc/BUILD.bazel |  44 ++--
 12 files changed, 286 insertions(+), 214 deletions(-)
 create mode 100644 libc/shared/math/atan.h
 create mode 100644 libc/src/__support/math/atan.h
 rename libc/src/{math/generic => __support/math}/atan_utils.h (96%)

diff --git a/libc/shared/math.h b/libc/shared/math.h
index 26e33ecd45d73..70b1b7b0bef09 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -22,6 +22,7 @@
 #include "math/asinf16.h"
 #include "math/asinhf.h"
 #include "math/asinhf16.h"
+#include "math/atan.h"
 #include "math/erff.h"
 #include "math/exp.h"
 #include "math/exp10.h"
diff --git a/libc/shared/math/atan.h b/libc/shared/math/atan.h
new file mode 100644
index 0..b9ba89b7e6225
--- /dev/null
+++ b/libc/shared/math/atan.h
@@ -0,0 +1,23 @@
+//===-- Shared atan function *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_ATAN_H
+#define LLVM_LIBC_SHARED_MATH_ATAN_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/atan.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::atan;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_ATAN_H
diff --git a/libc/src/__support/math/CMakeLists.txt 
b/libc/src/__support/math/CMakeLists.txt
index be208f946024a..cc02920c2a1ef 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -172,6 +172,33 @@ DEPENDS
 libc.src.__support.macros.optimization
 )
 
+add_header_library(
+  atan_utils
+  HDRS
+atan_utils.h
+DEPENDS
+libc.src.__support.integer_literals
+libc.src.__support.FPUtil.double_double
+libc.src.__support.FPUtil.dyadic_float
+libc.src.__support.FPUtil.multiply_add
+libc.src.__support.FPUtil.polyeval
+libc.src.__support.macros.optimization
+)
+
+add_header_library(
+  atan
+  HDRS
+atan.h
+DEPENDS
+.atan_utils
+libc.src.__support.FPUtil.double_double
+libc.src.__support.FPUtil.fenv_impl
+libc.src.__support.FPUtil.fp_bits
+libc.src.__support.FPUtil.multiply_add
+libc.src.__support.FPUtil.nearest_integer
+libc.src.__support.macros.optimization
+)
+
 add_header_library(
   asinf
   HDRS
diff --git a/libc/src/__support/math/atan.h b/libc/src/__support/math/atan.h
new file mode 100644
index 0..62190b092429a
--- /dev/null
+++ b/libc/src/__support/math/atan.h
@@ -0,0 +1,189 @@
+//===-- Implementation header for atan --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ATAN_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_ATAN_H
+
+#include "atan_utils.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/double_double.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/FPUtil/nearest_integer.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+// To compute atan(x), we divided it into the following cases:
+// * |x| < 2^-26:
+//  Since |x| > atan(|x|) > |x| - |x|^3/3, and |x|^3/3 < ulp(x)/2, we 
simply
+//  return atan(x) = x - sign(x) * epsilon.
+// * 2^-26 <= |x| < 1:
+//  We perform range reduction mod 2^-6 = 1/64 as follow:
+//  Let k = 2^(-6) * round(|x| * 2^6), then
+//atan(x) = sign(x) * atan(|x|)
+//

[llvm-branch-commits] [llvm] [DataLayout][LangRef] Split non-integral and unstable pointer properties (PR #105735)

2025-07-27 Thread Alexander Richardson via llvm-branch-commits

https://github.com/arichardson updated 
https://github.com/llvm/llvm-project/pull/105735

>From e4bd1181d160b8728e7d4158417a83e183bd1709 Mon Sep 17 00:00:00 2001
From: Alex Richardson 
Date: Thu, 22 Aug 2024 14:36:04 -0700
Subject: [PATCH 1/5] fix indentation in langref

Created using spr 1.3.6-beta.1
---
 llvm/docs/LangRef.rst | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 200224c78be00..1a59fba65815c 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -3103,19 +3103,19 @@ as follows:
 ``A``
 Specifies the address space of objects created by '``alloca``'.
 Defaults to the default address space of 0.
-``p[][n]::[:][:]``
+``p[][]::[:][:]``
 This specifies the *size* of a pointer and its  and
 \erred alignments for address space ``n``.  is optional
 and defaults to . The fourth parameter  is the size of 
the
 index that used for address calculation, which must be less than or equal
 to the pointer size. If not
 specified, the default index size is equal to the pointer size. All sizes
-are in bits. The address space, ``n``, is optional, and if not specified,
-denotes the default address space 0. The value of ``n`` must be
-in the range [1,2^24).
+are in bits. The , is optional, and if not specified,
+denotes the default address space 0. The value of  must
+be in the range [1,2^24).
 The optional are used to specify properties of pointers in this
-address space: the character ``u`` marks pointers as having an unstable
-representation and ```n`` marks pointers as non-integral (i.e. having
+address space: the character ``u`` marks pointers as having an unstable
+representation and ``n`` marks pointers as non-integral (i.e. having
 additional metadata). See :ref:`Non-Integral Pointer Types `.
 
 ``i:[:]``

>From db97145d3a653f2999b5935f9b1cb4550230689d Mon Sep 17 00:00:00 2001
From: Alex Richardson 
Date: Fri, 25 Oct 2024 12:51:11 -0700
Subject: [PATCH 2/5] include feedback

Created using spr 1.3.6-beta.1
---
 llvm/docs/LangRef.rst | 30 +-
 llvm/include/llvm/IR/DataLayout.h |  8 
 2 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index c137318af678b..3c3d0e0b4ab8e 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -659,7 +659,7 @@ LLVM IR optionally allows the frontend to denote pointers 
in certain address
 spaces as "non-integral" or "unstable" (or both "non-integral" and "unstable")
 via the :ref:`datalayout string`.
 
-These exact implications of these properties are target-specific, but the
+The exact implications of these properties are target-specific, but the
 following IR semantics and restrictions to optimization passes apply:
 
 Unstable pointer representation
@@ -668,7 +668,7 @@ Unstable pointer representation
 Pointers in this address space have an *unspecified* bitwise representation
 (i.e. not backed by a fixed integer). The bitwise pattern of such pointers is
 allowed to change in a target-specific way. For example, this could be a 
pointer
-type used for with copying garbage collection where the garbage collector could
+type used with copying garbage collection where the garbage collector could
 update the pointer at any time in the collection sweep.
 
 ``inttoptr`` and ``ptrtoint`` instructions have the same semantics as for
@@ -705,10 +705,10 @@ representation of the pointer.
 Non-integral pointer representation
 ^^^
 
-Pointers are not represented as an address, but may instead include
+Pointers are not represented as just an address, but may instead include
 additional metadata such as bounds information or a temporal identifier.
 Examples include AMDGPU buffer descriptors with a 128-bit fat pointer and a
-32-bit offset or CHERI capabilities that contain bounds, permissions and an
+32-bit offset, or CHERI capabilities that contain bounds, permissions and an
 out-of-band validity bit. In general, these pointers cannot be re-created
 from just an integer value.
 
@@ -716,23 +716,25 @@ In most cases pointers with a non-integral representation 
behave exactly the
 same as an integral pointer, the only difference is that it is not possible to
 create a pointer just from an address.
 
-"Non-integral" pointers also impose restrictions on the optimizer, but in
-general these are less restrictive than for "unstable" pointers. The main
+"Non-integral" pointers also impose restrictions on transformation passes, but
+in general these are less restrictive than for "unstable" pointers. The main
 difference compared to integral pointers is that ``inttoptr`` instructions
 should not be inserted by passes as they may not be able to create a valid
 pointer. This property also means that ``inttoptr(ptrtoint(x))`` cannot be
 folded to ``x`` as the ``ptrt

[llvm-branch-commits] [llvm] [DataLayout][LangRef] Split non-integral and unstable pointer properties (PR #105735)

2025-07-27 Thread Alexander Richardson via llvm-branch-commits


@@ -650,48 +650,136 @@ literal types are uniqued in recent versions of LLVM.
 
 .. _nointptrtype:
 
-Non-Integral Pointer Type
--
+Non-Integral and Unstable Pointer Types
+---
 
-Note: non-integral pointer types are a work in progress, and they should be
-considered experimental at this time.
+Note: non-integral/unstable pointer types are a work in progress, and they
+should be considered experimental at this time.
 
 LLVM IR optionally allows the frontend to denote pointers in certain address
-spaces as "non-integral" via the :ref:`datalayout string`.
-Non-integral pointer types represent pointers that have an *unspecified* 
bitwise
-representation; that is, the integral representation may be target dependent or
-unstable (not backed by a fixed integer).
+spaces as "unstable", "non-integral", or "non-integral with external state"
+(or combinations of these) via the :ref:`datalayout 
string`.
+
+The exact implications of these properties are target-specific, but the
+following IR semantics and restrictions to optimization passes apply:
+
+Unstable pointer representation
+^^^
+
+Pointers in this address space have an *unspecified* bitwise representation
+(i.e. not backed by a fixed integer). The bitwise pattern of such pointers is
+allowed to change in a target-specific way. For example, this could be a 
pointer
+type used with copying garbage collection where the garbage collector could
+update the pointer at any time in the collection sweep.
 
 ``inttoptr`` and ``ptrtoint`` instructions have the same semantics as for
 integral (i.e. normal) pointers in that they convert integers to and from
-corresponding pointer types, but there are additional implications to be
-aware of.  Because the bit-representation of a non-integral pointer may
-not be stable, two identical casts of the same operand may or may not
+corresponding pointer types, but there are additional implications to be aware
+of.
+
+For "unstable" pointer representations, the bit-representation of the pointer
+may not be stable, so two identical casts of the same operand may or may not
 return the same value.  Said differently, the conversion to or from the
-non-integral type depends on environmental state in an implementation
+"unstable" pointer type depends on environmental state in an implementation
 defined manner.
-
 If the frontend wishes to observe a *particular* value following a cast, the
 generated IR must fence with the underlying environment in an implementation
 defined manner. (In practice, this tends to require ``noinline`` routines for
 such operations.)
 
 From the perspective of the optimizer, ``inttoptr`` and ``ptrtoint`` for
-non-integral types are analogous to ones on integral types with one
+"unstable" pointer types are analogous to ones on integral types with one
 key exception: the optimizer may not, in general, insert new dynamic
 occurrences of such casts.  If a new cast is inserted, the optimizer would
 need to either ensure that a) all possible values are valid, or b)
 appropriate fencing is inserted.  Since the appropriate fencing is
 implementation defined, the optimizer can't do the latter.  The former is
 challenging as many commonly expected properties, such as
-``ptrtoint(v)-ptrtoint(v) == 0``, don't hold for non-integral types.
+``ptrtoint(v)-ptrtoint(v) == 0``, don't hold for "unstable" pointer types.
 Similar restrictions apply to intrinsics that might examine the pointer bits,
 such as :ref:`llvm.ptrmask`.
 
-The alignment information provided by the frontend for a non-integral pointer
+The alignment information provided by the frontend for an "unstable" pointer
 (typically using attributes or metadata) must be valid for every possible
 representation of the pointer.
 
+Non-integral pointer representation
+^^^
+
+Pointers are not represented as just an address, but may instead include
+additional metadata such as bounds information or a temporal identifier.
+Examples include AMDGPU buffer descriptors with a 128-bit fat pointer and a
+32-bit offset, or CHERI capabilities that contain bounds, permissions and a
+type field (as well as an out-of-band validity bit, see next section).
+
+In most cases pointers with a non-integral representation behave exactly the
+same as an integral pointer, the only difference is that it is not possible to
+create a pointer just from an address unless all the metadata bits were
+also recreated correctly.
+
+"Non-integral" pointers also impose restrictions on transformation passes, but
+in general these are less restrictive than for "unstable" pointers. The main
+difference compared to integral pointers is that the address width of a
+non-integral pointer is not equal to the bitwise representation, so extracting
+the address needs to truncate to the index width of the pointer.
+
+Note: Currently all supported targets require that truncating the `

[llvm-branch-commits] [libc] [llvm] [libc][math] Refactor atan implementation to header-only in src/__support/math folder. (PR #150852)

2025-07-27 Thread Muhammad Bassiouni via llvm-branch-commits

https://github.com/bassiounix updated 
https://github.com/llvm/llvm-project/pull/150852

>From da6cf0f3700bcc5442c672800540ea4d68424b24 Mon Sep 17 00:00:00 2001
From: bassiounix 
Date: Sun, 27 Jul 2025 23:44:37 +0300
Subject: [PATCH] [libc][math] Refactor atan implementation to header-only in
 src/__support/math folder.

---
 libc/shared/math.h|   1 +
 libc/shared/math/atan.h   |  23 +++
 libc/src/__support/math/CMakeLists.txt|  27 +++
 libc/src/__support/math/atan.h| 189 ++
 .../generic => __support/math}/atan_utils.h   |  16 +-
 libc/src/math/generic/CMakeLists.txt  |  25 +--
 libc/src/math/generic/atan.cpp| 167 +---
 libc/src/math/generic/atan2.cpp   |   3 +-
 libc/src/math/generic/atan2f128.cpp   |   3 +-
 libc/test/shared/CMakeLists.txt   |   1 +
 libc/test/shared/shared_math_test.cpp |   1 +
 .../llvm-project-overlay/libc/BUILD.bazel |  44 ++--
 12 files changed, 286 insertions(+), 214 deletions(-)
 create mode 100644 libc/shared/math/atan.h
 create mode 100644 libc/src/__support/math/atan.h
 rename libc/src/{math/generic => __support/math}/atan_utils.h (96%)

diff --git a/libc/shared/math.h b/libc/shared/math.h
index 26e33ecd45d73..70b1b7b0bef09 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -22,6 +22,7 @@
 #include "math/asinf16.h"
 #include "math/asinhf.h"
 #include "math/asinhf16.h"
+#include "math/atan.h"
 #include "math/erff.h"
 #include "math/exp.h"
 #include "math/exp10.h"
diff --git a/libc/shared/math/atan.h b/libc/shared/math/atan.h
new file mode 100644
index 0..b9ba89b7e6225
--- /dev/null
+++ b/libc/shared/math/atan.h
@@ -0,0 +1,23 @@
+//===-- Shared atan function *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_ATAN_H
+#define LLVM_LIBC_SHARED_MATH_ATAN_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/atan.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::atan;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_ATAN_H
diff --git a/libc/src/__support/math/CMakeLists.txt 
b/libc/src/__support/math/CMakeLists.txt
index be208f946024a..cc02920c2a1ef 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -172,6 +172,33 @@ DEPENDS
 libc.src.__support.macros.optimization
 )
 
+add_header_library(
+  atan_utils
+  HDRS
+atan_utils.h
+DEPENDS
+libc.src.__support.integer_literals
+libc.src.__support.FPUtil.double_double
+libc.src.__support.FPUtil.dyadic_float
+libc.src.__support.FPUtil.multiply_add
+libc.src.__support.FPUtil.polyeval
+libc.src.__support.macros.optimization
+)
+
+add_header_library(
+  atan
+  HDRS
+atan.h
+DEPENDS
+.atan_utils
+libc.src.__support.FPUtil.double_double
+libc.src.__support.FPUtil.fenv_impl
+libc.src.__support.FPUtil.fp_bits
+libc.src.__support.FPUtil.multiply_add
+libc.src.__support.FPUtil.nearest_integer
+libc.src.__support.macros.optimization
+)
+
 add_header_library(
   asinf
   HDRS
diff --git a/libc/src/__support/math/atan.h b/libc/src/__support/math/atan.h
new file mode 100644
index 0..62190b092429a
--- /dev/null
+++ b/libc/src/__support/math/atan.h
@@ -0,0 +1,189 @@
+//===-- Implementation header for atan --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ATAN_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_ATAN_H
+
+#include "atan_utils.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/double_double.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/FPUtil/nearest_integer.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+// To compute atan(x), we divided it into the following cases:
+// * |x| < 2^-26:
+//  Since |x| > atan(|x|) > |x| - |x|^3/3, and |x|^3/3 < ulp(x)/2, we 
simply
+//  return atan(x) = x - sign(x) * epsilon.
+// * 2^-26 <= |x| < 1:
+//  We perform range reduction mod 2^-6 = 1/64 as follow:
+//  Let k = 2^(-6) * round(|x| * 2^6), then
+//atan(x) = sign(x) * atan(|x|)
+//

[llvm-branch-commits] [libc] [llvm] [libc][math] Refactor atan implementation to header-only in src/__support/math folder. (PR #150852)

2025-07-27 Thread Muhammad Bassiouni via llvm-branch-commits

https://github.com/bassiounix updated 
https://github.com/llvm/llvm-project/pull/150852

>From da6cf0f3700bcc5442c672800540ea4d68424b24 Mon Sep 17 00:00:00 2001
From: bassiounix 
Date: Sun, 27 Jul 2025 23:44:37 +0300
Subject: [PATCH] [libc][math] Refactor atan implementation to header-only in
 src/__support/math folder.

---
 libc/shared/math.h|   1 +
 libc/shared/math/atan.h   |  23 +++
 libc/src/__support/math/CMakeLists.txt|  27 +++
 libc/src/__support/math/atan.h| 189 ++
 .../generic => __support/math}/atan_utils.h   |  16 +-
 libc/src/math/generic/CMakeLists.txt  |  25 +--
 libc/src/math/generic/atan.cpp| 167 +---
 libc/src/math/generic/atan2.cpp   |   3 +-
 libc/src/math/generic/atan2f128.cpp   |   3 +-
 libc/test/shared/CMakeLists.txt   |   1 +
 libc/test/shared/shared_math_test.cpp |   1 +
 .../llvm-project-overlay/libc/BUILD.bazel |  44 ++--
 12 files changed, 286 insertions(+), 214 deletions(-)
 create mode 100644 libc/shared/math/atan.h
 create mode 100644 libc/src/__support/math/atan.h
 rename libc/src/{math/generic => __support/math}/atan_utils.h (96%)

diff --git a/libc/shared/math.h b/libc/shared/math.h
index 26e33ecd45d73..70b1b7b0bef09 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -22,6 +22,7 @@
 #include "math/asinf16.h"
 #include "math/asinhf.h"
 #include "math/asinhf16.h"
+#include "math/atan.h"
 #include "math/erff.h"
 #include "math/exp.h"
 #include "math/exp10.h"
diff --git a/libc/shared/math/atan.h b/libc/shared/math/atan.h
new file mode 100644
index 0..b9ba89b7e6225
--- /dev/null
+++ b/libc/shared/math/atan.h
@@ -0,0 +1,23 @@
+//===-- Shared atan function *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_ATAN_H
+#define LLVM_LIBC_SHARED_MATH_ATAN_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/atan.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::atan;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_ATAN_H
diff --git a/libc/src/__support/math/CMakeLists.txt 
b/libc/src/__support/math/CMakeLists.txt
index be208f946024a..cc02920c2a1ef 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -172,6 +172,33 @@ DEPENDS
 libc.src.__support.macros.optimization
 )
 
+add_header_library(
+  atan_utils
+  HDRS
+atan_utils.h
+DEPENDS
+libc.src.__support.integer_literals
+libc.src.__support.FPUtil.double_double
+libc.src.__support.FPUtil.dyadic_float
+libc.src.__support.FPUtil.multiply_add
+libc.src.__support.FPUtil.polyeval
+libc.src.__support.macros.optimization
+)
+
+add_header_library(
+  atan
+  HDRS
+atan.h
+DEPENDS
+.atan_utils
+libc.src.__support.FPUtil.double_double
+libc.src.__support.FPUtil.fenv_impl
+libc.src.__support.FPUtil.fp_bits
+libc.src.__support.FPUtil.multiply_add
+libc.src.__support.FPUtil.nearest_integer
+libc.src.__support.macros.optimization
+)
+
 add_header_library(
   asinf
   HDRS
diff --git a/libc/src/__support/math/atan.h b/libc/src/__support/math/atan.h
new file mode 100644
index 0..62190b092429a
--- /dev/null
+++ b/libc/src/__support/math/atan.h
@@ -0,0 +1,189 @@
+//===-- Implementation header for atan --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ATAN_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_ATAN_H
+
+#include "atan_utils.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/double_double.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/FPUtil/nearest_integer.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+// To compute atan(x), we divided it into the following cases:
+// * |x| < 2^-26:
+//  Since |x| > atan(|x|) > |x| - |x|^3/3, and |x|^3/3 < ulp(x)/2, we 
simply
+//  return atan(x) = x - sign(x) * epsilon.
+// * 2^-26 <= |x| < 1:
+//  We perform range reduction mod 2^-6 = 1/64 as follow:
+//  Let k = 2^(-6) * round(|x| * 2^6), then
+//atan(x) = sign(x) * atan(|x|)
+//

[llvm-branch-commits] [libc] [llvm] [libc][math] Refactor asinhf16 implementation to header-only in src/__support/math folder. (PR #150849)

2025-07-27 Thread Muhammad Bassiouni via llvm-branch-commits

https://github.com/bassiounix updated 
https://github.com/llvm/llvm-project/pull/150849

>From 7be3b70ef8d3c8f39006dbee302fe5291491cb77 Mon Sep 17 00:00:00 2001
From: bassiounix 
Date: Sun, 27 Jul 2025 22:21:00 +0300
Subject: [PATCH 1/2] [libc][math] Refactor asinhf16 implementation to
 header-only in src/__support/math folder.

---
 libc/shared/math.h|   1 +
 libc/shared/math/asinf16.h|   2 +-
 libc/shared/math/asinhf16.h   |  28 
 libc/src/__support/math/CMakeLists.txt|  18 +++
 libc/src/__support/math/asinhf16.h| 123 ++
 libc/src/math/generic/CMakeLists.txt  |  13 +-
 libc/src/math/generic/asinhf16.cpp|  96 +-
 libc/test/shared/CMakeLists.txt   |   1 +
 libc/test/shared/shared_math_test.cpp |   1 +
 .../llvm-project-overlay/libc/BUILD.bazel |  25 
 10 files changed, 201 insertions(+), 107 deletions(-)
 create mode 100644 libc/shared/math/asinhf16.h
 create mode 100644 libc/src/__support/math/asinhf16.h

diff --git a/libc/shared/math.h b/libc/shared/math.h
index e0f00f52e9dc3..26e33ecd45d73 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -21,6 +21,7 @@
 #include "math/asinf.h"
 #include "math/asinf16.h"
 #include "math/asinhf.h"
+#include "math/asinhf16.h"
 #include "math/erff.h"
 #include "math/exp.h"
 #include "math/exp10.h"
diff --git a/libc/shared/math/asinf16.h b/libc/shared/math/asinf16.h
index d545e269a6402..af5b2ec179233 100644
--- a/libc/shared/math/asinf16.h
+++ b/libc/shared/math/asinf16.h
@@ -25,4 +25,4 @@ using math::asinf16;
 
 #endif // LIBC_TYPES_HAS_FLOAT16
 
-#endif // LLVM_LIBC_SHARED_MATH_ASINF_H
+#endif // LLVM_LIBC_SHARED_MATH_ASINF16_H
diff --git a/libc/shared/math/asinhf16.h b/libc/shared/math/asinhf16.h
new file mode 100644
index 0..1a0525b6a9b8b
--- /dev/null
+++ b/libc/shared/math/asinhf16.h
@@ -0,0 +1,28 @@
+//===-- Shared asinhf16 function -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_ASINHF16_H
+#define LLVM_LIBC_SHARED_MATH_ASINHF16_H
+
+#include "shared/libc_common.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/asinhf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::asinhf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_ASINHF16_H
diff --git a/libc/src/__support/math/CMakeLists.txt 
b/libc/src/__support/math/CMakeLists.txt
index 13f46a13fe0d7..be208f946024a 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -154,6 +154,24 @@ add_header_library(
 libc.src.__support.macros.optimization
 )
 
+add_header_library(
+  asinhf16
+  HDRS
+asinhf16.h
+DEPENDS
+.acoshf_utils
+libc.src.__support.FPUtil.fenv_impl
+libc.src.__support.FPUtil.fp_bits
+libc.src.__support.FPUtil.polyeval
+libc.src.__support.FPUtil.cast
+libc.src.__support.FPUtil.except_value_utils
+libc.src.__support.FPUtil.multiply_add
+libc.src.__support.FPUtil.rounding_mode
+libc.src.__support.FPUtil.sqrt
+libc.src.__support.macros.config
+libc.src.__support.macros.optimization
+)
+
 add_header_library(
   asinf
   HDRS
diff --git a/libc/src/__support/math/asinhf16.h 
b/libc/src/__support/math/asinhf16.h
new file mode 100644
index 0..81657b8db97b0
--- /dev/null
+++ b/libc/src/__support/math/asinhf16.h
@@ -0,0 +1,123 @@
+//===-- Implementation header for asinhf16 --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ASINHF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_ASINHF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "acoshf_utils.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/PolyEval.h"
+#include "src/__support/FPUtil/cast.h"
+#include "src/__support/FPUtil/except_value_utils.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/FPUtil/rounding_mode.h"
+#include "src/__support/FPUtil/sqrt.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE static constexpr float16 asinhf16(float16 x) {
+
+#ifn

[llvm-branch-commits] [libc] [llvm] [libc][math] Refactor atan implementation to header-only in src/__support/math folder. (PR #150852)

2025-07-27 Thread Muhammad Bassiouni via llvm-branch-commits

https://github.com/bassiounix updated 
https://github.com/llvm/llvm-project/pull/150852

>From 5c608185f7c4ccd7746b2eef6b33fbbf945e8a2c Mon Sep 17 00:00:00 2001
From: bassiounix 
Date: Sun, 27 Jul 2025 23:44:37 +0300
Subject: [PATCH] [libc][math] Refactor atan implementation to header-only in
 src/__support/math folder.

---
 libc/shared/math.h|   1 +
 libc/shared/math/atan.h   |  23 +++
 libc/src/__support/math/CMakeLists.txt|  27 +++
 libc/src/__support/math/atan.h| 189 ++
 .../generic => __support/math}/atan_utils.h   |  16 +-
 libc/src/math/generic/CMakeLists.txt  |  25 +--
 libc/src/math/generic/atan.cpp| 167 +---
 libc/src/math/generic/atan2.cpp   |   3 +-
 libc/src/math/generic/atan2f128.cpp   |   3 +-
 libc/test/shared/CMakeLists.txt   |   1 +
 libc/test/shared/shared_math_test.cpp |   1 +
 .../llvm-project-overlay/libc/BUILD.bazel |  44 ++--
 12 files changed, 286 insertions(+), 214 deletions(-)
 create mode 100644 libc/shared/math/atan.h
 create mode 100644 libc/src/__support/math/atan.h
 rename libc/src/{math/generic => __support/math}/atan_utils.h (96%)

diff --git a/libc/shared/math.h b/libc/shared/math.h
index 26e33ecd45d73..70b1b7b0bef09 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -22,6 +22,7 @@
 #include "math/asinf16.h"
 #include "math/asinhf.h"
 #include "math/asinhf16.h"
+#include "math/atan.h"
 #include "math/erff.h"
 #include "math/exp.h"
 #include "math/exp10.h"
diff --git a/libc/shared/math/atan.h b/libc/shared/math/atan.h
new file mode 100644
index 0..b9ba89b7e6225
--- /dev/null
+++ b/libc/shared/math/atan.h
@@ -0,0 +1,23 @@
+//===-- Shared atan function *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_ATAN_H
+#define LLVM_LIBC_SHARED_MATH_ATAN_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/atan.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::atan;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_ATAN_H
diff --git a/libc/src/__support/math/CMakeLists.txt 
b/libc/src/__support/math/CMakeLists.txt
index be208f946024a..cc02920c2a1ef 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -172,6 +172,33 @@ DEPENDS
 libc.src.__support.macros.optimization
 )
 
+add_header_library(
+  atan_utils
+  HDRS
+atan_utils.h
+DEPENDS
+libc.src.__support.integer_literals
+libc.src.__support.FPUtil.double_double
+libc.src.__support.FPUtil.dyadic_float
+libc.src.__support.FPUtil.multiply_add
+libc.src.__support.FPUtil.polyeval
+libc.src.__support.macros.optimization
+)
+
+add_header_library(
+  atan
+  HDRS
+atan.h
+DEPENDS
+.atan_utils
+libc.src.__support.FPUtil.double_double
+libc.src.__support.FPUtil.fenv_impl
+libc.src.__support.FPUtil.fp_bits
+libc.src.__support.FPUtil.multiply_add
+libc.src.__support.FPUtil.nearest_integer
+libc.src.__support.macros.optimization
+)
+
 add_header_library(
   asinf
   HDRS
diff --git a/libc/src/__support/math/atan.h b/libc/src/__support/math/atan.h
new file mode 100644
index 0..62190b092429a
--- /dev/null
+++ b/libc/src/__support/math/atan.h
@@ -0,0 +1,189 @@
+//===-- Implementation header for atan --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ATAN_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_ATAN_H
+
+#include "atan_utils.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/double_double.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/FPUtil/nearest_integer.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+// To compute atan(x), we divided it into the following cases:
+// * |x| < 2^-26:
+//  Since |x| > atan(|x|) > |x| - |x|^3/3, and |x|^3/3 < ulp(x)/2, we 
simply
+//  return atan(x) = x - sign(x) * epsilon.
+// * 2^-26 <= |x| < 1:
+//  We perform range reduction mod 2^-6 = 1/64 as follow:
+//  Let k = 2^(-6) * round(|x| * 2^6), then
+//atan(x) = sign(x) * atan(|x|)
+//

[llvm-branch-commits] [libc] [llvm] [libc][math] Refactor asinhf16 implementation to header-only in src/__support/math folder. (PR #150849)

2025-07-27 Thread Muhammad Bassiouni via llvm-branch-commits

https://github.com/bassiounix updated 
https://github.com/llvm/llvm-project/pull/150849

>From 7be3b70ef8d3c8f39006dbee302fe5291491cb77 Mon Sep 17 00:00:00 2001
From: bassiounix 
Date: Sun, 27 Jul 2025 22:21:00 +0300
Subject: [PATCH 1/2] [libc][math] Refactor asinhf16 implementation to
 header-only in src/__support/math folder.

---
 libc/shared/math.h|   1 +
 libc/shared/math/asinf16.h|   2 +-
 libc/shared/math/asinhf16.h   |  28 
 libc/src/__support/math/CMakeLists.txt|  18 +++
 libc/src/__support/math/asinhf16.h| 123 ++
 libc/src/math/generic/CMakeLists.txt  |  13 +-
 libc/src/math/generic/asinhf16.cpp|  96 +-
 libc/test/shared/CMakeLists.txt   |   1 +
 libc/test/shared/shared_math_test.cpp |   1 +
 .../llvm-project-overlay/libc/BUILD.bazel |  25 
 10 files changed, 201 insertions(+), 107 deletions(-)
 create mode 100644 libc/shared/math/asinhf16.h
 create mode 100644 libc/src/__support/math/asinhf16.h

diff --git a/libc/shared/math.h b/libc/shared/math.h
index e0f00f52e9dc3..26e33ecd45d73 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -21,6 +21,7 @@
 #include "math/asinf.h"
 #include "math/asinf16.h"
 #include "math/asinhf.h"
+#include "math/asinhf16.h"
 #include "math/erff.h"
 #include "math/exp.h"
 #include "math/exp10.h"
diff --git a/libc/shared/math/asinf16.h b/libc/shared/math/asinf16.h
index d545e269a6402..af5b2ec179233 100644
--- a/libc/shared/math/asinf16.h
+++ b/libc/shared/math/asinf16.h
@@ -25,4 +25,4 @@ using math::asinf16;
 
 #endif // LIBC_TYPES_HAS_FLOAT16
 
-#endif // LLVM_LIBC_SHARED_MATH_ASINF_H
+#endif // LLVM_LIBC_SHARED_MATH_ASINF16_H
diff --git a/libc/shared/math/asinhf16.h b/libc/shared/math/asinhf16.h
new file mode 100644
index 0..1a0525b6a9b8b
--- /dev/null
+++ b/libc/shared/math/asinhf16.h
@@ -0,0 +1,28 @@
+//===-- Shared asinhf16 function -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_ASINHF16_H
+#define LLVM_LIBC_SHARED_MATH_ASINHF16_H
+
+#include "shared/libc_common.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/asinhf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::asinhf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_ASINHF16_H
diff --git a/libc/src/__support/math/CMakeLists.txt 
b/libc/src/__support/math/CMakeLists.txt
index 13f46a13fe0d7..be208f946024a 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -154,6 +154,24 @@ add_header_library(
 libc.src.__support.macros.optimization
 )
 
+add_header_library(
+  asinhf16
+  HDRS
+asinhf16.h
+DEPENDS
+.acoshf_utils
+libc.src.__support.FPUtil.fenv_impl
+libc.src.__support.FPUtil.fp_bits
+libc.src.__support.FPUtil.polyeval
+libc.src.__support.FPUtil.cast
+libc.src.__support.FPUtil.except_value_utils
+libc.src.__support.FPUtil.multiply_add
+libc.src.__support.FPUtil.rounding_mode
+libc.src.__support.FPUtil.sqrt
+libc.src.__support.macros.config
+libc.src.__support.macros.optimization
+)
+
 add_header_library(
   asinf
   HDRS
diff --git a/libc/src/__support/math/asinhf16.h 
b/libc/src/__support/math/asinhf16.h
new file mode 100644
index 0..81657b8db97b0
--- /dev/null
+++ b/libc/src/__support/math/asinhf16.h
@@ -0,0 +1,123 @@
+//===-- Implementation header for asinhf16 --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ASINHF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_ASINHF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "acoshf_utils.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/PolyEval.h"
+#include "src/__support/FPUtil/cast.h"
+#include "src/__support/FPUtil/except_value_utils.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/FPUtil/rounding_mode.h"
+#include "src/__support/FPUtil/sqrt.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE static constexpr float16 asinhf16(float16 x) {
+
+#ifn

[llvm-branch-commits] [libc] [llvm] [libc][math] Refactor atan implementation to header-only in src/__support/math folder. (PR #150852)

2025-07-27 Thread Muhammad Bassiouni via llvm-branch-commits

https://github.com/bassiounix updated 
https://github.com/llvm/llvm-project/pull/150852

>From 5c608185f7c4ccd7746b2eef6b33fbbf945e8a2c Mon Sep 17 00:00:00 2001
From: bassiounix 
Date: Sun, 27 Jul 2025 23:44:37 +0300
Subject: [PATCH] [libc][math] Refactor atan implementation to header-only in
 src/__support/math folder.

---
 libc/shared/math.h|   1 +
 libc/shared/math/atan.h   |  23 +++
 libc/src/__support/math/CMakeLists.txt|  27 +++
 libc/src/__support/math/atan.h| 189 ++
 .../generic => __support/math}/atan_utils.h   |  16 +-
 libc/src/math/generic/CMakeLists.txt  |  25 +--
 libc/src/math/generic/atan.cpp| 167 +---
 libc/src/math/generic/atan2.cpp   |   3 +-
 libc/src/math/generic/atan2f128.cpp   |   3 +-
 libc/test/shared/CMakeLists.txt   |   1 +
 libc/test/shared/shared_math_test.cpp |   1 +
 .../llvm-project-overlay/libc/BUILD.bazel |  44 ++--
 12 files changed, 286 insertions(+), 214 deletions(-)
 create mode 100644 libc/shared/math/atan.h
 create mode 100644 libc/src/__support/math/atan.h
 rename libc/src/{math/generic => __support/math}/atan_utils.h (96%)

diff --git a/libc/shared/math.h b/libc/shared/math.h
index 26e33ecd45d73..70b1b7b0bef09 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -22,6 +22,7 @@
 #include "math/asinf16.h"
 #include "math/asinhf.h"
 #include "math/asinhf16.h"
+#include "math/atan.h"
 #include "math/erff.h"
 #include "math/exp.h"
 #include "math/exp10.h"
diff --git a/libc/shared/math/atan.h b/libc/shared/math/atan.h
new file mode 100644
index 0..b9ba89b7e6225
--- /dev/null
+++ b/libc/shared/math/atan.h
@@ -0,0 +1,23 @@
+//===-- Shared atan function *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_ATAN_H
+#define LLVM_LIBC_SHARED_MATH_ATAN_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/atan.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::atan;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_ATAN_H
diff --git a/libc/src/__support/math/CMakeLists.txt 
b/libc/src/__support/math/CMakeLists.txt
index be208f946024a..cc02920c2a1ef 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -172,6 +172,33 @@ DEPENDS
 libc.src.__support.macros.optimization
 )
 
+add_header_library(
+  atan_utils
+  HDRS
+atan_utils.h
+DEPENDS
+libc.src.__support.integer_literals
+libc.src.__support.FPUtil.double_double
+libc.src.__support.FPUtil.dyadic_float
+libc.src.__support.FPUtil.multiply_add
+libc.src.__support.FPUtil.polyeval
+libc.src.__support.macros.optimization
+)
+
+add_header_library(
+  atan
+  HDRS
+atan.h
+DEPENDS
+.atan_utils
+libc.src.__support.FPUtil.double_double
+libc.src.__support.FPUtil.fenv_impl
+libc.src.__support.FPUtil.fp_bits
+libc.src.__support.FPUtil.multiply_add
+libc.src.__support.FPUtil.nearest_integer
+libc.src.__support.macros.optimization
+)
+
 add_header_library(
   asinf
   HDRS
diff --git a/libc/src/__support/math/atan.h b/libc/src/__support/math/atan.h
new file mode 100644
index 0..62190b092429a
--- /dev/null
+++ b/libc/src/__support/math/atan.h
@@ -0,0 +1,189 @@
+//===-- Implementation header for atan --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ATAN_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_ATAN_H
+
+#include "atan_utils.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/double_double.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/FPUtil/nearest_integer.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+// To compute atan(x), we divided it into the following cases:
+// * |x| < 2^-26:
+//  Since |x| > atan(|x|) > |x| - |x|^3/3, and |x|^3/3 < ulp(x)/2, we 
simply
+//  return atan(x) = x - sign(x) * epsilon.
+// * 2^-26 <= |x| < 1:
+//  We perform range reduction mod 2^-6 = 1/64 as follow:
+//  Let k = 2^(-6) * round(|x| * 2^6), then
+//atan(x) = sign(x) * atan(|x|)
+//

[llvm-branch-commits] [llvm] RuntimeLibcalls: Add bitset for available libcalls (PR #150869)

2025-07-27 Thread Matt Arsenault via llvm-branch-commits

https://github.com/arsenm updated 
https://github.com/llvm/llvm-project/pull/150869

>From 78b0865aef1217571e4127067ff19a7a4d533e3a Mon Sep 17 00:00:00 2001
From: Matt Arsenault 
Date: Sun, 27 Jul 2025 23:26:20 +0900
Subject: [PATCH] RuntimeLibcalls: Add bitset for available libcalls

This is a step towards separating the set of available libcalls
from the lowering decision of which call to use. Libcall recognition
now directly checks availability instead of indirectly checking through
the lowering table.
---
 llvm/include/llvm/IR/RuntimeLibcalls.h| 64 +++
 llvm/lib/IR/RuntimeLibcalls.cpp   |  8 +--
 .../RuntimeLibcallEmitter-calling-conv.td | 22 +++
 .../RuntimeLibcallEmitter-conflict-warning.td | 15 +
 llvm/test/TableGen/RuntimeLibcallEmitter.td   | 27 
 .../TableGen/Basic/RuntimeLibcallsEmitter.cpp | 36 ++-
 6 files changed, 164 insertions(+), 8 deletions(-)

diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h 
b/llvm/include/llvm/IR/RuntimeLibcalls.h
index ad3bb4eca1c56..1fc217b10d49d 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.h
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.h
@@ -53,8 +53,64 @@ static inline auto libcall_impls() {
   return enum_seq(static_cast(1), RTLIB::NumLibcallImpls);
 }
 
+/// Manage a bitset representing the list of available libcalls for a module.
+///
+/// Most of this exists because std::bitset cannot be statically constructed in
+/// a size large enough before c++23
+class LibcallImplBitset {
+private:
+  using BitWord = uint64_t;
+  static constexpr unsigned BitWordSize = sizeof(BitWord) * CHAR_BIT;
+  static constexpr size_t NumArrayElts =
+  divideCeil(RTLIB::NumLibcallImpls, BitWordSize);
+  using Storage = BitWord[NumArrayElts];
+
+  Storage Bits = {};
+
+  /// Get bitmask for \p Impl in its Bits element.
+  static constexpr BitWord getBitmask(RTLIB::LibcallImpl Impl) {
+unsigned Idx = static_cast(Impl);
+return BitWord(1) << (Idx % BitWordSize);
+  }
+
+  /// Get index of array element of Bits for \p Impl
+  static constexpr unsigned getArrayIdx(RTLIB::LibcallImpl Impl) {
+return static_cast(Impl) / BitWordSize;
+  }
+
+public:
+  constexpr LibcallImplBitset() = default;
+  constexpr LibcallImplBitset(const Storage &Src) {
+for (size_t I = 0; I != NumArrayElts; ++I)
+  Bits[I] = Src[I];
+  }
+
+  /// Check if a LibcallImpl is available.
+  constexpr bool test(RTLIB::LibcallImpl Impl) const {
+BitWord Mask = getBitmask(Impl);
+return (Bits[getArrayIdx(Impl)] & Mask) != 0;
+  }
+
+  /// Mark a LibcallImpl as available
+  void set(RTLIB::LibcallImpl Impl) {
+assert(Impl != RTLIB::Unsupported && "cannot enable unsupported libcall");
+Bits[getArrayIdx(Impl)] |= getBitmask(Impl);
+  }
+
+  /// Mark a LibcallImpl as unavailable
+  void unset(RTLIB::LibcallImpl Impl) {
+assert(Impl != RTLIB::Unsupported && "cannot enable unsupported libcall");
+Bits[getArrayIdx(Impl)] &= ~getBitmask(Impl);
+  }
+};
+
 /// A simple container for information about the supported runtime calls.
 struct RuntimeLibcallsInfo {
+private:
+  /// Bitset of libcalls a module may emit a call to.
+  LibcallImplBitset AvailableLibcallImpls;
+
+public:
   explicit RuntimeLibcallsInfo(
   const Triple &TT,
   ExceptionHandling ExceptionModel = ExceptionHandling::None,
@@ -132,6 +188,14 @@ struct RuntimeLibcallsInfo {
 return ImplToLibcall[Impl];
   }
 
+  bool isAvailable(RTLIB::LibcallImpl Impl) const {
+return AvailableLibcallImpls.test(Impl);
+  }
+
+  void setAvailable(RTLIB::LibcallImpl Impl) {
+AvailableLibcallImpls.set(Impl);
+  }
+
   /// Check if this is valid libcall for the current module, otherwise
   /// RTLIB::Unsupported.
   RTLIB::LibcallImpl getSupportedLibcallImpl(StringRef FuncName) const;
diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index 8c90c52141dc7..569f63f28db77 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -114,12 +114,8 @@ RuntimeLibcallsInfo::getSupportedLibcallImpl(StringRef 
FuncName) const {
   for (auto I = Range.begin(); I != Range.end(); ++I) {
 RTLIB::LibcallImpl Impl =
 static_cast(I - RuntimeLibcallNameOffsets.begin());
-
-// FIXME: This should not depend on looking up ImplToLibcall, only the list
-// of libcalls for the module.
-RTLIB::LibcallImpl Recognized = LibcallImpls[ImplToLibcall[Impl]];
-if (Recognized != RTLIB::Unsupported)
-  return Recognized;
+if (isAvailable(Impl))
+  return Impl;
   }
 
   return RTLIB::Unsupported;
diff --git a/llvm/test/TableGen/RuntimeLibcallEmitter-calling-conv.td 
b/llvm/test/TableGen/RuntimeLibcallEmitter-calling-conv.td
index 49d5ecaa0e5c5..14c811da64910 100644
--- a/llvm/test/TableGen/RuntimeLibcallEmitter-calling-conv.td
+++ b/llvm/test/TableGen/RuntimeLibcallEmitter-calling-conv.td
@@ -48,12 +48,18 @@ def MSP430LibraryWithCondCC : SystemRuntimeLibrary;
 // func_a and func_b both provid

[llvm-branch-commits] [llvm] RuntimeLibcalls: Move __stack_chk_fail config to tablegen (PR #148789)

2025-07-27 Thread Matt Arsenault via llvm-branch-commits

https://github.com/arsenm updated 
https://github.com/llvm/llvm-project/pull/148789

>From dfa00acbc5bd9fc2433855a895deda92f1a0a0af Mon Sep 17 00:00:00 2001
From: Matt Arsenault 
Date: Tue, 15 Jul 2025 15:47:10 +0900
Subject: [PATCH] RuntimeLibcalls: Move __stack_chk_fail config to tablegen

---
 llvm/include/llvm/IR/RuntimeLibcalls.td | 43 -
 llvm/lib/IR/RuntimeLibcalls.cpp |  4 +--
 2 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td 
b/llvm/include/llvm/IR/RuntimeLibcalls.td
index fba478df7715d..1f029c4edd415 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.td
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td
@@ -18,6 +18,7 @@ class DuplicateLibcallImplWithPrefix
 /// Libcall Predicates
 def isOSDarwin : RuntimeLibcallPredicate<"TT.isOSDarwin()">;
 def isOSOpenBSD : RuntimeLibcallPredicate<"TT.isOSOpenBSD()">;
+def isNotOSOpenBSD : RuntimeLibcallPredicate<"!TT.isOSOpenBSD()">;
 def isOSWindows : RuntimeLibcallPredicate<"TT.isOSWindows()">;
 def isNotOSWindows : RuntimeLibcallPredicate<"!TT.isOSWindows()">;
 def isNotOSMSVCRT : RuntimeLibcallPredicate<"!TT.isOSMSVCRT()">;
@@ -705,9 +706,6 @@ foreach lc = LibCalls__atomic in {
   def __#!tolower(!cast(lc)) : RuntimeLibcallImpl;
 }
 
-// Stack Protector Fail
-def __stack_chk_fail : RuntimeLibcallImpl;
-
 // Safe stack.
 def __safestack_pointer_address : 
RuntimeLibcallImpl;
 
@@ -955,6 +953,9 @@ def exp10l_f80 : RuntimeLibcallImpl;
 def exp10l_f128 : RuntimeLibcallImpl;
 def exp10l_ppcf128 : RuntimeLibcallImpl;
 
+// Stack Protector Fail
+def __stack_chk_fail : RuntimeLibcallImpl;
+
 //
 // compiler-rt/libgcc but 64-bit only, not available by default
 //
@@ -1144,6 +1145,7 @@ defvar LibmHasLdexpF80 = LibcallImpls<(add ldexp_f80), 
isNotOSWindowsOrIsCygwinM
 defvar LibmHasFrexpF128 = LibcallImpls<(add frexp_f128), 
isNotOSWindowsOrIsCygwinMinGW>;
 defvar LibmHasLdexpF128 = LibcallImpls<(add ldexp_f128), 
isNotOSWindowsOrIsCygwinMinGW>;
 
+defvar has__stack_chk_fail = LibcallImpls<(add __stack_chk_fail), 
isNotOSOpenBSD>;
 
 
//===--===//
 // Objective-C Runtime Libcalls
@@ -1221,7 +1223,8 @@ def AArch64SystemLibrary : SystemRuntimeLibrary<
LibcallImpls<(add bzero), isOSDarwin>,
DarwinExp10, DarwinSinCosStret,
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
-   LibmHasExp10F32, LibmHasExp10F64, LibmHasExp10F128)
+   LibmHasExp10F32, LibmHasExp10F64, LibmHasExp10F128,
+   has__stack_chk_fail)
 >;
 
 // Prepend a # to every name
@@ -1237,7 +1240,7 @@ defset list 
WinArm64ECDefaultRuntimeLibcallImpls = {
 
 def WindowsARM64ECSystemLibrary
 : SystemRuntimeLibrary;
+   (add WinArm64ECDefaultRuntimeLibcallImpls, 
__stack_chk_fail)>;
 
 
//===--===//
 // AMDGPU Runtime Libcalls
@@ -1497,7 +1500,8 @@ def ARMSystemLibrary
// Use divmod compiler-rt calls for iOS 5.0 and later.
LibcallImpls<(add __divmodsi4, __udivmodsi4),
 RuntimeLibcallPredicate<[{TT.isOSBinFormatMachO() &&
-  (!TT.isiOS() || 
!TT.isOSVersionLT(5, 0))}]>>)> {
+  (!TT.isiOS() || 
!TT.isOSVersionLT(5, 0))}]>>,
+   has__stack_chk_fail)> {
   let DefaultLibcallCallingConv = LibcallCallingConv<[{
  (!TT.isOSDarwin() && !TT.isiOS() && !TT.isWatchOS() && !TT.isDriverKit()) 
?
 (FloatABI == FloatABI::Hard ? CallingConv::ARM_AAPCS_VFP
@@ -1608,7 +1612,7 @@ def HexagonSystemLibrary
 __umoddi3, __divdf3, __muldf3, __divsi3, __subdf3, sqrtf,
 __divdi3, __umodsi3, __moddi3, __modsi3), HexagonLibcalls,
 LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
-exp10f, exp10, exp10l_f128)>;
+exp10f, exp10, exp10l_f128, __stack_chk_fail)>;
 
 
//===--===//
 // Lanai Runtime Libcalls
@@ -1618,7 +1622,8 @@ def isLanai : RuntimeLibcallPredicate<"TT.getArch() == 
Triple::lanai">;
 
 // Use fast calling convention for library functions.
 def LanaiSystemLibrary
-: SystemRuntimeLibrary {
+: SystemRuntimeLibrary {
   let DefaultLibcallCallingConv = FASTCC;
 }
 
@@ -1910,8 +1915,10 @@ def MSP430SystemLibrary
   // TODO: __mspabi_[srli/srai/slli] ARE implemented in libgcc
   __mspabi_srll,
   __mspabi_sral,
-  __mspabi_slll
+  __mspabi_slll,
   // __mspabi_[srlll/srall/s/rlli/rlll] are NOT implemented in libgcc
+
+  __stack_chk_fail
   )
 >;
 
@@ -2002,7 +2009,8 @@ def PPCSystemLibrary
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
LibmHasSinCosPPCF128,
AvailableIf,
-   Li

[llvm-branch-commits] [llvm] RuntimeLibcalls: Remove target check for sjlj config (PR #148792)

2025-07-27 Thread Matt Arsenault via llvm-branch-commits

https://github.com/arsenm updated 
https://github.com/llvm/llvm-project/pull/148792

>From 204630da22da2170ca8425fce71aafdd5699c5ec Mon Sep 17 00:00:00 2001
From: Matt Arsenault 
Date: Tue, 15 Jul 2025 16:01:44 +0900
Subject: [PATCH] RuntimeLibcalls: Remove target check for sjlj config

I'm assuming this was the set of targets that were relevant
for sjlj handling. Just take the raw exception setting instead,
and assume it makes sense for the target.
---
 llvm/lib/IR/RuntimeLibcalls.cpp | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index bfe2a3d6af867..1ba2fa7f93b03 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -73,10 +73,8 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
EABI EABIVersion, StringRef ABIName) {
   setTargetRuntimeLibcallSets(TT, FloatABI);
 
-  if (TT.isX86() || TT.isVE() || TT.isARM() || TT.isThumb()) {
-if (ExceptionModel == ExceptionHandling::SjLj)
-  setLibcallImpl(RTLIB::UNWIND_RESUME, RTLIB::_Unwind_SjLj_Resume);
-  }
+  if (ExceptionModel == ExceptionHandling::SjLj)
+setLibcallImpl(RTLIB::UNWIND_RESUME, RTLIB::_Unwind_SjLj_Resume);
 
   if (TT.isOSOpenBSD())
 setLibcallImpl(RTLIB::STACK_SMASH_HANDLER, RTLIB::__stack_smash_handler);

___
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] RuntimeLibcalls: Remove target check for sjlj config (PR #148792)

2025-07-27 Thread Matt Arsenault via llvm-branch-commits

https://github.com/arsenm updated 
https://github.com/llvm/llvm-project/pull/148792

>From 204630da22da2170ca8425fce71aafdd5699c5ec Mon Sep 17 00:00:00 2001
From: Matt Arsenault 
Date: Tue, 15 Jul 2025 16:01:44 +0900
Subject: [PATCH] RuntimeLibcalls: Remove target check for sjlj config

I'm assuming this was the set of targets that were relevant
for sjlj handling. Just take the raw exception setting instead,
and assume it makes sense for the target.
---
 llvm/lib/IR/RuntimeLibcalls.cpp | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index bfe2a3d6af867..1ba2fa7f93b03 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -73,10 +73,8 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
EABI EABIVersion, StringRef ABIName) {
   setTargetRuntimeLibcallSets(TT, FloatABI);
 
-  if (TT.isX86() || TT.isVE() || TT.isARM() || TT.isThumb()) {
-if (ExceptionModel == ExceptionHandling::SjLj)
-  setLibcallImpl(RTLIB::UNWIND_RESUME, RTLIB::_Unwind_SjLj_Resume);
-  }
+  if (ExceptionModel == ExceptionHandling::SjLj)
+setLibcallImpl(RTLIB::UNWIND_RESUME, RTLIB::_Unwind_SjLj_Resume);
 
   if (TT.isOSOpenBSD())
 setLibcallImpl(RTLIB::STACK_SMASH_HANDLER, RTLIB::__stack_smash_handler);

___
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] RuntimeLibcalls: Move __stack_smash_handler config to tablegen (PR #150870)

2025-07-27 Thread Matt Arsenault via llvm-branch-commits

https://github.com/arsenm created 
https://github.com/llvm/llvm-project/pull/150870

None

>From 4c052b7e175f7efc7e1c3f88c8f44323a40e0519 Mon Sep 17 00:00:00 2001
From: Matt Arsenault 
Date: Mon, 28 Jul 2025 11:47:04 +0900
Subject: [PATCH] RuntimeLibcalls: Move __stack_smash_handler config to
 tablegen

---
 llvm/include/llvm/IR/RuntimeLibcalls.td | 17 ++---
 llvm/lib/IR/RuntimeLibcalls.cpp |  3 ---
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td 
b/llvm/include/llvm/IR/RuntimeLibcalls.td
index 1f029c4edd415..d7166e7d059aa 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.td
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td
@@ -1146,6 +1146,7 @@ defvar LibmHasFrexpF128 = LibcallImpls<(add frexp_f128), 
isNotOSWindowsOrIsCygwi
 defvar LibmHasLdexpF128 = LibcallImpls<(add ldexp_f128), 
isNotOSWindowsOrIsCygwinMinGW>;
 
 defvar has__stack_chk_fail = LibcallImpls<(add __stack_chk_fail), 
isNotOSOpenBSD>;
+defvar has__stack_smash_handler = LibcallImpls<(add __stack_smash_handler), 
isOSOpenBSD>;
 
 
//===--===//
 // Objective-C Runtime Libcalls
@@ -1224,7 +1225,7 @@ def AArch64SystemLibrary : SystemRuntimeLibrary<
DarwinExp10, DarwinSinCosStret,
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
LibmHasExp10F32, LibmHasExp10F64, LibmHasExp10F128,
-   has__stack_chk_fail)
+   has__stack_chk_fail, has__stack_smash_handler)
 >;
 
 // Prepend a # to every name
@@ -1501,7 +1502,7 @@ def ARMSystemLibrary
LibcallImpls<(add __divmodsi4, __udivmodsi4),
 RuntimeLibcallPredicate<[{TT.isOSBinFormatMachO() &&
   (!TT.isiOS() || 
!TT.isOSVersionLT(5, 0))}]>>,
-   has__stack_chk_fail)> {
+   has__stack_chk_fail, has__stack_smash_handler)> {
   let DefaultLibcallCallingConv = LibcallCallingConv<[{
  (!TT.isOSDarwin() && !TT.isiOS() && !TT.isWatchOS() && !TT.isDriverKit()) 
?
 (FloatABI == FloatABI::Hard ? CallingConv::ARM_AAPCS_VFP
@@ -2010,7 +2011,7 @@ def PPCSystemLibrary
LibmHasSinCosPPCF128,
AvailableIf,
LibcallImpls<(add Int128RTLibcalls), isPPC64>,
-   has__stack_chk_fail)>;
+   has__stack_chk_fail, has__stack_smash_handler)>;
 
 
//===--===//
 // RISCV Runtime Libcalls
@@ -2025,7 +2026,7 @@ def RISCVSystemLibrary
exp10f, exp10, exp10l_f128,
__riscv_flush_icache,
LibcallImpls<(add Int128RTLibcalls), isRISCV64>,
-   has__stack_chk_fail)>;
+   has__stack_chk_fail, has__stack_smash_handler)>;
 
 
//===--===//
 // SPARC Runtime Libcalls
@@ -2093,7 +2094,7 @@ def SPARCSystemLibrary
LibcallImpls<(add _Q_qtoll, _Q_qtoull, _Q_lltoq, _Q_ulltoq), isSPARC32>,
LibcallImpls<(add SPARC64_MulDivCalls, Int128RTLibcalls), isSPARC64>,
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
-   has__stack_chk_fail)
+   has__stack_chk_fail, has__stack_smash_handler)
 >;
 
 
//===--===//
@@ -2154,7 +2155,8 @@ defvar X86CommonLibcalls =
// FIXME: MSVCRT doesn't have powi. The f128 case is added as a
// hack for one test relying on it.
__powitf2_f128,
-   has__stack_chk_fail
+   has__stack_chk_fail,
+   has__stack_smash_handler
 );
 
 defvar Windows32DivRemMulCalls =
@@ -2323,5 +2325,6 @@ def LegacyDefaultSystemLibrary
  exp10f, exp10, exp10l_f128,
  __powisf2, __powidf2, __powitf2_f128,
  LibcallImpls<(add Int128RTLibcalls), isArch64Bit>,
- has__stack_chk_fail
+ has__stack_chk_fail,
+ has__stack_smash_handler
 )>;
diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index bfe2a3d6af867..a930414d177c5 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -78,9 +78,6 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
   setLibcallImpl(RTLIB::UNWIND_RESUME, RTLIB::_Unwind_SjLj_Resume);
   }
 
-  if (TT.isOSOpenBSD())
-setLibcallImpl(RTLIB::STACK_SMASH_HANDLER, RTLIB::__stack_smash_handler);
-
   if (TT.isARM() || TT.isThumb()) {
 setARMLibcallNames(*this, TT, FloatABI, EABIVersion);
 return;

___
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] RuntimeLibcalls: Move __stack_smash_handler config to tablegen (PR #150870)

2025-07-27 Thread Matt Arsenault via llvm-branch-commits

arsenm 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/150870?utm_source=stack-comment-downstack-mergeability-warning";
>  >on Graphite.
> https://graphite.dev/docs/merge-pull-requests";>Learn more

* **#150870** https://app.graphite.dev/github/pr/llvm/llvm-project/150870?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/150870?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#148789** https://app.graphite.dev/github/pr/llvm/llvm-project/148789?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 
([#148792](https://github.com/llvm/llvm-project/pull/148792) https://app.graphite.dev/github/pr/llvm/llvm-project/148792?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>)
* **#148782** https://app.graphite.dev/github/pr/llvm/llvm-project/148782?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#148780** https://app.graphite.dev/github/pr/llvm/llvm-project/148780?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 
([#150869](https://github.com/llvm/llvm-project/pull/150869) https://app.graphite.dev/github/pr/llvm/llvm-project/150869?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>)
* **#148604** https://app.graphite.dev/github/pr/llvm/llvm-project/148604?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#148575** https://app.graphite.dev/github/pr/llvm/llvm-project/148575?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#148571** https://app.graphite.dev/github/pr/llvm/llvm-project/148571?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#148562** https://app.graphite.dev/github/pr/llvm/llvm-project/148562?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/150870
___
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] RuntimeLibcalls: Move __stack_smash_handler config to tablegen (PR #150870)

2025-07-27 Thread via llvm-branch-commits

llvmbot wrote:



@llvm/pr-subscribers-backend-x86

@llvm/pr-subscribers-backend-arm

Author: Matt Arsenault (arsenm)


Changes



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


2 Files Affected:

- (modified) llvm/include/llvm/IR/RuntimeLibcalls.td (+10-7) 
- (modified) llvm/lib/IR/RuntimeLibcalls.cpp (-3) 


``diff
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td 
b/llvm/include/llvm/IR/RuntimeLibcalls.td
index 1f029c4edd415..d7166e7d059aa 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.td
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td
@@ -1146,6 +1146,7 @@ defvar LibmHasFrexpF128 = LibcallImpls<(add frexp_f128), 
isNotOSWindowsOrIsCygwi
 defvar LibmHasLdexpF128 = LibcallImpls<(add ldexp_f128), 
isNotOSWindowsOrIsCygwinMinGW>;
 
 defvar has__stack_chk_fail = LibcallImpls<(add __stack_chk_fail), 
isNotOSOpenBSD>;
+defvar has__stack_smash_handler = LibcallImpls<(add __stack_smash_handler), 
isOSOpenBSD>;
 
 
//===--===//
 // Objective-C Runtime Libcalls
@@ -1224,7 +1225,7 @@ def AArch64SystemLibrary : SystemRuntimeLibrary<
DarwinExp10, DarwinSinCosStret,
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
LibmHasExp10F32, LibmHasExp10F64, LibmHasExp10F128,
-   has__stack_chk_fail)
+   has__stack_chk_fail, has__stack_smash_handler)
 >;
 
 // Prepend a # to every name
@@ -1501,7 +1502,7 @@ def ARMSystemLibrary
LibcallImpls<(add __divmodsi4, __udivmodsi4),
 RuntimeLibcallPredicate<[{TT.isOSBinFormatMachO() &&
   (!TT.isiOS() || 
!TT.isOSVersionLT(5, 0))}]>>,
-   has__stack_chk_fail)> {
+   has__stack_chk_fail, has__stack_smash_handler)> {
   let DefaultLibcallCallingConv = LibcallCallingConv<[{
  (!TT.isOSDarwin() && !TT.isiOS() && !TT.isWatchOS() && !TT.isDriverKit()) 
?
 (FloatABI == FloatABI::Hard ? CallingConv::ARM_AAPCS_VFP
@@ -2010,7 +2011,7 @@ def PPCSystemLibrary
LibmHasSinCosPPCF128,
AvailableIf,
LibcallImpls<(add Int128RTLibcalls), isPPC64>,
-   has__stack_chk_fail)>;
+   has__stack_chk_fail, has__stack_smash_handler)>;
 
 
//===--===//
 // RISCV Runtime Libcalls
@@ -2025,7 +2026,7 @@ def RISCVSystemLibrary
exp10f, exp10, exp10l_f128,
__riscv_flush_icache,
LibcallImpls<(add Int128RTLibcalls), isRISCV64>,
-   has__stack_chk_fail)>;
+   has__stack_chk_fail, has__stack_smash_handler)>;
 
 
//===--===//
 // SPARC Runtime Libcalls
@@ -2093,7 +2094,7 @@ def SPARCSystemLibrary
LibcallImpls<(add _Q_qtoll, _Q_qtoull, _Q_lltoq, _Q_ulltoq), isSPARC32>,
LibcallImpls<(add SPARC64_MulDivCalls, Int128RTLibcalls), isSPARC64>,
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
-   has__stack_chk_fail)
+   has__stack_chk_fail, has__stack_smash_handler)
 >;
 
 
//===--===//
@@ -2154,7 +2155,8 @@ defvar X86CommonLibcalls =
// FIXME: MSVCRT doesn't have powi. The f128 case is added as a
// hack for one test relying on it.
__powitf2_f128,
-   has__stack_chk_fail
+   has__stack_chk_fail,
+   has__stack_smash_handler
 );
 
 defvar Windows32DivRemMulCalls =
@@ -2323,5 +2325,6 @@ def LegacyDefaultSystemLibrary
  exp10f, exp10, exp10l_f128,
  __powisf2, __powidf2, __powitf2_f128,
  LibcallImpls<(add Int128RTLibcalls), isArch64Bit>,
- has__stack_chk_fail
+ has__stack_chk_fail,
+ has__stack_smash_handler
 )>;
diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index bfe2a3d6af867..a930414d177c5 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -78,9 +78,6 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
   setLibcallImpl(RTLIB::UNWIND_RESUME, RTLIB::_Unwind_SjLj_Resume);
   }
 
-  if (TT.isOSOpenBSD())
-setLibcallImpl(RTLIB::STACK_SMASH_HANDLER, RTLIB::__stack_smash_handler);
-
   if (TT.isARM() || TT.isThumb()) {
 setARMLibcallNames(*this, TT, FloatABI, EABIVersion);
 return;

``




https://github.com/llvm/llvm-project/pull/150870
___
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] RuntimeLibcalls: Move __stack_smash_handler config to tablegen (PR #150870)

2025-07-27 Thread Matt Arsenault via llvm-branch-commits

https://github.com/arsenm ready_for_review 
https://github.com/llvm/llvm-project/pull/150870
___
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] c669c22 - Revert "[CodeGen][NPM] Stitch up loop passes in codegen pipeline (#148114)"

2025-07-27 Thread via llvm-branch-commits

Author: Vikram Hegde
Date: 2025-07-28T11:25:27+05:30
New Revision: c669c22b774d58e4f4fb2114d810ada24ece1dac

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

LOG: Revert "[CodeGen][NPM] Stitch up loop passes in codegen pipeline (#148114)"

This reverts commit d35bf478a81e0ca5c9fac76767d41a23df262f94.

Added: 


Modified: 
llvm/include/llvm/Passes/CodeGenPassBuilder.h
llvm/include/llvm/Target/CGPassBuilderOption.h
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
llvm/test/CodeGen/AMDGPU/llc-pipeline-npm.ll

Removed: 




diff  --git a/llvm/include/llvm/Passes/CodeGenPassBuilder.h 
b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
index 97c3ff869edf4..b0360f1903c0e 100644
--- a/llvm/include/llvm/Passes/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
@@ -114,16 +114,13 @@
 #include "llvm/Target/CGPassBuilderOption.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Transforms/CFGuard.h"
-#include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar/ConstantHoisting.h"
 #include "llvm/Transforms/Scalar/LoopPassManager.h"
 #include "llvm/Transforms/Scalar/LoopStrengthReduce.h"
-#include "llvm/Transforms/Scalar/LoopTermFold.h"
 #include "llvm/Transforms/Scalar/LowerConstantIntrinsics.h"
 #include "llvm/Transforms/Scalar/MergeICmps.h"
 #include "llvm/Transforms/Scalar/PartiallyInlineLibCalls.h"
 #include "llvm/Transforms/Scalar/ScalarizeMaskedMemIntrin.h"
-#include "llvm/Transforms/Utils/CanonicalizeFreezeInLoops.h"
 #include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
 #include "llvm/Transforms/Utils/LowerInvoke.h"
 #include 
@@ -757,12 +754,7 @@ void CodeGenPassBuilder::addIRPasses(
 
   // Run loop strength reduction before anything else.
   if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableLSR) {
-LoopPassManager LPM;
-LPM.addPass(CanonicalizeFreezeInLoopsPass());
-LPM.addPass(LoopStrengthReducePass());
-if (Opt.EnableLoopTermFold)
-  LPM.addPass(LoopTermFoldPass());
-addPass(createFunctionToLoopPassAdaptor(std::move(LPM),
+addPass(createFunctionToLoopPassAdaptor(LoopStrengthReducePass(),
 /*UseMemorySSA=*/true));
   }
 
@@ -807,8 +799,7 @@ void CodeGenPassBuilder::addIRPasses(
   addPass(ScalarizeMaskedMemIntrinPass());
 
   // Expand reduction intrinsics into shuffle sequences if the target wants to.
-  if (!Opt.DisableExpandReductions)
-addPass(ExpandReductionsPass());
+  addPass(ExpandReductionsPass());
 
   // Convert conditional moves to conditional jumps when profitable.
   if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableSelectOptimize)
@@ -886,9 +877,6 @@ void CodeGenPassBuilder::addISelPrepare(
   if (Opt.RequiresCodeGenSCCOrder)
 addPass.requireCGSCCOrder();
 
-  if (getOptLevel() != CodeGenOptLevel::None)
-addPass(ObjCARCContractPass());
-
   addPass(CallBrPreparePass());
   // Add both the safe stack and the stack protection passes: each of them will
   // only protect functions that have corresponding attributes.

diff  --git a/llvm/include/llvm/Target/CGPassBuilderOption.h 
b/llvm/include/llvm/Target/CGPassBuilderOption.h
index 8d0a7e61970fa..f29cbe78a1853 100644
--- a/llvm/include/llvm/Target/CGPassBuilderOption.h
+++ b/llvm/include/llvm/Target/CGPassBuilderOption.h
@@ -52,8 +52,6 @@ struct CGPassBuilderOption {
   bool EnableMachineFunctionSplitter = false;
   bool EnableSinkAndFold = false;
   bool EnableTailMerge = true;
-  /// Enable LoopTermFold immediately after LSR.
-  bool EnableLoopTermFold = false;
   bool MISchedPostRA = false;
   bool EarlyLiveIntervals = false;
   bool GCEmptyBlocks = false;

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
index 8e7bde554bfd9..c865082a1dcea 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -104,9 +104,7 @@
 #include "llvm/Transforms/Scalar/FlattenCFG.h"
 #include "llvm/Transforms/Scalar/GVN.h"
 #include "llvm/Transforms/Scalar/InferAddressSpaces.h"
-#include "llvm/Transforms/Scalar/LICM.h"
 #include "llvm/Transforms/Scalar/LoopDataPrefetch.h"
-#include "llvm/Transforms/Scalar/LoopPassManager.h"
 #include "llvm/Transforms/Scalar/NaryReassociate.h"
 #include "llvm/Transforms/Scalar/SeparateConstOffsetFromGEP.h"
 #include "llvm/Transforms/Scalar/Sink.h"
@@ -2064,12 +2062,7 @@ void AMDGPUCodeGenPassBuilder::addIRPasses(AddIRPass 
&addPass) const {
 // TODO: May want to move later or split into an early and late one.
 addPass(AMDGPUCodeGenPreparePass(TM));
 
-// Try to hoist loop invariant parts of divisions AMDGPUCodeGenPrepare may
-// have expanded.
-if (TM.getOptLevel() > CodeGenOptLevel::Less) {
-  addPass(createFuncti

[llvm-branch-commits] [llvm] [IR] Introduce the `ptrtoaddr` instruction (PR #139357)

2025-07-27 Thread S. VenkataKeerthy via llvm-branch-commits


@@ -66,7 +66,8 @@
 "ExtractValue": [127, 128],
 "InsertValue": [129, 130],
 "LandingPad": [131, 132],
-"Freeze": [133, 134]
+"Freeze": [133, 134],
+"PtrToAddr": [135, 136]

svkeerthy wrote:

Having an entry here should get the tests working. For the sake of 
interpretability, it would be great if you can please keep it in the enum 
order. Value could still be the same. 

https://github.com/llvm/llvm-project/pull/139357
___
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] [IR] Introduce the `ptrtoaddr` instruction (PR #139357)

2025-07-27 Thread S. VenkataKeerthy via llvm-branch-commits


@@ -320,11 +320,13 @@ TEST_F(IR2VecTestFixture, GetInstVecMap) {
   EXPECT_TRUE(InstMap.count(AddInst));
   EXPECT_TRUE(InstMap.count(RetInst));
 
-  EXPECT_EQ(InstMap.at(AddInst).size(), 2u);
-  EXPECT_EQ(InstMap.at(RetInst).size(), 2u);
+  const auto &AddEmb = InstMap.at(AddInst);
+  const auto &RetEmb = InstMap.at(RetInst);
+  EXPECT_EQ(AddEmb.size(), 2u);
+  EXPECT_EQ(RetEmb.size(), 2u);
 
-  EXPECT_TRUE(InstMap.at(AddInst).approximatelyEquals(Embedding(2, 27.6)));
-  EXPECT_TRUE(InstMap.at(RetInst).approximatelyEquals(Embedding(2, 16.8)));
+  EXPECT_TRUE(AddEmb.approximatelyEquals(Embedding(2, 27.9)));
+  EXPECT_TRUE(RetEmb.approximatelyEquals(Embedding(2, 17.0)));

svkeerthy wrote:

Ack - your points on reducing the hardcoded values. However, it seems 
unavoidable here. We'll see how better we can refactor this while reducing the 
hardcoding. 

These changes look fine for me. 

https://github.com/llvm/llvm-project/pull/139357
___
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] [llvm-profgen] Extend llvm-profgen to generate vtable profiles with data access events. (PR #148013)

2025-07-27 Thread Mingming Liu via llvm-branch-commits


@@ -370,6 +375,65 @@ PerfReaderBase::create(ProfiledBinary *Binary, 
PerfInputFile &PerfInput,
   return PerfReader;
 }
 
+Error PerfReaderBase::parseDataAccessPerfTraces(
+StringRef DataAccessPerfTraceFile, std::optional PIDFilter) {
+  // A perf_record_sample line is like
+  // . 1282514022939813 0x87b0 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002):
+  // 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3fb0
+  constexpr static const char *const DataAccessSamplePattern =
+  "PERF_RECORD_SAMPLE\\([A-Za-z]+, 0x[0-9a-fA-F]+\\): "
+  "([0-9]+)\\/[0-9]+: (0x[0-9a-fA-F]+) period: [0-9]+ addr: "
+  "(0x[0-9a-fA-F]+)";
+
+  llvm::Regex logRegex(DataAccessSamplePattern);
+
+  auto BufferOrErr = MemoryBuffer::getFile(DataAccessPerfTraceFile);
+  std::error_code EC = BufferOrErr.getError();
+  if (EC)
+return make_error("Failed to open perf trace file: " +
+   DataAccessPerfTraceFile,
+   inconvertibleErrorCode());
+
+  assert(!SampleCounters.empty() && "Sample counters should not be empty!");
+  SampleCounter &Counter = SampleCounters.begin()->second;
+  line_iterator LineIt(*BufferOrErr.get(), true);
+  for (; !LineIt.is_at_eof(); ++LineIt) {
+StringRef Line = *LineIt;
+
+MMapEvent MMap;
+if (Line.contains("PERF_RECORD_MMAP2")) {
+  if (PerfScriptReader::extractMMapEventForBinary(Binary, Line, MMap)) {
+if (!MMap.MemProtectionFlag.contains("x")) {
+  Binary->addMMapNonTextEvent(MMap);
+}
+  }
+  continue;
+}
+
+SmallVector Fields;
+if (logRegex.match(Line, &Fields)) {
+  int32_t PID = 0;
+  Fields[1].getAsInteger(0, PID);

mingmingl-llvm wrote:

specified the radix for each field and returned error on malformed input.

It turns out `0x` prefix should be removed when radix=16 is used, so updated 
regex above slightly to not capture '0x' in the group.

https://github.com/llvm/llvm-project/pull/148013
___
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] [llvm-profgen] Extend llvm-profgen to generate vtable profiles with data access events. (PR #148013)

2025-07-27 Thread Mingming Liu via llvm-branch-commits

https://github.com/mingmingl-llvm edited 
https://github.com/llvm/llvm-project/pull/148013
___
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] [llvm-profgen] Extend llvm-profgen to generate vtable profiles with data access events. (PR #148013)

2025-07-27 Thread Mingming Liu via llvm-branch-commits


@@ -603,6 +640,16 @@ class ProfiledBinary {
 return ProbeDecoder.getInlinerDescForProbe(Probe);
   }
 
+  void addMMapNonTextEvent(MMapEvent MMap) {
+MMapNonTextEvents.push_back(MMap);

mingmingl-llvm wrote:

My understanding is that it's rare for the virtual address ranges (i.e., the 
intervals formed by `[MMapEvent.Address, MMapEvent.Address + MMap.Size)`) of 
mmap events to overlap with each other. Assuming this is true, I think there 
are two implementation options here:

1)  Make llvm-profgen to validate mmap events don't have overlapping virtual 
address (and report 'unimplemented error' otherwise). This way, the 
implementation can use a map to do efficient address canonicalization and 
handle the common case. The updated change implements this option.
  
2) llvm-profgen doesn't validate address interval and cannot assume 
non-overlapping address ranges. The implementation uses a vector to record the 
mmap events in the order they are added and reverse iterate the map to do data 
address canonicalization. While a linear reverse iteration is probably 
acceptable given the number of non-text mmap events is observed to be 3 in most 
cases, I think option 1) does the better trade-off. 

Let me know your thoughts and I'd be glad to follow up.


https://github.com/llvm/llvm-project/pull/148013
___
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] [llvm-profgen] Extend llvm-profgen to generate vtable profiles with data access events. (PR #148013)

2025-07-27 Thread Mingming Liu via llvm-branch-commits

https://github.com/mingmingl-llvm commented:

thanks for reviews! PTAL.

https://github.com/llvm/llvm-project/pull/148013
___
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] [llvm-profgen] Extend llvm-profgen to generate vtable profiles with data access events. (PR #148013)

2025-07-27 Thread Mingming Liu via llvm-branch-commits


@@ -370,6 +375,65 @@ PerfReaderBase::create(ProfiledBinary *Binary, 
PerfInputFile &PerfInput,
   return PerfReader;
 }
 
+Error PerfReaderBase::parseDataAccessPerfTraces(
+StringRef DataAccessPerfTraceFile, std::optional PIDFilter) {
+  // A perf_record_sample line is like
+  // . 1282514022939813 0x87b0 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002):
+  // 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3fb0
+  constexpr static const char *const DataAccessSamplePattern =

mingmingl-llvm wrote:

done.

https://github.com/llvm/llvm-project/pull/148013
___
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] [llvm-profgen] Extend llvm-profgen to generate vtable profiles with data access events. (PR #148013)

2025-07-27 Thread Mingming Liu via llvm-branch-commits


@@ -1027,6 +1027,20 @@ class FunctionSamples {
 return VirtualCallsiteTypeCounts[mapIRLocToProfileLoc(Loc)];
   }
 
+  // At location \p Loc, add a type sample for the given \p Type with

mingmingl-llvm wrote:

done.

https://github.com/llvm/llvm-project/pull/148013
___
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] [llvm-profgen] Extend llvm-profgen to generate vtable profiles with data access events. (PR #148013)

2025-07-27 Thread Mingming Liu via llvm-branch-commits


@@ -370,6 +375,65 @@ PerfReaderBase::create(ProfiledBinary *Binary, 
PerfInputFile &PerfInput,
   return PerfReader;
 }
 
+Error PerfReaderBase::parseDataAccessPerfTraces(
+StringRef DataAccessPerfTraceFile, std::optional PIDFilter) {
+  // A perf_record_sample line is like
+  // . 1282514022939813 0x87b0 [0x60]: PERF_RECORD_SAMPLE(IP, 0x4002):
+  // 3446532/3446532: 0x2608a2 period: 233 addr: 0x3b3fb0
+  constexpr static const char *const DataAccessSamplePattern =
+  "PERF_RECORD_SAMPLE\\([A-Za-z]+, 0x[0-9a-fA-F]+\\): "
+  "([0-9]+)\\/[0-9]+: (0x[0-9a-fA-F]+) period: [0-9]+ addr: "
+  "(0x[0-9a-fA-F]+)";
+
+  llvm::Regex logRegex(DataAccessSamplePattern);
+
+  auto BufferOrErr = MemoryBuffer::getFile(DataAccessPerfTraceFile);
+  std::error_code EC = BufferOrErr.getError();
+  if (EC)
+return make_error("Failed to open perf trace file: " +
+   DataAccessPerfTraceFile,
+   inconvertibleErrorCode());
+
+  assert(!SampleCounters.empty() && "Sample counters should not be empty!");
+  SampleCounter &Counter = SampleCounters.begin()->second;
+  line_iterator LineIt(*BufferOrErr.get(), true);
+  for (; !LineIt.is_at_eof(); ++LineIt) {
+StringRef Line = *LineIt;
+
+MMapEvent MMap;
+if (Line.contains("PERF_RECORD_MMAP2")) {
+  if (PerfScriptReader::extractMMapEventForBinary(Binary, Line, MMap)) {
+if (!MMap.MemProtectionFlag.contains("x")) {
+  Binary->addMMapNonTextEvent(MMap);
+}
+  }
+  continue;
+}
+
+SmallVector Fields;
+if (logRegex.match(Line, &Fields)) {
+  int32_t PID = 0;
+  Fields[1].getAsInteger(0, PID);
+  if (PIDFilter.has_value() && *PIDFilter != PID) {
+continue;
+  }
+
+  uint64_t DataAddress = 0;
+  Fields[3].getAsInteger(0, DataAddress);
+
+  StringRef DataSymbol = Binary->symbolizeDataAddress(

mingmingl-llvm wrote:

Commented that vtable accesses are used and Itanium C++ ABI is assumed to find 
out vtable accesses.

https://github.com/llvm/llvm-project/pull/148013
___
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] [llvm-profgen] Extend llvm-profgen to generate vtable profiles with data access events. (PR #148013)

2025-07-27 Thread Mingming Liu via llvm-branch-commits


@@ -185,6 +185,16 @@ class BinarySizeContextTracker {
 
 using AddressRange = std::pair;
 
+// The parsed MMap event
+struct MMapEvent {

mingmingl-llvm wrote:

Previously this class definition is moved for ProfiledBinary class to use.

Now moved `MMapEvent` back to PerfReader.h and kept it outside `PerfReaderBase` 
class, and updated ProfiledBinary class to use subfields of `MMapEvent`.

https://github.com/llvm/llvm-project/pull/148013
___
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] [llvm-profgen] Extend llvm-profgen to generate vtable profiles with data access events. (PR #148013)

2025-07-27 Thread Mingming Liu via llvm-branch-commits

mingmingl-llvm wrote:

> A couple of requests regarding testing --
> 
> 1. I think the current dap.bin is non-PIE, can you add a PIE variant test 
> case too?
> 2. Can you trim the lbr-perf-for-dap.script test input to preserve only whats 
> needed for a minimal test. I think a lot of the samples are repeated and we 
> can just test for a lower count.

done! It took me sometime to find a good time to tune the profiling period for 
a non-PIE binary without over-heating the machine, and now sampling at 
1,000,003 is a good number :)

https://github.com/llvm/llvm-project/pull/148013
___
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] [lldb] [PATCH 7/7] [clang] improve NestedNameSpecifier: LLDB changes (PR #149949)

2025-07-27 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/149949

>From ff7f559bb48df18dea7cc12e568e61b70f3a7f72 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Mon, 21 Jul 2025 22:00:01 -0300
Subject: [PATCH] [PATCH 7/7] [clang] improve NestedNameSpecifier: LLDB changes

Patch series starting at https://github.com/llvm/llvm-project/pull/147835
---
 clang/include/clang/AST/QualTypeNames.h   |  10 +
 clang/lib/AST/QualTypeNames.cpp   |   7 +
 .../Clang/ClangASTImporter.cpp|  31 +--
 .../ExpressionParser/Clang/ClangASTSource.cpp |   5 +-
 .../Clang/ClangExpressionDeclMap.cpp  |   4 +-
 .../Clang/ClangPersistentVariables.cpp|   6 +-
 .../Clang/NameSearchContext.cpp   |   2 +-
 .../Plugins/Language/ObjC/NSDictionary.cpp|   3 +-
 .../RegisterTypeBuilderClang.cpp  |   4 +-
 .../SymbolFile/NativePDB/PdbAstBuilder.cpp|  11 +-
 .../Plugins/SymbolFile/PDB/PDBASTParser.cpp   |  11 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 243 +-
 .../TypeSystem/Clang/TypeSystemClang.h|   9 +-
 .../DWARF/x86/dwp-foreign-type-units.cpp  |   8 +-
 .../lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp|   5 +-
 15 files changed, 180 insertions(+), 179 deletions(-)

diff --git a/clang/include/clang/AST/QualTypeNames.h 
b/clang/include/clang/AST/QualTypeNames.h
index daa86cda2d992..9f5cf045d1d4c 100644
--- a/clang/include/clang/AST/QualTypeNames.h
+++ b/clang/include/clang/AST/QualTypeNames.h
@@ -87,6 +87,16 @@ std::string getFullyQualifiedName(QualType QT, const 
ASTContext &Ctx,
 /// specifier "::" should be prepended or not.
 QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx,
bool WithGlobalNsPrefix = false);
+
+/// Get the fully qualified name for the declared context of a declaration.
+///
+/// \param[in] Ctx - the ASTContext to be used.
+/// \param[in] Decl - the declaration for which to get the fully qualified 
name.
+/// \param[in] WithGlobalNsPrefix - If true, then the global namespace
+/// specifier "::" will be prepended to the fully qualified name.
+NestedNameSpecifier
+getFullyQualifiedDeclaredContext(const ASTContext &Ctx, const Decl *Decl,
+ bool WithGlobalNsPrefix = false);
 } // end namespace TypeName
 } // end namespace clang
 #endif // LLVM_CLANG_AST_QUALTYPENAMES_H
diff --git a/clang/lib/AST/QualTypeNames.cpp b/clang/lib/AST/QualTypeNames.cpp
index 319becd8a5a98..086450e790541 100644
--- a/clang/lib/AST/QualTypeNames.cpp
+++ b/clang/lib/AST/QualTypeNames.cpp
@@ -491,5 +491,12 @@ std::string getFullyQualifiedName(QualType QT,
   return FQQT.getAsString(Policy);
 }
 
+NestedNameSpecifier getFullyQualifiedDeclaredContext(const ASTContext &Ctx,
+ const Decl *Decl,
+ bool WithGlobalNsPrefix) {
+  return createNestedNameSpecifierForScopeOf(Ctx, Decl, 
/*FullyQualified=*/true,
+ WithGlobalNsPrefix);
+}
+
 }  // end namespace TypeName
 }  // end namespace clang
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index 2529e78f78bca..7ba8b730c6e9b 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -320,7 +320,8 @@ CompilerType ClangASTImporter::DeportType(TypeSystemClang 
&dst,
   DeclContextOverride decl_context_override;
 
   if (auto *t = ClangUtil::GetQualType(src_type)->getAs())
-decl_context_override.OverrideAllDeclsFromContainingFunction(t->getDecl());
+decl_context_override.OverrideAllDeclsFromContainingFunction(
+t->getOriginalDecl());
 
   CompleteTagDeclsScope complete_scope(*this, &dst.getASTContext(),
&src_ctxt->getASTContext());
@@ -377,8 +378,7 @@ bool ClangASTImporter::CanImport(const CompilerType &type) {
   } break;
 
   case clang::Type::Enum: {
-clang::EnumDecl *enum_decl =
-llvm::cast(qual_type)->getDecl();
+auto *enum_decl = 
llvm::cast(qual_type)->getOriginalDecl();
 if (enum_decl) {
   if (GetDeclOrigin(enum_decl).Valid())
 return true;
@@ -414,12 +414,6 @@ bool ClangASTImporter::CanImport(const CompilerType &type) 
{
   ->getDeducedType()
   .getAsOpaquePtr()));
 
-  case clang::Type::Elaborated:
-return CanImport(CompilerType(type.GetTypeSystem(),
-  llvm::cast(qual_type)
-  ->getNamedType()
-  .getAsOpaquePtr()));
-
   case clang::Type::Paren:
 return CanImport(CompilerType(
 type.GetTypeSystem(),
@@ -452,7 +446,7 @@ bool ClangASTImporter::Import(const CompilerType &type) {
 
   ca

[llvm-branch-commits] [clang] [lldb] [PATCH 7/7] [clang] improve NestedNameSpecifier: LLDB changes (PR #149949)

2025-07-27 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/149949

>From 75be9efd3ffcdb9e42d9261af59f2668a771f09a Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Mon, 21 Jul 2025 22:00:01 -0300
Subject: [PATCH] [PATCH 7/7] [clang] improve NestedNameSpecifier: LLDB changes

Patch series starting at https://github.com/llvm/llvm-project/pull/147835
---
 clang/include/clang/AST/QualTypeNames.h   |  10 +
 clang/lib/AST/QualTypeNames.cpp   |   7 +
 .../Clang/ClangASTImporter.cpp|  31 +--
 .../ExpressionParser/Clang/ClangASTSource.cpp |   5 +-
 .../Clang/ClangExpressionDeclMap.cpp  |   4 +-
 .../Clang/ClangPersistentVariables.cpp|   6 +-
 .../Clang/NameSearchContext.cpp   |   2 +-
 .../Plugins/Language/ObjC/NSDictionary.cpp|   3 +-
 .../RegisterTypeBuilderClang.cpp  |   4 +-
 .../SymbolFile/NativePDB/PdbAstBuilder.cpp|  11 +-
 .../Plugins/SymbolFile/PDB/PDBASTParser.cpp   |  11 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 243 +-
 .../TypeSystem/Clang/TypeSystemClang.h|   9 +-
 .../string/TestDataFormatterStdString.py  |   3 -
 .../completions/TestDAP_completions.py|   2 +-
 .../DWARF/x86/dwp-foreign-type-units.cpp  |   8 +-
 .../lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp|   5 +-
 17 files changed, 181 insertions(+), 183 deletions(-)

diff --git a/clang/include/clang/AST/QualTypeNames.h 
b/clang/include/clang/AST/QualTypeNames.h
index daa86cda2d992..9f5cf045d1d4c 100644
--- a/clang/include/clang/AST/QualTypeNames.h
+++ b/clang/include/clang/AST/QualTypeNames.h
@@ -87,6 +87,16 @@ std::string getFullyQualifiedName(QualType QT, const 
ASTContext &Ctx,
 /// specifier "::" should be prepended or not.
 QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx,
bool WithGlobalNsPrefix = false);
+
+/// Get the fully qualified name for the declared context of a declaration.
+///
+/// \param[in] Ctx - the ASTContext to be used.
+/// \param[in] Decl - the declaration for which to get the fully qualified 
name.
+/// \param[in] WithGlobalNsPrefix - If true, then the global namespace
+/// specifier "::" will be prepended to the fully qualified name.
+NestedNameSpecifier
+getFullyQualifiedDeclaredContext(const ASTContext &Ctx, const Decl *Decl,
+ bool WithGlobalNsPrefix = false);
 } // end namespace TypeName
 } // end namespace clang
 #endif // LLVM_CLANG_AST_QUALTYPENAMES_H
diff --git a/clang/lib/AST/QualTypeNames.cpp b/clang/lib/AST/QualTypeNames.cpp
index 319becd8a5a98..086450e790541 100644
--- a/clang/lib/AST/QualTypeNames.cpp
+++ b/clang/lib/AST/QualTypeNames.cpp
@@ -491,5 +491,12 @@ std::string getFullyQualifiedName(QualType QT,
   return FQQT.getAsString(Policy);
 }
 
+NestedNameSpecifier getFullyQualifiedDeclaredContext(const ASTContext &Ctx,
+ const Decl *Decl,
+ bool WithGlobalNsPrefix) {
+  return createNestedNameSpecifierForScopeOf(Ctx, Decl, 
/*FullyQualified=*/true,
+ WithGlobalNsPrefix);
+}
+
 }  // end namespace TypeName
 }  // end namespace clang
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index 2529e78f78bca..7ba8b730c6e9b 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -320,7 +320,8 @@ CompilerType ClangASTImporter::DeportType(TypeSystemClang 
&dst,
   DeclContextOverride decl_context_override;
 
   if (auto *t = ClangUtil::GetQualType(src_type)->getAs())
-decl_context_override.OverrideAllDeclsFromContainingFunction(t->getDecl());
+decl_context_override.OverrideAllDeclsFromContainingFunction(
+t->getOriginalDecl());
 
   CompleteTagDeclsScope complete_scope(*this, &dst.getASTContext(),
&src_ctxt->getASTContext());
@@ -377,8 +378,7 @@ bool ClangASTImporter::CanImport(const CompilerType &type) {
   } break;
 
   case clang::Type::Enum: {
-clang::EnumDecl *enum_decl =
-llvm::cast(qual_type)->getDecl();
+auto *enum_decl = 
llvm::cast(qual_type)->getOriginalDecl();
 if (enum_decl) {
   if (GetDeclOrigin(enum_decl).Valid())
 return true;
@@ -414,12 +414,6 @@ bool ClangASTImporter::CanImport(const CompilerType &type) 
{
   ->getDeducedType()
   .getAsOpaquePtr()));
 
-  case clang::Type::Elaborated:
-return CanImport(CompilerType(type.GetTypeSystem(),
-  llvm::cast(qual_type)
-  ->getNamedType()
-  .getAsOpaquePtr()));
-
   case clang::Type::Paren:
 return CanImport(CompilerType(
 

[llvm-branch-commits] [llvm] release/21.x: [Mips] Fix wrong ELF FP ABI info when inline asm was empty (#146457) (PR #150866)

2025-07-27 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/150866

Backport 778fb76e6308534a63239a91b98f5dad055f6fdb

Requested by: @brad0

>From 1bd4d3ecb2f31051b666bc4151fa52996228029c Mon Sep 17 00:00:00 2001
From: yingopq <115543042+ying...@users.noreply.github.com>
Date: Mon, 28 Jul 2025 09:07:51 +0800
Subject: [PATCH] [Mips] Fix wrong ELF FP ABI info when inline asm was empty
 (#146457)

When Mips process emitStartOfAsmFile and updateABIInfo, it did not know
the real value of IsSoftFloat and STI.useSoftFloat(). And when inline
asm instruction was empty, Mips did not process asm parser, so it would
not do TS.updateABIInfo(STI) again and at this time the value of
IsSoftFloat is correct.

Fix #135283.

(cherry picked from commit 778fb76e6308534a63239a91b98f5dad055f6fdb)
---
 llvm/lib/Target/Mips/MipsAsmPrinter.cpp   |  8 ++--
 llvm/test/CodeGen/Mips/abiflags-soft-float.ll | 12 
 2 files changed, 18 insertions(+), 2 deletions(-)
 create mode 100644 llvm/test/CodeGen/Mips/abiflags-soft-float.ll

diff --git a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp 
b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
index 87e06a6d3c08a..2903ff75475cf 100644
--- a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -747,14 +747,18 @@ void MipsAsmPrinter::emitStartOfAsmFile(Module &M) {
 if (FS.empty() && M.size() && F->hasFnAttribute("target-features"))
   FS = F->getFnAttribute("target-features").getValueAsString();
 
+std::string strFS = FS.str();
+if (M.size() && F->getFnAttribute("use-soft-float").getValueAsBool())
+  strFS += strFS.empty() ? "+soft-float" : ",+soft-float";
+
 // Compute MIPS architecture attributes based on the default subtarget
 // that we'd have constructed.
 // FIXME: For ifunc related functions we could iterate over and look
 // for a feature string that doesn't match the default one.
 StringRef CPU = MIPS_MC::selectMipsCPU(TT, TM.getTargetCPU());
 const MipsTargetMachine &MTM = static_cast(TM);
-const MipsSubtarget STI(TT, CPU, FS, MTM.isLittleEndian(), MTM,
-std::nullopt);
+const MipsSubtarget STI(TT, CPU, StringRef(strFS), MTM.isLittleEndian(),
+MTM, std::nullopt);
 
 bool IsABICalls = STI.isABICalls();
 const MipsABIInfo &ABI = MTM.getABI();
diff --git a/llvm/test/CodeGen/Mips/abiflags-soft-float.ll 
b/llvm/test/CodeGen/Mips/abiflags-soft-float.ll
new file mode 100644
index 0..01821f2d9b6c6
--- /dev/null
+++ b/llvm/test/CodeGen/Mips/abiflags-soft-float.ll
@@ -0,0 +1,12 @@
+; RUN: llc -filetype=obj -mtriple mipsel-unknown-linux -mcpu=mips32 %s -o tmp.o
+; RUN: llvm-readobj -A tmp.o | FileCheck %s -check-prefix=OBJ
+; RUN: llc -filetype=asm -mtriple mipsel-unknown-linux -mcpu=mips32 %s -o - | \
+; RUN: FileCheck %s -check-prefix=ASM
+
+; OBJ: FP ABI: Soft float
+; ASM: .module softfloat 
+
+define dso_local void @asm_is_null() "use-soft-float"="true" {
+  call void asm sideeffect "", ""()
+  ret void
+}

___
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: [Mips] Fix wrong ELF FP ABI info when inline asm was empty (#146457) (PR #150866)

2025-07-27 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/150866
___
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: [Mips] Fix wrong ELF FP ABI info when inline asm was empty (#146457) (PR #150866)

2025-07-27 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-mips

Author: None (llvmbot)


Changes

Backport 778fb76e6308534a63239a91b98f5dad055f6fdb

Requested by: @brad0

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


2 Files Affected:

- (modified) llvm/lib/Target/Mips/MipsAsmPrinter.cpp (+6-2) 
- (added) llvm/test/CodeGen/Mips/abiflags-soft-float.ll (+12) 


``diff
diff --git a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp 
b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
index 87e06a6d3c08a..2903ff75475cf 100644
--- a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -747,14 +747,18 @@ void MipsAsmPrinter::emitStartOfAsmFile(Module &M) {
 if (FS.empty() && M.size() && F->hasFnAttribute("target-features"))
   FS = F->getFnAttribute("target-features").getValueAsString();
 
+std::string strFS = FS.str();
+if (M.size() && F->getFnAttribute("use-soft-float").getValueAsBool())
+  strFS += strFS.empty() ? "+soft-float" : ",+soft-float";
+
 // Compute MIPS architecture attributes based on the default subtarget
 // that we'd have constructed.
 // FIXME: For ifunc related functions we could iterate over and look
 // for a feature string that doesn't match the default one.
 StringRef CPU = MIPS_MC::selectMipsCPU(TT, TM.getTargetCPU());
 const MipsTargetMachine &MTM = static_cast(TM);
-const MipsSubtarget STI(TT, CPU, FS, MTM.isLittleEndian(), MTM,
-std::nullopt);
+const MipsSubtarget STI(TT, CPU, StringRef(strFS), MTM.isLittleEndian(),
+MTM, std::nullopt);
 
 bool IsABICalls = STI.isABICalls();
 const MipsABIInfo &ABI = MTM.getABI();
diff --git a/llvm/test/CodeGen/Mips/abiflags-soft-float.ll 
b/llvm/test/CodeGen/Mips/abiflags-soft-float.ll
new file mode 100644
index 0..01821f2d9b6c6
--- /dev/null
+++ b/llvm/test/CodeGen/Mips/abiflags-soft-float.ll
@@ -0,0 +1,12 @@
+; RUN: llc -filetype=obj -mtriple mipsel-unknown-linux -mcpu=mips32 %s -o tmp.o
+; RUN: llvm-readobj -A tmp.o | FileCheck %s -check-prefix=OBJ
+; RUN: llc -filetype=asm -mtriple mipsel-unknown-linux -mcpu=mips32 %s -o - | \
+; RUN: FileCheck %s -check-prefix=ASM
+
+; OBJ: FP ABI: Soft float
+; ASM: .module softfloat 
+
+define dso_local void @asm_is_null() "use-soft-float"="true" {
+  call void asm sideeffect "", ""()
+  ret void
+}

``




https://github.com/llvm/llvm-project/pull/150866
___
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: [Mips] Fix wrong ELF FP ABI info when inline asm was empty (#146457) (PR #150866)

2025-07-27 Thread Brad Smith via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/150866
___
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: [Mips] Fix wrong ELF FP ABI info when inline asm was empty (#146457) (PR #150866)

2025-07-27 Thread via llvm-branch-commits

github-actions[bot] wrote:

⚠️ We detected that you are using a GitHub private e-mail address to contribute 
to the repo. Please turn off [Keep my email addresses 
private](https://github.com/settings/emails) setting in your account. See 
[LLVM Developer 
Policy](https://llvm.org/docs/DeveloperPolicy.html#email-addresses) and [LLVM 
Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it)
 for more information.

https://github.com/llvm/llvm-project/pull/150866
___
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] [NFCI][ELF][Mips] Refactor MipsGotSection to avoid explicit writes (PR #150730)

2025-07-27 Thread Brad Smith via llvm-branch-commits

brad0 wrote:

> It's indeed very difficult to find folks still concerned with MIPS... I 
> believe only one company is still actively contributing to the MIPS backend 
> in LLVM... @wzssyqa
> 
> Besides the ClangBuiltLinux maintainer and the OpenBSD maintainer continue to 
> support MIPS.

It's a catch 22 when the linker has never been feature complete / bug free 
enough to be usable. For OpenBSD it's the only arch we currently don't use as a 
linker due to issues / bugs.

https://github.com/llvm/llvm-project/pull/150730
___
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] [NFCI][ELF][Mips] Refactor MipsGotSection to avoid explicit writes (PR #150730)

2025-07-27 Thread Jessica Clarke via llvm-branch-commits

jrtc27 wrote:

> > It's indeed very difficult to find folks still concerned with MIPS... I 
> > believe only one company is still actively contributing to the MIPS backend 
> > in LLVM... @wzssyqa
> > Besides the ClangBuiltLinux maintainer and the OpenBSD maintainer continue 
> > to support MIPS.
> 
> It's a catch 22 when the linker has never been feature complete / bug free 
> enough to be usable. For OpenBSD it's the only arch we currently don't use as 
> a linker due to issues / bugs.

Hm, that surprises me. We got it to a good enough point to be usable as the 
system linker for FreeBSD, before MIPS was dropped as a supported architecture.

https://github.com/llvm/llvm-project/pull/150730
___
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] [NFCI][ELF][Mips] Refactor MipsGotSection to avoid explicit writes (PR #150730)

2025-07-27 Thread Brad Smith via llvm-branch-commits

brad0 wrote:

> Hm, that surprises me. We got it to a good enough point to be usable as the 
> system linker for FreeBSD, before MIPS was dropped as a supported 
> architecture.

We've run into bugs even with other OS's using the linker as a system linker on 
other arches too. Anyway, it's a bit frustrating as I can't get details out of 
the other developers and the group as a whole really does not seem to want to 
be involved with upstream unless its under their specific conditions.

https://github.com/llvm/llvm-project/pull/150730
___
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] [libc] [llvm] [libc][math] Refactor atanf16 implementation to header-only in src/__support/math folder. (PR #150868)

2025-07-27 Thread Muhammad Bassiouni via llvm-branch-commits

https://github.com/bassiounix created 
https://github.com/llvm/llvm-project/pull/150868

Part of #147386

in preparation for: 
https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450

>From 65ffa9615224d4ffe094b95ab197bf5ee5d1d529 Mon Sep 17 00:00:00 2001
From: bassiounix 
Date: Mon, 28 Jul 2025 05:26:38 +0300
Subject: [PATCH] [libc][math] Refactor atanf16 implementation to header-only
 in src/__support/math folder.

---
 libc/shared/math.h|   1 +
 libc/shared/math/atanf16.h|  28 +
 libc/src/__support/math/CMakeLists.txt|  15 +++
 libc/src/__support/math/atanf16.h | 119 ++
 libc/src/math/generic/CMakeLists.txt  |  12 +-
 libc/src/math/generic/atanf16.cpp |  95 +-
 libc/test/shared/CMakeLists.txt   |   1 +
 libc/test/shared/shared_math_test.cpp |   1 +
 .../llvm-project-overlay/libc/BUILD.bazel |  22 
 9 files changed, 190 insertions(+), 104 deletions(-)
 create mode 100644 libc/shared/math/atanf16.h
 create mode 100644 libc/src/__support/math/atanf16.h

diff --git a/libc/shared/math.h b/libc/shared/math.h
index 21536647948f4..bcbe0de56170a 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -24,6 +24,7 @@
 #include "math/asinhf16.h"
 #include "math/atan.h"
 #include "math/atanf.h"
+#include "math/atanf16.h"
 #include "math/erff.h"
 #include "math/exp.h"
 #include "math/exp10.h"
diff --git a/libc/shared/math/atanf16.h b/libc/shared/math/atanf16.h
new file mode 100644
index 0..f196907059e01
--- /dev/null
+++ b/libc/shared/math/atanf16.h
@@ -0,0 +1,28 @@
+//===-- Shared atanf16 function -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_ATANF16_H
+#define LLVM_LIBC_SHARED_MATH_ATANF16_H
+
+#include "shared/libc_common.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/atanf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::atanf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_ATANF16_H
diff --git a/libc/src/__support/math/CMakeLists.txt 
b/libc/src/__support/math/CMakeLists.txt
index 95acc962cc885..04cbd3fd1cc01 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -214,6 +214,21 @@ add_header_library(
 libc.src.__support.macros.optimization
 )
 
+add_header_library(
+  atanf16
+  HDRS
+atanf16.h
+  DEPENDS
+libc.src.__support.FPUtil.cast
+libc.src.__support.FPUtil.except_value_utils
+libc.src.__support.FPUtil.fenv_impl
+libc.src.__support.FPUtil.fp_bits
+libc.src.__support.FPUtil.multiply_add
+libc.src.__support.FPUtil.polyeval
+libc.src.__support.FPUtil.sqrt
+libc.src.__support.macros.optimization
+)
+
 add_header_library(
   asinf
   HDRS
diff --git a/libc/src/__support/math/atanf16.h 
b/libc/src/__support/math/atanf16.h
new file mode 100644
index 0..f75d145f36852
--- /dev/null
+++ b/libc/src/__support/math/atanf16.h
@@ -0,0 +1,119 @@
+//===-- Implementation header for atanf16 ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ATANF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_ATANF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/PolyEval.h"
+#include "src/__support/FPUtil/cast.h"
+#include "src/__support/FPUtil/except_value_utils.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/FPUtil/sqrt.h"
+#include "src/__support/macros/optimization.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE static constexpr float16 atanf16(float16 x) {
+  // Generated by Solly using the following command:
+  // > round(pi/2, SG, RN);
+  constexpr float PI_2 = 0x1.921fb6p0;
+
+#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+  constexpr size_t N_EXCEPTS = 6;
+
+  constexpr fputil::ExceptValues ATANF16_EXCEPTS{{
+  // (input, RZ output, RU offset, RD offset, RN offset)
+  {0x2745, 0x2744, 1, 0, 1},
+  {0x3099, 0x3090, 1, 0, 1},
+  {0x3c6c, 0x3aae, 1, 0, 1},
+  {0x466e, 0x3daa, 1, 0, 1},
+  {0x48a

[llvm-branch-commits] [libc] [llvm] [libc][math] Refactor atanf16 implementation to header-only in src/__support/math folder. (PR #150868)

2025-07-27 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libc

Author: Muhammad Bassiouni (bassiounix)


Changes

Part of #147386

in preparation for: 
https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450

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


9 Files Affected:

- (modified) libc/shared/math.h (+1) 
- (added) libc/shared/math/atanf16.h (+28) 
- (modified) libc/src/__support/math/CMakeLists.txt (+15) 
- (added) libc/src/__support/math/atanf16.h (+119) 
- (modified) libc/src/math/generic/CMakeLists.txt (+1-11) 
- (modified) libc/src/math/generic/atanf16.cpp (+2-93) 
- (modified) libc/test/shared/CMakeLists.txt (+1) 
- (modified) libc/test/shared/shared_math_test.cpp (+1) 
- (modified) utils/bazel/llvm-project-overlay/libc/BUILD.bazel (+22) 


``diff
diff --git a/libc/shared/math.h b/libc/shared/math.h
index 21536647948f4..bcbe0de56170a 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -24,6 +24,7 @@
 #include "math/asinhf16.h"
 #include "math/atan.h"
 #include "math/atanf.h"
+#include "math/atanf16.h"
 #include "math/erff.h"
 #include "math/exp.h"
 #include "math/exp10.h"
diff --git a/libc/shared/math/atanf16.h b/libc/shared/math/atanf16.h
new file mode 100644
index 0..f196907059e01
--- /dev/null
+++ b/libc/shared/math/atanf16.h
@@ -0,0 +1,28 @@
+//===-- Shared atanf16 function -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_ATANF16_H
+#define LLVM_LIBC_SHARED_MATH_ATANF16_H
+
+#include "shared/libc_common.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/atanf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::atanf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_ATANF16_H
diff --git a/libc/src/__support/math/CMakeLists.txt 
b/libc/src/__support/math/CMakeLists.txt
index 95acc962cc885..04cbd3fd1cc01 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -214,6 +214,21 @@ add_header_library(
 libc.src.__support.macros.optimization
 )
 
+add_header_library(
+  atanf16
+  HDRS
+atanf16.h
+  DEPENDS
+libc.src.__support.FPUtil.cast
+libc.src.__support.FPUtil.except_value_utils
+libc.src.__support.FPUtil.fenv_impl
+libc.src.__support.FPUtil.fp_bits
+libc.src.__support.FPUtil.multiply_add
+libc.src.__support.FPUtil.polyeval
+libc.src.__support.FPUtil.sqrt
+libc.src.__support.macros.optimization
+)
+
 add_header_library(
   asinf
   HDRS
diff --git a/libc/src/__support/math/atanf16.h 
b/libc/src/__support/math/atanf16.h
new file mode 100644
index 0..f75d145f36852
--- /dev/null
+++ b/libc/src/__support/math/atanf16.h
@@ -0,0 +1,119 @@
+//===-- Implementation header for atanf16 ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ATANF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_ATANF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/PolyEval.h"
+#include "src/__support/FPUtil/cast.h"
+#include "src/__support/FPUtil/except_value_utils.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/FPUtil/sqrt.h"
+#include "src/__support/macros/optimization.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE static constexpr float16 atanf16(float16 x) {
+  // Generated by Solly using the following command:
+  // > round(pi/2, SG, RN);
+  constexpr float PI_2 = 0x1.921fb6p0;
+
+#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+  constexpr size_t N_EXCEPTS = 6;
+
+  constexpr fputil::ExceptValues ATANF16_EXCEPTS{{
+  // (input, RZ output, RU offset, RD offset, RN offset)
+  {0x2745, 0x2744, 1, 0, 1},
+  {0x3099, 0x3090, 1, 0, 1},
+  {0x3c6c, 0x3aae, 1, 0, 1},
+  {0x466e, 0x3daa, 1, 0, 1},
+  {0x48ae, 0x3ddb, 1, 0, 0},
+  {0x5619, 0x3e3d, 1, 0, 1},
+  }};
+#endif // !LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+
+  using FPBits = fputil::FPBits;
+  FPBits xbits(x);
+
+  uint16_t x_u = xbits.uintval();
+  uint16_t x_abs = x_u & 0x7fff;
+  bool x_sign = x_u >> 15;
+  float sign = (x_sign ? -1.0 : 1.0);
+
+  // |x| >= +/-inf
+  if (L

[llvm-branch-commits] [libc] [llvm] [libc][math] Refactor atanf16 implementation to header-only in src/__support/math folder. (PR #150868)

2025-07-27 Thread Muhammad Bassiouni via llvm-branch-commits

bassiounix 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/150868?utm_source=stack-comment-downstack-mergeability-warning";
>  >on Graphite.
> https://graphite.dev/docs/merge-pull-requests";>Learn more

* **#150868** https://app.graphite.dev/github/pr/llvm/llvm-project/150868?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/150868?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#150854** https://app.graphite.dev/github/pr/llvm/llvm-project/150854?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#150852** https://app.graphite.dev/github/pr/llvm/llvm-project/150852?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#150849** https://app.graphite.dev/github/pr/llvm/llvm-project/150849?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#150843** https://app.graphite.dev/github/pr/llvm/llvm-project/150843?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/150868
___
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] [NFCI][ELF] Merge AddendOnly and AddendOnlyWithTargetVA (PR #150797)

2025-07-27 Thread Alexander Richardson via llvm-branch-commits


@@ -422,13 +422,10 @@ class DynamicReloc {
 /// The resulting dynamic relocation has already had its addend computed.
 /// Calling computeAddend() is an error. Only for internal use.
 Computed,
-/// The resulting dynamic relocation does not reference a symbol (#sym must
-/// be nullptr) and uses #addend as the result of computeAddend(ctx).
-AddendOnly,
 /// The resulting dynamic relocation will not reference a symbol: #sym is
 /// only used to compute the addend with InputSection::getRelocTargetVA().
 /// Useful for various relative and TLS relocations (e.g. 
R_X86_64_TPOFF64).
-AddendOnlyWithTargetVA,
+AddendOnly,

arichardson wrote:

Well Ctx().dummySym to be precise.

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


  1   2   >