[llvm-branch-commits] [llvm] [StaticDataLayout] Factor out a helper function for section prefix eligibility and use it in both optimizer and codegen (PR #162348)

2025-10-18 Thread Mingming Liu via llvm-branch-commits

https://github.com/mingmingl-llvm updated 
https://github.com/llvm/llvm-project/pull/162348

>From f68b06f65609078d7e1c788e95d78fab397e4966 Mon Sep 17 00:00:00 2001
From: mingmingl 
Date: Tue, 7 Oct 2025 11:59:13 -0700
Subject: [PATCH 01/10] [nfc][StaticDataLayout]Add helper functions to tell the
 eligibility status of a global variable for section prefix annotation

---
 .../llvm/Analysis/StaticDataProfileInfo.h | 18 +
 llvm/lib/Analysis/StaticDataProfileInfo.cpp   | 37 +++
 llvm/lib/CodeGen/StaticDataAnnotator.cpp  | 15 +---
 .../Transforms/Instrumentation/MemProfUse.cpp | 30 ---
 4 files changed, 65 insertions(+), 35 deletions(-)

diff --git a/llvm/include/llvm/Analysis/StaticDataProfileInfo.h 
b/llvm/include/llvm/Analysis/StaticDataProfileInfo.h
index fa21eba1377df..f06e7ceaa74ce 100644
--- a/llvm/include/llvm/Analysis/StaticDataProfileInfo.h
+++ b/llvm/include/llvm/Analysis/StaticDataProfileInfo.h
@@ -10,6 +10,24 @@
 
 namespace llvm {
 
+namespace memprof {
+// Represents the eligibility status of a global variable for section prefix
+// annotation. Other than AnnotationOk, each enum value indicates a specific
+// reason for ineligibility.
+enum class AnnotationKind : uint8_t {
+  AnnotationOK,
+  DeclForLinker,
+  ExplicitSection,
+  ReservedName,
+};
+/// Returns the annotation kind of the global variable \p GV.
+AnnotationKind getAnnotationKind(const GlobalVariable &GV);
+
+/// Returns true if the annotation kind of the global variable \p GV is
+/// AnnotationOK.
+bool IsAnnotationOK(const GlobalVariable &GV);
+} // namespace memprof
+
 /// A class that holds the constants that represent static data and their
 /// profile information and provides methods to operate on them.
 class StaticDataProfileInfo {
diff --git a/llvm/lib/Analysis/StaticDataProfileInfo.cpp 
b/llvm/lib/Analysis/StaticDataProfileInfo.cpp
index b036b2dde770e..ff4582ca7eeb1 100644
--- a/llvm/lib/Analysis/StaticDataProfileInfo.cpp
+++ b/llvm/lib/Analysis/StaticDataProfileInfo.cpp
@@ -6,6 +6,43 @@
 #include "llvm/ProfileData/InstrProf.h"
 
 using namespace llvm;
+
+namespace llvm {
+namespace memprof {
+// Returns true iff the global variable has custom section either by
+// __attribute__((section("name")))
+// 
(https://clang.llvm.org/docs/AttributeReference.html#section-declspec-allocate)
+// or #pragma clang section directives
+// 
(https://clang.llvm.org/docs/LanguageExtensions.html#specifying-section-names-for-global-objects-pragma-clang-section).
+static bool hasExplicitSectionName(const GlobalVariable &GVar) {
+  if (GVar.hasSection())
+return true;
+
+  auto Attrs = GVar.getAttributes();
+  if (Attrs.hasAttribute("bss-section") || Attrs.hasAttribute("data-section") 
||
+  Attrs.hasAttribute("relro-section") ||
+  Attrs.hasAttribute("rodata-section"))
+return true;
+  return false;
+}
+
+AnnotationKind getAnnotationKind(const GlobalVariable &GV) {
+  if (GV.isDeclarationForLinker())
+return AnnotationKind::DeclForLinker;
+  StringRef Name = GV.getName();
+  if (Name.starts_with("llvm."))
+return AnnotationKind::ReservedName;
+  if (hasExplicitSectionName(GV))
+return AnnotationKind::ExplicitSection;
+  return AnnotationKind::AnnotationOK;
+}
+
+bool IsAnnotationOK(const GlobalVariable &GV) {
+  return getAnnotationKind(GV) == AnnotationKind::AnnotationOK;
+}
+} // namespace memprof
+} // namespace llvm
+
 void StaticDataProfileInfo::addConstantProfileCount(
 const Constant *C, std::optional Count) {
   if (!Count) {
diff --git a/llvm/lib/CodeGen/StaticDataAnnotator.cpp 
b/llvm/lib/CodeGen/StaticDataAnnotator.cpp
index 53a9ab4dbda02..9a68ee96ab056 100644
--- a/llvm/lib/CodeGen/StaticDataAnnotator.cpp
+++ b/llvm/lib/CodeGen/StaticDataAnnotator.cpp
@@ -75,22 +75,11 @@ bool StaticDataAnnotator::runOnModule(Module &M) {
 
   bool Changed = false;
   for (auto &GV : M.globals()) {
-if (GV.isDeclarationForLinker())
+if (!llvm::memprof::IsAnnotationOK(GV))
   continue;
 
-// The implementation below assumes prior passes don't set section 
prefixes,
-// and specifically do 'assign' rather than 'update'. So report error if a
-// section prefix is already set.
-if (auto maybeSectionPrefix = GV.getSectionPrefix();
-maybeSectionPrefix && !maybeSectionPrefix->empty())
-  llvm::report_fatal_error("Global variable " + GV.getName() +
-   " already has a section prefix " +
-   *maybeSectionPrefix);
-
 StringRef SectionPrefix = SDPI->getConstantSectionPrefix(&GV, PSI);
-if (SectionPrefix.empty())
-  continue;
-
+// setSectionPrefix returns true if the section prefix is changed.
 Changed |= GV.setSectionPrefix(SectionPrefix);
   }
 
diff --git a/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp 
b/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp
index d86fcf268ce4f..ca2af1a9534d3 100644
--- a/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp
+++ b/

[llvm-branch-commits] [clang] [Clang] Introduce -fsanitize=alloc-token (PR #156839)

2025-10-18 Thread Hans Wennborg via llvm-branch-commits


@@ -0,0 +1,173 @@
+=
+Allocation Tokens

zmodem wrote:

Thanks for writing comprehensive documentation!

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


[llvm-branch-commits] [clang] [llvm] [AArch64][llvm] Armv9.7-A: Add support for SVE2p3 arithmetic operations (PR #163160)

2025-10-18 Thread Jonathan Thackray via llvm-branch-commits

https://github.com/jthackray updated 
https://github.com/llvm/llvm-project/pull/163160

>From cb1530ff8ccdaab1ed36a38eb741dafa35c1a7e3 Mon Sep 17 00:00:00 2001
From: Jonathan Thackray 
Date: Mon, 8 Sep 2025 16:47:07 +0100
Subject: [PATCH 1/3] [AArch64][llvm] Armv9.7-A: Add support for SVE2p3
 arithmetic operations

Add instructions for SVE2p3 arithmetic operations:
  - `ADDQP`(add pairwise within quadword vector segments)
  - `ADDSUBP`  (add subtract pairwise)
  - `SABAL`(two-way signed absolute difference sum and accumulate long)
  - `SUBP` (subtract pairwise)
  - `UABAL`(two-way unsigned absolute difference sum and accumulate long)

as documented here:

  * https://developer.arm.com/documentation/ddi0602/2025-09/
  * 
https://developer.arm.com/documentation/109697/2025_09/2025-Architecture-Extensions
---
 clang/test/Driver/aarch64-v97a.c  |  12 +-
 .../print-supported-extensions-aarch64.c  |   2 +
 llvm/lib/Target/AArch64/AArch64.td|  13 +-
 llvm/lib/Target/AArch64/AArch64Features.td|  10 +-
 llvm/lib/Target/AArch64/AArch64InstrInfo.td   |   4 +
 .../lib/Target/AArch64/AArch64SVEInstrInfo.td |  18 ++
 .../AArch64/AsmParser/AArch64AsmParser.cpp|   2 +
 llvm/lib/Target/AArch64/SVEInstrFormats.td|  32 +-
 .../AArch64/SVE2p3/arithmetic-diagnostics.s   | 147 ++
 llvm/test/MC/AArch64/SVE2p3/arithmetic.s  | 275 ++
 .../AArch64/SVE2p3/directive-arch-negative.s  |   7 +
 .../directive-arch_extension-negative.s   |   7 +
 .../AArch64/SVE2p3/directive-cpu-negative.s   |   7 +
 .../TargetParser/TargetParserTest.cpp |  15 +-
 14 files changed, 530 insertions(+), 21 deletions(-)
 create mode 100644 llvm/test/MC/AArch64/SVE2p3/arithmetic-diagnostics.s
 create mode 100644 llvm/test/MC/AArch64/SVE2p3/arithmetic.s
 create mode 100644 llvm/test/MC/AArch64/SVE2p3/directive-arch-negative.s
 create mode 100644 
llvm/test/MC/AArch64/SVE2p3/directive-arch_extension-negative.s
 create mode 100644 llvm/test/MC/AArch64/SVE2p3/directive-cpu-negative.s

diff --git a/clang/test/Driver/aarch64-v97a.c b/clang/test/Driver/aarch64-v97a.c
index 8518d6b069556..a607c1f92ed07 100644
--- a/clang/test/Driver/aarch64-v97a.c
+++ b/clang/test/Driver/aarch64-v97a.c
@@ -6,7 +6,7 @@
 // RUN: %clang -target aarch64 -mlittle-endian -march=armv9.7-a -### -c %s 
2>&1 | FileCheck -check-prefix=GENERICV97A %s
 // RUN: %clang -target aarch64_be -mlittle-endian -march=armv9.7a -### -c %s 
2>&1 | FileCheck -check-prefix=GENERICV97A %s
 // RUN: %clang -target aarch64_be -mlittle-endian -march=armv9.7-a -### -c %s 
2>&1 | FileCheck -check-prefix=GENERICV97A %s
-// GENERICV97A: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" 
"-target-feature" "+v9.7a"{{.*}}
+// GENERICV97A: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" 
"-target-feature" "+v9.7a"{{.*}} "-target-feature" "+sve2p3"
 
 // RUN: %clang -target aarch64_be -march=armv9.7a -### -c %s 2>&1 | FileCheck 
-check-prefix=GENERICV97A-BE %s
 // RUN: %clang -target aarch64_be -march=armv9.7-a -### -c %s 2>&1 | FileCheck 
-check-prefix=GENERICV97A-BE %s
@@ -14,10 +14,18 @@
 // RUN: %clang -target aarch64 -mbig-endian -march=armv9.7-a -### -c %s 2>&1 | 
FileCheck -check-prefix=GENERICV97A-BE %s
 // RUN: %clang -target aarch64_be -mbig-endian -march=armv9.7a -### -c %s 2>&1 
| FileCheck -check-prefix=GENERICV97A-BE %s
 // RUN: %clang -target aarch64_be -mbig-endian -march=armv9.7-a -### -c %s 
2>&1 | FileCheck -check-prefix=GENERICV97A-BE %s
-// GENERICV97A-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" 
"generic" "-target-feature" "+v9.7a"{{.*}}
+// GENERICV97A-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" 
"generic" "-target-feature" "+v9.7a"{{.*}} "-target-feature" "+sve2p3"
 
 // = Features supported on aarch64 =
 
+// RUN: %clang -target aarch64 -march=armv9.7a+sme2p3 -### -c %s 2>&1 | 
FileCheck -check-prefix=V97A-SME2p3 %s
+// RUN: %clang -target aarch64 -march=armv9.7-a+sme2p3 -### -c %s 2>&1 | 
FileCheck -check-prefix=V97A-SME2p3 %s
+// V97A-SME2p3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" 
"-target-feature" "+v9.7a"{{.*}} "-target-feature" "+sme2p3"
+
+// RUN: %clang -target aarch64 -march=armv9.7a+sve2p3 -### -c %s 2>&1 | 
FileCheck -check-prefix=V97A-SVE2p3 %s
+// RUN: %clang -target aarch64 -march=armv9.7-a+sve2p3 -### -c %s 2>&1 | 
FileCheck -check-prefix=V97A-SVE2p3 %s
+// V97A-SVE2p3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" 
"-target-feature" "+v9.7a"{{.*}} "-target-feature" "+sve2p3"
+
 // RUN: %clang -target aarch64 -march=armv9.7a+cmh -### -c %s 2>&1 | FileCheck 
-check-prefix=V97A-CMH %s
 // RUN: %clang -target aarch64 -march=armv9.7-a+cmh -### -c %s 2>&1 | 
FileCheck -check-prefix=V97A-CMH %s
 // V97A-CMH: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" 
"-target-feature" "+v9.7a"{{.*}} "-target-feature" "+cmh"
diff --git a/clang/test/Driver/print-supported-extensions-aarc

[llvm-branch-commits] [MC] Pass through MCDecodedPseudoProbe::print ShowName param (PR #162557)

2025-10-18 Thread Amir Ayupov via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [DirectX] Updating DXContainer logic to read version 1.2 of static samplers (PR #160184)

2025-10-18 Thread Finn Plummer via llvm-branch-commits


@@ -1200,4 +1200,49 @@ TEST(RootSignature, ParseStaticSamplers) {
 ASSERT_EQ(Sampler.RegisterSpace, 32u);
 ASSERT_EQ(Sampler.ShaderVisibility, 7u);
   }
+  {

inbelic wrote:

Can we add some indication of what this test is uniquely testing? (I assume the 
version and sampler flag fields, plus updated size computation)

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


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

2025-10-18 Thread Marco Elver via llvm-branch-commits

https://github.com/melver updated 
https://github.com/llvm/llvm-project/pull/156842

>From 48227c8f7712b2dc807b252d18353c91905b1fb5 Mon Sep 17 00:00:00 2001
From: Marco Elver 
Date: Mon, 8 Sep 2025 17:19:04 +0200
Subject: [PATCH] fixup!

Created using spr 1.3.8-beta.1
---
 llvm/lib/Transforms/Instrumentation/AllocToken.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Transforms/Instrumentation/AllocToken.cpp 
b/llvm/lib/Transforms/Instrumentation/AllocToken.cpp
index d5ac3035df71b..3a28705d87523 100644
--- a/llvm/lib/Transforms/Instrumentation/AllocToken.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AllocToken.cpp
@@ -151,7 +151,8 @@ STATISTIC(NumAllocations, "Allocations found");
 /// Expected format is: !{, }
 MDNode *getAllocTokenHintMetadata(const CallBase &CB) {
   MDNode *Ret = nullptr;
-  if (auto *II = dyn_cast(&CB)) {
+  if (auto *II = dyn_cast(&CB);
+  II && II->getIntrinsicID() == Intrinsic::alloc_token_id) {
 auto *MDV = cast(II->getArgOperand(0));
 Ret = cast(MDV->getMetadata());
 // If the intrinsic has an empty MDNode, type inference failed.
@@ -358,7 +359,7 @@ bool AllocToken::instrumentFunction(Function &F) {
   // Collect all allocation calls to avoid iterator invalidation.
   for (Instruction &I : instructions(F)) {
 // Collect all alloc_token_* intrinsics.
-if (IntrinsicInst *II = dyn_cast(&I);
+if (auto *II = dyn_cast(&I);
 II && II->getIntrinsicID() == Intrinsic::alloc_token_id) {
   IntrinsicInsts.emplace_back(II);
   continue;

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


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

2025-10-18 Thread Muhammad Bassiouni via llvm-branch-commits

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

>From f2e2010a4077d9bf0f2cb55e05f0273c3c6fe10b Mon Sep 17 00:00:00 2001
From: bassiounix 
Date: Sun, 5 Oct 2025 17:52:54 +0300
Subject: [PATCH] [libc][math] Refactor exp2m1f implementation to header-only
 in src/__support/math folder.

---
 libc/shared/math.h|   1 +
 libc/shared/math/exp2m1f.h|  23 +++
 libc/src/__support/math/CMakeLists.txt|  18 ++
 libc/src/__support/math/exp2m1f.h | 195 ++
 libc/src/math/generic/CMakeLists.txt  |  12 +-
 libc/src/math/generic/exp2m1f.cpp | 177 +---
 libc/test/shared/CMakeLists.txt   |   1 +
 libc/test/shared/shared_math_test.cpp |   1 +
 .../llvm-project-overlay/libc/BUILD.bazel |  19 +-
 9 files changed, 259 insertions(+), 188 deletions(-)
 create mode 100644 libc/shared/math/exp2m1f.h
 create mode 100644 libc/src/__support/math/exp2m1f.h

diff --git a/libc/shared/math.h b/libc/shared/math.h
index 8bff70f1c5336..0c0e8560bd40f 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -50,6 +50,7 @@
 #include "math/exp2.h"
 #include "math/exp2f.h"
 #include "math/exp2f16.h"
+#include "math/exp2m1f.h"
 #include "math/expf.h"
 #include "math/expf16.h"
 #include "math/frexpf.h"
diff --git a/libc/shared/math/exp2m1f.h b/libc/shared/math/exp2m1f.h
new file mode 100644
index 0..ca9754774f0fc
--- /dev/null
+++ b/libc/shared/math/exp2m1f.h
@@ -0,0 +1,23 @@
+//===-- Shared exp2m1f 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_EXP2M1F_H
+#define LLVM_LIBC_SHARED_MATH_EXP2M1F_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/exp2m1f.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::exp2m1f;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_EXP2M1F_H
diff --git a/libc/src/__support/math/CMakeLists.txt 
b/libc/src/__support/math/CMakeLists.txt
index 185900efa7354..ec2d8948f615b 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -767,6 +767,24 @@ add_header_library(
 libc.src.__support.macros.optimization
 )
 
+add_header_library(
+  exp2m1f
+  HDRS
+exp2m1f.h
+  DEPENDS
+.exp10f_utils
+libc.src.errno.errno
+libc.src.__support.common
+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.rounding_mode
+libc.src.__support.macros.optimization
+libc.src.__support.macros.properties.cpu_features
+)
+
 add_header_library(
   exp10
   HDRS
diff --git a/libc/src/__support/math/exp2m1f.h 
b/libc/src/__support/math/exp2m1f.h
new file mode 100644
index 0..e95076c9eac22
--- /dev/null
+++ b/libc/src/__support/math/exp2m1f.h
@@ -0,0 +1,195 @@
+//===-- Implementation header for exp2m1f *- 
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_EXP2M1F_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_EXP2M1F_H
+
+#include "exp10f_utils.h"
+#include "src/__support/FPUtil/FEnvImpl.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/rounding_mode.h"
+#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h"
+#include "src/__support/macros/properties/cpu_features.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE static constexpr float exp2m1f(float x) {
+#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+  constexpr size_t N_EXCEPTS_LO = 8;
+
+  constexpr fputil::ExceptValues EXP2M1F_EXCEPTS_LO = {{
+  // (input, RZ output, RU offset, RD offset, RN offset)
+  // x = 0x1.36dc8ep-36, exp2m1f(x) = 0x1.aef212p-37 (RZ)
+  {0x2d9b'6e47U, 0x2d57'7909U, 1U, 0U, 0U},
+  // x = 0x1.224936p-19, exp2m1f(x) = 0x1.926c0ep-20 (RZ)
+  {0x3611'249bU, 0x35c9'3607U, 1U, 0U, 1U},
+  // x = 0x1.d16d2p-20, exp2m1f(x) = 0x1.429becp-20 (RZ)
+  {0x35e8'b690U, 0x35a1'4df6U, 1U, 0U, 1U}

[llvm-branch-commits] [flang] [flang][OpenMP] Dump requirement clauses/flags in WithOmpDeclarative (PR #163450)

2025-10-18 Thread Krzysztof Parzyszek via llvm-branch-commits

https://github.com/kparzysz created 
https://github.com/llvm/llvm-project/pull/163450

None

>From 639f10efafc662f28644f71301f40f8c51012cf8 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Tue, 14 Oct 2025 15:02:19 -0500
Subject: [PATCH] [flang][OpenMP] Dump requirement clauses/flags in
 WithOmpDeclarative

---
 flang/include/flang/Semantics/symbol.h|  3 ++
 flang/lib/Semantics/symbol.cpp| 32 ++-
 .../OpenMP/dump-requires-details.f90  | 14 
 3 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 flang/test/Semantics/OpenMP/dump-requires-details.f90

diff --git a/flang/include/flang/Semantics/symbol.h 
b/flang/include/flang/Semantics/symbol.h
index 14da5b443633f..04a063957082a 100644
--- a/flang/include/flang/Semantics/symbol.h
+++ b/flang/include/flang/Semantics/symbol.h
@@ -73,6 +73,9 @@ class WithOmpDeclarative {
 ompAtomicDefaultMemOrder_ = flags;
   }
 
+  friend llvm::raw_ostream &operator<<(
+  llvm::raw_ostream &, const WithOmpDeclarative &);
+
 private:
   std::optional ompRequires_;
   std::optional ompAtomicDefaultMemOrder_;
diff --git a/flang/lib/Semantics/symbol.cpp b/flang/lib/Semantics/symbol.cpp
index 69169469fe8ce..a5f9706a73cf7 100644
--- a/flang/lib/Semantics/symbol.cpp
+++ b/flang/lib/Semantics/symbol.cpp
@@ -70,6 +70,32 @@ static void DumpList(llvm::raw_ostream &os, const char 
*label, const T &list) {
   }
 }
 
+llvm::raw_ostream &operator<<(
+llvm::raw_ostream &os, const WithOmpDeclarative &x) {
+  if (x.has_ompRequires() || x.has_ompAtomicDefaultMemOrder()) {
+os << " OmpRequirements:(";
+if (const common::OmpMemoryOrderType *atmo{x.ompAtomicDefaultMemOrder()}) {
+  os << parser::ToLowerCaseLetters(llvm::omp::getOpenMPClauseName(
+llvm::omp::Clause::OMPC_atomic_default_mem_order))
+ << '(' << parser::ToLowerCaseLetters(EnumToString(*atmo)) << ')';
+  if (x.has_ompRequires()) {
+os << ',';
+  }
+}
+if (const WithOmpDeclarative::RequiresClauses *reqs{x.ompRequires()}) {
+  size_t num{0}, size{reqs->count()};
+  reqs->IterateOverMembers([&](llvm::omp::Clause f) {
+os << parser::ToLowerCaseLetters(llvm::omp::getOpenMPClauseName(f));
+if (++num < size) {
+  os << ',';
+}
+  });
+}
+os << ')';
+  }
+  return os;
+}
+
 void SubprogramDetails::set_moduleInterface(Symbol &symbol) {
   CHECK(!moduleInterface_);
   moduleInterface_ = &symbol;
@@ -150,6 +176,7 @@ llvm::raw_ostream &operator<<(
   os << x;
 }
   }
+  os << static_cast(x);
   return os;
 }
 
@@ -580,7 +607,9 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const 
Details &details) {
   common::visit( //
   common::visitors{
   [&](const UnknownDetails &) {},
-  [&](const MainProgramDetails &) {},
+  [&](const MainProgramDetails &x) {
+os << static_cast(x);
+  },
   [&](const ModuleDetails &x) {
 if (x.isSubmodule()) {
   os << " (";
@@ -599,6 +628,7 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const 
Details &details) {
 if (x.isDefaultPrivate()) {
   os << " isDefaultPrivate";
 }
+os << static_cast(x);
   },
   [&](const SubprogramNameDetails &x) {
 os << ' ' << EnumToString(x.kind());
diff --git a/flang/test/Semantics/OpenMP/dump-requires-details.f90 
b/flang/test/Semantics/OpenMP/dump-requires-details.f90
new file mode 100644
index 0..9c844c092c5e6
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/dump-requires-details.f90
@@ -0,0 +1,14 @@
+!RUN: %flang_fc1 -fopenmp -fopenmp-version=60 -fdebug-dump-symbols %s | 
FileCheck %s
+
+module fred
+!$omp requires atomic_default_mem_order(relaxed)
+contains
+subroutine f00
+  !$omp requires unified_address
+end
+subroutine f01
+  !$omp requires unified_shared_memory
+end
+end module
+
+!CHECK: fred: Module 
OmpRequirements:(atomic_default_mem_order(relaxed),unified_address,unified_shared_memory)

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


[llvm-branch-commits] [llvm] [StaticDataLayout] Factor out a helper function for section prefix eligibility and use it in both optimizer and codegen (PR #162348)

2025-10-18 Thread Mingming Liu via llvm-branch-commits


@@ -0,0 +1,42 @@
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+;; A minimal test case. llc will crash if global variables already has a 
section

mingmingl-llvm wrote:

done in https://github.com/llvm/llvm-project/pull/162938 to pre-commit the test 
case.

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


[llvm-branch-commits] [AllocToken, Clang] Infer type hints from sizeof expressions and casts (PR #156841)

2025-10-18 Thread Marco Elver via llvm-branch-commits

https://github.com/melver updated 
https://github.com/llvm/llvm-project/pull/156841


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


[llvm-branch-commits] [clang] Add pointer field protection feature. (PR #133538)

2025-10-18 Thread Peter Collingbourne via llvm-branch-commits

https://github.com/pcc updated https://github.com/llvm/llvm-project/pull/133538

>From e816ed160ed53ff8d9d9039b778c41ecad8a7da2 Mon Sep 17 00:00:00 2001
From: Peter Collingbourne 
Date: Wed, 6 Aug 2025 17:12:25 -0700
Subject: [PATCH 1/2] Add tests and documentation

Created using spr 1.3.6-beta.1
---
 clang/docs/StructureProtection.rst   |  32 +++-
 clang/docs/index.rst |   1 +
 clang/lib/CodeGen/CGCall.cpp |  21 ++-
 clang/test/CodeGenCXX/pfp-coerce.cpp | 220 +++
 clang/test/CodeGenCXX/pfp-null-init.cpp  |  13 +-
 clang/test/CodeGenCXX/pfp-struct-gep.cpp |  29 ++-
 6 files changed, 296 insertions(+), 20 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/pfp-coerce.cpp

diff --git a/clang/docs/StructureProtection.rst 
b/clang/docs/StructureProtection.rst
index 06187f270d49a..6db01cc579b8e 100644
--- a/clang/docs/StructureProtection.rst
+++ b/clang/docs/StructureProtection.rst
@@ -9,11 +9,12 @@ Structure Protection
 Introduction
 
 
-Structure protection is an experimental mitigation against use-after-free
-vulnerabilities. For more details, please see the original `RFC
+Structure protection is an *experimental* mitigation
+against use-after-free vulnerabilities. For
+more information, please see the original `RFC
 
`_.
-An independent set of documentation will be added here when the feature
-is promoted to non-experimental.
+An independent set of documentation will be contributed when the feature
+is promoted to stable.
 
 Usage
 =
@@ -24,9 +25,30 @@ To use structure protection, build your program using one of 
the flags:
   field protection with untagged pointers.
 
 - ``-fexperimental-pointer-field-protection=tagged``: Enable pointer
-  field protection with heap pointers assumed to be tagged by the allocator:
+  field protection with heap pointers assumed to be tagged by the allocator.
 
 The entire C++ part of the program must be built with a consistent
 ``-fexperimental-pointer-field-protection`` flag, and the C++ standard
 library must also be built with the same flag and statically linked into
 the program.
+
+To build libc++ with pointer field protection support, pass the following
+CMake flags:
+
+.. code-block:: console
+ 
+"-DRUNTIMES_${triple}_LIBCXXABI_ENABLE_SHARED=OFF" \
+"-DRUNTIMES_${triple}_LIBCXX_USE_COMPILER_RT=ON" \
+"-DRUNTIMES_${triple}_LIBCXX_PFP=untagged" \
+"-DRUNTIMES_${triple}_LIBCXX_ENABLE_SHARED=OFF" \
+"-DRUNTIMES_${triple}_LIBCXX_TEST_CONFIG=llvm-libc++-static.cfg.in" \
+"-DRUNTIMES_${triple}_LIBUNWIND_ENABLE_SHARED=OFF" \
+
+where ``${triple}`` is your target triple, such as
+``aarch64-unknown-linux``.
+
+The resulting toolchain may then be used to build programs
+with pointer field protection by passing ``-stdlib=libc++
+-fexperimental-pointer-field-protection=untagged`` at compile time
+and ``-Wl,-Bstatic -lc++ -lc++abi -Wl,-Bdynamic -lm -fuse-ld=lld
+-static-libstdc++`` at link time.
diff --git a/clang/docs/index.rst b/clang/docs/index.rst
index 4871d05e932ae..e267c66af1e1d 100644
--- a/clang/docs/index.rst
+++ b/clang/docs/index.rst
@@ -47,6 +47,7 @@ Using Clang as a Compiler
LTOVisibility
SafeStack
ShadowCallStack
+   StructureProtection
SourceBasedCodeCoverage
StandardCPlusPlusModules
Modules
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index f7fca42cd7a07..c26d51c28f305 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3538,6 +3538,13 @@ void CodeGenFunction::EmitFunctionProlog(const 
CGFunctionInfo &FI,
   if (SrcSize > DstSize) {
 Builder.CreateMemCpy(Ptr, AddrToStoreInto, DstSize);
   }
+
+  // Structures with PFP fields require a coerced store to add any
+  // pointer signatures.
+  if (getContext().hasPFPFields(Ty)) {
+llvm::Value *Struct = Builder.CreateLoad(Ptr);
+CreatePFPCoercedStore(Struct, Ty, Ptr, *this);
+  }
 }
   } else {
 // Simple case, just do a coerced store of the argument into the 
alloca.
@@ -5717,15 +5724,25 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
 } else {
   uint64_t SrcSize = SrcTypeSize.getFixedValue();
   uint64_t DstSize = DstTypeSize.getFixedValue();
+  bool HasPFPFields = getContext().hasPFPFields(I->Ty);
 
   // If the source type is smaller than the destination type of the
   // coerce-to logic, copy the source value into a temp alloca the size
   // of the destination type to allow loading all of it. The bits past
   // the source value are left undef.
-  if (SrcSize < DstSize) {
+  if (HasPFPFields || SrcSize < DstSize) {
 Address TempAlloca = CreateTempAlloca(STy, Src.getAlignment(),
  

[llvm-branch-commits] [clang] release/21.x: [clang-format] Correctly handle backward compatibility of C headers (#159908) (PR #163910)

2025-10-18 Thread via llvm-branch-commits

owenca wrote:

See #163919.

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


[llvm-branch-commits] [lld] release/21.x: [LLD] [COFF] Fix symbol names for import thunks (#160694) (PR #160770)

2025-10-18 Thread via llvm-branch-commits

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


[llvm-branch-commits] CodeGen: Optionally emit PAuth relocations as IRELATIVE relocations. (PR #133533)

2025-10-18 Thread Peter Collingbourne via llvm-branch-commits

pcc wrote:

Ping, now unblocked

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


[llvm-branch-commits] [llvm] [LoongArch] Custom legalize vector_shuffle to `xvinsve0.{w/d}` when possible (PR #160857)

2025-10-18 Thread via llvm-branch-commits

https://github.com/zhaoqi5 updated 
https://github.com/llvm/llvm-project/pull/160857

>From f8c413dcb8cb641d94770df48eff80e6dd8a21fb Mon Sep 17 00:00:00 2001
From: Qi Zhao 
Date: Fri, 26 Sep 2025 19:07:22 +0800
Subject: [PATCH 1/3] [LoongArch] Custom legalize vector_shuffle to
 `xvinsve0.{w/d}` when possible

---
 .../LoongArch/LoongArchISelLowering.cpp   | 52 +++
 .../Target/LoongArch/LoongArchISelLowering.h  |  1 +
 .../LoongArch/LoongArchLASXInstrInfo.td   |  9 
 .../ir-instruction/shuffle-as-xvinsve0.ll |  4 +-
 4 files changed, 64 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp 
b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
index 5d4a8fd080202..194f42995d55a 100644
--- a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
@@ -2317,6 +2317,54 @@ static SDValue lowerVECTOR_SHUFFLE_XVPICKOD(const SDLoc 
&DL, ArrayRef Mask,
   return DAG.getNode(LoongArchISD::VPICKOD, DL, VT, V2, V1);
 }
 
+// Check if exactly one element of the Mask is replaced by 'Replaced', while
+// all other elements are either 'Base + i' or undef (-1). On success, return
+// the index of the replaced element. Otherwise, just return -1.
+static int checkReplaceOne(ArrayRef Mask, int Base, int Replaced) {
+  int MaskSize = Mask.size();
+  int Idx = -1;
+  for (int i = 0; i < MaskSize; ++i) {
+if (Mask[i] == Base + i || Mask[i] == -1)
+  continue;
+if (Mask[i] != Replaced)
+  return -1;
+if (Idx == -1)
+  Idx = i;
+else
+  return -1;
+  }
+  return Idx;
+}
+
+/// Lower VECTOR_SHUFFLE into XVINSVE0 (if possible).
+static SDValue
+lowerVECTOR_SHUFFLE_XVINSVE0(const SDLoc &DL, ArrayRef Mask, MVT VT,
+ SDValue V1, SDValue V2, SelectionDAG &DAG,
+ const LoongArchSubtarget &Subtarget) {
+  // LoongArch LASX only supports xvinsve0.{w/d}.
+  if (VT != MVT::v8i32 && VT != MVT::v8f32 && VT != MVT::v4i64 &&
+  VT != MVT::v4f64)
+return SDValue();
+
+  MVT GRLenVT = Subtarget.getGRLenVT();
+  int MaskSize = Mask.size();
+  assert(MaskSize == (int)VT.getVectorNumElements() && "Unexpected mask size");
+
+  // Case 1: the lowest element of V2 replaces one element in V1.
+  int Idx = checkReplaceOne(Mask, 0, MaskSize);
+  if (Idx != -1)
+return DAG.getNode(LoongArchISD::XVINSVE0, DL, VT, V1, V2,
+   DAG.getConstant(Idx, DL, GRLenVT));
+
+  // Case 2: the lowest element of V1 replaces one element in V2.
+  Idx = checkReplaceOne(Mask, MaskSize, 0);
+  if (Idx != -1)
+return DAG.getNode(LoongArchISD::XVINSVE0, DL, VT, V2, V1,
+   DAG.getConstant(Idx, DL, GRLenVT));
+
+  return SDValue();
+}
+
 /// Lower VECTOR_SHUFFLE into XVSHUF (if possible).
 static SDValue lowerVECTOR_SHUFFLE_XVSHUF(const SDLoc &DL, ArrayRef Mask,
   MVT VT, SDValue V1, SDValue V2,
@@ -2593,6 +2641,9 @@ static SDValue lower256BitShuffle(const SDLoc &DL, 
ArrayRef Mask, MVT VT,
   if ((Result = lowerVECTOR_SHUFFLEAsShift(DL, Mask, VT, V1, V2, DAG, 
Subtarget,
Zeroable)))
 return Result;
+  if ((Result =
+   lowerVECTOR_SHUFFLE_XVINSVE0(DL, Mask, VT, V1, V2, DAG, Subtarget)))
+return Result;
   if ((Result = lowerVECTOR_SHUFFLEAsByteRotate(DL, Mask, VT, V1, V2, DAG,
 Subtarget)))
 return Result;
@@ -7450,6 +7501,7 @@ const char 
*LoongArchTargetLowering::getTargetNodeName(unsigned Opcode) const {
 NODE_NAME_CASE(XVPERM)
 NODE_NAME_CASE(XVREPLVE0)
 NODE_NAME_CASE(XVREPLVE0Q)
+NODE_NAME_CASE(XVINSVE0)
 NODE_NAME_CASE(VPICK_SEXT_ELT)
 NODE_NAME_CASE(VPICK_ZEXT_ELT)
 NODE_NAME_CASE(VREPLVE)
diff --git a/llvm/lib/Target/LoongArch/LoongArchISelLowering.h 
b/llvm/lib/Target/LoongArch/LoongArchISelLowering.h
index b2fccf59169ff..3e7ea5ebba79e 100644
--- a/llvm/lib/Target/LoongArch/LoongArchISelLowering.h
+++ b/llvm/lib/Target/LoongArch/LoongArchISelLowering.h
@@ -151,6 +151,7 @@ enum NodeType : unsigned {
   XVPERM,
   XVREPLVE0,
   XVREPLVE0Q,
+  XVINSVE0,
 
   // Extended vector element extraction
   VPICK_SEXT_ELT,
diff --git a/llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td 
b/llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
index adfe990ba1234..dfcbfff2a9a72 100644
--- a/llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
+++ b/llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
@@ -20,6 +20,7 @@ def loongarch_xvpermi: SDNode<"LoongArchISD::XVPERMI", 
SDT_LoongArchV1RUimm>;
 def loongarch_xvperm: SDNode<"LoongArchISD::XVPERM", SDT_LoongArchXVPERM>;
 def loongarch_xvreplve0: SDNode<"LoongArchISD::XVREPLVE0", 
SDT_LoongArchXVREPLVE0>;
 def loongarch_xvreplve0q: SDNode<"LoongArchISD::XVREPLVE0Q", 
SDT_LoongArchXVREPLVE0>;
+def loongarch_xvinsve0 : SDNode<"LoongArchISD::XVINSVE0", 
SDT_LoongArchV2RUimm>;
 def loongarch_xvms

[llvm-branch-commits] [clang] [CIR] Make all opt tests verify roundtrip (PR #161439)

2025-10-18 Thread Henrich Lauko via llvm-branch-commits

xlauko wrote:

> This looks fine, but I noticed that mlir-opt has a build option that causes 
> it to implicitly add this argument in LIT tests. Should we do that?

TIL, that would be best. Though there is one test failing on the roundtrip at 
the moment: https://github.com/llvm/llvm-project/issues/161441

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


[llvm-branch-commits] [llvm] AMDGPU: Stop using the wavemask register class for SCC cross class copies (PR #161801)

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

* **#161801** https://app.graphite.dev/github/pr/llvm/llvm-project/161801?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/161801?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#161800** https://app.graphite.dev/github/pr/llvm/llvm-project/161800?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/161801
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] [libc][annex_k] Add errno_t. (PR #163094)

2025-10-18 Thread Michael Jones via llvm-branch-commits

https://github.com/michaelrj-google edited 
https://github.com/llvm/llvm-project/pull/163094
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [llvm] [AArch64][llvm] Armv9.7-A: Add support for FEAT_CMH and FEAT_LSCP (PR #163155)

2025-10-18 Thread Jonathan Thackray via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [DirectX] Updating DXContainer logic to read version 1.2 of static samplers (PR #160184)

2025-10-18 Thread via llvm-branch-commits

https://github.com/joaosaffran updated 
https://github.com/llvm/llvm-project/pull/160184

>From fefd58c2ab1044ac51c546b6bc6df968eb5edaa8 Mon Sep 17 00:00:00 2001
From: Joao Saffran 
Date: Fri, 19 Sep 2025 12:48:11 -0700
Subject: [PATCH 1/7] fix test

---
 llvm/include/llvm/Object/DXContainer.h| 57 ---
 llvm/lib/ObjectYAML/DXContainerYAML.cpp   | 16 ++-
 llvm/unittests/Object/DXContainerTest.cpp | 16 ---
 3 files changed, 63 insertions(+), 26 deletions(-)

diff --git a/llvm/include/llvm/Object/DXContainer.h 
b/llvm/include/llvm/Object/DXContainer.h
index 9bc1918852335..e3e532f6635a4 100644
--- a/llvm/include/llvm/Object/DXContainer.h
+++ b/llvm/include/llvm/Object/DXContainer.h
@@ -123,25 +123,26 @@ template  struct ViewArray {
 };
 
 namespace DirectX {
+
+template  Expected readParameter(StringRef Data) {
+  T Struct;
+  if (sizeof(T) != Data.size())
+return make_error(
+"Reading structure out of file bounds", object_error::parse_failed);
+
+  memcpy(&Struct, Data.data(), sizeof(T));
+  // DXContainer is always little endian
+  if (sys::IsBigEndianHost)
+Struct.swapBytes();
+  return Struct;
+}
+
 struct RootParameterView {
   const dxbc::RTS0::v1::RootParameterHeader &Header;
   StringRef ParamData;
 
   RootParameterView(const dxbc::RTS0::v1::RootParameterHeader &H, StringRef P)
   : Header(H), ParamData(P) {}
-
-  template  Expected readParameter() {
-T Struct;
-if (sizeof(T) != ParamData.size())
-  return make_error(
-  "Reading structure out of file bounds", object_error::parse_failed);
-
-memcpy(&Struct, ParamData.data(), sizeof(T));
-// DXContainer is always little endian
-if (sys::IsBigEndianHost)
-  Struct.swapBytes();
-return Struct;
-  }
 };
 
 struct RootConstantView : RootParameterView {
@@ -151,7 +152,7 @@ struct RootConstantView : RootParameterView {
   }
 
   llvm::Expected read() {
-return readParameter();
+return readParameter(ParamData);
   }
 };
 
@@ -167,7 +168,8 @@ struct RootDescriptorView : RootParameterView {
 
   llvm::Expected read(uint32_t Version) {
 if (Version == 1) {
-  auto Descriptor = readParameter();
+  auto Descriptor =
+  readParameter(ParamData);
   if (Error E = Descriptor.takeError())
 return E;
   return dxbc::RTS0::v2::RootDescriptor(*Descriptor);
@@ -176,9 +178,10 @@ struct RootDescriptorView : RootParameterView {
   return make_error("Invalid Root Signature version: " 
+
 Twine(Version),
 object_error::parse_failed);
-return readParameter();
+return readParameter(ParamData);
   }
 };
+
 template  struct DescriptorTable {
   uint32_t NumRanges;
   uint32_t RangesOffset;
@@ -247,8 +250,26 @@ class RootSignature {
   llvm::iterator_range param_headers() const {
 return llvm::make_range(ParametersHeaders.begin(), 
ParametersHeaders.end());
   }
-  llvm::iterator_range samplers() const {
-return llvm::make_range(StaticSamplers.begin(), StaticSamplers.end());
+  llvm::Expected getSampler(uint32_t Loc) const 
{
+if (Loc >= getNumStaticSamplers())
+  return parseFailed("Static sampler index out of range");
+
+auto SamplerSize = (Version <= 2) ? sizeof(dxbc::RTS0::v1::StaticSampler)
+ : sizeof(dxbc::RTS0::v3::StaticSampler);
+
+StringRef Buff = PartData.substr(StaticSamplersOffset + (Loc * 
SamplerSize),
+ SamplerSize);
+if (Version < 3) {
+  auto Sampler = readParameter(Buff);
+  if (Error E = Sampler.takeError())
+return E;
+  return dxbc::RTS0::v3::StaticSampler(*Sampler);
+}
+if (Version != 3)
+  return make_error("Invalid Root Signature version: " 
+
+Twine(Version),
+object_error::parse_failed);
+return readParameter(Buff);
   }
   uint32_t getFlags() const { return Flags; }
 
diff --git a/llvm/lib/ObjectYAML/DXContainerYAML.cpp 
b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
index 42074731c4e16..6f24b7d2573ec 100644
--- a/llvm/lib/ObjectYAML/DXContainerYAML.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
@@ -163,7 +163,13 @@ DXContainerYAML::RootSignatureYamlDesc::create(
 }
   }
 
-  for (const auto &S : Data.samplers()) {
+  for (uint32_t Loc = 0; Loc < Data.getNumStaticSamplers(); ++Loc) {
+llvm::Expected MaybeSampler =
+Data.getSampler(Loc);
+if (Error E = MaybeSampler.takeError())
+  return std::move(E);
+const llvm::dxbc::RTS0::v3::StaticSampler &S = *MaybeSampler;
+
 if (!dxbc::isValidSamplerFilter(S.Filter))
   return createStringError(std::errc::invalid_argument,
"Invalid value for static sampler filter");
@@ -209,6 +215,14 @@ DXContainerYAML::RootSignatureYamlDesc::create(
 NewS.RegisterSpace = S.RegisterSpace;
 NewS.Shad

[llvm-branch-commits] [llvm] [AArch64][llvm] Armv9.7-A: Add support for SVE2p3 LUTI6 operations (PR #163164)

2025-10-18 Thread via llvm-branch-commits


@@ -0,0 +1,70 @@
+// RUN: not llvm-mc -triple=aarch64 -show-encoding -mattr=+sve2p3 2>&1 < %s| 
FileCheck %s
+
+// --//
+// Invalid element width
+
+luti6 z10.h, { z0.b, z1.b }, z0
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
+// CHECK-NEXT: luti6 z10.h, { z0.b, z1.b }, z0
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+luti6 z10.s, { z0.b, z1.b }, z0
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid element width
+// CHECK-NEXT: luti6 z10.s, { z0.b, z1.b }, z0
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+// --//
+// Negative tests for instructions that are incompatible with movprfx
+
+movprfx z0.h, p0/m, z7.h
+luti6 z10.b, { z0.b, z1.b }, z0
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: instruction is unpredictable when 
following a movprfx, suggest replacing movprfx with mov
+// CHECK-NEXT: luti6 z10.b, { z0.b, z1.b }, z0
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+movprfx z0, z7

CarolineConcatto wrote:

an we have something like this instead:
movprfx z0.h, z7.h
luti6 z0.b, { z2.b, z3.b }, z4

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


[llvm-branch-commits] [clang] [llvm] [AArch64][llvm] Armv9.7-A: Add support for TLBI Domains (FEAT_TLBID) (PR #163156)

2025-10-18 Thread Jonathan Thackray via llvm-branch-commits

https://github.com/jthackray updated 
https://github.com/llvm/llvm-project/pull/163156

>From 3d6ab1b50e6fa4a06f74cf1ec1c86b478b7d33e5 Mon Sep 17 00:00:00 2001
From: Jonathan Thackray 
Date: Mon, 8 Sep 2025 13:19:57 +0100
Subject: [PATCH] [AArch64][llvm] Armv9.7-A: Add support for TLBI Domains
 (FEAT_TLBID)

Allow the following `TLBI` operation types to take an optional register
operand when enabled by `FEAT_TLBID`:
  - ALL*
  - VMALL*
  - VMALLS12*
  - VMALLWS2*

as documented here:

  * https://developer.arm.com/documentation/ddi0602/2025-09/
  * 
https://developer.arm.com/documentation/109697/2025_09/2025-Architecture-Extensions

Notes on implementation:

Currently, AArch64 `SYS` alias instructions fall into two categories:
  * a register value must be present (indicated by any value except `XZR`)
  * no register value must be present (this value must be `XZR`)

When +tblid is enabled, `SYS` aliases are now allowed to take an optional
register, or no register as before. We need an extra tablegen flag to
indicate if the register is optional or not (the existing "NeedsReg" flag
is binary and not suitable; the register is either present or absent,
not either for a specific TLBI operation)

Don't produce an error message if the register operand is missing or
unexpected, if it is specified as an optional register.
---
 clang/test/Driver/aarch64-v97a.c  |  4 +
 .../print-supported-extensions-aarch64.c  |  1 +
 llvm/lib/Target/AArch64/AArch64Features.td|  3 +
 llvm/lib/Target/AArch64/AArch64InstrInfo.td   |  2 +
 .../Target/AArch64/AArch64SystemOperands.td   | 72 
 .../AArch64/AsmParser/AArch64AsmParser.cpp| 20 +++--
 .../MCTargetDesc/AArch64InstPrinter.cpp   | 14 +++-
 .../Target/AArch64/Utils/AArch64BaseInfo.h| 24 --
 .../MC/AArch64/armv9.7a-tlbid-diagnostics.s   | 64 ++
 llvm/test/MC/AArch64/armv9.7a-tlbid.s | 84 +++
 .../TargetParser/TargetParserTest.cpp |  4 +-
 11 files changed, 239 insertions(+), 53 deletions(-)
 create mode 100644 llvm/test/MC/AArch64/armv9.7a-tlbid-diagnostics.s
 create mode 100644 llvm/test/MC/AArch64/armv9.7a-tlbid.s

diff --git a/clang/test/Driver/aarch64-v97a.c b/clang/test/Driver/aarch64-v97a.c
index 4a55d44466cc0..ec0e4245b81aa 100644
--- a/clang/test/Driver/aarch64-v97a.c
+++ b/clang/test/Driver/aarch64-v97a.c
@@ -25,3 +25,7 @@
 // RUN: %clang -target aarch64 -march=armv9.7a+lscp -### -c %s 2>&1 | 
FileCheck -check-prefix=V97A-LSCP %s
 // RUN: %clang -target aarch64 -march=armv9.7-a+lscp -### -c %s 2>&1 | 
FileCheck -check-prefix=V97A-LSCP %s
 // V97A-LSCP: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" 
"-target-feature" "+v9.7a"{{.*}} "-target-feature" "+lscp"
+
+// RUN: %clang -target aarch64 -march=armv9.7a+tlbid -### -c %s 2>&1 | 
FileCheck -check-prefix=V97A-TLBID %s
+// RUN: %clang -target aarch64 -march=armv9.7-a+tlbid -### -c %s 2>&1 | 
FileCheck -check-prefix=V97A-TLBID %s
+// V97A-TLBID: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" 
"-target-feature" "+v9.7a"{{.*}} "-target-feature" "+tlbid"
diff --git a/clang/test/Driver/print-supported-extensions-aarch64.c 
b/clang/test/Driver/print-supported-extensions-aarch64.c
index 9928f395866d8..3e4ceae5bd5c1 100644
--- a/clang/test/Driver/print-supported-extensions-aarch64.c
+++ b/clang/test/Driver/print-supported-extensions-aarch64.c
@@ -104,6 +104,7 @@
 // CHECK-NEXT: sve2p1  FEAT_SVE2p1 
   Enable Scalable Vector Extension 2.1 instructions
 // CHECK-NEXT: sve2p2  FEAT_SVE2p2 
   Enable Armv9.6-A Scalable Vector Extension 2.2 instructions
 // CHECK-NEXT: the FEAT_THE
   Enable Armv8.9-A Translation Hardening Extension
+// CHECK-NEXT: tlbid   FEAT_TLBID  
   Enable Armv9.7-A TLBI Domains extension
 // CHECK-NEXT: tlbiw   FEAT_TLBIW  
   Enable Armv9.5-A TLBI VMALL for Dirty State
 // CHECK-NEXT: tme FEAT_TME
   Enable Transactional Memory Extension
 // CHECK-NEXT: wfxtFEAT_WFxT   
   Enable Armv8.7-A WFET and WFIT instruction
diff --git a/llvm/lib/Target/AArch64/AArch64Features.td 
b/llvm/lib/Target/AArch64/AArch64Features.td
index 7fe83537b7a36..eea06968f438a 100644
--- a/llvm/lib/Target/AArch64/AArch64Features.td
+++ b/llvm/lib/Target/AArch64/AArch64Features.td
@@ -595,6 +595,9 @@ def FeatureCMH : ExtensionWithMArch<"cmh", "CMH", 
"FEAT_CMH",
 def FeatureLSCP : ExtensionWithMArch<"lscp", "LSCP", "FEAT_LSCP",
   "Enable Armv9.7-A Load-acquire and store-release pair extension">;
 
+def FeatureTLBID: ExtensionWithMArch<"tlbid", "TLBID", "FEAT_TLBID",
+  "Enable Armv9.7-A TLBI Domains extension

[llvm-branch-commits] [clang] [clang] Add clang::nooutline Attribute (PR #163666)

2025-10-18 Thread via llvm-branch-commits


@@ -0,0 +1,16 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-attributes --version 6
+// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-unknown-linux-gnu 
-disable-O0-optnone -o - | FileCheck %s

Sirraide wrote:

We should also have a C++ codegen test, but that can just be an extra RUN line 
w/ `-x c++`.

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


[llvm-branch-commits] [libc++] Annotate classes with _LIBCPP_PFP to enable pointer field protection (PR #151652)

2025-10-18 Thread Peter Collingbourne via llvm-branch-commits


@@ -195,3 +195,16 @@ prevent compilers from generating said debug information. 
Aliases inside type tr
 should be annotated for the same reason.
 
 This is enforced by the clang-tidy check ``libcpp-nodebug-on-aliases``.
+
+Pointer field protection
+
+
+To improve the effectiveness of Clang's `pointer field protection
+`_ feature,
+commonly used vocabulary types with pointer fields are marked with the
+``_LIBCPP_PFP`` attribute, to give Clang permission to use PFP to protect
+their pointer fields. Newly added vocabulary types should be marked with
+this attribute if they contain pointer fields.

pcc wrote:

That was an oversight; now added.

Technically, `basic_string::__long` is the type that needs to be annotated 
because that's the one with a pointer field, so that's what I did. I also 
improved the wording here to clarify that internal base classes and fields need 
the annotations if they have pointer fields.

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


[llvm-branch-commits] [clang] [clang] Add clang::nooutline Attribute (PR #163666)

2025-10-18 Thread Nikolas Klauser via llvm-branch-commits

philnik777 wrote:

> Thanks for the reviews. They're very helpful. Working on those changes now.
> 
> > General comment: I really dislike the spelling. The first time I read this 
> > I interpreted it as "noout-line" not "no-outline".
> 
> I went through other Clang attributes with similar `no *` naming, to see what 
> the status quo is.
> 
> Clang attributes starting "no" without punctuation to split words:
> 
> * `noinline` (Function, Statement)
> 
> * `nomerge` (Function, Statement, Var)
> 
> * `noduplicate` (Function)
> 
> * `nouwtable` (Function, Variable)
> 
> * `noescape` (Parameter)
> 
> * `noderef` (Type?)
> 
> 
> Clang attributes starting "no" with punctuation to split words:
> 
> * `no_stack_protector` (Function)
> 
> * `no_specializations` (Function, Class, Variable)
> 
> * `no_sanitize_memory` (Function)
> 
> * `no_thread_safety_analysis` (Function)
> 
> * `no_speculative_load_hardening` (Function)
> 
> * `no_builtin` (Function)
> 
> * `no_destroy` (Variable)
> 
> 
> To me this split is pretty even between with an underscore and without, but I 
> would prefer the symmetry with `noinline` and `nomerge`, if possible.

I'm really not a fan of that. I don't think `noinline` or `nomerge` have the 
same problem, since they don't have `noo` as the start, making the parsing 
significantly easier.

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


[llvm-branch-commits] [llvm] [AArch64][llvm] Armv9.7-A: Add support for SVE2p3 LUTI6 operations (PR #163164)

2025-10-18 Thread Jonathan Thackray via llvm-branch-commits

https://github.com/jthackray updated 
https://github.com/llvm/llvm-project/pull/163164

>From 11ce378cc0404d4f6a2f52049f71dcc5344ba560 Mon Sep 17 00:00:00 2001
From: Jonathan Thackray 
Date: Sat, 6 Sep 2025 00:00:23 +0100
Subject: [PATCH 1/3] [AArch64][llvm] Armv9.7-A: Add support for SVE2p3 LUTI6
 operations

Add instructions for SVE2p3 LUTI6 operations:
  - LUTI6 (16-bit)
  - LUTI6 (8-bit)
  - LUTI6 (vector, 16-bit)
  - LUTI6 (table, four registers, 8-bit)
  - LUTI6 (table, single, 8-bit)

as documented here:

  * https://developer.arm.com/documentation/ddi0602/2025-09/
  * 
https://developer.arm.com/documentation/109697/2025_09/2025-Architecture-Extensions
---
 llvm/lib/Target/AArch64/AArch64InstrInfo.td   |   4 +
 .../lib/Target/AArch64/AArch64RegisterInfo.td |   8 +
 .../lib/Target/AArch64/AArch64SMEInstrInfo.td |  11 +
 .../lib/Target/AArch64/AArch64SVEInstrInfo.td |   9 +
 .../AArch64/AsmParser/AArch64AsmParser.cpp|   7 +
 llvm/lib/Target/AArch64/SMEInstrFormats.td|  74 +++
 llvm/lib/Target/AArch64/SVEInstrFormats.td|  35 +-
 .../MC/AArch64/SME2p3/luti6-diagnostics.s | 176 +++
 llvm/test/MC/AArch64/SME2p3/luti6.s   | 472 ++
 .../MC/AArch64/SVE2p3/luti6-diagnostics.s |  70 +++
 llvm/test/MC/AArch64/SVE2p3/luti6.s   | 115 +
 11 files changed, 977 insertions(+), 4 deletions(-)
 create mode 100644 llvm/test/MC/AArch64/SME2p3/luti6-diagnostics.s
 create mode 100644 llvm/test/MC/AArch64/SME2p3/luti6.s
 create mode 100644 llvm/test/MC/AArch64/SVE2p3/luti6-diagnostics.s
 create mode 100644 llvm/test/MC/AArch64/SVE2p3/luti6.s

diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td 
b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
index 448a101582193..56b3e84a4ac96 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -252,6 +252,10 @@ def HasSVE_B16MM: 
Predicate<"Subtarget->isSVEAvailable() && Subtarget->hasSV
  AssemblerPredicateWithAll<(all_of 
FeatureSVE_B16MM), "sve-b16mm">;
 def HasF16MM: Predicate<"Subtarget->isSVEAvailable() && 
Subtarget->hasF16MM()">,
  AssemblerPredicateWithAll<(all_of 
FeatureF16MM), "f16mm">;
+def HasSVE2p3   : Predicate<"Subtarget->hasSVE2p3()">,
+ AssemblerPredicateWithAll<(all_of 
FeatureSVE2p3), "sve2p3">;
+def HasSME2p3   : Predicate<"Subtarget->hasSME2p3()">,
+ AssemblerPredicateWithAll<(all_of 
FeatureSME2p3), "sme2p3">;
 
 // A subset of SVE(2) instructions are legal in Streaming SVE execution mode,
 // they should be enabled if either has been specified.
diff --git a/llvm/lib/Target/AArch64/AArch64RegisterInfo.td 
b/llvm/lib/Target/AArch64/AArch64RegisterInfo.td
index ef974df823100..86a1fb52be789 100644
--- a/llvm/lib/Target/AArch64/AArch64RegisterInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64RegisterInfo.td
@@ -1341,6 +1341,10 @@ def Z_q  : RegisterOperand"> {
   let ParserMatchClass = ZPRVectorList<128, 1>;
 }
 
+def ZZ_Any  : RegisterOperand"> {
+  let ParserMatchClass = ZPRVectorList<0, 2>;
+}
+
 def ZZ_b  : RegisterOperand"> {
   let ParserMatchClass = ZPRVectorList<8, 2>;
 }
@@ -1361,6 +1365,10 @@ def ZZ_q  : RegisterOperand"> {
   let ParserMatchClass = ZPRVectorList<128, 2>;
 }
 
+def ZZZ_Any  : RegisterOperand"> {
+  let ParserMatchClass = ZPRVectorList<0, 3>;
+}
+
 def ZZZ_b  : RegisterOperand"> {
   let ParserMatchClass = ZPRVectorList<8, 3>;
 }
diff --git a/llvm/lib/Target/AArch64/AArch64SMEInstrInfo.td 
b/llvm/lib/Target/AArch64/AArch64SMEInstrInfo.td
index e552afee0d8cf..f3411c4d95d19 100644
--- a/llvm/lib/Target/AArch64/AArch64SMEInstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64SMEInstrInfo.td
@@ -1173,3 +1173,14 @@ let Predicates = [HasSME_MOP4, HasSMEF64F64] in {
   defm FMOP4A : sme2_fmop4as_fp64_non_widening<0, "fmop4a", 
"int_aarch64_sme_mop4a">;
   defm FMOP4S : sme2_fmop4as_fp64_non_widening<1, "fmop4s", 
"int_aarch64_sme_mop4s">;
 }
+
+//===--===//
+// SME2.3 instructions
+//===--===//
+let Predicates = [HasSME2p3] in {
+  def LUTI6_ZTZ   : sme2_lut_single<"luti6">;
+  def LUTI6_4ZT3Z : sme2_luti6_zt<"luti6">;
+  def LUTI6_S_4ZT3Z   : sme2_luti6_zt_strided<"luti6">;
+  def LUTI6_4Z2Z2ZI   : sme2_luti6_vector_vg4<"luti6">;
+  def LUTI6_S_4Z2Z2ZI : sme2_luti6_vector_vg4_strided<"luti6">;
+} // [HasSME2p3]
diff --git a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td 
b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
index 7de6071d29467..0a0f1f41c3e56 100644
--- a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
@@ -4659,8 +4659,17 @@ let Predicates = [HasSVE2p3_or_SME2p3] in {
   defm SQSHRUN_Z2ZI_StoH  : sve_multi_vec_shift_narrow<"sqshrun",  0b100, 
null_frag>;
   defm SQSHRN_Z2ZI_StoH   : sve_multi_

[llvm-branch-commits] [FlowSensitive] [StatusOr] [4/N] Support comparisons (PR #163871)

2025-10-18 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-analysis

Author: Florian Mayer (fmayer)


Changes



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


2 Files Affected:

- (modified) 
clang/lib/Analysis/FlowSensitive/Models/UncheckedStatusOrAccessModel.cpp (+122) 
- (modified) 
clang/unittests/Analysis/FlowSensitive/UncheckedStatusOrAccessModelTestFixture.cpp
 (+228) 


``diff
diff --git 
a/clang/lib/Analysis/FlowSensitive/Models/UncheckedStatusOrAccessModel.cpp 
b/clang/lib/Analysis/FlowSensitive/Models/UncheckedStatusOrAccessModel.cpp
index 11c4ad90293d9..4ebf3e4251dd6 100644
--- a/clang/lib/Analysis/FlowSensitive/Models/UncheckedStatusOrAccessModel.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Models/UncheckedStatusOrAccessModel.cpp
@@ -115,6 +115,20 @@ static auto valueOperatorCall() {
 isStatusOrOperatorCallWithName("->")));
 }
 
+static clang::ast_matchers::TypeMatcher statusType() {
+  using namespace ::clang::ast_matchers;  // NOLINT: Too many names
+  return hasCanonicalType(qualType(hasDeclaration(statusClass(;
+}
+
+
+static auto isComparisonOperatorCall(llvm::StringRef operator_name) {
+  using namespace ::clang::ast_matchers;  // NOLINT: Too many names
+  return cxxOperatorCallExpr(
+  hasOverloadedOperatorName(operator_name), argumentCountIs(2),
+  hasArgument(0, anyOf(hasType(statusType()), hasType(statusOrType(,
+  hasArgument(1, anyOf(hasType(statusType()), hasType(statusOrType();
+}
+
 static auto
 buildDiagnoseMatchSwitch(const UncheckedStatusOrAccessModelOptions &Options) {
   return CFGMatchSwitchBuilder res (a.k.a. !res => !lhs || !rhs)
+  Env.assume(A.makeImplies(A.makeAnd(LhsOkVal.formula(), RhsOkVal.formula()),
+   Res.formula()));
+  // res => (lhs == rhs)
+  Env.assume(A.makeImplies(
+  Res.formula(), A.makeEquals(LhsOkVal.formula(), RhsOkVal.formula(;
+
+  return &Res;
+}
+
+static BoolValue* evaluateStatusOrEquality(
+RecordStorageLocation& LhsStatusOrLoc,
+RecordStorageLocation& RhsStatusOrLoc, Environment& Env) {
+  auto& A = Env.arena();
+  // Logically, a StatusOr object is composed of two values - a Status and a
+  // value of type T. Equality of StatusOr objects compares both values.
+  // Therefore, merely comparing the `ok` bits of the Status values isn't
+  // sufficient. When two StatusOr objects are engaged, the equality of their
+  // respective values of type T matters. Similarly, when two StatusOr objects
+  // have Status values that have non-ok error codes, the equality of the error
+  // codes matters. Since we only track the `ok` bits of the Status values, we
+  // can't make any conclusions about equality when we know that two StatusOr
+  // objects are engaged or when their Status values contain non-ok error 
codes.
+  auto& LhsOkVal = valForOk(locForStatus(LhsStatusOrLoc), Env);
+  auto& RhsOkVal = valForOk(locForStatus(RhsStatusOrLoc), Env);
+  auto& res = Env.makeAtomicBoolValue();
+
+  // res => (lhs == rhs)
+  Env.assume(A.makeImplies(
+  res.formula(), A.makeEquals(LhsOkVal.formula(), RhsOkVal.formula(;
+  return &res;
+}
+
+
+static BoolValue* evaluateEquality(const Expr* LhsExpr, const Expr* RhsExpr,
+   Environment& Env) {
+  // Check the type of both sides in case an operator== is added that admits
+  // different types.
+  if (isStatusOrType(LhsExpr->getType()) &&
+  isStatusOrType(RhsExpr->getType())) {
+auto* LhsStatusOrLoc = Env.get(*LhsExpr);
+if (LhsStatusOrLoc == nullptr) return nullptr;
+auto* RhsStatusOrLoc = Env.get(*RhsExpr);
+if (RhsStatusOrLoc == nullptr) return nullptr;
+
+return evaluateStatusOrEquality(*LhsStatusOrLoc, *RhsStatusOrLoc, Env);
+
+// Check the type of both sides in case an operator== is added that admits
+// different types.
+  }
+  if (isStatusType(LhsExpr->getType()) && isStatusType(RhsExpr->getType())) {
+auto* LhsStatusLoc = Env.get(*LhsExpr);
+if (LhsStatusLoc == nullptr) return nullptr;
+
+auto* RhsStatusLoc = Env.get(*RhsExpr);
+if (RhsStatusLoc == nullptr) return nullptr;
+
+return evaluateStatusEquality(*LhsStatusLoc, *RhsStatusLoc, Env);
+  }
+  return nullptr;
+}
+
+static void transferComparisonOperator(const CXXOperatorCallExpr* Expr,
+   LatticeTransferState& State,
+   bool IsNegative) {
+  auto* LhsAndRhsVal =
+  evaluateEquality(Expr->getArg(0), Expr->getArg(1), State.Env);
+  if (LhsAndRhsVal == nullptr) return;
+
+  if (IsNegative)
+State.Env.setValue(*Expr, State.Env.makeNot(*LhsAndRhsVal));
+  else
+State.Env.setValue(*Expr, *LhsAndRhsVal);
+}
+
+
 CFGMatchSwitch
 buildTransferMatchSwitch(ASTContext &Ctx,
  CFGMatchSwitchBuilder Builder) {
@@ -317,6 +425,20 @@ buildTransferMatchSwitch(ASTContext &Ctx,
 transferStatusOkCall)
   .CaseOfCFGStmt(isStatusM

[llvm-branch-commits] [llvm] release/21.x: [X86] Use pseudo instructions to zero registers in `buildClearRegister` (#163358) (PR #164076)

2025-10-18 Thread via llvm-branch-commits

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


[llvm-branch-commits] [llvm] release/21.x: [X86] Use pseudo instructions to zero registers in `buildClearRegister` (#163358) (PR #164076)

2025-10-18 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-x86

Author: None (llvmbot)


Changes

Backport 228dae786b94bb85fb34bc157a43ca6c16932b6d

Requested by: @RKSimon

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


2 Files Affected:

- (modified) llvm/lib/Target/X86/X86InstrInfo.cpp (+5-17) 
- (added) llvm/test/CodeGen/X86/zero-call-used-regs-simd.ll (+216) 


``diff
diff --git a/llvm/lib/Target/X86/X86InstrInfo.cpp 
b/llvm/lib/Target/X86/X86InstrInfo.cpp
index abf365eedec39..9bf58dd3458cd 100644
--- a/llvm/lib/Target/X86/X86InstrInfo.cpp
+++ b/llvm/lib/Target/X86/X86InstrInfo.cpp
@@ -10739,39 +10739,27 @@ void X86InstrInfo::buildClearRegister(Register Reg, 
MachineBasicBlock &MBB,
 if (!ST.hasSSE1())
   return;
 
-// PXOR is safe to use because it doesn't affect flags.
-BuildMI(MBB, Iter, DL, get(X86::PXORrr), Reg)
-.addReg(Reg, RegState::Undef)
-.addReg(Reg, RegState::Undef);
+BuildMI(MBB, Iter, DL, get(X86::V_SET0), Reg);
   } else if (X86::VR256RegClass.contains(Reg)) {
 // YMM#
 if (!ST.hasAVX())
   return;
 
-// VPXOR is safe to use because it doesn't affect flags.
-BuildMI(MBB, Iter, DL, get(X86::VPXORrr), Reg)
-.addReg(Reg, RegState::Undef)
-.addReg(Reg, RegState::Undef);
+BuildMI(MBB, Iter, DL, get(X86::AVX_SET0), Reg);
   } else if (X86::VR512RegClass.contains(Reg)) {
 // ZMM#
 if (!ST.hasAVX512())
   return;
 
-// VPXORY is safe to use because it doesn't affect flags.
-BuildMI(MBB, Iter, DL, get(X86::VPXORYrr), Reg)
-.addReg(Reg, RegState::Undef)
-.addReg(Reg, RegState::Undef);
+BuildMI(MBB, Iter, DL, get(X86::AVX512_512_SET0), Reg);
   } else if (X86::VK1RegClass.contains(Reg) || X86::VK2RegClass.contains(Reg) 
||
  X86::VK4RegClass.contains(Reg) || X86::VK8RegClass.contains(Reg) 
||
  X86::VK16RegClass.contains(Reg)) {
 if (!ST.hasVLX())
   return;
 
-// KXOR is safe to use because it doesn't affect flags.
-unsigned Op = ST.hasBWI() ? X86::KXORQkk : X86::KXORWkk;
-BuildMI(MBB, Iter, DL, get(Op), Reg)
-.addReg(Reg, RegState::Undef)
-.addReg(Reg, RegState::Undef);
+unsigned Op = ST.hasBWI() ? X86::KSET0Q : X86::KSET0W;
+BuildMI(MBB, Iter, DL, get(Op), Reg);
   }
 }
 
diff --git a/llvm/test/CodeGen/X86/zero-call-used-regs-simd.ll 
b/llvm/test/CodeGen/X86/zero-call-used-regs-simd.ll
new file mode 100644
index 0..d9253e0ca127b
--- /dev/null
+++ b/llvm/test/CodeGen/X86/zero-call-used-regs-simd.ll
@@ -0,0 +1,216 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 6
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+sse2
-verify-machineinstrs | FileCheck %s --check-prefixes=SSE
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx 
-verify-machineinstrs | FileCheck %s --check-prefixes=AVX,AVX1
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx2
-verify-machineinstrs | FileCheck %s --check-prefixes=AVX,AVX2
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx512f,+avx512vl   
-verify-machineinstrs | FileCheck %s --check-prefixes=AVX512,AVX512VL
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx512f,+avx512vl,+avx512bw 
-verify-machineinstrs | FileCheck %s --check-prefixes=AVX512,AVX512BW
+
+define void @zero_xmm(<4 x i32> %arg) #0 {
+; SSE-LABEL: zero_xmm:
+; SSE:   # %bb.0:
+; SSE-NEXT:movaps %xmm0, 0
+; SSE-NEXT:xorps %xmm0, %xmm0
+; SSE-NEXT:retq
+;
+; AVX-LABEL: zero_xmm:
+; AVX:   # %bb.0:
+; AVX-NEXT:vmovaps %xmm0, 0
+; AVX-NEXT:vxorps %xmm0, %xmm0, %xmm0
+; AVX-NEXT:retq
+;
+; AVX512-LABEL: zero_xmm:
+; AVX512:   # %bb.0:
+; AVX512-NEXT:vmovaps %xmm0, 0
+; AVX512-NEXT:vxorps %xmm0, %xmm0, %xmm0
+; AVX512-NEXT:retq
+  store <4 x i32> %arg, ptr null, align 32
+  ret void
+}
+
+define void @zero_ymm(<8 x i32> %arg) #0 {
+; SSE-LABEL: zero_ymm:
+; SSE:   # %bb.0:
+; SSE-NEXT:movaps %xmm1, 16
+; SSE-NEXT:movaps %xmm0, 0
+; SSE-NEXT:xorps %xmm0, %xmm0
+; SSE-NEXT:xorps %xmm1, %xmm1
+; SSE-NEXT:retq
+;
+; AVX-LABEL: zero_ymm:
+; AVX:   # %bb.0:
+; AVX-NEXT:vmovaps %ymm0, 0
+; AVX-NEXT:vxorps %xmm0, %xmm0, %xmm0
+; AVX-NEXT:vzeroupper
+; AVX-NEXT:retq
+;
+; AVX512-LABEL: zero_ymm:
+; AVX512:   # %bb.0:
+; AVX512-NEXT:vmovaps %ymm0, 0
+; AVX512-NEXT:vxorps %xmm0, %xmm0, %xmm0
+; AVX512-NEXT:vzeroupper
+; AVX512-NEXT:retq
+  store <8 x i32> %arg, ptr null, align 32
+  ret void
+}
+
+define void @zero_zmm(<16 x i32> %arg) #0 {
+; SSE-LABEL: zero_zmm:
+; SSE:   # %bb.0:
+; SSE-NEXT:movaps %xmm3, 48
+; SSE-NEXT:movaps %xmm2, 32
+; SSE-NEXT:movaps %xmm1, 16
+; SSE-NEXT:movaps %xmm0, 0
+; SSE-NEXT:xorps %xmm0, %xmm0
+; SSE-NEXT:xorps %xmm1, %xmm1
+; SSE-NEXT:xorps %xmm2, %xmm2
+; SSE-NEXT:xorps %xmm3, %xmm3
+; SSE-NEXT:retq
+;
+; AVX-LABEL: z

[llvm-branch-commits] [llvm] release/21.x: [X86] Use pseudo instructions to zero registers in `buildClearRegister` (#163358) (PR #164076)

2025-10-18 Thread via llvm-branch-commits

llvmbot wrote:

@RKSimon What do you think about merging this PR to the release branch?

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


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

2025-10-18 Thread Muhammad Bassiouni via llvm-branch-commits

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

None

>From 8400f595f9cf58fbb1769c42d2bdd91a75995cd5 Mon Sep 17 00:00:00 2001
From: bassiounix 
Date: Sun, 5 Oct 2025 18:08:23 +0300
Subject: [PATCH] [libc][math] Refactor exp2m1f16 implementation to header-only
 in src/__support/math folder.

---
 libc/shared/math.h|   1 +
 libc/shared/math/exp2m1f16.h  |  29 +++
 libc/src/__support/math/CMakeLists.txt|  18 ++
 libc/src/__support/math/exp2m1f16.h   | 180 ++
 libc/src/math/generic/CMakeLists.txt  |  14 +-
 libc/src/math/generic/exp2m1f16.cpp   | 155 +--
 libc/test/shared/CMakeLists.txt   |   1 +
 libc/test/shared/shared_math_test.cpp |   1 +
 .../llvm-project-overlay/libc/BUILD.bazel |  18 +-
 9 files changed, 250 insertions(+), 167 deletions(-)
 create mode 100644 libc/shared/math/exp2m1f16.h
 create mode 100644 libc/src/__support/math/exp2m1f16.h

diff --git a/libc/shared/math.h b/libc/shared/math.h
index 0c0e8560bd40f..bcddb39021a9c 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -51,6 +51,7 @@
 #include "math/exp2f.h"
 #include "math/exp2f16.h"
 #include "math/exp2m1f.h"
+#include "math/exp2m1f16.h"
 #include "math/expf.h"
 #include "math/expf16.h"
 #include "math/frexpf.h"
diff --git a/libc/shared/math/exp2m1f16.h b/libc/shared/math/exp2m1f16.h
new file mode 100644
index 0..96a404708be18
--- /dev/null
+++ b/libc/shared/math/exp2m1f16.h
@@ -0,0 +1,29 @@
+//===-- Shared exp2m1f16 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_EXP2M1F16_H
+#define LLVM_LIBC_SHARED_MATH_EXP2M1F16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+#include "shared/libc_common.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/exp2m1f16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::exp2m1f16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_EXP2M1F16_H
diff --git a/libc/src/__support/math/CMakeLists.txt 
b/libc/src/__support/math/CMakeLists.txt
index ec2d8948f615b..aaace44d04d3b 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -785,6 +785,24 @@ add_header_library(
 libc.src.__support.macros.properties.cpu_features
 )
 
+add_header_library(
+  exp2m1f16
+  HDRS
+exp2m1f16.h
+  DEPENDS
+.expxf16_utils
+libc.src.__support.common
+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.rounding_mode
+libc.src.__support.macros.optimization
+libc.src.__support.macros.properties.cpu_features
+)
+
 add_header_library(
   exp10
   HDRS
diff --git a/libc/src/__support/math/exp2m1f16.h 
b/libc/src/__support/math/exp2m1f16.h
new file mode 100644
index 0..0424af4aa953d
--- /dev/null
+++ b/libc/src/__support/math/exp2m1f16.h
@@ -0,0 +1,180 @@
+//===-- Implementation header for exp2m1f16 --*- 
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_EXP2M1F16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_EXP2M1F16_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/rounding_mode.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h"
+#include "src/__support/macros/properties/cpu_features.h"
+#include "src/__support/math/expxf16_utils.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE static constexpr float16 exp2m1f16(float16 x) {
+#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+  constexpr fputil::ExceptValues EXP2M1F16_EXCEPTS_LO = {{
+  // (input, RZ output, RU offset, RD offset, RN offset)
+  // x = 0x1.cf4p-13, exp2m1f16(x) = 0x1.41p-13 (RZ)
+  {0x0b3dU, 0x0904U, 1U, 0U, 1U},

[llvm-branch-commits] [llvm] [mlir] [MLIR][OpenMP][OMPIRBuilder] Improve shared memory checks (PR #161864)

2025-10-18 Thread Sergio Afonso via llvm-branch-commits

skatrak wrote:

PR stack:
- #150922
- #150923
- #150924
- #150925
- #150926
- #150927
- #154752
- #161861
- #161862
- #161863
- #161864 ◀️

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


[llvm-branch-commits] [libc] [libc][annex_k] Add errno_t. (PR #163094)

2025-10-18 Thread Muhammad Bassiouni via llvm-branch-commits


@@ -0,0 +1,21 @@
+//===-- Definition of type errno_t 
===//
+//
+// 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_INCLUDE_LLVM_LIBC_TYPES_ERRNO_T_H
+#define LLVM_LIBC_INCLUDE_LLVM_LIBC_TYPES_ERRNO_T_H
+
+// LIBC_HAS_ANNEX_K is a necessary check guard here because errno_t is only
+// defined when Annex K is enabled. We use LIBC_HAS_ANNEX_K internally to
+// indicate whether Annex K is enabled or not.

bassiounix wrote:

done.

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


[llvm-branch-commits] [llvm] [AllocToken] Refactor stateless token calculation into Support (PR #163633)

2025-10-18 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-support

Author: Marco Elver (melver)


Changes

Refactor the stateless (hash-based) token calculation logic out of the
`AllocToken` pass and into `llvm/Support/AllocToken.h`.

This helps with making the token calculation logic available to other parts of
the codebase, which will be necessary for frontend implementation of
`__builtin_infer_alloc_token` to perform constexpr evaluation.

The `AllocTokenMode` enum and a new `AllocTokenMetadata` struct are moved into
a shared header. The `getAllocTokenHash()` function now provides the source of
truth for calculating token IDs for `TypeHash` and `TypeHashPointerSplit`
modes.

---

This change is part of the following series:

1. https://github.com/llvm/llvm-project/pull/163632
2. https://github.com/llvm/llvm-project/pull/163633
3. https://github.com/llvm/llvm-project/pull/163634
4. https://github.com/llvm/llvm-project/pull/163635
5. https://github.com/llvm/llvm-project/pull/163636
6. https://github.com/llvm/llvm-project/pull/163638
7. https://github.com/llvm/llvm-project/pull/163639
8. https://github.com/llvm/llvm-project/pull/156842

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


5 Files Affected:

- (added) llvm/include/llvm/Support/AllocToken.h (+58) 
- (added) llvm/lib/Support/AllocToken.cpp (+46) 
- (modified) llvm/lib/Support/CMakeLists.txt (+1) 
- (modified) llvm/lib/Transforms/Instrumentation/AllocToken.cpp (+19-39) 
- (modified) llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn (+1) 


``diff
diff --git a/llvm/include/llvm/Support/AllocToken.h 
b/llvm/include/llvm/Support/AllocToken.h
new file mode 100644
index 0..6617b7d1f7668
--- /dev/null
+++ b/llvm/include/llvm/Support/AllocToken.h
@@ -0,0 +1,58 @@
+//===- llvm/Support/AllocToken.h - Allocation Token Calculation -*- 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
+//
+//===--===//
+//
+// Definition of AllocToken modes and shared calculation of stateless token 
IDs.
+//
+//===--===//
+
+#ifndef LLVM_SUPPORT_ALLOCTOKEN_H
+#define LLVM_SUPPORT_ALLOCTOKEN_H
+
+#include "llvm/ADT/SmallString.h"
+#include 
+#include 
+
+namespace llvm {
+
+/// Modes for generating allocation token IDs.
+enum class AllocTokenMode {
+  /// Incrementally increasing token ID.
+  Increment,
+
+  /// Simple mode that returns a statically-assigned random token ID.
+  Random,
+
+  /// Token ID based on allocated type hash.
+  TypeHash,
+
+  /// Token ID based on allocated type hash, where the top half ID-space is
+  /// reserved for types that contain pointers and the bottom half for types
+  /// that do not contain pointers.
+  TypeHashPointerSplit,
+};
+
+/// Metadata about an allocation used to generate a token ID.
+struct AllocTokenMetadata {
+  SmallString<64> TypeName;
+  bool ContainsPointer;
+};
+
+/// Calculates stable allocation token ID. Returns std::nullopt for stateful
+/// modes that are only available in the AllocToken pass.
+///
+/// \param Mode The token generation mode.
+/// \param Metadata The metadata about the allocation.
+/// \param MaxTokens The maximum number of tokens (must not be 0)
+/// \return The calculated allocation token ID, or std::nullopt.
+std::optional getAllocTokenHash(AllocTokenMode Mode,
+  const AllocTokenMetadata &Metadata,
+  uint64_t MaxTokens);
+
+} // end namespace llvm
+
+#endif // LLVM_SUPPORT_ALLOCTOKEN_H
diff --git a/llvm/lib/Support/AllocToken.cpp b/llvm/lib/Support/AllocToken.cpp
new file mode 100644
index 0..6c6f80ac4997c
--- /dev/null
+++ b/llvm/lib/Support/AllocToken.cpp
@@ -0,0 +1,46 @@
+//===- AllocToken.cpp - Allocation Token Calculation 
--===//
+//
+// 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
+//
+//===--===//
+//
+// Definition of AllocToken modes and shared calculation of stateless token 
IDs.
+//
+//===--===//
+
+#include "llvm/Support/AllocToken.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/SipHash.h"
+
+namespace llvm {
+std::optional getAllocTokenHash(AllocTokenMode Mode,
+  const AllocTokenMetadata &Metadata,
+  uint64_t MaxTokens) {
+  assert(MaxTokens && "Must provide concrete max tokens");
+
+  switch (Mode) {
+  case AllocTokenMode::Increment:
+  case AllocTokenMode

[llvm-branch-commits] [llvm] [AArch64] (NFC) Tidy up alignment/formatting in AArch64/AArch64InstrInfo.td (PR #163645)

2025-10-18 Thread Jonathan Thackray via llvm-branch-commits

https://github.com/jthackray updated 
https://github.com/llvm/llvm-project/pull/163645

>From 1b865592cfa8d989bdca6715432cdbb2414a9e2e Mon Sep 17 00:00:00 2001
From: Jonathan Thackray 
Date: Wed, 15 Oct 2025 22:24:17 +0100
Subject: [PATCH] (NFC) Tidy up alignment/formatting in
 AArch64/AArch64InstrInfo.td

It was noted in a code-review for earlier changes in this stack
that some of the new 9.7 entries were mis-aligned. But actually,
many of the entries were, so I've tidied them all up.
---
 llvm/lib/Target/AArch64/AArch64InstrInfo.td | 227 +---
 1 file changed, 104 insertions(+), 123 deletions(-)

diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td 
b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
index 176040d5f3475..3ac9486a64335 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -50,63 +50,44 @@ def HasV9_4a : 
Predicate<"Subtarget->hasV9_4aOps()">,
  AssemblerPredicateWithAll<(all_of 
HasV9_4aOps), "armv9.4a">;
 def HasV8_0r : Predicate<"Subtarget->hasV8_0rOps()">,
  AssemblerPredicateWithAll<(all_of 
HasV8_0rOps), "armv8-r">;
-
 def HasEL2VMSA   : Predicate<"Subtarget->hasEL2VMSA()">,
-   AssemblerPredicateWithAll<(all_of FeatureEL2VMSA), 
"el2vmsa">;
-
+ AssemblerPredicateWithAll<(all_of 
FeatureEL2VMSA), "el2vmsa">;
 def HasEL3   : Predicate<"Subtarget->hasEL3()">,
-   AssemblerPredicateWithAll<(all_of FeatureEL3), "el3">;
-
+ AssemblerPredicateWithAll<(all_of 
FeatureEL3), "el3">;
 def HasVH: Predicate<"Subtarget->hasVH()">,
-   AssemblerPredicateWithAll<(all_of FeatureVH), "vh">;
-
+ AssemblerPredicateWithAll<(all_of FeatureVH), 
"vh">;
 def HasLOR   : Predicate<"Subtarget->hasLOR()">,
-   AssemblerPredicateWithAll<(all_of FeatureLOR), "lor">;
-
+ AssemblerPredicateWithAll<(all_of 
FeatureLOR), "lor">;
 def HasPAuth : Predicate<"Subtarget->hasPAuth()">,
-   AssemblerPredicateWithAll<(all_of FeaturePAuth), 
"pauth">;
-
+ AssemblerPredicateWithAll<(all_of 
FeaturePAuth), "pauth">;
 def HasPAuthLR   : Predicate<"Subtarget->hasPAuthLR()">,
-   AssemblerPredicateWithAll<(all_of FeaturePAuthLR), 
"pauth-lr">;
-
+ AssemblerPredicateWithAll<(all_of 
FeaturePAuthLR), "pauth-lr">;
 def HasJS: Predicate<"Subtarget->hasJS()">,
-   AssemblerPredicateWithAll<(all_of FeatureJS), "jsconv">;
-
+ AssemblerPredicateWithAll<(all_of FeatureJS), 
"jsconv">;
 def HasCCIDX : Predicate<"Subtarget->hasCCIDX()">,
-   AssemblerPredicateWithAll<(all_of FeatureCCIDX), 
"ccidx">;
-
-def HasComplxNum  : Predicate<"Subtarget->hasComplxNum()">,
-   AssemblerPredicateWithAll<(all_of FeatureComplxNum), 
"complxnum">;
-
+ AssemblerPredicateWithAll<(all_of 
FeatureCCIDX), "ccidx">;
+def HasComplxNum : Predicate<"Subtarget->hasComplxNum()">,
+ AssemblerPredicateWithAll<(all_of 
FeatureComplxNum), "complxnum">;
 def HasNV: Predicate<"Subtarget->hasNV()">,
-   AssemblerPredicateWithAll<(all_of FeatureNV), "nv">;
-
+ AssemblerPredicateWithAll<(all_of FeatureNV), 
"nv">;
 def HasMPAM  : Predicate<"Subtarget->hasMPAM()">,
-   AssemblerPredicateWithAll<(all_of FeatureMPAM), "mpam">;
-
+ AssemblerPredicateWithAll<(all_of 
FeatureMPAM), "mpam">;
 def HasDIT   : Predicate<"Subtarget->hasDIT()">,
-   AssemblerPredicateWithAll<(all_of FeatureDIT), "dit">;
-
-def HasTRACEV8_4 : Predicate<"Subtarget->hasTRACEV8_4()">,
-   AssemblerPredicateWithAll<(all_of FeatureTRACEV8_4), 
"tracev8.4">;
-
+ AssemblerPredicateWithAll<(all_of 
FeatureDIT), "dit">;
+def HasTRACEV8_4 : Predicate<"Subtarget->hasTRACEV8_4()">,
+ AssemblerPredicateWithAll<(all_of 
FeatureTRACEV8_4), "tracev8.4">;
 def HasAM: Predicate<"Subtarget->hasAM()">,
-   AssemblerPredicateWithAll<(all_of FeatureAM), "am">;
-
+ AssemblerPredicateWithAll<(all_of FeatureAM), 
"am">;
 def HasSEL2  : Predicate<"Subtarget->hasSEL2()">,
-   AssemblerPredicateWithAll<(all_of FeatureSEL2), "sel2">;
-
-def HasTLB_RMI  : Predicate<"Subtarget->hasTLB_RMI()">,
-   AssemblerPredicateWithAll<(all_of FeatureTLB_RMI), 
"tlb-rmi">;
-
+ A

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

2025-10-18 Thread Muhammad Bassiouni via llvm-branch-commits

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


[llvm-branch-commits] [Clang] Implement constexpr evaluation for __builtin_infer_alloc_token() (PR #163639)

2025-10-18 Thread Timm Baeder via llvm-branch-commits


@@ -1306,6 +1308,44 @@ interp__builtin_ptrauth_string_discriminator(InterpState 
&S, CodePtr OpPC,
   return true;
 }
 
+static bool interp__builtin_infer_alloc_token(InterpState &S, CodePtr OpPC,
+  const InterpFrame *Frame,
+  const CallExpr *Call) {
+  const ASTContext &Ctx = S.getASTContext();
+  const uint64_t BitWidth = Ctx.getTypeSize(Ctx.getSizeType());
+  const auto Mode =
+  Ctx.getLangOpts().AllocTokenMode.value_or(llvm::DefaultAllocTokenMode);
+  const uint64_t MaxTokens =
+  Ctx.getLangOpts().AllocTokenMax.value_or(~0ULL >> (64 - BitWidth));
+
+  // We do not read any of the arguments; discard them.
+  for (int I = Call->getNumArgs() - 1; I >= 0; --I)
+discard(S.Stk, *S.getContext().classify(Call->getArg(I)));
+
+  // Note: Type inference from a surrounding cast is not supported in
+  // constexpr evaluation.
+  QualType AllocType = infer_alloc::inferPossibleType(Call, Ctx, nullptr);
+  if (AllocType.isNull()) {
+S.CCEDiag(Call) << "could not infer allocation type";
+return false;
+  }
+
+  auto ATMD = infer_alloc::getAllocTokenMetadata(AllocType, Ctx);
+  if (!ATMD) {
+S.CCEDiag(Call) << "could not get token metadata for type";

tbaederr wrote:

Do we not have diagnostic IDs for these?

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


[llvm-branch-commits] [clang-tools-extra] [llvm] [llvm][mustache] Use BumpPtrAllocator to save ASTNodes (PR #159194)

2025-10-18 Thread Paul Kirth via llvm-branch-commits

https://github.com/ilovepi updated 
https://github.com/llvm/llvm-project/pull/159194

>From a6c453d2be6534d28ccca028671e28ebfe3631da Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Mon, 15 Sep 2025 16:26:11 -0700
Subject: [PATCH] [llvm][mustache] Use BumpPtrAllocator to save ASTNodes

We make the Mustache ASTNodes usable in the arena by first removing all
of the memory owning data structures, like std::vector, std::unique_ptr,
and SmallVector. We use standard LLVM list types to hold this data
instead, and make use of a UniqueStringSaver to hold the various
templates strings.

Additionally, update clang-doc APIs to use the new interfaces.

Future work can make better use of Twine interfaces to help avoid any
intermediate copies or allocations.
---
 .../clang-doc/HTMLMustacheGenerator.cpp   |  22 +-
 llvm/include/llvm/Support/Mustache.h  |  15 +-
 llvm/lib/Support/Mustache.cpp | 177 +++--
 llvm/unittests/Support/MustacheTest.cpp   | 725 ++
 .../llvm-test-mustache-spec.cpp   |   5 +-
 5 files changed, 697 insertions(+), 247 deletions(-)

diff --git a/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp 
b/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
index b37dc272ea156..b4b9322b0500a 100644
--- a/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
@@ -46,7 +46,13 @@ class MustacheHTMLGenerator : public Generator {
const ClangDocContext &CDCtx) override;
 };
 
-class MustacheTemplateFile : public Template {
+class MustacheTemplateFile {
+  BumpPtrAllocator Allocator;
+  StringSaver Saver;
+  MustacheContext Ctx;
+  Template T;
+  std::unique_ptr Buffer;
+
 public:
   static Expected>
   createMustacheFile(StringRef FileName) {
@@ -54,10 +60,8 @@ class MustacheTemplateFile : public Template {
 MemoryBuffer::getFile(FileName);
 if (auto EC = BufferOrError.getError())
   return createFileOpenError(FileName, EC);
-
-std::unique_ptr Buffer = std::move(BufferOrError.get());
-StringRef FileContent = Buffer->getBuffer();
-return std::make_unique(FileContent);
+return std::make_unique(
+std::move(BufferOrError.get()));
   }
 
   Error registerPartialFile(StringRef Name, StringRef FileName) {
@@ -68,11 +72,15 @@ class MustacheTemplateFile : public Template {
 
 std::unique_ptr Buffer = std::move(BufferOrError.get());
 StringRef FileContent = Buffer->getBuffer();
-registerPartial(Name.str(), FileContent.str());
+T.registerPartial(Name.str(), FileContent.str());
 return Error::success();
   }
 
-  MustacheTemplateFile(StringRef TemplateStr) : Template(TemplateStr) {}
+  void render(json::Value &V, raw_ostream &OS) { T.render(V, OS); }
+
+  MustacheTemplateFile(std::unique_ptr &&B)
+  : Saver(Allocator), Ctx(Allocator, Saver), T(B->getBuffer(), Ctx),
+Buffer(std::move(B)) {}
 };
 
 static std::unique_ptr NamespaceTemplate = nullptr;
diff --git a/llvm/include/llvm/Support/Mustache.h 
b/llvm/include/llvm/Support/Mustache.h
index ee9f40638fd12..83047f2aafff6 100644
--- a/llvm/include/llvm/Support/Mustache.h
+++ b/llvm/include/llvm/Support/Mustache.h
@@ -71,6 +71,8 @@
 
 #include "Error.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/ilist.h"
+#include "llvm/ADT/ilist_node.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/JSON.h"
@@ -84,10 +86,15 @@ using Lambda = std::function;
 using SectionLambda = std::function;
 
 class ASTNode;
-using AstPtr = std::unique_ptr;
+using AstPtr = ASTNode *;
 using EscapeMap = DenseMap;
+using ASTNodeList = iplist;
 
 struct MustacheContext {
+  MustacheContext(BumpPtrAllocator &Allocator, StringSaver &Saver)
+  : Allocator(Allocator), Saver(Saver) {}
+  BumpPtrAllocator &Allocator;
+  StringSaver &Saver;
   StringMap Partials;
   StringMap Lambdas;
   StringMap SectionLambdas;
@@ -98,7 +105,7 @@ struct MustacheContext {
 // and Lambdas that are registered with it.
 class Template {
 public:
-  LLVM_ABI Template(StringRef TemplateStr);
+  LLVM_ABI Template(StringRef TemplateStr, MustacheContext &Ctx);
 
   Template(const Template &) = delete;
 
@@ -110,7 +117,7 @@ class Template {
   // type.
   LLVM_ABI ~Template();
 
-  LLVM_ABI Template &operator=(Template &&Other) noexcept;
+  Template &operator=(Template &&) = delete;
 
   LLVM_ABI void render(const llvm::json::Value &Data, llvm::raw_ostream &OS);
 
@@ -126,7 +133,7 @@ class Template {
   LLVM_ABI void overrideEscapeCharacters(DenseMap Escapes);
 
 private:
-  MustacheContext Ctx;
+  MustacheContext &Ctx;
   AstPtr Tree;
 };
 } // namespace llvm::mustache
diff --git a/llvm/lib/Support/Mustache.cpp b/llvm/lib/Support/Mustache.cpp
index ba22cb75cbf5d..eadf4c1f7cda9 100644
--- a/llvm/lib/Support/Mustache.cpp
+++ b/llvm/lib/Support/Mustache.cpp
@@ -20,7 +20,7 @@ using namespace llvm::mustache;
 
 namespace {
 
-using Accessor = SmallVector;
+using Acc

[llvm-branch-commits] [llvm] release/21.x: [NVPTX] Disable relative lookup tables (#159748) (PR #160064)

2025-10-18 Thread via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [AllocToken] Introduce AllocToken instrumentation pass (PR #156838)

2025-10-18 Thread Marco Elver via llvm-branch-commits


@@ -0,0 +1,471 @@
+//===- AllocToken.cpp - Allocation token instrumentation 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements AllocToken, an instrumentation pass that
+// replaces allocation calls with token-enabled versions.
+//
+//===--===//
+
+#include "llvm/Transforms/Instrumentation/AllocToken.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Statistic.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Analysis/MemoryBuiltins.h"
+#include "llvm/Analysis/OptimizationRemarkEmitter.h"
+#include "llvm/Analysis/TargetLibraryInfo.h"
+#include "llvm/IR/Analysis.h"
+#include "llvm/IR/Attributes.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/DerivedTypes.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/GlobalValue.h"
+#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/InstIterator.h"
+#include "llvm/IR/InstrTypes.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/IR/Metadata.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
+#include "llvm/IR/Type.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Compiler.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/RandomNumberGenerator.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/xxhash.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+using namespace llvm;
+
+#define DEBUG_TYPE "alloc-token"
+
+namespace {
+
+//===--- Constants 
===//
+
+enum class TokenMode : unsigned {
+  /// Incrementally increasing token ID.
+  Increment = 0,
+
+  /// Simple mode that returns a statically-assigned random token ID.
+  Random = 1,
+
+  /// Token ID based on allocated type hash.
+  TypeHash = 2,
+};
+
+//===--- Command-line options 
-===//
+
+cl::opt
+ClMode("alloc-token-mode", cl::Hidden, cl::desc("Token assignment mode"),
+   cl::init(TokenMode::TypeHash),
+   cl::values(clEnumValN(TokenMode::Increment, "increment",
+ "Incrementally increasing token ID"),
+  clEnumValN(TokenMode::Random, "random",
+ "Statically-assigned random token ID"),
+  clEnumValN(TokenMode::TypeHash, "typehash",
+ "Token ID based on allocated type hash")));
+
+cl::opt ClFuncPrefix("alloc-token-prefix",
+  cl::desc("The allocation function prefix"),
+  cl::Hidden, cl::init("__alloc_token_"));
+
+cl::opt ClMaxTokens("alloc-token-max",
+  cl::desc("Maximum number of tokens (0 = no 
max)"),
+  cl::Hidden, cl::init(0));
+
+cl::opt
+ClFastABI("alloc-token-fast-abi",
+  cl::desc("The token ID is encoded in the function name"),
+  cl::Hidden, cl::init(false));
+
+// Instrument libcalls only by default - compatible allocators only need to 
take
+// care of providing standard allocation functions. With extended coverage, 
also
+// instrument non-libcall allocation function calls with !alloc_token
+// metadata.
+cl::opt
+ClExtended("alloc-token-extended",
+   cl::desc("Extend coverage to custom allocation functions"),
+   cl::Hidden, cl::init(false));
+
+// C++ defines ::operator new (and variants) as replaceable (vs. standard
+// library versions), which are nobuiltin, and are therefore not covered by
+// isAllocationFn(). Cover by default, as users of AllocToken are already
+// required to provide token-aware allocation functions (no defaults).
+cl::opt ClCoverReplaceableNew("alloc-token-cover-replaceable-new",
+cl::desc("Cover replaceable operator new"),
+cl::Hidden, cl::init(true));
+
+cl::opt ClFallbackToken(
+"alloc-token-fallback",
+cl::desc("The default fallback token where none could be determined"),
+cl::Hidden, cl::init(0));
+
+//===--- Statistics 
---===//
+
+STATISTIC(NumFunctionsInstrumented, "Functions instrumented");
+STATISTIC(NumAllocationsInstrumented, "Allocations instrumented");
+
+//===--===//
+
+/// Returns the !alloc_token metadata if available.
+///
+/// Expected format is: !{}
+MDNode *getAllocTokenMetadata(const 

[llvm-branch-commits] [llvm] release/21.x: [X86] Use pseudo instructions to zero registers in `buildClearRegister` (#163358) (PR #164076)

2025-10-18 Thread via llvm-branch-commits

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

Backport 228dae786b94bb85fb34bc157a43ca6c16932b6d

Requested by: @RKSimon

>From 8ec2f6d462406c6f35728cd5be3c1d95e00530a1 Mon Sep 17 00:00:00 2001
From: Abhishek Kaushik 
Date: Sat, 18 Oct 2025 02:30:18 +0530
Subject: [PATCH] [X86] Use pseudo instructions to zero registers in
 `buildClearRegister` (#163358)

In `buildClearRegister` use the correct pseudo-opcode for each register
class:

- For `VR128`, use `V_SET0`
- For `VR256`, use `AVX_SET0`
- For `VR512`, use `AVX512_512_SET0`
- For `VK*`, use `KSET0Q/KSET0W`

This avoids illegal register/opcode pairings and machine verifier errors
when clearing call-used registers under `-fzero-call-used-regs=used`.

Fixes: #163053

-

Co-authored-by: Simon Pilgrim 
(cherry picked from commit 228dae786b94bb85fb34bc157a43ca6c16932b6d)
---
 llvm/lib/Target/X86/X86InstrInfo.cpp  |  22 +-
 .../CodeGen/X86/zero-call-used-regs-simd.ll   | 216 ++
 2 files changed, 221 insertions(+), 17 deletions(-)
 create mode 100644 llvm/test/CodeGen/X86/zero-call-used-regs-simd.ll

diff --git a/llvm/lib/Target/X86/X86InstrInfo.cpp 
b/llvm/lib/Target/X86/X86InstrInfo.cpp
index abf365eedec39..9bf58dd3458cd 100644
--- a/llvm/lib/Target/X86/X86InstrInfo.cpp
+++ b/llvm/lib/Target/X86/X86InstrInfo.cpp
@@ -10739,39 +10739,27 @@ void X86InstrInfo::buildClearRegister(Register Reg, 
MachineBasicBlock &MBB,
 if (!ST.hasSSE1())
   return;
 
-// PXOR is safe to use because it doesn't affect flags.
-BuildMI(MBB, Iter, DL, get(X86::PXORrr), Reg)
-.addReg(Reg, RegState::Undef)
-.addReg(Reg, RegState::Undef);
+BuildMI(MBB, Iter, DL, get(X86::V_SET0), Reg);
   } else if (X86::VR256RegClass.contains(Reg)) {
 // YMM#
 if (!ST.hasAVX())
   return;
 
-// VPXOR is safe to use because it doesn't affect flags.
-BuildMI(MBB, Iter, DL, get(X86::VPXORrr), Reg)
-.addReg(Reg, RegState::Undef)
-.addReg(Reg, RegState::Undef);
+BuildMI(MBB, Iter, DL, get(X86::AVX_SET0), Reg);
   } else if (X86::VR512RegClass.contains(Reg)) {
 // ZMM#
 if (!ST.hasAVX512())
   return;
 
-// VPXORY is safe to use because it doesn't affect flags.
-BuildMI(MBB, Iter, DL, get(X86::VPXORYrr), Reg)
-.addReg(Reg, RegState::Undef)
-.addReg(Reg, RegState::Undef);
+BuildMI(MBB, Iter, DL, get(X86::AVX512_512_SET0), Reg);
   } else if (X86::VK1RegClass.contains(Reg) || X86::VK2RegClass.contains(Reg) 
||
  X86::VK4RegClass.contains(Reg) || X86::VK8RegClass.contains(Reg) 
||
  X86::VK16RegClass.contains(Reg)) {
 if (!ST.hasVLX())
   return;
 
-// KXOR is safe to use because it doesn't affect flags.
-unsigned Op = ST.hasBWI() ? X86::KXORQkk : X86::KXORWkk;
-BuildMI(MBB, Iter, DL, get(Op), Reg)
-.addReg(Reg, RegState::Undef)
-.addReg(Reg, RegState::Undef);
+unsigned Op = ST.hasBWI() ? X86::KSET0Q : X86::KSET0W;
+BuildMI(MBB, Iter, DL, get(Op), Reg);
   }
 }
 
diff --git a/llvm/test/CodeGen/X86/zero-call-used-regs-simd.ll 
b/llvm/test/CodeGen/X86/zero-call-used-regs-simd.ll
new file mode 100644
index 0..d9253e0ca127b
--- /dev/null
+++ b/llvm/test/CodeGen/X86/zero-call-used-regs-simd.ll
@@ -0,0 +1,216 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 6
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+sse2
-verify-machineinstrs | FileCheck %s --check-prefixes=SSE
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx 
-verify-machineinstrs | FileCheck %s --check-prefixes=AVX,AVX1
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx2
-verify-machineinstrs | FileCheck %s --check-prefixes=AVX,AVX2
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx512f,+avx512vl   
-verify-machineinstrs | FileCheck %s --check-prefixes=AVX512,AVX512VL
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx512f,+avx512vl,+avx512bw 
-verify-machineinstrs | FileCheck %s --check-prefixes=AVX512,AVX512BW
+
+define void @zero_xmm(<4 x i32> %arg) #0 {
+; SSE-LABEL: zero_xmm:
+; SSE:   # %bb.0:
+; SSE-NEXT:movaps %xmm0, 0
+; SSE-NEXT:xorps %xmm0, %xmm0
+; SSE-NEXT:retq
+;
+; AVX-LABEL: zero_xmm:
+; AVX:   # %bb.0:
+; AVX-NEXT:vmovaps %xmm0, 0
+; AVX-NEXT:vxorps %xmm0, %xmm0, %xmm0
+; AVX-NEXT:retq
+;
+; AVX512-LABEL: zero_xmm:
+; AVX512:   # %bb.0:
+; AVX512-NEXT:vmovaps %xmm0, 0
+; AVX512-NEXT:vxorps %xmm0, %xmm0, %xmm0
+; AVX512-NEXT:retq
+  store <4 x i32> %arg, ptr null, align 32
+  ret void
+}
+
+define void @zero_ymm(<8 x i32> %arg) #0 {
+; SSE-LABEL: zero_ymm:
+; SSE:   # %bb.0:
+; SSE-NEXT:movaps %xmm1, 16
+; SSE-NEXT:movaps %xmm0, 0
+; SSE-NEXT:xorps %xmm0, %xmm0
+; SSE-NEXT:xorps %xmm1, %xmm1
+; SSE-NEXT:retq
+;
+; AVX-LABEL: zero_ymm:
+; AVX:   # %bb.0:
+; AVX-NEXT:vmovaps %ymm0, 0
+; AVX-NEX

[llvm-branch-commits] [llvm] [AllocToken] Introduce AllocToken instrumentation pass (PR #156838)

2025-10-18 Thread Hans Wennborg via llvm-branch-commits

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

lgtm

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


[llvm-branch-commits] [Clang][CodeGen] Emit !alloc_token for new expressions (PR #162099)

2025-10-18 Thread Marco Elver via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [BOLT] Gadget scanner: prevent false positives due to jump tables (PR #138884)

2025-10-18 Thread Anatoly Trosinenko via llvm-branch-commits

https://github.com/atrosinenko updated 
https://github.com/llvm/llvm-project/pull/138884

>From 5c1edeb727636b1dcbf6573dd4d3f9d14abd8799 Mon Sep 17 00:00:00 2001
From: Anatoly Trosinenko 
Date: Tue, 6 May 2025 11:31:03 +0300
Subject: [PATCH] [BOLT] Gadget scanner: prevent false positives due to jump
 tables

As part of PAuth hardening, AArch64 LLVM backend can use a special
BR_JumpTable pseudo (enabled by -faarch64-jump-table-hardening
Clang option) which is expanded in the AsmPrinter into a contiguous
sequence without unsafe instructions in the middle.

This commit adds another target-specific callback to MCPlusBuilder
to make it possible to inhibit false positives for known-safe jump
table dispatch sequences. Without special handling, the branch
instruction is likely to be reported as a non-protected call (as its
destination is not produced by an auth instruction, PC-relative address
materialization, etc.) and possibly as a tail call being performed with
unsafe link register (as the detection whether the branch instruction
is a tail call is an heuristic).

For now, only the specific instruction sequence used by the AArch64
LLVM backend is matched.
---
 bolt/include/bolt/Core/MCInstUtils.h  |   9 +
 bolt/include/bolt/Core/MCPlusBuilder.h|  14 +
 bolt/lib/Core/MCInstUtils.cpp |  20 +
 bolt/lib/Passes/PAuthGadgetScanner.cpp|  10 +
 .../Target/AArch64/AArch64MCPlusBuilder.cpp   |  73 ++
 .../AArch64/gs-pauth-jump-table.s | 703 ++
 6 files changed, 829 insertions(+)
 create mode 100644 bolt/test/binary-analysis/AArch64/gs-pauth-jump-table.s

diff --git a/bolt/include/bolt/Core/MCInstUtils.h 
b/bolt/include/bolt/Core/MCInstUtils.h
index 2436e1359f40e..2df2054712457 100644
--- a/bolt/include/bolt/Core/MCInstUtils.h
+++ b/bolt/include/bolt/Core/MCInstUtils.h
@@ -142,6 +142,15 @@ class MCInstReference {
 return nullptr;
   }
 
+  /// Returns the only preceding instruction, or std::nullopt if multiple or no
+  /// predecessors are possible.
+  ///
+  /// If CFG information is available, basic block boundary can be crossed,
+  /// provided there is exactly one predecessor. If CFG is not available, the
+  /// preceding instruction in the offset order is returned, unless this is the
+  /// first instruction of the function.
+  std::optional getSinglePredecessor();
+
   raw_ostream &print(raw_ostream &OS) const;
 };
 
diff --git a/bolt/include/bolt/Core/MCPlusBuilder.h 
b/bolt/include/bolt/Core/MCPlusBuilder.h
index ae04891e791f9..f13e41c75c2ac 100644
--- a/bolt/include/bolt/Core/MCPlusBuilder.h
+++ b/bolt/include/bolt/Core/MCPlusBuilder.h
@@ -14,6 +14,7 @@
 #ifndef BOLT_CORE_MCPLUSBUILDER_H
 #define BOLT_CORE_MCPLUSBUILDER_H
 
+#include "bolt/Core/MCInstUtils.h"
 #include "bolt/Core/MCPlus.h"
 #include "bolt/Core/Relocation.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -711,6 +712,19 @@ class MCPlusBuilder {
 return std::nullopt;
   }
 
+  /// Tests if BranchInst corresponds to an instruction sequence which is known
+  /// to be a safe dispatch via jump table.
+  ///
+  /// The target can decide which instruction sequences to consider "safe" from
+  /// the Pointer Authentication point of view, such as any jump table dispatch
+  /// sequence without function calls inside, any sequence which is contiguous,
+  /// or only some specific well-known sequences.
+  virtual bool
+  isSafeJumpTableBranchForPtrAuth(MCInstReference BranchInst) const {
+llvm_unreachable("not implemented");
+return false;
+  }
+
   virtual bool isTerminator(const MCInst &Inst) const;
 
   virtual bool isNoop(const MCInst &Inst) const {
diff --git a/bolt/lib/Core/MCInstUtils.cpp b/bolt/lib/Core/MCInstUtils.cpp
index 3cdb9673d4dc0..39bc96f087f8e 100644
--- a/bolt/lib/Core/MCInstUtils.cpp
+++ b/bolt/lib/Core/MCInstUtils.cpp
@@ -54,3 +54,23 @@ raw_ostream &MCInstReference::print(raw_ostream &OS) const {
   OS << ">";
   return OS;
 }
+
+std::optional MCInstReference::getSinglePredecessor() {
+  if (const RefInBB *Ref = tryGetRefInBB()) {
+if (Ref->It != Ref->BB->begin())
+  return MCInstReference(Ref->BB, &*std::prev(Ref->It));
+
+if (Ref->BB->pred_size() != 1)
+  return std::nullopt;
+
+BinaryBasicBlock *PredBB = *Ref->BB->pred_begin();
+assert(!PredBB->empty() && "Empty basic blocks are not supported yet");
+return MCInstReference(PredBB, &*PredBB->rbegin());
+  }
+
+  const RefInBF &Ref = getRefInBF();
+  if (Ref.It == Ref.BF->instrs().begin())
+return std::nullopt;
+
+  return MCInstReference(Ref.BF, std::prev(Ref.It));
+}
diff --git a/bolt/lib/Passes/PAuthGadgetScanner.cpp 
b/bolt/lib/Passes/PAuthGadgetScanner.cpp
index 5d884e2d37354..3a6c3e3d925cf 100644
--- a/bolt/lib/Passes/PAuthGadgetScanner.cpp
+++ b/bolt/lib/Passes/PAuthGadgetScanner.cpp
@@ -1370,6 +1370,11 @@ shouldReportUnsafeTailCall(const BinaryContext &BC, 
const BinaryFunction &BF,
 return std::nullopt;
   }
 
+  if (BC.MIB->isSafeJumpTableBranchForPtrAuth(Inst)) {
+LL

[llvm-branch-commits] [llvm] [PowerPC] Implement paddis (PR #161572)

2025-10-18 Thread Lei Huang via llvm-branch-commits

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


[llvm-branch-commits] [clang] [llvm] [Clang][CodeGen] Implement code generation for __builtin_infer_alloc_token() (PR #156842)

2025-10-18 Thread Marco Elver via llvm-branch-commits

melver wrote:

> I'll take another stab at this one now, and see if I can make it constexpr, 
> too. [..]

Alright, so I reworked the whole thing. Making it constexpr meant sharing more 
of the token calculation logic. We now have this series to make the builtin 
work also in constexpr:

1. https://github.com/llvm/llvm-project/pull/163632
2. https://github.com/llvm/llvm-project/pull/163633
3. https://github.com/llvm/llvm-project/pull/163634
4. https://github.com/llvm/llvm-project/pull/163635
5. https://github.com/llvm/llvm-project/pull/163636
6. https://github.com/llvm/llvm-project/pull/163638
7. https://github.com/llvm/llvm-project/pull/163639
8. https://github.com/llvm/llvm-project/pull/156842

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


[llvm-branch-commits] [llvm] [AArch64][SME] Support split ZPR and PPR area allocation (PR #142392)

2025-10-18 Thread Sander de Smalen via llvm-branch-commits

https://github.com/sdesmalen-arm commented:

Mostly some minor nits and request for some more tests, but otherwise it looks 
good to me.

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


[llvm-branch-commits] [FlowSensitive] [StatusOr] [6/N] support pointer comparison (PR #163875)

2025-10-18 Thread Florian Mayer via llvm-branch-commits

https://github.com/fmayer created 
https://github.com/llvm/llvm-project/pull/163875

None


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


[llvm-branch-commits] [llvm] [PowerPC] Implement Elliptic Curve Cryptography (ECC) Instructions (PR #158362)

2025-10-18 Thread Lei Huang via llvm-branch-commits

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


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

2025-10-18 Thread Muhammad Bassiouni via llvm-branch-commits

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


[llvm-branch-commits] [libcxx] [libc++] Add accessor functions to __tree_node_base (PR #147679)

2025-10-18 Thread Louis Dionne via llvm-branch-commits


@@ -132,18 +139,18 @@ unsigned __tree_sub_invariant(_NodePtr __x) {
   if (__x->__left_ == __x->__right_ && __x->__left_ != nullptr)
 return 0;
   // If this is red, neither child can be red
-  if (!__x->__is_black_) {
-if (__x->__left_ && !__x->__left_->__is_black_)
+  if (__x->__color_ == __red) {

ldionne wrote:

```suggestion
  if (__x->__color_ == __tree_color::__red) {
```

The combination of `using enum __tree_color;` and using lowercase for the enum 
constants hurt readability IMO -- it makes it look like a variable comparison. 
I would at minimum qualify the enum accesses throughout.

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


[llvm-branch-commits] [libc] [libc][annex_k] Add rsize_t. (PR #163238)

2025-10-18 Thread Muhammad Bassiouni via llvm-branch-commits

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

>From 9b4e574910dd6bda74e412240d2b0399b97adc7c Mon Sep 17 00:00:00 2001
From: bassiounix 
Date: Mon, 13 Oct 2025 21:14:40 +0300
Subject: [PATCH] [libc][annex_k] Add rsize_t.

---
 libc/hdr/types/CMakeLists.txt   |  8 +++
 libc/hdr/types/rsize_t.h| 23 +
 libc/include/llvm-libc-types/CMakeLists.txt |  1 +
 libc/include/llvm-libc-types/rsize_t.h  | 18 
 4 files changed, 50 insertions(+)
 create mode 100644 libc/hdr/types/rsize_t.h
 create mode 100644 libc/include/llvm-libc-types/rsize_t.h

diff --git a/libc/hdr/types/CMakeLists.txt b/libc/hdr/types/CMakeLists.txt
index 8ec2926ee16fc..6fe26881f737e 100644
--- a/libc/hdr/types/CMakeLists.txt
+++ b/libc/hdr/types/CMakeLists.txt
@@ -135,6 +135,14 @@ add_proxy_header_library(
 libc.include.llvm-libc-types.struct_tm
 )
 
+add_proxy_header_library(
+  rsize_t
+  HDRS
+rsize_t.h
+  FULL_BUILD_DEPENDS
+libc.include.llvm-libc-types.rsize_t
+)
+
 add_proxy_header_library(
   size_t
   HDRS
diff --git a/libc/hdr/types/rsize_t.h b/libc/hdr/types/rsize_t.h
new file mode 100644
index 0..130e6c308e264
--- /dev/null
+++ b/libc/hdr/types/rsize_t.h
@@ -0,0 +1,23 @@
+//===-- Proxy for rsize_t 
-===//
+//
+// 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_HDR_TYPES_SIZE_T_H
+#define LLVM_LIBC_HDR_TYPES_SIZE_T_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/rsize_t.h"
+
+#else
+
+#define __need_rsize_t
+#include 
+#undef __need_rsize_t
+
+#endif // LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_SIZE_T_H
diff --git a/libc/include/llvm-libc-types/CMakeLists.txt 
b/libc/include/llvm-libc-types/CMakeLists.txt
index e8b3ae8c08a90..cc7b2847909e4 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -1,4 +1,5 @@
 add_header(off64_t HDR off64_t.h)
+add_header(rsize_t HDR rsize_t.h)
 add_header(size_t HDR size_t.h)
 add_header(ssize_t HDR ssize_t.h)
 add_header(__atfork_callback_t HDR __atfork_callback_t.h)
diff --git a/libc/include/llvm-libc-types/rsize_t.h 
b/libc/include/llvm-libc-types/rsize_t.h
new file mode 100644
index 0..dc8be02bee592
--- /dev/null
+++ b/libc/include/llvm-libc-types/rsize_t.h
@@ -0,0 +1,18 @@
+//===-- Definition of size_t types 
===//
+//
+// 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_TYPES_RSIZE_T_H
+#define LLVM_LIBC_TYPES_RSIZE_T_H
+
+#ifdef LIBC_HAS_ANNEX_K
+
+typedef __SIZE_TYPE__ rsize_t;
+
+#endif // LIBC_HAS_ANNEX_K
+
+#endif // LLVM_LIBC_TYPES_RSIZE_T_H

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


[llvm-branch-commits] [libc] [libc][stdlib][annex_k] Add abort_handler_s. (PR #163309)

2025-10-18 Thread Muhammad Bassiouni via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [StaticDataLayout] Factor out a helper function for section prefix eligibility and use it in both optimizer and codegen (PR #162348)

2025-10-18 Thread Teresa Johnson via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [AMDGPU] Improve StructurizeCFG pass performance by using SSAUpdaterBulk. (PR #150937)

2025-10-18 Thread Valery Pykhtin via llvm-branch-commits

https://github.com/vpykhtin updated 
https://github.com/llvm/llvm-project/pull/150937

>From fa7a95135fbc91838a0ca6e75e05718e0aeb8af9 Mon Sep 17 00:00:00 2001
From: Valery Pykhtin 
Date: Thu, 10 Apr 2025 11:58:13 +
Subject: [PATCH] amdgpu_use_ssaupdaterbulk_in_structurizecfg

---
 llvm/lib/Transforms/Scalar/StructurizeCFG.cpp | 25 +++
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp 
b/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp
index 2ee91a9b40026..0f3978f56045e 100644
--- a/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp
+++ b/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp
@@ -47,6 +47,7 @@
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
 #include "llvm/Transforms/Utils/Local.h"
 #include "llvm/Transforms/Utils/SSAUpdater.h"
+#include "llvm/Transforms/Utils/SSAUpdaterBulk.h"
 #include 
 #include 
 
@@ -321,7 +322,7 @@ class StructurizeCFG {
 
   void collectInfos();
 
-  void insertConditions(bool Loops);
+  void insertConditions(bool Loops, SSAUpdaterBulk &PhiInserter);
 
   void simplifyConditions();
 
@@ -671,10 +672,9 @@ void StructurizeCFG::collectInfos() {
 }
 
 /// Insert the missing branch conditions
-void StructurizeCFG::insertConditions(bool Loops) {
+void StructurizeCFG::insertConditions(bool Loops, SSAUpdaterBulk &PhiInserter) 
{
   BranchVector &Conds = Loops ? LoopConds : Conditions;
   Value *Default = Loops ? BoolTrue : BoolFalse;
-  SSAUpdater PhiInserter;
 
   for (BranchInst *Term : Conds) {
 assert(Term->isConditional());
@@ -683,8 +683,9 @@ void StructurizeCFG::insertConditions(bool Loops) {
 BasicBlock *SuccTrue = Term->getSuccessor(0);
 BasicBlock *SuccFalse = Term->getSuccessor(1);
 
-PhiInserter.Initialize(Boolean, "");
-PhiInserter.AddAvailableValue(Loops ? SuccFalse : Parent, Default);
+unsigned Variable = PhiInserter.AddVariable("", Boolean);
+PhiInserter.AddAvailableValue(Variable, Loops ? SuccFalse : Parent,
+  Default);
 
 BBPredicates &Preds = Loops ? LoopPreds[SuccFalse] : Predicates[SuccTrue];
 
@@ -697,7 +698,7 @@ void StructurizeCFG::insertConditions(bool Loops) {
 ParentInfo = PI;
 break;
   }
-  PhiInserter.AddAvailableValue(BB, PI.Pred);
+  PhiInserter.AddAvailableValue(Variable, BB, PI.Pred);
   Dominator.addAndRememberBlock(BB);
 }
 
@@ -706,9 +707,9 @@ void StructurizeCFG::insertConditions(bool Loops) {
   CondBranchWeights::setMetadata(*Term, ParentInfo.Weights);
 } else {
   if (!Dominator.resultIsRememberedBlock())
-PhiInserter.AddAvailableValue(Dominator.result(), Default);
+PhiInserter.AddAvailableValue(Variable, Dominator.result(), Default);
 
-  Term->setCondition(PhiInserter.GetValueInMiddleOfBlock(Parent));
+  PhiInserter.AddUse(Variable, &Term->getOperandUse(0));
 }
   }
 }
@@ -1414,8 +1415,12 @@ bool StructurizeCFG::run(Region *R, DominatorTree *DT,
   orderNodes();
   collectInfos();
   createFlow();
-  insertConditions(false);
-  insertConditions(true);
+
+  SSAUpdaterBulk PhiInserter;
+  insertConditions(false, PhiInserter);
+  insertConditions(true, PhiInserter);
+  PhiInserter.RewriteAndOptimizeAllUses(*DT);
+
   setPhiValues();
   simplifyHoistedPhis();
   simplifyConditions();

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


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

2025-10-18 Thread Muhammad Bassiouni via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [AArch64] (NFC) Tidy up alignment/formatting in AArch64/AArch64InstrInfo.td (PR #163645)

2025-10-18 Thread Jonathan Thackray via llvm-branch-commits

https://github.com/jthackray updated 
https://github.com/llvm/llvm-project/pull/163645

>From b717897c56af89fbaeef85031d62dcc938c26567 Mon Sep 17 00:00:00 2001
From: Jonathan Thackray 
Date: Wed, 15 Oct 2025 22:24:17 +0100
Subject: [PATCH] (NFC) Tidy up alignment/formatting in
 AArch64/AArch64InstrInfo.td

It was noted in a code-review for earlier changes in this stack
that some of the new 9.7 entries were mis-aligned. But actually,
many of the entries were, so I've tidied them all up.
---
 llvm/lib/Target/AArch64/AArch64InstrInfo.td | 227 +---
 1 file changed, 104 insertions(+), 123 deletions(-)

diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td 
b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
index ab8cd055002f7..86c1f8aa88052 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -50,63 +50,44 @@ def HasV9_4a : 
Predicate<"Subtarget->hasV9_4aOps()">,
  AssemblerPredicateWithAll<(all_of 
HasV9_4aOps), "armv9.4a">;
 def HasV8_0r : Predicate<"Subtarget->hasV8_0rOps()">,
  AssemblerPredicateWithAll<(all_of 
HasV8_0rOps), "armv8-r">;
-
 def HasEL2VMSA   : Predicate<"Subtarget->hasEL2VMSA()">,
-   AssemblerPredicateWithAll<(all_of FeatureEL2VMSA), 
"el2vmsa">;
-
+ AssemblerPredicateWithAll<(all_of 
FeatureEL2VMSA), "el2vmsa">;
 def HasEL3   : Predicate<"Subtarget->hasEL3()">,
-   AssemblerPredicateWithAll<(all_of FeatureEL3), "el3">;
-
+ AssemblerPredicateWithAll<(all_of 
FeatureEL3), "el3">;
 def HasVH: Predicate<"Subtarget->hasVH()">,
-   AssemblerPredicateWithAll<(all_of FeatureVH), "vh">;
-
+ AssemblerPredicateWithAll<(all_of FeatureVH), 
"vh">;
 def HasLOR   : Predicate<"Subtarget->hasLOR()">,
-   AssemblerPredicateWithAll<(all_of FeatureLOR), "lor">;
-
+ AssemblerPredicateWithAll<(all_of 
FeatureLOR), "lor">;
 def HasPAuth : Predicate<"Subtarget->hasPAuth()">,
-   AssemblerPredicateWithAll<(all_of FeaturePAuth), 
"pauth">;
-
+ AssemblerPredicateWithAll<(all_of 
FeaturePAuth), "pauth">;
 def HasPAuthLR   : Predicate<"Subtarget->hasPAuthLR()">,
-   AssemblerPredicateWithAll<(all_of FeaturePAuthLR), 
"pauth-lr">;
-
+ AssemblerPredicateWithAll<(all_of 
FeaturePAuthLR), "pauth-lr">;
 def HasJS: Predicate<"Subtarget->hasJS()">,
-   AssemblerPredicateWithAll<(all_of FeatureJS), "jsconv">;
-
+ AssemblerPredicateWithAll<(all_of FeatureJS), 
"jsconv">;
 def HasCCIDX : Predicate<"Subtarget->hasCCIDX()">,
-   AssemblerPredicateWithAll<(all_of FeatureCCIDX), 
"ccidx">;
-
-def HasComplxNum  : Predicate<"Subtarget->hasComplxNum()">,
-   AssemblerPredicateWithAll<(all_of FeatureComplxNum), 
"complxnum">;
-
+ AssemblerPredicateWithAll<(all_of 
FeatureCCIDX), "ccidx">;
+def HasComplxNum : Predicate<"Subtarget->hasComplxNum()">,
+ AssemblerPredicateWithAll<(all_of 
FeatureComplxNum), "complxnum">;
 def HasNV: Predicate<"Subtarget->hasNV()">,
-   AssemblerPredicateWithAll<(all_of FeatureNV), "nv">;
-
+ AssemblerPredicateWithAll<(all_of FeatureNV), 
"nv">;
 def HasMPAM  : Predicate<"Subtarget->hasMPAM()">,
-   AssemblerPredicateWithAll<(all_of FeatureMPAM), "mpam">;
-
+ AssemblerPredicateWithAll<(all_of 
FeatureMPAM), "mpam">;
 def HasDIT   : Predicate<"Subtarget->hasDIT()">,
-   AssemblerPredicateWithAll<(all_of FeatureDIT), "dit">;
-
-def HasTRACEV8_4 : Predicate<"Subtarget->hasTRACEV8_4()">,
-   AssemblerPredicateWithAll<(all_of FeatureTRACEV8_4), 
"tracev8.4">;
-
+ AssemblerPredicateWithAll<(all_of 
FeatureDIT), "dit">;
+def HasTRACEV8_4 : Predicate<"Subtarget->hasTRACEV8_4()">,
+ AssemblerPredicateWithAll<(all_of 
FeatureTRACEV8_4), "tracev8.4">;
 def HasAM: Predicate<"Subtarget->hasAM()">,
-   AssemblerPredicateWithAll<(all_of FeatureAM), "am">;
-
+ AssemblerPredicateWithAll<(all_of FeatureAM), 
"am">;
 def HasSEL2  : Predicate<"Subtarget->hasSEL2()">,
-   AssemblerPredicateWithAll<(all_of FeatureSEL2), "sel2">;
-
-def HasTLB_RMI  : Predicate<"Subtarget->hasTLB_RMI()">,
-   AssemblerPredicateWithAll<(all_of FeatureTLB_RMI), 
"tlb-rmi">;
-
+ A

[llvm-branch-commits] [libcxx] release/21.x: [libc++] Properly implement array cookies in the ARM ABI (#160182) (PR #163903)

2025-10-18 Thread via llvm-branch-commits

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


[llvm-branch-commits] [lld] release/21.x: [LLD] [COFF] Fix symbol names for import thunks (#160694) (PR #160770)

2025-10-18 Thread via llvm-branch-commits

https://github.com/dyung updated 
https://github.com/llvm/llvm-project/pull/160770

>From d1e2f8916128c8c8f402565b0612f6b6e5566702 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 
Date: Thu, 25 Sep 2025 23:11:17 +0300
Subject: [PATCH] [LLD] [COFF] Fix symbol names for import thunks (#160694)

9cc9efc483339ece1d52923569bb755db42b69f3 changed LLD to use a
StringTableBuilder for optimizing the string table, used for long
section and symbol names.

That commit had a bug, where the symbol table entry for an import thunk
with a long symbol name wouldn't get fetched from the
StringTableBuilder, if the base symbol name (without the "__imp_"
prefix) wasn't over 8 chars.

This should fix issues with Go, which errors out on reading the
executables with a broken symbol table, as noted in
https://github.com/mstorsjo/llvm-mingw/issues/518 and
https://github.com/golang/go/issues/75219.

(cherry picked from commit 0d6af2db6cd9c964ff300e5b5246c070a57d45e2)
---
 lld/COFF/Writer.cpp|  2 +-
 lld/test/COFF/strtab.s | 22 +++---
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index 076561807af47..ef9d051bf976e 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -1553,7 +1553,7 @@ void Writer::createSymbolAndStringTable() {
 dthunk->wrappedSym->writtenToSymtab = true;
 if (std::optional sym =
 createSymbol(dthunk->wrappedSym)) {
-  if (d->getName().size() > COFF::NameSize)
+  if (dthunk->wrappedSym->getName().size() > COFF::NameSize)
 longNameSymbols.emplace_back(outputSymtab.size(),
  dthunk->wrappedSym->getName());
   outputSymtab.push_back(*sym);
diff --git a/lld/test/COFF/strtab.s b/lld/test/COFF/strtab.s
index fbdd8df52d540..9edc13e19e825 100644
--- a/lld/test/COFF/strtab.s
+++ b/lld/test/COFF/strtab.s
@@ -1,17 +1,32 @@
 # REQUIRES: x86
 # RUN: llvm-mc -triple=x86_64-windows-msvc %s -filetype=obj -o %t.obj
-# RUN: lld-link -out:%t.exe -entry:main %t.obj -debug:dwarf
+# RUN: lld-link -machine:x64 -def:%S/Inputs/library.def -implib:%t.lib
+# RUN: lld-link -out:%t.exe -entry:main %t.obj %t.lib -debug:dwarf
 # RUN: llvm-readobj --string-table %t.exe | FileCheck %s
+# RUN: llvm-nm %t.exe | FileCheck %s --check-prefix=SYMBOLS
+
+# Note, for this test to have the intended test coverage, the imported symbol
+# "function" needs to be such that the symbol name itself is <= 8 chars, while
+# "__imp_"+name is >8 chars.
 
 # CHECK:  StringTable {
-# CHECK-NEXT:   Length: 87
+# CHECK-NEXT:   Length: 102
 # CHECK-NEXT:   [ 4] .debug_abbrev
 # CHECK-NEXT:   [12] .debug_line
 # CHECK-NEXT:   [1e] long_name_symbolz
 # CHECK-NEXT:   [30] .debug_abbrez
-# CHECK-NEXT:   [3e] __impl_long_name_symbolA
+# CHECK-NEXT:   [3e] __imp_function
+# CHECK-NEXT:   [4d] __impl_long_name_symbolA
 # CHECK-NEXT: }
 
+# SYMBOLS:  140001000 N .debug_abbrez
+# SYMBOLS-NEXT: 140002070 R __imp_function
+# SYMBOLS-NEXT: 140001000 t __impl_long_name_symbolA
+# SYMBOLS-NEXT: 140001010 T function
+# SYMBOLS-NEXT: 140001000 t long_name_symbolA
+# SYMBOLS-NEXT: 140001000 t long_name_symbolz
+# SYMBOLS-NEXT: 140001000 T main
+# SYMBOLS-NEXT: 140001000 t name_symbolA
 
 .global main
 .text
@@ -21,6 +36,7 @@ long_name_symbolA:
 __impl_long_name_symbolA:
 name_symbolA:
 .debug_abbrez:
+  call function
   ret
 
 .section.debug_abbrev,"dr"

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


[llvm-branch-commits] [llvm] [llvm][mustache] Precommit test for Set Delimiter (PR #159186)

2025-10-18 Thread Erick Velez via llvm-branch-commits

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


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


[llvm-branch-commits] [Clang] Implement constexpr evaluation for __builtin_infer_alloc_token() (PR #163639)

2025-10-18 Thread Florian Mayer via llvm-branch-commits


@@ -1,12 +1,57 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++23 -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++23 -fsyntax-only -verify 
%s -fexperimental-new-constant-interpreter
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++23 -fsyntax-only -verify 
%s -falloc-token-mode=typehash -DMODE_TYPEHASH
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++23 -fsyntax-only -verify 
%s -falloc-token-max=2 -DTOKEN_MAX=2
 
 #if !__has_builtin(__builtin_infer_alloc_token)
 #error "missing __builtin_infer_alloc_token"
 #endif
 
+#ifndef TOKEN_MAX
+#define TOKEN_MAX 0
+#endif
+
+struct NoPtr {
+  int x;
+  long y;
+};
+
+struct WithPtr {
+  int a;
+  char *buf;
+};
+
+// Check specific known values; these are guaranteed to be stable.
+#ifdef MODE_TYPEHASH
+static_assert(__builtin_infer_alloc_token(sizeof(int)) == 
2689373973731826898ULL);
+static_assert(__builtin_infer_alloc_token(sizeof(char*)) == 
2250492667400517147ULL);
+static_assert(__builtin_infer_alloc_token(sizeof(NoPtr)) == 
7465259095297095368ULL);
+static_assert(__builtin_infer_alloc_token(sizeof(WithPtr)) == 
11898882936532569145ULL);
+#elif TOKEN_MAX == 2
+static_assert(__builtin_infer_alloc_token(sizeof(int)) == 0);
+static_assert(__builtin_infer_alloc_token(sizeof(char*)) == 1);
+static_assert(__builtin_infer_alloc_token(sizeof(NoPtr)) == 0);
+static_assert(__builtin_infer_alloc_token(sizeof(WithPtr)) == 1);

fmayer wrote:

just in case:

```
#elif defined(TOKEN_MAX)
 #error
```

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


[llvm-branch-commits] [Clang] Refactor allocation type inference logic (PR #163636)

2025-10-18 Thread Marco Elver via llvm-branch-commits

https://github.com/melver updated 
https://github.com/llvm/llvm-project/pull/163636


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


[llvm-branch-commits] [NFC][SpecialCaseList] Split Matcher into RegexMatcher and GlobMatcher (PR #162303)

2025-10-18 Thread Vitaly Buka via llvm-branch-commits


@@ -29,55 +29,79 @@
 
 namespace llvm {
 
-Error SpecialCaseList::Matcher::insert(StringRef Pattern, unsigned LineNumber,
-   bool UseGlobs) {
+Error SpecialCaseList::RegexMatcher::insert(StringRef Pattern,
+unsigned LineNumber) {
   if (Pattern.empty())
 return createStringError(errc::invalid_argument,
- Twine("Supplied ") +
- (UseGlobs ? "glob" : "regex") + " was blank");
-
-  if (!UseGlobs) {
-// Replace * with .*
-auto Regexp = Pattern.str();
-for (size_t pos = 0; (pos = Regexp.find('*', pos)) != std::string::npos;
- pos += strlen(".*")) {
-  Regexp.replace(pos, strlen("*"), ".*");
-}
+ "Supplied regex was blank");
+
+  // Replace * with .*
+  auto Regexp = Pattern.str();
+  for (size_t pos = 0; (pos = Regexp.find('*', pos)) != std::string::npos;
+   pos += strlen(".*")) {
+Regexp.replace(pos, strlen("*"), ".*");
+  }
 
-Regexp = (Twine("^(") + StringRef(Regexp) + ")$").str();
+  Regexp = (Twine("^(") + StringRef(Regexp) + ")$").str();
 
-// Check that the regexp is valid.
-Regex CheckRE(Regexp);
-std::string REError;
-if (!CheckRE.isValid(REError))
-  return createStringError(errc::invalid_argument, REError);
+  // Check that the regexp is valid.
+  Regex CheckRE(Regexp);
+  std::string REError;
+  if (!CheckRE.isValid(REError))
+return createStringError(errc::invalid_argument, REError);
 
-auto Rg =
-std::make_unique(Pattern, LineNumber, 
std::move(CheckRE));
-RegExes.emplace_back(std::move(Rg));
+  auto Rg = std::make_unique(Pattern, LineNumber, std::move(CheckRE));
+  RegExes.emplace_back(std::move(Rg));
 
-return Error::success();
-  }
+  return Error::success();
+}
+
+void SpecialCaseList::RegexMatcher::match(
+StringRef Query,
+llvm::function_ref Cb) const {
+  for (const auto &Regex : reverse(RegExes))
+if (Regex->Rg.match(Query))
+  Cb(Regex->Name, Regex->LineNo);
+}
+
+Error SpecialCaseList::GlobMatcher::insert(StringRef Pattern,
+   unsigned LineNumber) {
+  if (Pattern.empty())
+return createStringError(errc::invalid_argument, "Supplied glob was 
blank");
 
-  auto Glob = std::make_unique(Pattern, LineNumber);
+  auto G = std::make_unique(Pattern, LineNumber);
   // We must be sure to use the string in `Glob` rather than the provided
   // reference which could be destroyed before match() is called
-  if (auto Err = GlobPattern::create(Glob->Name, /*MaxSubPatterns=*/1024)
- .moveInto(Glob->Pattern))
+  if (auto Err = GlobPattern::create(G->Name, /*MaxSubPatterns=*/1024)
+ .moveInto(G->Pattern))
 return Err;
-  Globs.push_back(std::move(Glob));
+  Globs.emplace_back(std::move(G));
   return Error::success();
 }
 
-void SpecialCaseList::Matcher::match(
+void SpecialCaseList::GlobMatcher::match(
 StringRef Query,
 llvm::function_ref Cb) const {
   for (const auto &Glob : reverse(Globs))
 if (Glob->Pattern.match(Query))
   Cb(Glob->Name, Glob->LineNo);
-  for (const auto &Regex : reverse(RegExes))
-if (Regex->Rg.match(Query))
-  Cb(Regex->Name, Regex->LineNo);
+}
+
+SpecialCaseList::Matcher::Matcher(bool UseGlobs) {
+  if (UseGlobs)
+M.emplace();
+  else
+M.emplace();
+}
+
+void SpecialCaseList::Matcher::match(
+StringRef Query,
+llvm::function_ref Cb) const {
+  return std::visit([&](auto &V) { return V.match(Query, Cb); }, M);

vitalybuka wrote:

assuming Matcher is a base class,
you technically can have it, but you can't 

`StringMap>`

you will have:
`StringMap>>`



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


[llvm-branch-commits] [llvm] [X86] Cast atomic vectors in IR to support floats (PR #148899)

2025-10-18 Thread via llvm-branch-commits

https://github.com/jofrn updated 
https://github.com/llvm/llvm-project/pull/148899

>From 1f63bc7454da093ca555289e15e439a3e3cb6c7f Mon Sep 17 00:00:00 2001
From: jofrn 
Date: Tue, 15 Jul 2025 13:02:04 -0400
Subject: [PATCH] [X86] Cast atomic vectors in IR to support floats

This commit casts floats to ints in an atomic load during AtomicExpand to 
support
floating point types. It also is required to support 128 bit vectors in SSE/AVX.
---
 llvm/lib/Target/X86/X86ISelLowering.cpp|   7 +
 llvm/lib/Target/X86/X86ISelLowering.h  |   2 +
 llvm/test/CodeGen/X86/atomic-load-store.ll | 181 +++--
 3 files changed, 172 insertions(+), 18 deletions(-)

diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index e38bf46e3c41a..1f62b17eec3e2 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -32177,6 +32177,13 @@ 
X86TargetLowering::shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const {
   }
 }
 
+TargetLowering::AtomicExpansionKind
+X86TargetLowering::shouldCastAtomicLoadInIR(LoadInst *LI) const {
+  if (LI->getType()->getScalarType()->isFloatingPointTy())
+return AtomicExpansionKind::CastToInteger;
+  return AtomicExpansionKind::None;
+}
+
 LoadInst *
 X86TargetLowering::lowerIdempotentRMWIntoFencedLoad(AtomicRMWInst *AI) const {
   unsigned NativeWidth = Subtarget.is64Bit() ? 64 : 32;
diff --git a/llvm/lib/Target/X86/X86ISelLowering.h 
b/llvm/lib/Target/X86/X86ISelLowering.h
index e28b9c11a04cd..9cf727dda0c19 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.h
+++ b/llvm/lib/Target/X86/X86ISelLowering.h
@@ -1842,6 +1842,8 @@ namespace llvm {
 shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override;
 TargetLoweringBase::AtomicExpansionKind
 shouldExpandLogicAtomicRMWInIR(AtomicRMWInst *AI) const;
+TargetLoweringBase::AtomicExpansionKind
+shouldCastAtomicLoadInIR(LoadInst *LI) const override;
 void emitBitTestAtomicRMWIntrinsic(AtomicRMWInst *AI) const override;
 void emitCmpArithAtomicRMWIntrinsic(AtomicRMWInst *AI) const override;
 
diff --git a/llvm/test/CodeGen/X86/atomic-load-store.ll 
b/llvm/test/CodeGen/X86/atomic-load-store.ll
index 4b818b6cfa57e..039edcbf83544 100644
--- a/llvm/test/CodeGen/X86/atomic-load-store.ll
+++ b/llvm/test/CodeGen/X86/atomic-load-store.ll
@@ -207,19 +207,19 @@ define <1 x bfloat> @atomic_vec1_bfloat(ptr %x) {
 ; CHECK-O3-LABEL: atomic_vec1_bfloat:
 ; CHECK-O3:   # %bb.0:
 ; CHECK-O3-NEXT:movzwl (%rdi), %eax
-; CHECK-O3-NEXT:pinsrw $0, %eax, %xmm0
+; CHECK-O3-NEXT:movd %eax, %xmm0
 ; CHECK-O3-NEXT:retq
 ;
 ; CHECK-SSE-O3-LABEL: atomic_vec1_bfloat:
 ; CHECK-SSE-O3:   # %bb.0:
 ; CHECK-SSE-O3-NEXT:movzwl (%rdi), %eax
-; CHECK-SSE-O3-NEXT:pinsrw $0, %eax, %xmm0
+; CHECK-SSE-O3-NEXT:movd %eax, %xmm0
 ; CHECK-SSE-O3-NEXT:retq
 ;
 ; CHECK-AVX-O3-LABEL: atomic_vec1_bfloat:
 ; CHECK-AVX-O3:   # %bb.0:
 ; CHECK-AVX-O3-NEXT:movzwl (%rdi), %eax
-; CHECK-AVX-O3-NEXT:vpinsrw $0, %eax, %xmm0, %xmm0
+; CHECK-AVX-O3-NEXT:vmovd %eax, %xmm0
 ; CHECK-AVX-O3-NEXT:retq
 ;
 ; CHECK-O0-LABEL: atomic_vec1_bfloat:
@@ -227,8 +227,7 @@ define <1 x bfloat> @atomic_vec1_bfloat(ptr %x) {
 ; CHECK-O0-NEXT:movw (%rdi), %cx
 ; CHECK-O0-NEXT:# implicit-def: $eax
 ; CHECK-O0-NEXT:movw %cx, %ax
-; CHECK-O0-NEXT:# implicit-def: $xmm0
-; CHECK-O0-NEXT:pinsrw $0, %eax, %xmm0
+; CHECK-O0-NEXT:movd %eax, %xmm0
 ; CHECK-O0-NEXT:retq
 ;
 ; CHECK-SSE-O0-LABEL: atomic_vec1_bfloat:
@@ -236,8 +235,7 @@ define <1 x bfloat> @atomic_vec1_bfloat(ptr %x) {
 ; CHECK-SSE-O0-NEXT:movw (%rdi), %cx
 ; CHECK-SSE-O0-NEXT:# implicit-def: $eax
 ; CHECK-SSE-O0-NEXT:movw %cx, %ax
-; CHECK-SSE-O0-NEXT:# implicit-def: $xmm0
-; CHECK-SSE-O0-NEXT:pinsrw $0, %eax, %xmm0
+; CHECK-SSE-O0-NEXT:movd %eax, %xmm0
 ; CHECK-SSE-O0-NEXT:retq
 ;
 ; CHECK-AVX-O0-LABEL: atomic_vec1_bfloat:
@@ -245,8 +243,7 @@ define <1 x bfloat> @atomic_vec1_bfloat(ptr %x) {
 ; CHECK-AVX-O0-NEXT:movw (%rdi), %cx
 ; CHECK-AVX-O0-NEXT:# implicit-def: $eax
 ; CHECK-AVX-O0-NEXT:movw %cx, %ax
-; CHECK-AVX-O0-NEXT:# implicit-def: $xmm0
-; CHECK-AVX-O0-NEXT:vpinsrw $0, %eax, %xmm0, %xmm0
+; CHECK-AVX-O0-NEXT:vmovd %eax, %xmm0
 ; CHECK-AVX-O0-NEXT:retq
   %ret = load atomic <1 x bfloat>, ptr %x acquire, align 2
   ret <1 x bfloat> %ret
@@ -377,6 +374,74 @@ define <2 x float> @atomic_vec2_float_align(ptr %x) {
   ret <2 x float> %ret
 }
 
+define <2 x half> @atomic_vec2_half(ptr %x) {
+; CHECK-O3-LABEL: atomic_vec2_half:
+; CHECK-O3:   # %bb.0:
+; CHECK-O3-NEXT:movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; CHECK-O3-NEXT:retq
+;
+; CHECK-SSE-O3-LABEL: atomic_vec2_half:
+; CHECK-SSE-O3:   # %bb.0:
+; CHECK-SSE-O3-NEXT:movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; CHECK-SSE-O3-NEXT:retq
+;
+; CHECK-AVX-O3-LABEL: atomic_vec2_half:
+; CHECK-AVX-O3:   # %bb.0:
+; CHECK-AVX-O3-N

[llvm-branch-commits] [llvm] [StaticDataLayout] Reconcile data hotness based on PGO counters and data access profiles (PR #163325)

2025-10-18 Thread Mingming Liu via llvm-branch-commits

https://github.com/mingmingl-llvm updated 
https://github.com/llvm/llvm-project/pull/163325

>From ed7439604e857aaf2a7732b7b04f1ceb575036de Mon Sep 17 00:00:00 2001
From: mingmingl 
Date: Mon, 13 Oct 2025 21:22:20 -0700
Subject: [PATCH 1/2] reconcile hotness

---
 .../llvm/Analysis/StaticDataProfileInfo.h | 21 ++--
 llvm/lib/Analysis/StaticDataProfileInfo.cpp   | 59 ++-
 .../X86/global-variable-partition-with-dap.ll | 99 +--
 3 files changed, 163 insertions(+), 16 deletions(-)

diff --git a/llvm/include/llvm/Analysis/StaticDataProfileInfo.h 
b/llvm/include/llvm/Analysis/StaticDataProfileInfo.h
index 70199a904f320..4a97e3370e451 100644
--- a/llvm/include/llvm/Analysis/StaticDataProfileInfo.h
+++ b/llvm/include/llvm/Analysis/StaticDataProfileInfo.h
@@ -58,11 +58,18 @@ class StaticDataProfileInfo {
   LLVM_ABI StaticDataHotness getSectionHotnessUsingProfileCount(
   const Constant *C, const ProfileSummaryInfo *PSI, uint64_t Count) const;
 
+  /// Return the hotness based on section prefix \p SectionPrefix.
+  LLVM_ABI StaticDataHotness
+  getSectionHotnessUsingDAP(std::optional SectionPrefix) const;
+
   /// Return the string representation of the hotness enum \p Hotness.
   LLVM_ABI StringRef hotnessToStr(StaticDataHotness Hotness) const;
 
+  bool EnableDataAccessProf = false;
+
 public:
-  StaticDataProfileInfo() = default;
+  StaticDataProfileInfo(bool EnableDataAccessProf)
+  : EnableDataAccessProf(EnableDataAccessProf) {}
 
   /// If \p Count is not nullopt, add it to the profile count of the constant 
\p
   /// C in a saturating way, and clamp the count to \p getInstrMaxCountValue if
@@ -71,14 +78,10 @@ class StaticDataProfileInfo {
   LLVM_ABI void addConstantProfileCount(const Constant *C,
 std::optional Count);
 
-  /// Return a section prefix for the constant \p C based on its profile count.
-  /// - If a constant doesn't have a counter, return an empty string.
-  /// - Otherwise,
-  ///   - If it has a hot count, return "hot".
-  ///   - If it is seen by unprofiled function, return an empty string.
-  ///   - If it has a cold count, return "unlikely".
-  ///   - Otherwise (e.g. it's used by lukewarm functions), return an empty
-  /// string.
+  /// Given a constant \p C, returns a section prefix.
+  /// If \p C is a global variable, the section prefix is the bigger one
+  /// between its existing section prefix and its use profile count. Otherwise,
+  /// the section prefix is based on its use profile count.
   LLVM_ABI StringRef getConstantSectionPrefix(
   const Constant *C, const ProfileSummaryInfo *PSI) const;
 };
diff --git a/llvm/lib/Analysis/StaticDataProfileInfo.cpp 
b/llvm/lib/Analysis/StaticDataProfileInfo.cpp
index 27f8d216454aa..61e1e6779a2b0 100644
--- a/llvm/lib/Analysis/StaticDataProfileInfo.cpp
+++ b/llvm/lib/Analysis/StaticDataProfileInfo.cpp
@@ -1,10 +1,14 @@
 #include "llvm/Analysis/StaticDataProfileInfo.h"
 #include "llvm/Analysis/ProfileSummaryInfo.h"
 #include "llvm/IR/Constant.h"
+#include "llvm/IR/Constants.h"
 #include "llvm/IR/GlobalVariable.h"
+#include "llvm/IR/Module.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/ProfileData/InstrProf.h"
 
+#define DEBUG_TYPE "static-data-profile-info"
+
 using namespace llvm;
 
 namespace llvm {
@@ -46,6 +50,12 @@ bool IsAnnotationOK(const GlobalVariable &GV) {
 } // namespace memprof
 } // namespace llvm
 
+#ifndef NDEBUG
+static StringRef debugPrintSectionPrefix(StringRef Prefix) {
+  return Prefix.empty() ? "" : Prefix;
+}
+#endif
+
 void StaticDataProfileInfo::addConstantProfileCount(
 const Constant *C, std::optional Count) {
   if (!Count) {
@@ -79,6 +89,18 @@ StaticDataProfileInfo::getSectionHotnessUsingProfileCount(
   return StaticDataHotness::LukewarmOrUnknown;
 }
 
+StaticDataProfileInfo::StaticDataHotness
+StaticDataProfileInfo::getSectionHotnessUsingDAP(
+std::optional MaybeSectionPrefix) const {
+  if (!MaybeSectionPrefix)
+return StaticDataProfileInfo::StaticDataHotness::LukewarmOrUnknown;
+  StringRef Prefix = *MaybeSectionPrefix;
+  assert((Prefix == "hot" || Prefix == "unlikely") &&
+ "Expect section_prefix to be one of hot or unlikely");
+  return Prefix == "hot" ? StaticDataProfileInfo::StaticDataHotness::Hot
+ : StaticDataProfileInfo::StaticDataHotness::Cold;
+}
+
 StringRef StaticDataProfileInfo::hotnessToStr(
 StaticDataProfileInfo::StaticDataHotness Hotness) const {
   switch (Hotness) {
@@ -102,13 +124,48 @@ StaticDataProfileInfo::getConstantProfileCount(const 
Constant *C) const {
 StringRef StaticDataProfileInfo::getConstantSectionPrefix(
 const Constant *C, const ProfileSummaryInfo *PSI) const {
   std::optional Count = getConstantProfileCount(C);
+
+  if (EnableDataAccessProf) {
+// Module flag `HasDataAccessProf` is 1 -> empty section prefix means
+// unknown hotness except for string literals.
+if (const GlobalVariable *GV = dyn_cast(C);
+GV 

[llvm-branch-commits] [Clang][CodeGen] Introduce the AllocToken SanitizerKind (PR #162098)

2025-10-18 Thread via llvm-branch-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-codegen

@llvm/pr-subscribers-clang

Author: Marco Elver (melver)


Changes

Introduce the "alloc-token" sanitizer kind, in preparation of wiring it
up. Currently this is a no-op, and any attempt to enable it will result
in failure:

  clang: error: unsupported option '-fsanitize=alloc-token' for target 
'x86_64-unknown-linux-gnu'

In this step we can already wire up the `sanitize_alloc_token` IR
attribute where the instrumentation is enabled. Subsequent changes will
complete wiring up the AllocToken pass.

---

This change is part of the following series:
  1. https://github.com/llvm/llvm-project/pull/160131
  2. https://github.com/llvm/llvm-project/pull/156838
  3. https://github.com/llvm/llvm-project/pull/162098
  4. https://github.com/llvm/llvm-project/pull/162099
  5. https://github.com/llvm/llvm-project/pull/156839
  6. https://github.com/llvm/llvm-project/pull/156840
  7. https://github.com/llvm/llvm-project/pull/156841
  8. https://github.com/llvm/llvm-project/pull/156842

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


2 Files Affected:

- (modified) clang/include/clang/Basic/Sanitizers.def (+3) 
- (modified) clang/lib/CodeGen/CodeGenFunction.cpp (+2) 


``diff
diff --git a/clang/include/clang/Basic/Sanitizers.def 
b/clang/include/clang/Basic/Sanitizers.def
index 1d0e97cc7fb4c..da85431625026 100644
--- a/clang/include/clang/Basic/Sanitizers.def
+++ b/clang/include/clang/Basic/Sanitizers.def
@@ -195,6 +195,9 @@ SANITIZER_GROUP("bounds", Bounds, ArrayBounds | LocalBounds)
 // Scudo hardened allocator
 SANITIZER("scudo", Scudo)
 
+// AllocToken
+SANITIZER("alloc-token", AllocToken)
+
 // Magic group, containing all sanitizers. For example, "-fno-sanitize=all"
 // can be used to disable all the sanitizers.
 SANITIZER_GROUP("all", All, ~SanitizerMask())
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index b2fe9171372d8..acf8de4dee147 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -846,6 +846,8 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType 
RetTy,
   Fn->addFnAttr(llvm::Attribute::SanitizeNumericalStability);
 if (SanOpts.hasOneOf(SanitizerKind::Memory | SanitizerKind::KernelMemory))
   Fn->addFnAttr(llvm::Attribute::SanitizeMemory);
+if (SanOpts.has(SanitizerKind::AllocToken))
+  Fn->addFnAttr(llvm::Attribute::SanitizeAllocToken);
   }
   if (SanOpts.has(SanitizerKind::SafeStack))
 Fn->addFnAttr(llvm::Attribute::SafeStack);

``




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


[llvm-branch-commits] [clang] [LifetimeSafety] Introduce a liveness-based lifetime policy (PR #159991)

2025-10-18 Thread via llvm-branch-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r origin/main...HEAD 
clang/test/Analysis/LifetimeSafety/benchmark.py
``

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





View the diff from darker here.


``diff
--- benchmark.py2025-09-24 12:58:02.00 +
+++ benchmark.py2025-09-24 13:00:23.071600 +
@@ -195,11 +195,10 @@
 # Use volatile to prevent optimization from removing the pointers
 # We create a volatile pointer to each pointer.
 for i in range(1, n + 1):
 cpp_code += f"  MyObj* volatile* vp{i} = &p{i};\n"
 cpp_code += "\n"
-
 
 cpp_code += f"  switch (condition % {n}) {{\n"
 for case_num in range(n):
 cpp_code += f"case {case_num}:\n"
 # This is a read-use of p{case_num + 1}

``




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


[llvm-branch-commits] [AllocToken, Clang] Infer type hints from sizeof expressions and casts (PR #156841)

2025-10-18 Thread Marco Elver via llvm-branch-commits

https://github.com/melver updated 
https://github.com/llvm/llvm-project/pull/156841


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


[llvm-branch-commits] [flang] [Flang][OpenMP] Add pass to replace allocas with device shared memory (PR #161863)

2025-10-18 Thread Michael Kruse via llvm-branch-commits


@@ -0,0 +1,215 @@
+// RUN: fir-opt --split-input-file --omp-stack-to-shared %s | FileCheck %s
+
+module attributes {omp.is_target_device = true} {
+  omp.declare_reduction @add_reduction_i32 : i32 init {
+  ^bb0(%arg0: i32):
+%c0_i32 = arith.constant 0 : i32
+omp.yield(%c0_i32 : i32)
+  } combiner {
+  ^bb0(%arg0: i32, %arg1: i32):
+%0 = arith.addi %arg0, %arg1 : i32
+omp.yield(%0 : i32)
+  }
+
+  omp.private {type = private} @privatizer_i32 : i32
+  omp.private {type = firstprivate} @firstprivatizer_i32 : i32 copy {
+  ^bb0(%arg0: i32, %arg1: i32):
+omp.yield(%arg0 : i32)
+  }
+
+  // Verify that target device functions are searched for allocas shared across
+  // threads of a parallel region.
+  //
+  // Also ensure that all fir.alloca information is adequately forwarded to the
+  // new allocation, that uses of the allocation through hlfir.declare are
+  // detected and that only the expected types of uses (parallel reduction and
+  // non-private uses inside of a parallel region) are replaced.
+  // CHECK-LABEL: func.func @standalone_func
+  func.func @standalone_func(%lb: i32, %ub: i32, %step: i32) attributes 
{omp.declare_target = #omp.declaretarget} {
+// CHECK: %[[ALLOC_0:.*]] = omp.alloc_shared_mem i32 {uniq_name = "x"} : 
!fir.ref
+%0 = fir.alloca i32 {uniq_name = "x"}
+%c = arith.constant 1 : index
+// CHECK: %[[ALLOC_1:.*]] = omp.alloc_shared_mem !fir.char<1,?>(%[[C:.*]] 
: index), %[[C]] {bindc_name = "y", uniq_name = "y"} : !fir.ref>
+%1 = fir.alloca !fir.char<1,?>(%c : index), %c {bindc_name = "y", 
uniq_name = "y"}
+// CHECK: %{{.*}}:2 = hlfir.declare %[[ALLOC_1]] typeparams %[[C]] 
{uniq_name = "y"} : (!fir.ref>, index) -> (!fir.boxchar<1>, 
!fir.ref>)
+%decl:2 = hlfir.declare %1 typeparams %c {uniq_name = "y"} : 
(!fir.ref>, index) -> (!fir.boxchar<1>, !fir.ref>)
+// CHECK: %{{.*}} = fir.alloca i32 {uniq_name = "z"}
+%2 = fir.alloca i32 {uniq_name = "z"}
+// CHECK: %[[ALLOC_2:.*]] = omp.alloc_shared_mem i32 {uniq_name = "a"} : 
!fir.ref
+%3 = fir.alloca i32 {uniq_name = "a"}
+// CHECK: %{{.*}} = fir.alloca i32 {uniq_name = "b"}
+%4 = fir.alloca i32 {uniq_name = "b"}
+omp.parallel reduction(@add_reduction_i32 %0 -> %arg0 : !fir.ref) {
+  // CHECK: %{{.*}} = fir.alloca i32 {uniq_name = "c"}
+  %5 = fir.alloca i32 {uniq_name = "c"}
+  %6:2 = fir.unboxchar %decl#0 : (!fir.boxchar<1>) -> 
(!fir.ref>, index)
+  omp.wsloop private(@privatizer_i32 %2 -> %arg1, @firstprivatizer_i32 %3 
-> %arg2 : !fir.ref, !fir.ref) {
+omp.loop_nest (%arg3) : i32 = (%lb) to (%ub) inclusive step (%step) {
+  %7 = fir.load %5 : !fir.ref
+  omp.yield
+}
+  }
+  omp.terminator
+}
+%5 = fir.load %4 : !fir.ref
+// CHECK: omp.free_shared_mem %[[ALLOC_0]] : !fir.ref
+// CHECK-NEXT: omp.free_shared_mem %[[ALLOC_1]] : !fir.ref>
+// CHECK-NEXT: omp.free_shared_mem %[[ALLOC_2]] : !fir.ref
+// CHECK-NEXT: return
+return
+  }
+
+  // Verify that generic target regions are searched for allocas shared across
+  // threads of a parallel region.
+  // CHECK-LABEL: func.func @target_generic
+  func.func @target_generic() {
+// CHECK: omp.target
+omp.target {
+  %c = arith.constant 0 : i32
+  // CHECK: %[[ALLOC_0:.*]] = omp.alloc_shared_mem i32 {uniq_name = "x"} : 
!fir.ref
+  %0 = fir.alloca i32 {uniq_name = "x"}

Meinersbur wrote:

`omp.alloc_shared_mem` calls `__kmpc_alloc_shared`, i.e. teams-private memory. 
But should't `fir.alloca` here be accessible from all teams, i.e. global in the 
sense of `llvm_omp_target_alloc_device`/`TARGET_ALLOC_DEVICE`?

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


[llvm-branch-commits] [llvm] AMDGPU: Stop using the wavemask register class for SCC cross class copies (PR #161801)

2025-10-18 Thread Matt Arsenault via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [BOLT] Extend Inliner to work on functions with Pointer Autentication (PR #162458)

2025-10-18 Thread Gergely Bálint via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [StaticDataLayout] Factor out a helper function for section prefix eligibility and use it in both optimizer and codegen (PR #162348)

2025-10-18 Thread Teresa Johnson via llvm-branch-commits


@@ -817,13 +825,12 @@ bool MemProfUsePass::annotateGlobalVariables(
   for (GlobalVariable &GVar : M.globals()) {
 assert(!GVar.getSectionPrefix().has_value() &&
"GVar shouldn't have section prefix yet");
-if (GVar.isDeclarationForLinker())
-  continue;
-
-if (hasExplicitSectionName(GVar)) {
-  ++NumOfMemProfExplicitSectionGlobalVars;
-  LLVM_DEBUG(dbgs() << "Global variable " << GVar.getName()
-<< " has explicit section name. Skip annotating.\n");
+auto Kind = llvm::memprof::getAnnotationKind(GVar);
+switch (Kind) {

teresajohnson wrote:

Since the switch now only handles 2 cases, this would be clearer written as an 
if condition like:

```
if (Kind != llvm::memprof::AnnotationKind::AnnotationOK) {
   HandleUnsupportedAnnotationKinds(GVar, Kind);
   continue;
}
```

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


[llvm-branch-commits] [llvm] release/21.x: [sancov] Fix stack-depth tracking to use debug locations (#162428) (PR #162697)

2025-10-18 Thread via llvm-branch-commits

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

Backport 28b7f669e5c6427402f36c5a08def4b34089c7cd

Requested by: @nathanchance

>From 4dd357599e862bcd945ccd649131f059a0d908c8 Mon Sep 17 00:00:00 2001
From: Kees Cook 
Date: Thu, 9 Oct 2025 00:49:57 -0700
Subject: [PATCH] [sancov] Fix stack-depth tracking to use debug locations
 (#162428)

As fixed in commits llvm/llvm-project@913f7e9,
llvm/llvm-project@4a8b124, and llvm/llvm-project@4eef2e3, also fix the
stack-depth tracking code to use InstrumentationIRBuilder, and set the
Call's Debug location to EntryLoc.

https://github.com/ClangBuiltLinux/linux/issues/2125

cc @nathanchance @melver @JustinStitt @bwendling

(cherry picked from commit 28b7f669e5c6427402f36c5a08def4b34089c7cd)
---
 .../Instrumentation/SanitizerCoverage.cpp | 13 ++-
 .../SanitizerCoverage/missing_dbg.ll  | 92 +++
 2 files changed, 102 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp 
b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
index 5b8ea1547ca2f..b74a0708b67ae 100644
--- a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -1084,8 +1084,10 @@ void 
ModuleSanitizerCoverage::InjectCoverageAtBlock(Function &F, BasicBlock &BB,
 auto ThenTerm = SplitBlockAndInsertIfThen(
 IRB.CreateIsNull(Load), &*IP, false,
 MDBuilder(IRB.getContext()).createUnlikelyBranchWeights());
-IRBuilder<> ThenIRB(ThenTerm);
+InstrumentationIRBuilder ThenIRB(ThenTerm);
 auto Store = ThenIRB.CreateStore(ConstantInt::getTrue(Int1Ty), FlagPtr);
+if (EntryLoc)
+  Store->setDebugLoc(EntryLoc);
 Load->setNoSanitizeMetadata();
 Store->setNoSanitizeMetadata();
   }
@@ -1131,7 +1133,10 @@ void 
ModuleSanitizerCoverage::InjectCoverageAtBlock(Function &F, BasicBlock &BB,
   EstimatedStackSize >= Options.StackDepthCallbackMin) {
 if (InsertBefore)
   IRB.SetInsertPoint(InsertBefore);
-IRB.CreateCall(SanCovStackDepthCallback)->setCannotMerge();
+auto Call = IRB.CreateCall(SanCovStackDepthCallback);
+if (EntryLoc)
+  Call->setDebugLoc(EntryLoc);
+Call->setCannotMerge();
   }
 } else {
   // Check stack depth.  If it's the deepest so far, record it.
@@ -1144,8 +1149,10 @@ void 
ModuleSanitizerCoverage::InjectCoverageAtBlock(Function &F, BasicBlock &BB,
   auto ThenTerm = SplitBlockAndInsertIfThen(
   IsStackLower, &*IP, false,
   MDBuilder(IRB.getContext()).createUnlikelyBranchWeights());
-  IRBuilder<> ThenIRB(ThenTerm);
+  InstrumentationIRBuilder ThenIRB(ThenTerm);
   auto Store = ThenIRB.CreateStore(FrameAddrInt, SanCovLowestStack);
+  if (EntryLoc)
+Store->setDebugLoc(EntryLoc);
   LowestStack->setNoSanitizeMetadata();
   Store->setNoSanitizeMetadata();
 }
diff --git a/llvm/test/Instrumentation/SanitizerCoverage/missing_dbg.ll 
b/llvm/test/Instrumentation/SanitizerCoverage/missing_dbg.ll
index 35684346c4d5a..07b9a1ce496d9 100644
--- a/llvm/test/Instrumentation/SanitizerCoverage/missing_dbg.ll
+++ b/llvm/test/Instrumentation/SanitizerCoverage/missing_dbg.ll
@@ -1,5 +1,7 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 5
 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=2 -S 
| FileCheck %s
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 
-sanitizer-coverage-stack-depth -sanitizer-coverage-stack-depth-callback-min=1 
-S | FileCheck %s --check-prefix=CHECK-STACK-CALLBACK
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 
-sanitizer-coverage-stack-depth -S | FileCheck %s 
--check-prefix=CHECK-STACK-DEPTH
 
 target datalayout = 
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 
@@ -55,6 +57,86 @@ entry:
   ret i32 %t
 }
 
+define i32 @with_dbg_stack_callback(ptr %a) !dbg !8 {
+; CHECK-STACK-CALLBACK-LABEL: define i32 @with_dbg_stack_callback(
+; CHECK-STACK-CALLBACK-SAME: ptr [[A:%.*]]) !dbg [[DBG8:![0-9]+]] {
+; CHECK-STACK-CALLBACK-NEXT:  entry:
+; CHECK-STACK-CALLBACK-NEXT:[[BUF:%.*]] = alloca [64 x i8], align 1
+; CHECK-STACK-CALLBACK-NEXT:call void @__sanitizer_cov_stack_depth() 
#[[ATTR1:[0-9]+]], !dbg [[DBG9:![0-9]+]]
+; CHECK-STACK-CALLBACK-NEXT:%t = load i32, ptr [[A]], align 4
+; CHECK-STACK-CALLBACK-NEXT:call void @external_func()
+; CHECK-STACK-CALLBACK-NEXT:ret i32 %t
+;
+entry:
+  %buf = alloca [64 x i8], align 1
+  %t = load i32, ptr %a, align 4
+  call void @external_func()
+  ret i32 %t
+}
+
+define i32 @with_dbg_stack_depth(ptr %a) !dbg !10 {
+; CHECK-STACK-DEPTH-LABEL: define i32 @with_dbg_stack_depth(
+; CHECK-STACK-DEPTH-SAME: ptr [[A:%.*]]) !dbg [[DBG10:![0-9]+]] {
+; CHECK-STACK-DEP

[llvm-branch-commits] [clang] [LifetimeSafety] Introduce a liveness-based lifetime policy (PR #159991)

2025-10-18 Thread Utkarsh Saxena via llvm-branch-commits

https://github.com/usx95 updated 
https://github.com/llvm/llvm-project/pull/159991

>From 73f7069f9100441ccb3027b0890284b5d7fcf80e Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Sun, 21 Sep 2025 16:30:28 +
Subject: [PATCH] liveness-based-lifetime-policy

---
 .../clang/Analysis/Analyses/LifetimeSafety.h  |   9 +-
 clang/lib/Analysis/LifetimeSafety.cpp | 392 +++---
 clang/test/Sema/warn-lifetime-safety.cpp  | 141 +++--
 .../unittests/Analysis/LifetimeSafetyTest.cpp | 501 +-
 4 files changed, 583 insertions(+), 460 deletions(-)

diff --git a/clang/include/clang/Analysis/Analyses/LifetimeSafety.h 
b/clang/include/clang/Analysis/Analyses/LifetimeSafety.h
index 512cb76cd6349..2cc3fb3d69eb4 100644
--- a/clang/include/clang/Analysis/Analyses/LifetimeSafety.h
+++ b/clang/include/clang/Analysis/Analyses/LifetimeSafety.h
@@ -55,6 +55,7 @@ class Fact;
 class FactManager;
 class LoanPropagationAnalysis;
 class ExpiredLoansAnalysis;
+class LiveOriginAnalysis;
 struct LifetimeFactory;
 
 /// A generic, type-safe wrapper for an ID, distinguished by its `Tag` type.
@@ -89,6 +90,7 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, 
OriginID ID) {
 // TODO(opt): Consider using a bitset to represent the set of loans.
 using LoanSet = llvm::ImmutableSet;
 using OriginSet = llvm::ImmutableSet;
+using OriginLoanMap = llvm::ImmutableMap;
 
 /// A `ProgramPoint` identifies a location in the CFG by pointing to a specific
 /// `Fact`. identified by a lifetime-related event (`Fact`).
@@ -110,8 +112,9 @@ class LifetimeSafetyAnalysis {
   /// Returns the set of loans an origin holds at a specific program point.
   LoanSet getLoansAtPoint(OriginID OID, ProgramPoint PP) const;
 
-  /// Returns the set of loans that have expired at a specific program point.
-  std::vector getExpiredLoansAtPoint(ProgramPoint PP) const;
+  /// TODO:Document.
+  std::vector>
+  getLiveOriginsAtPoint(ProgramPoint PP) const;
 
   /// Finds the OriginID for a given declaration.
   /// Returns a null optional if not found.
@@ -138,7 +141,7 @@ class LifetimeSafetyAnalysis {
   std::unique_ptr Factory;
   std::unique_ptr FactMgr;
   std::unique_ptr LoanPropagation;
-  std::unique_ptr ExpiredLoans;
+  std::unique_ptr LiveOrigins;
 };
 } // namespace internal
 } // namespace clang::lifetimes
diff --git a/clang/lib/Analysis/LifetimeSafety.cpp 
b/clang/lib/Analysis/LifetimeSafety.cpp
index 14fb945382e65..01076a3cee7f2 100644
--- a/clang/lib/Analysis/LifetimeSafety.cpp
+++ b/clang/lib/Analysis/LifetimeSafety.cpp
@@ -22,6 +22,7 @@
 #include "llvm/ADT/SmallBitVector.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/TimeProfiler.h"
 #include 
 #include 
@@ -873,19 +874,26 @@ class DataflowAnalysis {
 llvm::SmallBitVector Visited(Cfg.getNumBlockIDs() + 1);
 
 while (const CFGBlock *B = W.dequeue()) {
-  Lattice StateIn = getInState(B);
+  Lattice StateIn = *getInState(B);
   Lattice StateOut = transferBlock(B, StateIn);
   OutStates[B] = StateOut;
-  Visited.set(B->getBlockID());
   for (const CFGBlock *AdjacentB : isForward() ? B->succs() : B->preds()) {
 if (!AdjacentB)
   continue;
-Lattice OldInState = getInState(AdjacentB);
-Lattice NewInState = D.join(OldInState, StateOut);
+Lattice OldInState;
+bool SawFirstTime = false;
+Lattice NewInState;
+if (const Lattice *In = getInState(AdjacentB)) {
+  OldInState = *In;
+  NewInState = D.join(OldInState, StateOut);
+} else {
+  OldInState = D.getInitialState();
+  SawFirstTime = true;
+  NewInState = StateOut;
+}
 // Enqueue the adjacent block if its in-state has changed or if we have
 // never visited it.
-if (!Visited.test(AdjacentB->getBlockID()) ||
-NewInState != OldInState) {
+if (SawFirstTime || NewInState != OldInState) {
   InStates[AdjacentB] = NewInState;
   W.enqueueBlock(AdjacentB);
 }
@@ -896,7 +904,12 @@ class DataflowAnalysis {
 protected:
   Lattice getState(ProgramPoint P) const { return PerPointStates.lookup(P); }
 
-  Lattice getInState(const CFGBlock *B) const { return InStates.lookup(B); }
+  const Lattice *getInState(const CFGBlock *B) const {
+auto It = InStates.find(B);
+if (It != InStates.end())
+  return &It->second;
+return nullptr;
+  }
 
   Lattice getOutState(const CFGBlock *B) const { return OutStates.lookup(B); }
 
@@ -992,22 +1005,26 @@ static bool isSubsetOf(const llvm::ImmutableSet &A,
 // instead of the current AVL-tree-based ImmutableMap.
 template 
 static llvm::ImmutableMap
-join(llvm::ImmutableMap A, llvm::ImmutableMap B,
+join(const llvm::ImmutableMap &A, const llvm::ImmutableMap &B,
  typename llvm::ImmutableMap::Factory &F, Joiner JoinValues) {
   if (A.getHeight() < B.getHeight())
-std::swap(A, B);

[llvm-branch-commits] [lld] release/21.x: [LLD] [COFF] Fix aarch64 delayimport of sret arguments (#163096) (PR #163333)

2025-10-18 Thread via llvm-branch-commits
Martin =?utf-8?q?Storsjö?= 
Message-ID:
In-Reply-To: 


github-actions[bot] wrote:

@mstorsjo (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

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


[llvm-branch-commits] [llvm] [LoongArch] Make fminnum/fmaxnum legal for lsx/lasx (PR #162768)

2025-10-18 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-loongarch

Author: Zhaoxin Yang (ylzsx)


Changes



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


5 Files Affected:

- (modified) llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp (+4) 
- (modified) llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td (+4) 
- (modified) llvm/lib/Target/LoongArch/LoongArchLSXInstrInfo.td (+4) 
- (modified) llvm/test/CodeGen/LoongArch/lasx/fp-max-min.ll (+14-102) 
- (modified) llvm/test/CodeGen/LoongArch/lsx/fp-max-min.ll (+14-54) 


``diff
diff --git a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp 
b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
index 7ddf996f53f4c..7b1d4f30faabf 100644
--- a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
@@ -366,6 +366,8 @@ LoongArchTargetLowering::LoongArchTargetLowering(const 
TargetMachine &TM,
  ISD::SETUGE, ISD::SETUGT},
 VT, Expand);
   setOperationAction(ISD::SCALAR_TO_VECTOR, VT, Legal);
+  setOperationAction(ISD::FMINNUM, VT, Legal);
+  setOperationAction(ISD::FMAXNUM, VT, Legal);
 }
 setOperationAction(ISD::CTPOP, GRLenVT, Legal);
 setOperationAction(ISD::FCEIL, {MVT::f32, MVT::f64}, Legal);
@@ -447,6 +449,8 @@ LoongArchTargetLowering::LoongArchTargetLowering(const 
TargetMachine &TM,
  ISD::SETUGE, ISD::SETUGT},
 VT, Expand);
   setOperationAction(ISD::SCALAR_TO_VECTOR, VT, Legal);
+  setOperationAction(ISD::FMINNUM, VT, Legal);
+  setOperationAction(ISD::FMAXNUM, VT, Legal);
 }
   }
 
diff --git a/llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td 
b/llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
index 5143d53bad719..cf8a7c1b517f8 100644
--- a/llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
+++ b/llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
@@ -1558,6 +1558,10 @@ defm : PatXrXrF;
 // XVFDIV_{S/D}
 defm : PatXrXrF;
 
+// XVFMAX_{S/D}, XVFMIN_{S/D}
+defm : PatXrXrF;
+defm : PatXrXrF;
+
 // XVFMADD_{S/D}
 def : Pat<(fma v8f32:$xj, v8f32:$xk, v8f32:$xa),
   (XVFMADD_S v8f32:$xj, v8f32:$xk, v8f32:$xa)>;
diff --git a/llvm/lib/Target/LoongArch/LoongArchLSXInstrInfo.td 
b/llvm/lib/Target/LoongArch/LoongArchLSXInstrInfo.td
index 8d1dc99e316c9..167bae93c0618 100644
--- a/llvm/lib/Target/LoongArch/LoongArchLSXInstrInfo.td
+++ b/llvm/lib/Target/LoongArch/LoongArchLSXInstrInfo.td
@@ -1748,6 +1748,10 @@ defm : PatVrVrF;
 // VFDIV_{S/D}
 defm : PatVrVrF;
 
+// VFMAX_{S/D}, VFMIN_{S/D}
+defm : PatVrVrF;
+defm : PatVrVrF;
+
 // VFMADD_{S/D}
 def : Pat<(fma v4f32:$vj, v4f32:$vk, v4f32:$va),
   (VFMADD_S v4f32:$vj, v4f32:$vk, v4f32:$va)>;
diff --git a/llvm/test/CodeGen/LoongArch/lasx/fp-max-min.ll 
b/llvm/test/CodeGen/LoongArch/lasx/fp-max-min.ll
index 48ec98c3a74bb..8e08e1ee9e094 100644
--- a/llvm/test/CodeGen/LoongArch/lasx/fp-max-min.ll
+++ b/llvm/test/CodeGen/LoongArch/lasx/fp-max-min.ll
@@ -5,40 +5,10 @@
 define void @minnum_v8f32(ptr %res, ptr %x, ptr %y) nounwind {
 ; CHECK-LABEL: minnum_v8f32:
 ; CHECK:   # %bb.0: # %entry
-; CHECK-NEXT:xvld $xr0, $a2, 0
-; CHECK-NEXT:xvld $xr1, $a1, 0
-; CHECK-NEXT:xvpickve.w $xr2, $xr0, 5
-; CHECK-NEXT:xvpickve.w $xr3, $xr1, 5
-; CHECK-NEXT:fmin.s $fa2, $fa3, $fa2
-; CHECK-NEXT:xvpickve.w $xr3, $xr0, 4
-; CHECK-NEXT:xvpickve.w $xr4, $xr1, 4
-; CHECK-NEXT:fmin.s $fa3, $fa4, $fa3
-; CHECK-NEXT:vextrins.w $vr3, $vr2, 16
-; CHECK-NEXT:xvpickve.w $xr2, $xr0, 6
-; CHECK-NEXT:xvpickve.w $xr4, $xr1, 6
-; CHECK-NEXT:fmin.s $fa2, $fa4, $fa2
-; CHECK-NEXT:vextrins.w $vr3, $vr2, 32
-; CHECK-NEXT:xvpickve.w $xr2, $xr0, 7
-; CHECK-NEXT:xvpickve.w $xr4, $xr1, 7
-; CHECK-NEXT:fmin.s $fa2, $fa4, $fa2
-; CHECK-NEXT:vextrins.w $vr3, $vr2, 48
-; CHECK-NEXT:xvpickve.w $xr2, $xr0, 1
-; CHECK-NEXT:xvpickve.w $xr4, $xr1, 1
-; CHECK-NEXT:fmin.s $fa2, $fa4, $fa2
-; CHECK-NEXT:xvpickve.w $xr4, $xr0, 0
-; CHECK-NEXT:xvpickve.w $xr5, $xr1, 0
-; CHECK-NEXT:fmin.s $fa4, $fa5, $fa4
-; CHECK-NEXT:vextrins.w $vr4, $vr2, 16
-; CHECK-NEXT:xvpickve.w $xr2, $xr0, 2
-; CHECK-NEXT:xvpickve.w $xr5, $xr1, 2
-; CHECK-NEXT:fmin.s $fa2, $fa5, $fa2
-; CHECK-NEXT:vextrins.w $vr4, $vr2, 32
-; CHECK-NEXT:xvpickve.w $xr0, $xr0, 3
-; CHECK-NEXT:xvpickve.w $xr1, $xr1, 3
-; CHECK-NEXT:fmin.s $fa0, $fa1, $fa0
-; CHECK-NEXT:vextrins.w $vr4, $vr0, 48
-; CHECK-NEXT:xvpermi.q $xr4, $xr3, 2
-; CHECK-NEXT:xvst $xr4, $a0, 0
+; CHECK-NEXT:xvld $xr0, $a1, 0
+; CHECK-NEXT:xvld $xr1, $a2, 0
+; CHECK-NEXT:xvfmin.s $xr0, $xr0, $xr1
+; CHECK-NEXT:xvst $xr0, $a0, 0
 ; CHECK-NEXT:ret
 entry:
   %v0 = load <8 x float>, ptr %x
@@ -51,23 +21,9 @@ entry:
 define void @minnum_v4f64(ptr %res, ptr %x, ptr %y) nounwind {
 ; CHECK-LABEL: minnum_v4f64:
 ; CHECK:   # %bb.0: # %entry
-; CHECK-NEXT:   

[llvm-branch-commits] [clang] [llvm] [AArch64][llvm] Armv9.7-A: Add support for SVE2p3 DOT and MLA operations (PR #163161)

2025-10-18 Thread Jonathan Thackray via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [MIR2Vec] Add embedder for machine instructions (PR #162161)

2025-10-18 Thread S. VenkataKeerthy via llvm-branch-commits


@@ -190,6 +197,28 @@ void MIRVocabulary::buildCanonicalOpcodeMapping() {
 << " unique base opcodes\n");
 }
 
+MIRVocabulary MIRVocabulary::createDummyVocabForTest(const TargetInstrInfo 
&TII,
+ unsigned Dim) {
+  assert(Dim > 0 && "Dimension must be greater than zero");
+
+  float DummyVal = 0.1f;

svkeerthy wrote:

No, I missed incrementing it in the loop. Added it now. (Tests in MIR2Vec are 
not looking for magic numbers like IR2Vec so it wasn't caught in tests.)

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


[llvm-branch-commits] [llvm] [InstCombine] Mark as unknown the branch weights of packed integer selecting shifts (PR #162726)

2025-10-18 Thread Mircea Trofin via llvm-branch-commits

https://github.com/mtrofin updated 
https://github.com/llvm/llvm-project/pull/162726

>From 73e18c06696d3737b7df3bccc0ab9424861e1153 Mon Sep 17 00:00:00 2001
From: Mircea Trofin 
Date: Thu, 9 Oct 2025 12:57:39 -0700
Subject: [PATCH] [InstCombine] Mark as unknown the branch weights of packed
 integer selecting shifts

---
 llvm/lib/Transforms/InstCombine/InstCombineInternal.h   | 2 +-
 .../Transforms/InstCombine/InstCombineSimplifyDemanded.cpp  | 6 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h 
b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
index 943c223e516fb..70718766e8ec5 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
+++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
@@ -471,6 +471,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
   Value *simplifyNonNullOperand(Value *V, bool HasDereferenceable,
 unsigned Depth = 0);
 
+public:
   /// Create `select C, S1, S2`. Use only when the profile cannot be calculated
   /// from existing profile metadata: if the Function has profiles, this will
   /// set the profile of this select to "unknown".
@@ -483,7 +484,6 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
 return Sel;
   }
 
-public:
   /// Create and insert the idiom we use to indicate a block is unreachable
   /// without having to rewrite the CFG from within InstCombine.
   void CreateNonTerminatorUnreachable(Instruction *InsertAt) {
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index 127a506e440b7..63e24a0e90853 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -16,6 +16,7 @@
 #include "llvm/IR/GetElementPtrTypeIterator.h"
 #include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/PatternMatch.h"
+#include "llvm/IR/ProfDataUtils.h"
 #include "llvm/Support/KnownBits.h"
 #include "llvm/Transforms/InstCombine/InstCombiner.h"
 
@@ -107,7 +108,10 @@ static Value 
*simplifyShiftSelectingPackedElement(Instruction *I,
   Value *ShrAmtZ =
   IC.Builder.CreateICmpEQ(ShrAmt, 
Constant::getNullValue(ShrAmt->getType()),
   ShrAmt->getName() + ".z");
-  Value *Select = IC.Builder.CreateSelect(ShrAmtZ, Lower, Upper);
+  // There is no existing !prof metadata we can derive the !prof metadata for
+  // this select.
+  Value *Select = IC.createSelectInstWithUnknownProfile(ShrAmtZ, Lower, Upper);
+  IC.Builder.Insert(Select);
   Select->takeName(I);
   return Select;
 }

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


[llvm-branch-commits] [llvm] [SimplifyCFG][profcheck] Profile propagation for `indirectbr` (PR #161747)

2025-10-18 Thread Mircea Trofin via llvm-branch-commits

https://github.com/mtrofin updated 
https://github.com/llvm/llvm-project/pull/161747

>From 349db63164964eb69da4653e3bc24c626401cb1a Mon Sep 17 00:00:00 2001
From: Mircea Trofin 
Date: Thu, 2 Oct 2025 15:56:16 -0700
Subject: [PATCH] [SimplifyCFG][profcheck] Profile propagation for `indirectbr`

---
 llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 39 +--
 .../test/Transforms/SimplifyCFG/indirectbr.ll | 32 +++
 2 files changed, 51 insertions(+), 20 deletions(-)

diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp 
b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 5aff662bc3586..c836d530b8f75 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -4895,9 +4895,8 @@ bool 
SimplifyCFGOpt::simplifyTerminatorOnSelect(Instruction *OldTerm,
   // We found both of the successors we were looking for.
   // Create a conditional branch sharing the condition of the select.
   BranchInst *NewBI = Builder.CreateCondBr(Cond, TrueBB, FalseBB);
-  if (TrueWeight != FalseWeight)
-setBranchWeights(*NewBI, {TrueWeight, FalseWeight},
- /*IsExpected=*/false, /*ElideAllZero=*/true);
+  setBranchWeights(*NewBI, {TrueWeight, FalseWeight},
+   /*IsExpected=*/false, /*ElideAllZero=*/true);
 }
   } else if (KeepEdge1 && (KeepEdge2 || TrueBB == FalseBB)) {
 // Neither of the selected blocks were successors, so this
@@ -4982,9 +4981,15 @@ bool 
SimplifyCFGOpt::simplifyIndirectBrOnSelect(IndirectBrInst *IBI,
   BasicBlock *TrueBB = TBA->getBasicBlock();
   BasicBlock *FalseBB = FBA->getBasicBlock();
 
+  // The select's profile becomes the profile of the conditional branch that
+  // replaces the indirect branch.
+  SmallVector SelectBranchWeights(2);
+  if (!ProfcheckDisableMetadataFixes)
+extractBranchWeights(*SI, SelectBranchWeights);
   // Perform the actual simplification.
-  return simplifyTerminatorOnSelect(IBI, SI->getCondition(), TrueBB, FalseBB, 
0,
-0);
+  return simplifyTerminatorOnSelect(IBI, SI->getCondition(), TrueBB, FalseBB,
+SelectBranchWeights[0],
+SelectBranchWeights[1]);
 }
 
 /// This is called when we find an icmp instruction
@@ -7877,20 +7882,29 @@ bool SimplifyCFGOpt::simplifySwitch(SwitchInst *SI, 
IRBuilder<> &Builder) {
 bool SimplifyCFGOpt::simplifyIndirectBr(IndirectBrInst *IBI) {
   BasicBlock *BB = IBI->getParent();
   bool Changed = false;
-
+  SmallVector BranchWeights;
+  const bool HasBranchWeights = !ProfcheckDisableMetadataFixes &&
+extractBranchWeights(*IBI, BranchWeights);
+  SmallVector NewBranchWeights;
   // Eliminate redundant destinations.
   SmallPtrSet Succs;
   SmallSetVector RemovedSuccs;
-  for (unsigned i = 0, e = IBI->getNumDestinations(); i != e; ++i) {
-BasicBlock *Dest = IBI->getDestination(i);
+  for (unsigned I = 0, E = IBI->getNumDestinations(); I != E; ++I) {
+BasicBlock *Dest = IBI->getDestination(I);
 if (!Dest->hasAddressTaken() || !Succs.insert(Dest).second) {
   if (!Dest->hasAddressTaken())
 RemovedSuccs.insert(Dest);
   Dest->removePredecessor(BB);
-  IBI->removeDestination(i);
-  --i;
-  --e;
+  IBI->removeDestination(I);
+  --I;
+  --E;
   Changed = true;
+  if (HasBranchWeights && BranchWeights[I] != 0) {
+LLVM_DEBUG(dbgs() << "Elided indirectbr edge with non-zero profile. "
+ "This is unexpected\n");
+  }
+} else if (HasBranchWeights) {
+  NewBranchWeights.push_back(BranchWeights[I]);
 }
   }
 
@@ -7915,7 +7929,8 @@ bool SimplifyCFGOpt::simplifyIndirectBr(IndirectBrInst 
*IBI) {
 eraseTerminatorAndDCECond(IBI);
 return true;
   }
-
+  if (HasBranchWeights)
+setBranchWeights(*IBI, NewBranchWeights, /*IsExpected=*/false);
   if (SelectInst *SI = dyn_cast(IBI->getAddress())) {
 if (simplifyIndirectBrOnSelect(IBI, SI))
   return requestResimplify();
diff --git a/llvm/test/Transforms/SimplifyCFG/indirectbr.ll 
b/llvm/test/Transforms/SimplifyCFG/indirectbr.ll
index 87d8b399494ce..3127b2c643f74 100644
--- a/llvm/test/Transforms/SimplifyCFG/indirectbr.ll
+++ b/llvm/test/Transforms/SimplifyCFG/indirectbr.ll
@@ -1,4 +1,4 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --check-globals
 ; RUN: opt -S -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 
< %s | FileCheck %s
 
 ; SimplifyCFG should eliminate redundant indirectbr edges.
@@ -8,7 +8,11 @@ declare void @A()
 declare void @B(i32)
 declare void @C()
 
-define void @indbrtest0(ptr %P, ptr %Q) {
+;.
+; CHECK: @anchor = constant [13 x ptr] [ptr blockaddress(@indbrtest3, %L1), 
ptr blockaddress(@indbrtest3, %L2), ptr inttoptr (i32 1 to ptr), ptr 
blockaddress(@indbrtest4,

[llvm-branch-commits] [lld] 7b785dc - [LLD][COFF] Fix tailMergeARM64 delayload thunk 128 MB range limitation (#161844)

2025-10-18 Thread Cullen Rhodes via llvm-branch-commits

Author: Hans Wennborg
Date: 2025-10-15T09:31:19Z
New Revision: 7b785dcb70f6ab2b8ecf1b75a9fc7cf2512b8ab6

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

LOG: [LLD][COFF] Fix tailMergeARM64 delayload thunk 128 MB range limitation 
(#161844)

lld would fail with "error: relocation out of range" if the thunk was
laid out more than 128 MB away from __delayLoadHelper2.

This patch changes the call sequence to load the offset into a register
and call through that, allowing for 32-bit offsets.

Fixes #161812

(cherry picked from commit 69b8d6d4ead01b88fb8d6642914ca7492e32fdb6)

Added: 


Modified: 
lld/COFF/DLL.cpp
lld/test/COFF/arm64-delayimport.yaml
lld/test/COFF/arm64x-delayimport.test

Removed: 





  



Unicorn! · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #4183c4; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { letter-spacing: -1px; line-height: 60px; font-size: 60px; 
font-weight: 100; margin: 0px; text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 10px 0 10px; font-size: 18px; 
font-weight: 200; line-height: 1.6em;}

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  


  

  

  We're having a really bad day.
  The Unicorns have taken over. We're doing our best to get them under 
control and get GitHub back up and running.
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  




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


[llvm-branch-commits] [clang] [LifetimeSafety] Introduce a liveness-based lifetime policy (PR #159991)

2025-10-18 Thread Utkarsh Saxena via llvm-branch-commits

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


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

2025-10-18 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/161992.diff


10 Files Affected:

- (modified) libc/shared/math.h (+1) 
- (added) libc/shared/math/exp2f.h (+23) 
- (modified) libc/src/__support/math/CMakeLists.txt (+18) 
- (renamed) libc/src/__support/math/exp2f.h (+12-10) 
- (modified) libc/src/math/generic/CMakeLists.txt (+2-20) 
- (modified) libc/src/math/generic/exp2f.cpp (+2-2) 
- (modified) libc/src/math/generic/powf.cpp (+2-3) 
- (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 (+18-18) 


``diff
diff --git a/libc/shared/math.h b/libc/shared/math.h
index 924d0cb4f3bfa..1262fa6f682d0 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -48,6 +48,7 @@
 #include "math/exp10m1f.h"
 #include "math/exp10m1f16.h"
 #include "math/exp2.h"
+#include "math/exp2f.h"
 #include "math/expf.h"
 #include "math/expf16.h"
 #include "math/frexpf.h"
diff --git a/libc/shared/math/exp2f.h b/libc/shared/math/exp2f.h
new file mode 100644
index 0..8c37cbb702e91
--- /dev/null
+++ b/libc/shared/math/exp2f.h
@@ -0,0 +1,23 @@
+//===-- Shared exp2f 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_EXP2F_H
+#define LLVM_LIBC_SHARED_MATH_EXP2F_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/exp2f.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::exp2f;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_EXP2F_H
diff --git a/libc/src/__support/math/CMakeLists.txt 
b/libc/src/__support/math/CMakeLists.txt
index 4130fdf02078b..1d49eaecea23b 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -735,6 +735,24 @@ add_header_library(
 libc.src.errno.errno
 )
 
+add_header_library(
+  exp2f
+  HDRS
+exp2f.h
+  DEPENDS
+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.nearest_integer
+libc.src.__support.FPUtil.polyeval
+libc.src.__support.FPUtil.rounding_mode
+libc.src.__support.macros.optimization
+libc.src.__support.math.exp10f_utils
+libc.src.__support.common
+libc.src.errno.errno
+)
+
 add_header_library(
   exp10
   HDRS
diff --git a/libc/src/math/generic/exp2f_impl.h 
b/libc/src/__support/math/exp2f.h
similarity index 94%
rename from libc/src/math/generic/exp2f_impl.h
rename to libc/src/__support/math/exp2f.h
index b85bb1548019f..ef2aad051b8a9 100644
--- a/libc/src/math/generic/exp2f_impl.h
+++ b/libc/src/__support/math/exp2f.h
@@ -1,4 +1,4 @@
-//===-- Single-precision 2^x function 
-===//
+//===-- Implementation header for exp2f -*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,9 +6,10 @@
 //
 
//===--===//
 
-#ifndef LLVM_LIBC_SRC_MATH_GENERIC_EXP2F_IMPL_H
-#define LLVM_LIBC_SRC_MATH_GENERIC_EXP2F_IMPL_H
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_EXP2F_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_EXP2F_H
 
+#include "exp10f_utils.h"
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/FPUtil/PolyEval.h"
@@ -20,12 +21,12 @@
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 #include "src/__support/macros/properties/cpu_features.h"
-#include "src/__support/math/exp10f_utils.h"
 
 namespace LIBC_NAMESPACE_DECL {
-namespace generic {
 
-LIBC_INLINE float exp2f(float x) {
+namespace math {
+
+LIBC_INLINE static constexpr float exp2f(float x) {
   using FPBits = typename fputil::FPBits;
   FPBits xbits(x);
 
@@ -120,8 +121,8 @@ LIBC_INLINE float exp2f(float x) {
   // of 2^mid.
 
   // kf = (hi + mid) * 2^5 = round(x * 2^5)
-  float kf;
-  int k;
+  float kf = 0;
+  int k = 0;
 #ifdef LIBC_TARGET_CPU_HAS_NEAREST_INT
   kf = fputil::nearest_integer(x * 32.0f);
   k = static_cast(kf);
@@ -161,7 +162,8 @@ LIBC_INLINE float exp2f(float x) {
   return static_cast(fputil::multiply_add(p, dx_sq * mh, c1 * mh));
 }
 
-} // name

[llvm-branch-commits] [FlowSensitive] [StatusOr] [4/N] Support comparisons (PR #163871)

2025-10-18 Thread Florian Mayer via llvm-branch-commits

https://github.com/fmayer created 
https://github.com/llvm/llvm-project/pull/163871

None


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


[llvm-branch-commits] [lldb] release/21.x: [LLDB][ProcessWindows] Set exit status on instance rather than going through all targets (#159308) (PR #161541)

2025-10-18 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (llvmbot)


Changes

Backport a868f28c6e9beecb2b3fbe8acfbe0d272fabd14d

Requested by: @Nerixyz

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


1 Files Affected:

- (modified) lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp 
(+1-1) 


``diff
diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp 
b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
index 27530f032ce51..0fecefe23b88e 100644
--- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -666,7 +666,7 @@ void ProcessWindows::OnExitProcess(uint32_t exit_code) {
 target->ModulesDidUnload(unloaded_modules, true);
   }
 
-  SetProcessExitStatus(GetID(), true, 0, exit_code);
+  SetExitStatus(exit_code, /*exit_string=*/"");
   SetPrivateState(eStateExited);
 
   ProcessDebugger::OnExitProcess(exit_code);

``




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


[llvm-branch-commits] [clang] [LifetimeSafety] Introduce a liveness-based lifetime policy (PR #159991)

2025-10-18 Thread Utkarsh Saxena via llvm-branch-commits

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


[llvm-branch-commits] [clang] [Clang] Introduce -fsanitize=alloc-token (PR #156839)

2025-10-18 Thread Marco Elver via llvm-branch-commits

https://github.com/melver updated 
https://github.com/llvm/llvm-project/pull/156839

>From b3653330c2c39ebaa094670f11afb0f9d36b9de2 Mon Sep 17 00:00:00 2001
From: Marco Elver 
Date: Thu, 4 Sep 2025 12:07:26 +0200
Subject: [PATCH] fixup! Insert AllocToken into index.rst

Created using spr 1.3.8-beta.1
---
 clang/docs/index.rst | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/docs/index.rst b/clang/docs/index.rst
index be654af57f890..aa2b3a73dc11b 100644
--- a/clang/docs/index.rst
+++ b/clang/docs/index.rst
@@ -40,6 +40,7 @@ Using Clang as a Compiler
SanitizerCoverage
SanitizerStats
SanitizerSpecialCaseList
+   AllocToken
BoundsSafety
BoundsSafetyAdoptionGuide
BoundsSafetyImplPlans

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


[llvm-branch-commits] [mlir] fd870cc - Revert "[MLIR][Python] add Python wheel build demo/test (#160388)"

2025-10-18 Thread via llvm-branch-commits

Author: Maksim Levental
Date: 2025-09-24T02:50:24-07:00
New Revision: fd870ccd8eb160dd0327f12556f79a9849dd4d10

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

LOG: Revert "[MLIR][Python] add Python wheel build demo/test (#160388)"

This reverts commit 1359f3a83feb04ee46f00685c0dd102afe2b682b.

Added: 


Modified: 
mlir/examples/standalone/CMakeLists.txt
mlir/test/Examples/standalone/lit.local.cfg
mlir/test/lit.site.cfg.py.in

Removed: 
mlir/examples/standalone/pyproject.toml
mlir/test/Examples/standalone/test.wheel.toy



diff  --git a/mlir/examples/standalone/CMakeLists.txt 
b/mlir/examples/standalone/CMakeLists.txt
index c6c49fde12d2e..e2bcda7fa6f0b 100644
--- a/mlir/examples/standalone/CMakeLists.txt
+++ b/mlir/examples/standalone/CMakeLists.txt
@@ -63,12 +63,8 @@ if(MLIR_ENABLE_BINDINGS_PYTHON)
   include(MLIRDetectPythonEnv)
   mlir_configure_python_dev_packages()
   # Note: for EXTERNAL_PROJECT_BUILD this must be set from the command line.
-  if(NOT MLIR_PYTHON_PACKAGE_PREFIX)
-set(MLIR_PYTHON_PACKAGE_PREFIX "mlir_standalone" CACHE STRING "" FORCE)
-  endif()
-  if(NOT MLIR_BINDINGS_PYTHON_INSTALL_PREFIX)
-set(MLIR_BINDINGS_PYTHON_INSTALL_PREFIX 
"python_packages/standalone/${MLIR_PYTHON_PACKAGE_PREFIX}" CACHE STRING "" 
FORCE)
-  endif()
+  set(MLIR_PYTHON_PACKAGE_PREFIX "mlir_standalone" CACHE STRING "" FORCE)
+  set(MLIR_BINDINGS_PYTHON_INSTALL_PREFIX 
"python_packages/standalone/${MLIR_PYTHON_PACKAGE_PREFIX}" CACHE STRING "" 
FORCE)
   add_subdirectory(python)
 endif()
 add_subdirectory(test)

diff  --git a/mlir/examples/standalone/pyproject.toml 
b/mlir/examples/standalone/pyproject.toml
deleted file mode 100644
index 5a1e6e86513c3..0
--- a/mlir/examples/standalone/pyproject.toml
+++ /dev/null
@@ -1,65 +0,0 @@
-# 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
-# Copyright (c) 2025.
-
-[project]
-name = "standalone-python-bindings"
-dynamic = ["version"]
-requires-python = ">=3.8,<=3.14"
-dependencies = [
-"numpy>=1.19.5, <=2.1.2",
-"PyYAML>=5.4.0, <=6.0.1",
-"ml_dtypes>=0.1.0, <=0.6.0; python_version<'3.13'",
-"ml_dtypes>=0.5.0, <=0.6.0; python_version>='3.13'",
-]
-
-[project.urls]
-Homepage = "https://github.com/llvm/llvm-project";
-Discussions = "https://discourse.llvm.org/";
-"Issue Tracker" = 
"https://github.com/llvm/llvm-project/issues?q=is%3Aissue%20state%3Aopen%20label%3Amlir%3Apython%20";
-"Source Code" = "https://github.com/llvm/llvm-project/tree/main/mlir/python";
-
-[build-system]
-requires = [
-"scikit-build-core>=0.10.7",
-"typing_extensions>=4.12.2",
-"nanobind>=2.9, <3.0",
-"pybind11>=2.10.0, <=2.13.6",
-]
-build-backend = "scikit_build_core.build"
-
-[tool.scikit-build]
-# This is the minimum version of scikit-build-core.
-minimum-version = "0.10.7"
-# This pyproject.toml must be adjacent to the root CMakeLists.txt (wherever 
project(...) is specified).
-cmake.source-dir = "."
-# This is for installing/distributing the python bindings target and only the 
python bindings target.
-build.targets = ["StandalonePythonModules"]
-install.components = ["StandalonePythonModules"]
-
-[tool.scikit-build.cmake.define]
-# Optional
-CMAKE_C_COMPILER = { env = "CMAKE_C_COMPILER", default = "" }
-CMAKE_CXX_COMPILER = { env = "CMAKE_CXX_COMPILER", default = "" }
-CMAKE_C_COMPILER_LAUNCHER = { env = "CMAKE_C_COMPILER_LAUNCHER", default = "" }
-CMAKE_CXX_COMPILER_LAUNCHER = { env = "CMAKE_CXX_COMPILER_LAUNCHER", default = 
"" }
-CMAKE_GENERATOR = { env = "CMAKE_GENERATOR", default = "Ninja" }
-LLVM_USE_LINKER = { env = "LLVM_USE_LINKER", default = "" }
-# Optional but highly recommended (this makes the bindings compatible with 
other bindings packages
-# by preventing symbol collisions).
-CMAKE_VISIBILITY_INLINES_HIDDEN = "ON"
-CMAKE_C_VISIBILITY_PRESET = "hidden"
-CMAKE_CXX_VISIBILITY_PRESET = "hidden"
-
-# Non-optional (alternatively you could use CMAKE_PREFIX_PATH here).
-MLIR_DIR = { env = "MLIR_DIR", default = "" }
-# Non-optional
-CMAKE_BUILD_TYPE = { env = "CMAKE_BUILD_TYPE", default = "Release" }
-MLIR_ENABLE_BINDINGS_PYTHON = "ON"
-# Effectively non-optional (any downstream project should specify this).
-MLIR_PYTHON_PACKAGE_PREFIX = "mlir_standalone"
-# This specifies the directory in the install directory (i.e., 
/tmp/pip-wheel/platlib) where _mlir_libs, dialects, etc.
-# are installed. Thus, this will be the package location (and the name of the 
package) that pip assumes is
-# the root package.
-MLIR_BINDINGS_PYTHON_INSTALL_PREFIX = "mlir_standalone"

diff  --git a/mlir/test/Examples/standalone/lit.local.cfg 
b/mlir/test/Examples/standalone/l

[llvm-branch-commits] [llvm] [AllocToken] Refactor stateless token calculation into Support (PR #163633)

2025-10-18 Thread Florian Mayer via llvm-branch-commits


@@ -0,0 +1,46 @@
+//===- AllocToken.cpp - Allocation Token Calculation 
--===//
+//
+// 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
+//
+//===--===//
+//
+// Definition of AllocToken modes and shared calculation of stateless token 
IDs.
+//
+//===--===//
+
+#include "llvm/Support/AllocToken.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/SipHash.h"
+
+namespace llvm {

fmayer wrote:

https://llvm.org/docs/CodingStandards.html#use-namespace-qualifiers-to-implement-previously-declared-functions

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


[llvm-branch-commits] [libc] [libc][stdlib][annex_k] Add ignore_handler_s. (PR #163313)

2025-10-18 Thread Muhammad Bassiouni via llvm-branch-commits

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

>From 55a25d4cab2f6b52ec59044b9f96d1ee34118ab9 Mon Sep 17 00:00:00 2001
From: bassiounix 
Date: Tue, 14 Oct 2025 06:20:42 +0300
Subject: [PATCH] [libc][stdlib][annex_k] Add ignore_handler_s.

---
 libc/config/linux/aarch64/entrypoints.txt |  1 +
 libc/config/linux/riscv/entrypoints.txt   |  1 +
 libc/config/linux/x86_64/entrypoints.txt  |  1 +
 libc/include/CMakeLists.txt   |  1 +
 libc/include/stdlib.yaml  |  9 +
 libc/src/stdlib/CMakeLists.txt| 13 +
 libc/src/stdlib/ignore_handler_s.cpp  | 16 
 libc/src/stdlib/ignore_handler_s.h| 22 ++
 8 files changed, 64 insertions(+)
 create mode 100644 libc/src/stdlib/ignore_handler_s.cpp
 create mode 100644 libc/src/stdlib/ignore_handler_s.h

diff --git a/libc/config/linux/aarch64/entrypoints.txt 
b/libc/config/linux/aarch64/entrypoints.txt
index b86d3f22afec1..b2b3789cc2f60 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -1,6 +1,7 @@
 set(TARGET_ANNEX_K_ENTRYPOINTS
 # stdlib.h entrypoints
 libc.src.stdlib.abort_handler_s
+libc.src.stdlib.ignore_handler_s
 )
 
 set(TARGET_LIBC_ENTRYPOINTS
diff --git a/libc/config/linux/riscv/entrypoints.txt 
b/libc/config/linux/riscv/entrypoints.txt
index fb0fbe9c456c9..5d92b112272fb 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -1,6 +1,7 @@
 set(TARGET_ANNEX_K_ENTRYPOINTS
 # stdlib.h entrypoints
 libc.src.stdlib.abort_handler_s
+libc.src.stdlib.ignore_handler_s
 )
 
 set(TARGET_LIBC_ENTRYPOINTS
diff --git a/libc/config/linux/x86_64/entrypoints.txt 
b/libc/config/linux/x86_64/entrypoints.txt
index f9d2379570c3b..4cb412ae7c526 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -1,6 +1,7 @@
 set(TARGET_ANNEX_K_ENTRYPOINTS
 # stdlib.h entrypoints
 libc.src.stdlib.abort_handler_s
+libc.src.stdlib.ignore_handler_s
 )
 
 set(TARGET_LIBC_ENTRYPOINTS
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 7ef6940763519..6f62a052b80e6 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -360,6 +360,7 @@ add_header_macro(
   ../libc/include/stdlib.yaml
   stdlib.h
   DEPENDS
+.llvm-libc-macros.annex_k_macros
 .llvm-libc-macros.null_macro
 .llvm-libc-macros.stdlib_macros
 .llvm-libc-types.__atexithandler_t
diff --git a/libc/include/stdlib.yaml b/libc/include/stdlib.yaml
index 050cf246decf6..7c3b113a62415 100644
--- a/libc/include/stdlib.yaml
+++ b/libc/include/stdlib.yaml
@@ -113,6 +113,15 @@ functions:
 return_type: char *
 arguments:
   - type: const char *
+  - name: ignore_handler_s
+standards:
+  - stdc
+return_type: void
+arguments:
+  - type: const char *__restrict
+  - type: void *__restrict
+  - type: errno_t
+guard: 'LIBC_HAS_ANNEX_K'
   - name: labs
 standards:
   - stdc
diff --git a/libc/src/stdlib/CMakeLists.txt b/libc/src/stdlib/CMakeLists.txt
index 8fd149880e2d5..5efd7f13ff3ee 100644
--- a/libc/src/stdlib/CMakeLists.txt
+++ b/libc/src/stdlib/CMakeLists.txt
@@ -663,3 +663,16 @@ add_entrypoint_object(
   DEPENDS
 .${LIBC_TARGET_OS}.system
 )
+
+add_entrypoint_object(
+  ignore_handler_s
+  HDRS
+ignore_handler_s.h
+  SRCS
+ignore_handler_s.cpp
+  DEPENDS
+libc.hdr.types.errno_t
+libc.src.__support.libc_errno
+libc.src.__support.macros.config
+libc.src.__support.macros.attributes
+)
diff --git a/libc/src/stdlib/ignore_handler_s.cpp 
b/libc/src/stdlib/ignore_handler_s.cpp
new file mode 100644
index 0..172b1bcdb7b30
--- /dev/null
+++ b/libc/src/stdlib/ignore_handler_s.cpp
@@ -0,0 +1,16 @@
+//===-- Implementation header for ignore_handler_s --*- 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
+//
+//===--===//
+
+#include "src/stdlib/ignore_handler_s.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(void, ignore_handler_s,
+   (const char *__restrict, void *__restrict, errno_t)) {}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/stdlib/ignore_handler_s.h 
b/libc/src/stdlib/ignore_handler_s.h
new file mode 100644
index 0..07328d4be01ce
--- /dev/null
+++ b/libc/src/stdlib/ignore_handler_s.h
@@ -0,0 +1,22 @@
+//===-- Implementation header for ignore_handler_s --*- 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

[llvm-branch-commits] [llvm] [llvm][mustache] Use single pass when tokenizing (PR #159196)

2025-10-18 Thread Paul Kirth via llvm-branch-commits

https://github.com/ilovepi updated 
https://github.com/llvm/llvm-project/pull/159196

>From cbc1f386bf88525a06976e8284889f720052c7ad Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Mon, 15 Sep 2025 23:27:50 -0700
Subject: [PATCH] [llvm][mustache] Use single pass when tokenizing

The old implementation used many string searches over the same portions
of the strings. This version sacrifices some API niceness for perf wins.

  Metric | Baseline | Single-Pass | Change
  -- |  | --- | ---
  Time (ms)  | 36.09| 35.78   | -0.86%
  Cycles | 35.3M| 35.0M   | -0.79%
  Instructions   | 86.7M| 85.8M   | -1.03%
  Branch Misses  | 116K | 114K| -1.91%
  Cache Misses   | 244K | 232K| -4.98%
---
 llvm/lib/Support/Mustache.cpp | 186 +-
 1 file changed, 73 insertions(+), 113 deletions(-)

diff --git a/llvm/lib/Support/Mustache.cpp b/llvm/lib/Support/Mustache.cpp
index 30ced31bd7c43..0053a425b758d 100644
--- a/llvm/lib/Support/Mustache.cpp
+++ b/llvm/lib/Support/Mustache.cpp
@@ -368,141 +368,101 @@ static const char *jsonKindToString(json::Value::Kind 
K) {
   llvm_unreachable("Unknown json::Value::Kind");
 }
 
-static Tag findNextTag(StringRef Template, size_t StartPos, StringRef Open,
-   StringRef Close) {
-  const StringLiteral TripleOpen("{{{");
-  const StringLiteral TripleClose("}}}");
-
-  size_t NormalOpenPos = Template.find(Open, StartPos);
-  size_t TripleOpenPos = Template.find(TripleOpen, StartPos);
-
-  Tag Result;
-
-  // Determine which tag comes first.
-  if (TripleOpenPos != StringRef::npos &&
-  (NormalOpenPos == StringRef::npos || TripleOpenPos <= NormalOpenPos)) {
-// Found a triple mustache tag.
-size_t EndPos =
-Template.find(TripleClose, TripleOpenPos + TripleOpen.size());
-if (EndPos == StringRef::npos)
-  return Result; // No closing tag found.
-
-Result.TagKind = Tag::Kind::Triple;
-Result.StartPosition = TripleOpenPos;
-size_t ContentStart = TripleOpenPos + TripleOpen.size();
-Result.Content = Template.substr(ContentStart, EndPos - ContentStart);
-Result.FullMatch = Template.substr(
-TripleOpenPos, (EndPos + TripleClose.size()) - TripleOpenPos);
-  } else if (NormalOpenPos != StringRef::npos) {
-// Found a normal mustache tag.
-size_t EndPos = Template.find(Close, NormalOpenPos + Open.size());
-if (EndPos == StringRef::npos)
-  return Result; // No closing tag found.
-
-Result.TagKind = Tag::Kind::Normal;
-Result.StartPosition = NormalOpenPos;
-size_t ContentStart = NormalOpenPos + Open.size();
-Result.Content = Template.substr(ContentStart, EndPos - ContentStart);
-Result.FullMatch =
-Template.substr(NormalOpenPos, (EndPos + Close.size()) - 
NormalOpenPos);
-  }
-
-  return Result;
-}
-
-static std::optional>
-processTag(const Tag &T, SmallVectorImpl &Tokens, MustacheContext &Ctx) 
{
-  LLVM_DEBUG(dbgs() << "[Tag] " << T.FullMatch << ", Content: " << T.Content
-<< ", Kind: " << tagKindToString(T.TagKind) << "\n");
-  if (T.TagKind == Tag::Kind::Triple) {
-Tokens.emplace_back(T.FullMatch, Ctx.Saver.save("&" + T.Content), '&', 
Ctx);
-return std::nullopt;
-  }
-  StringRef Interpolated = T.Content;
-  if (!Interpolated.trim().starts_with("=")) {
-char Front = Interpolated.empty() ? ' ' : Interpolated.trim().front();
-Tokens.emplace_back(T.FullMatch, Interpolated, Front, Ctx);
-return std::nullopt;
-  }
-  Tokens.emplace_back(T.FullMatch, Interpolated, '=', Ctx);
-  StringRef DelimSpec = Interpolated.trim();
-  DelimSpec = DelimSpec.drop_front(1);
-  DelimSpec = DelimSpec.take_until([](char C) { return C == '='; });
-  DelimSpec = DelimSpec.trim();
-
-  std::pair Ret = DelimSpec.split(' ');
-  LLVM_DEBUG(dbgs() << "[Set Delimiter] NewOpen: " << Ret.first
-<< ", NewClose: " << Ret.second << "\n");
-  return Ret;
-}
-
 // Simple tokenizer that splits the template into tokens.
-// The mustache spec allows {{{ }}} to unescape variables,
-// but we don't support that here. An unescape variable
-// is represented only by {{& variable}}.
 static SmallVector tokenize(StringRef Template, MustacheContext &Ctx) {
   LLVM_DEBUG(dbgs() << "[Tokenize Template] \"" << Template << "\"\n");
   SmallVector Tokens;
   SmallString<8> Open("{{");
   SmallString<8> Close("}}");
-  size_t Start = 0;
+  size_t Cursor = 0;
+  size_t TextStart = 0;
+
+  const StringLiteral TripleOpen("{{{");
+  const StringLiteral TripleClose("}}}");
 
-  while (Start < Template.size()) {
-LLVM_DEBUG(dbgs() << "[Tokenize Loop] Start=" << Start << ", Open='" << 
Open
-  << "', Close='" << Close << "'\n");
-Tag T = findNextTag(Template, Start, Open, Close);
+  while (Cursor < Template.size()) {
+StringRef TemplateSuffix = Template.substr(Cursor);
+StringRef TagOpen, TagClose;
+Tag::Kind Kind;
+
+ 

[llvm-branch-commits] [clang] release/21.x: [clang] Fix catching pointers by reference on mingw targets (#162546) (PR #163714)

2025-10-18 Thread via llvm-branch-commits

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


[llvm-branch-commits] [clang] [CIR] Upstream `AddressSpace` conversions support (PR #161212)

2025-10-18 Thread David Rivera via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [AArch64] (NFC) Tidy up alignment/formatting in AArch64/AArch64InstrInfo.td (PR #163645)

2025-10-18 Thread Jonathan Thackray via llvm-branch-commits

https://github.com/jthackray updated 
https://github.com/llvm/llvm-project/pull/163645

>From 57200cf27b2ae623a25a99482a6aa350065586c2 Mon Sep 17 00:00:00 2001
From: Jonathan Thackray 
Date: Wed, 15 Oct 2025 22:24:17 +0100
Subject: [PATCH] (NFC) Tidy up alignment/formatting in
 AArch64/AArch64InstrInfo.td

It was noted in a code-review for earlier changes in this stack
that some of the new 9.7 entries were mis-aligned. But actually,
many of the entries were, so I've tidied them all up.
---
 llvm/lib/Target/AArch64/AArch64InstrInfo.td | 227 +---
 1 file changed, 104 insertions(+), 123 deletions(-)

diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td 
b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
index 176040d5f3475..3ac9486a64335 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -50,63 +50,44 @@ def HasV9_4a : 
Predicate<"Subtarget->hasV9_4aOps()">,
  AssemblerPredicateWithAll<(all_of 
HasV9_4aOps), "armv9.4a">;
 def HasV8_0r : Predicate<"Subtarget->hasV8_0rOps()">,
  AssemblerPredicateWithAll<(all_of 
HasV8_0rOps), "armv8-r">;
-
 def HasEL2VMSA   : Predicate<"Subtarget->hasEL2VMSA()">,
-   AssemblerPredicateWithAll<(all_of FeatureEL2VMSA), 
"el2vmsa">;
-
+ AssemblerPredicateWithAll<(all_of 
FeatureEL2VMSA), "el2vmsa">;
 def HasEL3   : Predicate<"Subtarget->hasEL3()">,
-   AssemblerPredicateWithAll<(all_of FeatureEL3), "el3">;
-
+ AssemblerPredicateWithAll<(all_of 
FeatureEL3), "el3">;
 def HasVH: Predicate<"Subtarget->hasVH()">,
-   AssemblerPredicateWithAll<(all_of FeatureVH), "vh">;
-
+ AssemblerPredicateWithAll<(all_of FeatureVH), 
"vh">;
 def HasLOR   : Predicate<"Subtarget->hasLOR()">,
-   AssemblerPredicateWithAll<(all_of FeatureLOR), "lor">;
-
+ AssemblerPredicateWithAll<(all_of 
FeatureLOR), "lor">;
 def HasPAuth : Predicate<"Subtarget->hasPAuth()">,
-   AssemblerPredicateWithAll<(all_of FeaturePAuth), 
"pauth">;
-
+ AssemblerPredicateWithAll<(all_of 
FeaturePAuth), "pauth">;
 def HasPAuthLR   : Predicate<"Subtarget->hasPAuthLR()">,
-   AssemblerPredicateWithAll<(all_of FeaturePAuthLR), 
"pauth-lr">;
-
+ AssemblerPredicateWithAll<(all_of 
FeaturePAuthLR), "pauth-lr">;
 def HasJS: Predicate<"Subtarget->hasJS()">,
-   AssemblerPredicateWithAll<(all_of FeatureJS), "jsconv">;
-
+ AssemblerPredicateWithAll<(all_of FeatureJS), 
"jsconv">;
 def HasCCIDX : Predicate<"Subtarget->hasCCIDX()">,
-   AssemblerPredicateWithAll<(all_of FeatureCCIDX), 
"ccidx">;
-
-def HasComplxNum  : Predicate<"Subtarget->hasComplxNum()">,
-   AssemblerPredicateWithAll<(all_of FeatureComplxNum), 
"complxnum">;
-
+ AssemblerPredicateWithAll<(all_of 
FeatureCCIDX), "ccidx">;
+def HasComplxNum : Predicate<"Subtarget->hasComplxNum()">,
+ AssemblerPredicateWithAll<(all_of 
FeatureComplxNum), "complxnum">;
 def HasNV: Predicate<"Subtarget->hasNV()">,
-   AssemblerPredicateWithAll<(all_of FeatureNV), "nv">;
-
+ AssemblerPredicateWithAll<(all_of FeatureNV), 
"nv">;
 def HasMPAM  : Predicate<"Subtarget->hasMPAM()">,
-   AssemblerPredicateWithAll<(all_of FeatureMPAM), "mpam">;
-
+ AssemblerPredicateWithAll<(all_of 
FeatureMPAM), "mpam">;
 def HasDIT   : Predicate<"Subtarget->hasDIT()">,
-   AssemblerPredicateWithAll<(all_of FeatureDIT), "dit">;
-
-def HasTRACEV8_4 : Predicate<"Subtarget->hasTRACEV8_4()">,
-   AssemblerPredicateWithAll<(all_of FeatureTRACEV8_4), 
"tracev8.4">;
-
+ AssemblerPredicateWithAll<(all_of 
FeatureDIT), "dit">;
+def HasTRACEV8_4 : Predicate<"Subtarget->hasTRACEV8_4()">,
+ AssemblerPredicateWithAll<(all_of 
FeatureTRACEV8_4), "tracev8.4">;
 def HasAM: Predicate<"Subtarget->hasAM()">,
-   AssemblerPredicateWithAll<(all_of FeatureAM), "am">;
-
+ AssemblerPredicateWithAll<(all_of FeatureAM), 
"am">;
 def HasSEL2  : Predicate<"Subtarget->hasSEL2()">,
-   AssemblerPredicateWithAll<(all_of FeatureSEL2), "sel2">;
-
-def HasTLB_RMI  : Predicate<"Subtarget->hasTLB_RMI()">,
-   AssemblerPredicateWithAll<(all_of FeatureTLB_RMI), 
"tlb-rmi">;
-
+ A

[llvm-branch-commits] [llvm] [AArch64][SME] Support split ZPR and PPR area allocation (PR #142392)

2025-10-18 Thread Sander de Smalen via llvm-branch-commits


@@ -747,9 +759,13 @@ void AArch64FrameLowering::emitCalleeSavedSVELocations(
   continue;
 
 StackOffset Offset =
-StackOffset::getScalable(MFI.getObjectOffset(Info.getFrameIdx())) -
+StackOffset::getScalable(MFI.getObjectOffset(FI)) -
 StackOffset::getFixed(AFI.getCalleeSavedStackSize(MFI));
 
+if (AFI.hasSplitSVEObjects() &&
+MFI.getStackID(FI) == TargetStackID::ScalableVector)
+  Offset -= PPRStackSize;

sdesmalen-arm wrote:

This can do with a comment explaining that predicate callee-saves are allocated 
together with GPRs and that's the reason to subtract the PPRStackSize.

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


[llvm-branch-commits] [mlir] [MLIR][OpenMP] Support allocations of device shared memory (PR #150924)

2025-10-18 Thread Sergio Afonso via llvm-branch-commits

https://github.com/skatrak updated 
https://github.com/llvm/llvm-project/pull/150924

>From d839bbddbd70403653e45f69a221d391818e3e82 Mon Sep 17 00:00:00 2001
From: Sergio Afonso 
Date: Fri, 27 Jun 2025 13:29:13 +0100
Subject: [PATCH 1/2] [MLIR][OpenMP] Support allocations of device shared
 memory

This patch updates the allocation of some reduction and private variables
within target regions to use device shared memory rather than private memory.
This is a prerequisite to produce working Generic kernels containing parallel
regions.

In particular, the following situations result in the usage of device shared
memory (only when compiling for the target device if they are placed inside of
a target region representing a Generic kernel):
- Reduction variables on `teams` constructs.
- Private variables on `teams` and `distribute` constructs that are reduced or
used inside of a `parallel` region.

Currently, there is no support for delayed privatization on `teams` constructs,
so private variables on these constructs won't currently be affected. When
support is added, if it uses the existing `allocatePrivateVars` and
`cleanupPrivateVars` functions, usage of device shared memory will be
introduced automatically.
---
 .../OpenMP/OpenMPToLLVMIRTranslation.cpp  | 227 +-
 .../omptarget-device-shared-memory.mlir   |  86 +++
 2 files changed, 253 insertions(+), 60 deletions(-)
 create mode 100644 mlir/test/Target/LLVMIR/omptarget-device-shared-memory.mlir

diff --git 
a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp 
b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 172029196905d..360e7569bb261 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -1103,12 +1103,64 @@ struct DeferredStore {
 };
 } // namespace
 
+/// Check whether allocations for the given operation might potentially have to
+/// be done in device shared memory. That means we're compiling for a 
offloading
+/// target, the operation is an `omp::TargetOp` or nested inside of one and 
that
+/// target region represents a Generic (non-SPMD) kernel.
+///
+/// This represents a necessary but not sufficient set of conditions to use
+/// device shared memory in place of regular allocas. Depending on the 
variable,
+/// its uses or the associated OpenMP construct might also need to be taken 
into
+/// account.
+static bool
+mightAllocInDeviceSharedMemory(Operation &op,
+   const llvm::OpenMPIRBuilder &ompBuilder) {
+  if (!ompBuilder.Config.isTargetDevice())
+return false;
+
+  auto targetOp = dyn_cast(op);
+  if (!targetOp)
+targetOp = op.getParentOfType();
+
+  return targetOp &&
+ !bitEnumContainsAny(
+ targetOp.getKernelExecFlags(targetOp.getInnermostCapturedOmpOp()),
+ omp::TargetRegionFlags::spmd);
+}
+
+/// Check whether the entry block argument representing the private copy of a
+/// variable in an OpenMP construct must be allocated in device shared memory,
+/// based on what the uses of that copy are.
+///
+/// This must only be called if a previous call to
+/// \c mightAllocInDeviceSharedMemory has already returned \c true for the
+/// operation that owns the specified block argument.
+static bool mustAllocPrivateVarInDeviceSharedMemory(BlockArgument value) {
+  Operation *parentOp = value.getOwner()->getParentOp();
+  auto targetOp = dyn_cast(parentOp);
+  if (!targetOp)
+targetOp = parentOp->getParentOfType();
+  assert(targetOp && "expected a parent omp.target operation");
+
+  for (auto *user : value.getUsers()) {
+if (auto parallelOp = dyn_cast(user)) {
+  if (llvm::is_contained(parallelOp.getReductionVars(), value))
+return true;
+} else if (auto parallelOp = user->getParentOfType()) {
+  if (targetOp->isProperAncestor(parallelOp))
+return true;
+}
+  }
+
+  return false;
+}
+
 /// Allocate space for privatized reduction variables.
 /// `deferredStores` contains information to create store operations which 
needs
 /// to be inserted after all allocas
 template 
 static LogicalResult
-allocReductionVars(T loop, ArrayRef reductionArgs,
+allocReductionVars(T op, ArrayRef reductionArgs,
llvm::IRBuilderBase &builder,
LLVM::ModuleTranslation &moduleTranslation,
const llvm::OpenMPIRBuilder::InsertPointTy &allocaIP,
@@ -1120,10 +1172,14 @@ allocReductionVars(T loop, ArrayRef 
reductionArgs,
   llvm::IRBuilderBase::InsertPointGuard guard(builder);
   builder.SetInsertPoint(allocaIP.getBlock()->getTerminator());
 
+  llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
+  bool useDeviceSharedMem =
+  isa(op) && mightAllocInDeviceSharedMemory(*op, 
*ompBuilder);
+
   // delay creating stores until after all allocas
-  deferredStores.reserve(loop.getNumReductionVars());
+  deferredStores.rese

[llvm-branch-commits] [clang] [llvm] [AArch64][llvm] Armv9.7-A: Add support for new Advanced SIMD (Neon) instructions (PR #163165)

2025-10-18 Thread Jonathan Thackray via llvm-branch-commits

https://github.com/jthackray updated 
https://github.com/llvm/llvm-project/pull/163165

>From 97992a3cdc6fbbf95a05bd2baa2bbd6bcf1ee5aa Mon Sep 17 00:00:00 2001
From: Jonathan Thackray 
Date: Mon, 15 Sep 2025 21:13:29 +0100
Subject: [PATCH 1/2] [AArch64][llvm] Armv9.7-A: Add support for new Advanced
 SIMD (Neon) instructions

Add support for new Advanced SIMD (Neon) instructions:
 - FDOT (half-precision to single-precision, by element)
 - FDOT (half-precision to single-precision, vector)
 - FMMLA (half-precision, non-widening)
 - FMMLA (widening, half-precision to single-precision)

as documented here:

 * https://developer.arm.com/documentation/ddi0602/2025-09/
 * 
https://developer.arm.com/documentation/109697/2025_09/2025-Architecture-Extensions

Co-authored-by: Kerry McLaughlin 
Co-authored-by: Caroline Concatto 
Co-authored-by: Virginia Cangelosi 
---
 .../print-supported-extensions-aarch64.c  |   2 +
 llvm/lib/Target/AArch64/AArch64Features.td|   6 +
 .../lib/Target/AArch64/AArch64InstrFormats.td |  42 -
 llvm/lib/Target/AArch64/AArch64InstrInfo.td   |  17 +-
 .../AArch64/AsmParser/AArch64AsmParser.cpp|   2 +
 llvm/test/MC/AArch64/FP8/fmmla-diagnostics.s  |   2 +-
 llvm/test/MC/AArch64/neon-fdot-diagnostics.s  |  59 +++
 llvm/test/MC/AArch64/neon-fdot.s  | 147 ++
 .../MC/AArch64/neon-fmmla-HtoS-diagnostics.s  |  24 +++
 llvm/test/MC/AArch64/neon-fmmla-HtoS.s|  37 +
 llvm/test/MC/AArch64/neon-fmmla-diagnostics.s |  24 +++
 llvm/test/MC/AArch64/neon-fmmla.s |  37 +
 .../TargetParser/TargetParserTest.cpp |  32 +++-
 13 files changed, 424 insertions(+), 7 deletions(-)
 create mode 100644 llvm/test/MC/AArch64/neon-fdot-diagnostics.s
 create mode 100644 llvm/test/MC/AArch64/neon-fdot.s
 create mode 100644 llvm/test/MC/AArch64/neon-fmmla-HtoS-diagnostics.s
 create mode 100644 llvm/test/MC/AArch64/neon-fmmla-HtoS.s
 create mode 100644 llvm/test/MC/AArch64/neon-fmmla-diagnostics.s
 create mode 100644 llvm/test/MC/AArch64/neon-fmmla.s

diff --git a/clang/test/Driver/print-supported-extensions-aarch64.c 
b/clang/test/Driver/print-supported-extensions-aarch64.c
index 50c3610123646..7975b5ab7cb83 100644
--- a/clang/test/Driver/print-supported-extensions-aarch64.c
+++ b/clang/test/Driver/print-supported-extensions-aarch64.c
@@ -18,6 +18,8 @@
 // CHECK-NEXT: d128FEAT_D128, FEAT_LVA3, FEAT_SYSREG128, 
FEAT_SYSINSTR128 Enable Armv9.4-A 128-bit Page Table Descriptors, System 
Registers and instructions
 // CHECK-NEXT: dit FEAT_DIT
   Enable Armv8.4-A Data Independent Timing instructions
 // CHECK-NEXT: dotprod FEAT_DotProd
   Enable dot product support
+// CHECK-NEXT: f16f32dot   FEAT_F16F32DOT  
   Enable Armv9.7-A Advanced SIMD half-precision dot product 
accumulate to single-precision
+// CHECK-NEXT: f16f32mmFEAT_F16F32MM   
   Enable Armv9.7-A Advanced SIMD half-precision matrix 
multiply-accumulate to single-precision
 // CHECK-NEXT: f16mm   FEAT_F16MM  
   Enable Armv9.7-A non-widening half-precision matrix 
multiply-accumulate
 // CHECK-NEXT: f32mm   FEAT_F32MM  
   Enable Matrix Multiply FP32 Extension
 // CHECK-NEXT: f64mm   FEAT_F64MM  
   Enable Matrix Multiply FP64 Extension
diff --git a/llvm/lib/Target/AArch64/AArch64Features.td 
b/llvm/lib/Target/AArch64/AArch64Features.td
index 5f943d39321f9..d2838d5065d28 100644
--- a/llvm/lib/Target/AArch64/AArch64Features.td
+++ b/llvm/lib/Target/AArch64/AArch64Features.td
@@ -619,6 +619,12 @@ def FeatureSVE_B16MM : ExtensionWithMArch<"sve-b16mm", 
"SVE_B16MM", "FEAT_SVE_B1
 def FeatureF16MM : ExtensionWithMArch<"f16mm", "F16MM", "FEAT_F16MM",
   "Enable Armv9.7-A non-widening half-precision matrix multiply-accumulate", 
[FeatureFullFP16]>;
 
+def FeatureF16F32DOT : ExtensionWithMArch<"f16f32dot", "F16F32DOT", 
"FEAT_F16F32DOT",
+  "Enable Armv9.7-A Advanced SIMD half-precision dot product accumulate to 
single-precision", [FeatureNEON, FeatureFullFP16]>;
+
+def FeatureF16F32MM : ExtensionWithMArch<"f16f32mm", "F16F32MM", 
"FEAT_F16F32MM",
+  "Enable Armv9.7-A Advanced SIMD half-precision matrix multiply-accumulate to 
single-precision", [FeatureNEON, FeatureFullFP16]>;
+
 
//===--===//
 //  Other Features
 
//===--===//
diff --git a/llvm/lib/Target/AArch64/AArch64InstrFormats.td 
b/llvm/lib/Target/AArch64/AArch64InstrFormats.td
index d2f282eadd302..1bc9aea52a265 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrFormats.td
+++ b/llvm/lib/Target/AArch64

[llvm-branch-commits] [llvm] [AArch64][SME] Support split ZPR and PPR area allocation (PR #142392)

2025-10-18 Thread Sander de Smalen via llvm-branch-commits


@@ -2250,25 +2299,50 @@ void AArch64FrameLowering::determineStackHazardSlot(
   bool HasFPRCSRs = any_of(SavedRegs.set_bits(), [](unsigned Reg) {
 return AArch64::FPR64RegClass.contains(Reg) ||
AArch64::FPR128RegClass.contains(Reg) ||
-   AArch64::ZPRRegClass.contains(Reg) ||
-   AArch64::PPRRegClass.contains(Reg);
+   AArch64::ZPRRegClass.contains(Reg);
+  });
+  bool HasPPRCSRs = any_of(SavedRegs.set_bits(), [](unsigned Reg) {
+return AArch64::PPRRegClass.contains(Reg);
   });
   bool HasFPRStackObjects = false;
-  if (!HasFPRCSRs) {
-std::vector FrameObjects(MFI.getObjectIndexEnd());
+  bool HasPPRStackObjects = false;
+  if (!HasFPRCSRs || SplitSVEObjects) {
+enum SlotType : uint8_t {
+  Unknown = 0,
+  ZPRorFPR = 1 << 0,
+  PPR = 1 << 1,
+  GPR = 1 << 2,
+  LLVM_MARK_AS_BITMASK_ENUM(GPR)
+};
+
+// Find stack slots solely used for one kind of register (ZPR, PPR, etc.),
+// based on the kinds of accesses used in the function.
+SmallVector SlotTypes(MFI.getObjectIndexEnd(), 
SlotType::Unknown);
 for (auto &MBB : MF) {
   for (auto &MI : MBB) {
 std::optional FI = getLdStFrameID(MI, MFI);
-if (FI && *FI >= 0 && *FI < (int)FrameObjects.size()) {
-  if (MFI.isScalableStackID(*FI) || AArch64InstrInfo::isFpOrNEON(MI))
-FrameObjects[*FI] |= 2;
-  else
-FrameObjects[*FI] |= 1;
+if (!FI || FI < 0 || FI > int(SlotTypes.size()))
+  continue;
+if (MFI.isScalableStackID(*FI)) {
+  SlotTypes[*FI] |=
+  isPPRAccess(MI) ? SlotType::PPR : SlotType::ZPRorFPR;
+} else {
+  SlotTypes[*FI] |= AArch64InstrInfo::isFpOrNEON(MI)
+? SlotType::ZPRorFPR
+: SlotType::GPR;
 }
   }
 }
-HasFPRStackObjects =
-any_of(FrameObjects, [](unsigned B) { return (B & 3) == 2; });
+
+for (int FI = 0; FI < int(SlotTypes.size()); ++FI) {
+  HasFPRStackObjects |= SlotTypes[FI] == SlotType::ZPRorFPR;
+  // For SplitSVEObjects remember that this stack slot is a predicate, this
+  // will be needed later when determining the frame layout.
+  if (SlotTypes[FI] == SlotType::PPR) {
+MFI.setStackID(FI, TargetStackID::ScalablePredicateVector);

sdesmalen-arm wrote:

Not something I expect to be changed in this PR, but this should be set by 
`AArch64InstrInfo::storeRegToStackSlot` and 
`AArch64InstrInfo::loadRegFromStackSlot`, and `FunctionLoweringInfo::set` 
(which requires modifying `TFI->getStackIDForScalableVectors` to take a 
`Type*`), and for any other code to be modified to correctly deal with it 
either being a `ScalableVector` or a `ScalablePredicateVector`

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


[llvm-branch-commits] [clang] release/21.x: [clang-format] Fix an assertion failure on comment-only config files (#163111) (PR #163919)

2025-10-18 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: None (llvmbot)


Changes

Backport d7921de8027eec19a9d272bf445944973e6758b1 
059f2df74898ff7f394dc8e60f746323499ae32b

Requested by: @owenca

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


2 Files Affected:

- (modified) clang/lib/Format/Format.cpp (+54-38) 
- (modified) clang/unittests/Format/ConfigParseTest.cpp (+13-3) 


``diff
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 161a6c4b47e7f..5bdb810a3925b 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -2132,48 +2132,70 @@ std::error_code 
parseConfiguration(llvm::MemoryBufferRef Config,
   Input >> Styles;
   if (Input.error())
 return Input.error();
+  if (Styles.empty())
+return make_error_code(ParseError::Success);
+
+  const auto StyleCount = Styles.size();
 
-  for (unsigned i = 0; i < Styles.size(); ++i) {
-// Ensures that only the first configuration can skip the Language option.
-if (Styles[i].Language == FormatStyle::LK_None && i != 0)
+  // Start from the second style as (only) the first one may be the default.
+  for (unsigned I = 1; I < StyleCount; ++I) {
+const auto Lang = Styles[I].Language;
+if (Lang == FormatStyle::LK_None)
   return make_error_code(ParseError::Error);
 // Ensure that each language is configured at most once.
-for (unsigned j = 0; j < i; ++j) {
-  if (Styles[i].Language == Styles[j].Language) {
+for (unsigned J = 0; J < I; ++J) {
+  if (Lang == Styles[J].Language) {
 LLVM_DEBUG(llvm::dbgs()
<< "Duplicate languages in the config file on positions "
-   << j << " and " << i << "\n");
+   << J << " and " << I << '\n');
 return make_error_code(ParseError::Error);
   }
 }
   }
-  // Look for a suitable configuration starting from the end, so we can
-  // find the configuration for the specific language first, and the default
-  // configuration (which can only be at slot 0) after it.
-  FormatStyle::FormatStyleSet StyleSet;
-  bool LanguageFound = false;
-  for (const FormatStyle &Style : llvm::reverse(Styles)) {
-const auto Lang = Style.Language;
-if (Lang != FormatStyle::LK_None)
-  StyleSet.Add(Style);
-if (Lang == Language ||
-// For backward compatibility.
-(Lang == FormatStyle::LK_Cpp && Language == FormatStyle::LK_C)) {
-  LanguageFound = true;
-} else if (IsDotHFile && Language == FormatStyle::LK_Cpp &&
-   (Lang == FormatStyle::LK_C || Lang == FormatStyle::LK_ObjC)) {
-  Language = Lang;
-  LanguageFound = true;
+
+  int LanguagePos = -1; // Position of the style for Language.
+  int CppPos = -1;  // Position of the style for C++.
+  int CPos = -1;// Position of the style for C.
+
+  // Search Styles for Language and store the positions of C++ and C styles in
+  // case Language is not found.
+  for (unsigned I = 0; I < StyleCount; ++I) {
+const auto Lang = Styles[I].Language;
+if (Lang == Language) {
+  LanguagePos = I;
+  break;
 }
-  }
-  if (!LanguageFound) {
-if (Styles.empty() || Styles[0].Language != FormatStyle::LK_None)
+if (Lang == FormatStyle::LK_Cpp)
+  CppPos = I;
+else if (Lang == FormatStyle::LK_C)
+  CPos = I;
+  }
+
+  // If Language is not found, use the default style if there is one. 
Otherwise,
+  // use the C style for C++ .h files and for backward compatibility, the C++
+  // style for .c files.
+  if (LanguagePos < 0) {
+if (Styles[0].Language == FormatStyle::LK_None) // Default style.
+  LanguagePos = 0;
+else if (IsDotHFile && Language == FormatStyle::LK_Cpp)
+  LanguagePos = CPos;
+else if (!IsDotHFile && Language == FormatStyle::LK_C)
+  LanguagePos = CppPos;
+if (LanguagePos < 0)
   return make_error_code(ParseError::Unsuitable);
-FormatStyle DefaultStyle = Styles[0];
-DefaultStyle.Language = Language;
-StyleSet.Add(std::move(DefaultStyle));
   }
-  *Style = *StyleSet.Get(Language);
+
+  for (const auto &S : llvm::reverse(llvm::drop_begin(Styles)))
+Style->StyleSet.Add(S);
+
+  *Style = Styles[LanguagePos];
+
+  if (LanguagePos == 0) {
+if (Style->Language == FormatStyle::LK_None) // Default style.
+  Style->Language = Language;
+Style->StyleSet.Add(*Style);
+  }
+
   if (Style->InsertTrailingCommas != FormatStyle::TCS_None &&
   Style->BinPackArguments) {
 // See comment on FormatStyle::TSC_Wrapped.
@@ -2204,14 +2226,8 @@ 
FormatStyle::FormatStyleSet::Get(FormatStyle::LanguageKind Language) const {
   if (!Styles)
 return std::nullopt;
   auto It = Styles->find(Language);
-  if (It == Styles->end()) {
-if (Language != FormatStyle::LK_C)
-  return std::nullopt;
-// For backward compatibility.
-It = Styles->find(FormatStyle::LK_Cpp);
-if (It == Styles->end())
-  return std::nullopt;
-  }
+  if (It == Styles->end())

[llvm-branch-commits] [llvm] [StaticDataLayout] Reconcile data hotness based on PGO counters and data access profiles (PR #163325)

2025-10-18 Thread Mingming Liu via llvm-branch-commits

https://github.com/mingmingl-llvm updated 
https://github.com/llvm/llvm-project/pull/163325

>From ed7439604e857aaf2a7732b7b04f1ceb575036de Mon Sep 17 00:00:00 2001
From: mingmingl 
Date: Mon, 13 Oct 2025 21:22:20 -0700
Subject: [PATCH 1/2] reconcile hotness

---
 .../llvm/Analysis/StaticDataProfileInfo.h | 21 ++--
 llvm/lib/Analysis/StaticDataProfileInfo.cpp   | 59 ++-
 .../X86/global-variable-partition-with-dap.ll | 99 +--
 3 files changed, 163 insertions(+), 16 deletions(-)

diff --git a/llvm/include/llvm/Analysis/StaticDataProfileInfo.h 
b/llvm/include/llvm/Analysis/StaticDataProfileInfo.h
index 70199a904f320..4a97e3370e451 100644
--- a/llvm/include/llvm/Analysis/StaticDataProfileInfo.h
+++ b/llvm/include/llvm/Analysis/StaticDataProfileInfo.h
@@ -58,11 +58,18 @@ class StaticDataProfileInfo {
   LLVM_ABI StaticDataHotness getSectionHotnessUsingProfileCount(
   const Constant *C, const ProfileSummaryInfo *PSI, uint64_t Count) const;
 
+  /// Return the hotness based on section prefix \p SectionPrefix.
+  LLVM_ABI StaticDataHotness
+  getSectionHotnessUsingDAP(std::optional SectionPrefix) const;
+
   /// Return the string representation of the hotness enum \p Hotness.
   LLVM_ABI StringRef hotnessToStr(StaticDataHotness Hotness) const;
 
+  bool EnableDataAccessProf = false;
+
 public:
-  StaticDataProfileInfo() = default;
+  StaticDataProfileInfo(bool EnableDataAccessProf)
+  : EnableDataAccessProf(EnableDataAccessProf) {}
 
   /// If \p Count is not nullopt, add it to the profile count of the constant 
\p
   /// C in a saturating way, and clamp the count to \p getInstrMaxCountValue if
@@ -71,14 +78,10 @@ class StaticDataProfileInfo {
   LLVM_ABI void addConstantProfileCount(const Constant *C,
 std::optional Count);
 
-  /// Return a section prefix for the constant \p C based on its profile count.
-  /// - If a constant doesn't have a counter, return an empty string.
-  /// - Otherwise,
-  ///   - If it has a hot count, return "hot".
-  ///   - If it is seen by unprofiled function, return an empty string.
-  ///   - If it has a cold count, return "unlikely".
-  ///   - Otherwise (e.g. it's used by lukewarm functions), return an empty
-  /// string.
+  /// Given a constant \p C, returns a section prefix.
+  /// If \p C is a global variable, the section prefix is the bigger one
+  /// between its existing section prefix and its use profile count. Otherwise,
+  /// the section prefix is based on its use profile count.
   LLVM_ABI StringRef getConstantSectionPrefix(
   const Constant *C, const ProfileSummaryInfo *PSI) const;
 };
diff --git a/llvm/lib/Analysis/StaticDataProfileInfo.cpp 
b/llvm/lib/Analysis/StaticDataProfileInfo.cpp
index 27f8d216454aa..61e1e6779a2b0 100644
--- a/llvm/lib/Analysis/StaticDataProfileInfo.cpp
+++ b/llvm/lib/Analysis/StaticDataProfileInfo.cpp
@@ -1,10 +1,14 @@
 #include "llvm/Analysis/StaticDataProfileInfo.h"
 #include "llvm/Analysis/ProfileSummaryInfo.h"
 #include "llvm/IR/Constant.h"
+#include "llvm/IR/Constants.h"
 #include "llvm/IR/GlobalVariable.h"
+#include "llvm/IR/Module.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/ProfileData/InstrProf.h"
 
+#define DEBUG_TYPE "static-data-profile-info"
+
 using namespace llvm;
 
 namespace llvm {
@@ -46,6 +50,12 @@ bool IsAnnotationOK(const GlobalVariable &GV) {
 } // namespace memprof
 } // namespace llvm
 
+#ifndef NDEBUG
+static StringRef debugPrintSectionPrefix(StringRef Prefix) {
+  return Prefix.empty() ? "" : Prefix;
+}
+#endif
+
 void StaticDataProfileInfo::addConstantProfileCount(
 const Constant *C, std::optional Count) {
   if (!Count) {
@@ -79,6 +89,18 @@ StaticDataProfileInfo::getSectionHotnessUsingProfileCount(
   return StaticDataHotness::LukewarmOrUnknown;
 }
 
+StaticDataProfileInfo::StaticDataHotness
+StaticDataProfileInfo::getSectionHotnessUsingDAP(
+std::optional MaybeSectionPrefix) const {
+  if (!MaybeSectionPrefix)
+return StaticDataProfileInfo::StaticDataHotness::LukewarmOrUnknown;
+  StringRef Prefix = *MaybeSectionPrefix;
+  assert((Prefix == "hot" || Prefix == "unlikely") &&
+ "Expect section_prefix to be one of hot or unlikely");
+  return Prefix == "hot" ? StaticDataProfileInfo::StaticDataHotness::Hot
+ : StaticDataProfileInfo::StaticDataHotness::Cold;
+}
+
 StringRef StaticDataProfileInfo::hotnessToStr(
 StaticDataProfileInfo::StaticDataHotness Hotness) const {
   switch (Hotness) {
@@ -102,13 +124,48 @@ StaticDataProfileInfo::getConstantProfileCount(const 
Constant *C) const {
 StringRef StaticDataProfileInfo::getConstantSectionPrefix(
 const Constant *C, const ProfileSummaryInfo *PSI) const {
   std::optional Count = getConstantProfileCount(C);
+
+  if (EnableDataAccessProf) {
+// Module flag `HasDataAccessProf` is 1 -> empty section prefix means
+// unknown hotness except for string literals.
+if (const GlobalVariable *GV = dyn_cast(C);
+GV 

  1   2   3   4   5   6   7   8   9   10   >