[llvm-branch-commits] [flang] [mlir] [flang][OpenACC] generate Destroy region to free memory of private and firstprivate if needed (PR #162702)
https://github.com/Renaud-K approved this pull request. Looks good to me. Thank you. https://github.com/llvm/llvm-project/pull/162702 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [llvm][mustache] Support setting delimiters in templates (PR #159187)
@@ -7,9 +7,14 @@ //===--===// #include "llvm/Support/Mustache.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" + +#include ilovepi wrote: I misremembered the convention in LLVM as having separate blocks for system headers, so I added the new line. Easy to correct. The Debug.h file is required for LLVM_DEBUG, though. My own clangd and build aren't giving me any warnings for this file. That may depend on your build config type, though? I'm using RelWithDebInfo + assertions enabled. https://github.com/llvm/llvm-project/pull/159187 ___ 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)
https://github.com/jthackray updated
https://github.com/llvm/llvm-project/pull/163155
>From 465882c0e8f080efe5f08519ecd76bb9722ada19 Mon Sep 17 00:00:00 2001
From: Jonathan Thackray
Date: Mon, 8 Sep 2025 13:23:12 +0100
Subject: [PATCH 1/2] [AArch64][llvm] Armv9.7-A: Add support for FEAT_CMH and
FEAT_LSCP
Add the following instructions to support:
* `FEAT_CMH`: Contention Management Hints extension
* `SHUH` instruction
* `FEAT_LSCP`: Load-acquire and store-release pair extension
* `STLP` instruction
* `LDAP` instruction
* `LDAPP` instruction
as documented here:
*
https://developer.arm.com/documentation/109697/2025_09/2025-Architecture-Extensions
* https://developer.arm.com/documentation/ddi0602/2025-09/
Co-authored-by: Martin Wehking
---
clang/test/Driver/aarch64-v97a.c | 8 ++
.../print-supported-extensions-aarch64.c | 2 +
llvm/lib/Target/AArch64/AArch64Features.td| 5 ++
.../lib/Target/AArch64/AArch64InstrFormats.td | 78 +++
llvm/lib/Target/AArch64/AArch64InstrInfo.td | 19 +
.../Target/AArch64/AArch64SystemOperands.td | 15
.../AArch64/AsmParser/AArch64AsmParser.cpp| 61 +++
.../MCTargetDesc/AArch64InstPrinter.cpp | 11 +++
.../AArch64/MCTargetDesc/AArch64InstPrinter.h | 3 +
.../Target/AArch64/Utils/AArch64BaseInfo.cpp | 7 ++
.../Target/AArch64/Utils/AArch64BaseInfo.h| 8 ++
.../TargetParser/TargetParserTest.cpp | 7 +-
12 files changed, 223 insertions(+), 1 deletion(-)
diff --git a/clang/test/Driver/aarch64-v97a.c b/clang/test/Driver/aarch64-v97a.c
index d34e48ed91954..4a55d44466cc0 100644
--- a/clang/test/Driver/aarch64-v97a.c
+++ b/clang/test/Driver/aarch64-v97a.c
@@ -17,3 +17,11 @@
// GENERICV97A-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu"
"generic" "-target-feature" "+v9.7a"{{.*}}
// = Features supported on aarch64 =
+
+// 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"
+
+// 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"
diff --git a/clang/test/Driver/print-supported-extensions-aarch64.c
b/clang/test/Driver/print-supported-extensions-aarch64.c
index 5c840a60685c6..9928f395866d8 100644
--- a/clang/test/Driver/print-supported-extensions-aarch64.c
+++ b/clang/test/Driver/print-supported-extensions-aarch64.c
@@ -8,6 +8,7 @@
// CHECK-NEXT: bf16FEAT_BF16
Enable BFloat16 Extension
// CHECK-NEXT: brbeFEAT_BRBE
Enable Branch Record Buffer Extension
// CHECK-NEXT: bti FEAT_BTI
Enable Branch Target Identification
+// CHECK-NEXT: cmh FEAT_CMH
Enable Armv9.7-A Contention Management Hints
// CHECK-NEXT: cmpbr FEAT_CMPBR
Enable Armv9.6-A base compare and branch instructions
// CHECK-NEXT: fcmaFEAT_FCMA
Enable Armv8.3-A Floating-point complex number support
// CHECK-NEXT: cpa FEAT_CPA
Enable Armv9.5-A Checked Pointer Arithmetic
@@ -37,6 +38,7 @@
// CHECK-NEXT: ite FEAT_ITE
Enable Armv9.4-A Instrumentation Extension
// CHECK-NEXT: jscvt FEAT_JSCVT
Enable Armv8.3-A JavaScript FP conversion instructions
// CHECK-NEXT: ls64FEAT_LS64, FEAT_LS64_V,
FEAT_LS64_ACCDATA Enable Armv8.7-A LD64B/ST64B Accelerator
Extension
+// CHECK-NEXT: lscpFEAT_LSCP
Enable Armv9.7-A Load-acquire and store-release pair extension
// CHECK-NEXT: lse FEAT_LSE
Enable Armv8.1-A Large System Extension (LSE) atomic instructions
// CHECK-NEXT: lse128 FEAT_LSE128
Enable Armv9.4-A 128-bit Atomic instructions
// CHECK-NEXT: lsfeFEAT_LSFE
Enable Armv9.6-A base Atomic floating-point in-memory
instructio
[llvm-branch-commits] [llvm] [SimplifyCFG][profcheck] Handle branch weights in `simplifySwitchLookup` (PR #161739)
https://github.com/mtrofin edited https://github.com/llvm/llvm-project/pull/161739 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] RegAllocGreedy: Check if copied lanes are live in trySplitAroundHintReg (PR #160424)
https://github.com/arsenm ready_for_review https://github.com/llvm/llvm-project/pull/160424 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [mlir] [flang][OpenACC] generate Destroy region to free memory of private and firstprivate if needed (PR #162702)
llvmbot wrote:
@llvm/pr-subscribers-flang-fir-hlfir
Author: None (jeanPerier)
Changes
This patch extends the MappableTypeInterface to:
- allow genPrivateInit to indicate that a Destroy region will be needed.
- add genPrivateDestroy to generate the destruction code
- Implement both interfaces in FIR
- Update OpenACC lowering to generate the Destroy region when needed using
those interfaces.
Question: I followed the Destroy design from OpenACC.td and also passed the
original value. I am wondering if that it is needed (happy to keep it if you
want it to be very generic).
---
Full diff: https://github.com/llvm/llvm-project/pull/162702.diff
5 Files Affected:
- (modified)
flang/include/flang/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.h (+5-2)
- (modified) flang/lib/Lower/OpenACC.cpp (+26-1)
- (modified) flang/lib/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.cpp
(+58-6)
- (modified) flang/test/Lower/OpenACC/acc-private.f90 (+50)
- (modified) mlir/include/mlir/Dialect/OpenACC/OpenACCTypeInterfaces.td (+35-1)
``diff
diff --git
a/flang/include/flang/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.h
b/flang/include/flang/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.h
index 10853933317f7..f2b2e181c17cc 100644
--- a/flang/include/flang/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.h
+++ b/flang/include/flang/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.h
@@ -53,12 +53,15 @@ struct OpenACCMappableModel
mlir::acc::VariableTypeCategory getTypeCategory(mlir::Type type,
mlir::Value var) const;
+ bool generatePrivateDestroy(mlir::Type type, mlir::OpBuilder &builder,
+ mlir::Location loc, mlir::Value privatized)
const;
+
mlir::Value generatePrivateInit(mlir::Type type, mlir::OpBuilder &builder,
mlir::Location loc,
mlir::TypedValue
var,
llvm::StringRef varName,
- mlir::ValueRange extents,
- mlir::Value initVal) const;
+ mlir::ValueRange extents, mlir::Value
initVal,
+ bool &needsDestroy) const;
};
} // namespace fir::acc
diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index 742f58f3645bf..fb4e12585960b 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -978,15 +978,40 @@ static RecipeOp genRecipeOp(
auto mappableTy = mlir::dyn_cast(ty);
assert(mappableTy &&
"Expected that all variable types are considered mappable");
+ bool needsDestroy = false;
auto retVal = mappableTy.generatePrivateInit(
builder, loc,
mlir::cast>(
initBlock->getArgument(0)),
initName,
initBlock->getArguments().take_back(initBlock->getArguments().size() -
1),
- initValue);
+ initValue, needsDestroy);
mlir::acc::YieldOp::create(builder, loc,
retVal ? retVal : initBlock->getArgument(0));
+ // Create destroy region and generate destruction if requested.
+ if (needsDestroy) {
+llvm::SmallVector destroyArgsTy;
+llvm::SmallVector destroyArgsLoc;
+// original and privatized/reduction value
+destroyArgsTy.push_back(ty);
+destroyArgsTy.push_back(ty);
+destroyArgsLoc.push_back(loc);
+destroyArgsLoc.push_back(loc);
+// Append bounds arguments (if any) in the same order as init region
+if (argsTy.size() > 1) {
+ destroyArgsTy.append(argsTy.begin() + 1, argsTy.end());
+ destroyArgsLoc.insert(destroyArgsLoc.end(), argsTy.size() - 1, loc);
+}
+
+builder.createBlock(&recipe.getDestroyRegion(),
+recipe.getDestroyRegion().end(), destroyArgsTy,
+destroyArgsLoc);
+builder.setInsertionPointToEnd(&recipe.getDestroyRegion().back());
+// Call interface on the privatized/reduction value (2nd argument).
+(void)mappableTy.generatePrivateDestroy(
+builder, loc, recipe.getDestroyRegion().front().getArgument(1));
+mlir::acc::TerminatorOp::create(builder, loc);
+ }
return recipe;
}
diff --git a/flang/lib/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.cpp
b/flang/lib/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.cpp
index 89aa010e7d9a1..46806f9e28911 100644
--- a/flang/lib/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.cpp
+++ b/flang/lib/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.cpp
@@ -548,7 +548,8 @@ template
mlir::Value OpenACCMappableModel::generatePrivateInit(
mlir::Type type, mlir::OpBuilder &builder, mlir::Location loc,
mlir::TypedValue var, llvm::StringRef varName,
-mlir::ValueRange extents, mlir::Value initVal) const {
+mlir::ValueRange extents, mlir::Value initVal, bool &needsDestroy) const {
+ needsDestroy = false;
mlir::Value retVal;
mlir::Type unwra
[llvm-branch-commits] [clang] [AllocToken, Clang] Implement TypeHashPointerSplit mode (PR #156840)
https://github.com/melver updated
https://github.com/llvm/llvm-project/pull/156840
>From 14c75441e84aa32e4f5876598b9a2c59d4ecbe65 Mon Sep 17 00:00:00 2001
From: Marco Elver
Date: Mon, 8 Sep 2025 21:32:21 +0200
Subject: [PATCH 1/2] fixup! fix for incomplete types
Created using spr 1.3.8-beta.1
---
clang/lib/CodeGen/CGExpr.cpp | 7 +++
1 file changed, 7 insertions(+)
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 288b41bc42203..455de644daf00 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1289,6 +1289,7 @@ void CodeGenFunction::EmitAllocTokenHint(llvm::CallBase
*CB,
// Check if QualType contains a pointer. Implements a simple DFS to
// recursively check if a type contains a pointer type.
llvm::SmallPtrSet VisitedRD;
+ bool IncompleteType = false;
auto TypeContainsPtr = [&](auto &&self, QualType T) -> bool {
QualType CanonicalType = T.getCanonicalType();
if (CanonicalType->isPointerType())
@@ -1312,6 +1313,10 @@ void CodeGenFunction::EmitAllocTokenHint(llvm::CallBase
*CB,
return self(self, AT->getElementType());
// The type is a struct, class, or union.
if (const RecordDecl *RD = CanonicalType->getAsRecordDecl()) {
+ if (!RD->isCompleteDefinition()) {
+IncompleteType = true;
+return false;
+ }
if (!VisitedRD.insert(RD).second)
return false; // already visited
// Check all fields.
@@ -1333,6 +1338,8 @@ void CodeGenFunction::EmitAllocTokenHint(llvm::CallBase
*CB,
return false;
};
const bool ContainsPtr = TypeContainsPtr(TypeContainsPtr, AllocType);
+ if (!ContainsPtr && IncompleteType)
+return nullptr;
auto *ContainsPtrC = Builder.getInt1(ContainsPtr);
auto *ContainsPtrMD = MDB.createConstant(ContainsPtrC);
>From 7f706618ddc40375d4085bc2ebe03f02ec78823a Mon Sep 17 00:00:00 2001
From: Marco Elver
Date: Mon, 8 Sep 2025 21:58:01 +0200
Subject: [PATCH 2/2] fixup!
Created using spr 1.3.8-beta.1
---
clang/lib/CodeGen/CGExpr.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 455de644daf00..e7a0e7696e204 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1339,7 +1339,7 @@ void CodeGenFunction::EmitAllocTokenHint(llvm::CallBase
*CB,
};
const bool ContainsPtr = TypeContainsPtr(TypeContainsPtr, AllocType);
if (!ContainsPtr && IncompleteType)
-return nullptr;
+return;
auto *ContainsPtrC = Builder.getInt1(ContainsPtr);
auto *ContainsPtrMD = MDB.createConstant(ContainsPtrC);
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [AllocToken, Clang] Implement TypeHashPointerSplit mode (PR #156840)
@@ -0,0 +1,301 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 vitalybuka wrote: > Short term on review - yes, And even this it mostly resolved by pre-commiting test - on review you see relevant difference. Generated tests FTW! https://github.com/llvm/llvm-project/pull/156840 ___ 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: [NVPTX] Disable relative lookup tables (#159748) (PR #160064)
https://github.com/Artem-B approved this pull request. LGTM. 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] [Clang] Refactor allocation type inference logic (PR #163636)
@@ -0,0 +1,204 @@
+//===--- InferAlloc.cpp - Allocation type inference
---===//
+//
+// 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 allocation-related type inference.
+//
+//===--===//
+
+#include "clang/AST/InferAlloc.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/Type.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "llvm/ADT/SmallPtrSet.h"
+
+namespace clang {
+namespace {
+bool typeContainsPointer(QualType T,
+ llvm::SmallPtrSet &VisitedRD,
+ bool &IncompleteType) {
+ QualType CanonicalType = T.getCanonicalType();
+ if (CanonicalType->isPointerType())
+return true; // base case
+
+ // Look through typedef chain to check for special types.
+ for (QualType CurrentT = T; const auto *TT = CurrentT->getAs();
+ CurrentT = TT->getDecl()->getUnderlyingType()) {
+const IdentifierInfo *II = TT->getDecl()->getIdentifier();
+// Special Case: Syntactically uintptr_t is not a pointer; semantically,
+// however, very likely used as such. Therefore, classify uintptr_t as a
+// pointer, too.
+if (II && II->isStr("uintptr_t"))
+ return true;
+ }
+
+ // The type is an array; check the element type.
+ if (const ArrayType *AT = dyn_cast(CanonicalType))
+return typeContainsPointer(AT->getElementType(), VisitedRD,
IncompleteType);
+ // The type is a struct, class, or union.
+ if (const RecordDecl *RD = CanonicalType->getAsRecordDecl()) {
+if (!RD->isCompleteDefinition()) {
+ IncompleteType = true;
+ return false;
+}
+if (!VisitedRD.insert(RD).second)
+ return false; // already visited
+// Check all fields.
+for (const FieldDecl *Field : RD->fields()) {
+ if (typeContainsPointer(Field->getType(), VisitedRD, IncompleteType))
+return true;
+}
+// For C++ classes, also check base classes.
+if (const CXXRecordDecl *CXXRD = dyn_cast(RD)) {
+ // Polymorphic types require a vptr.
+ if (CXXRD->isDynamicClass())
+return true;
+ for (const CXXBaseSpecifier &Base : CXXRD->bases()) {
+if (typeContainsPointer(Base.getType(), VisitedRD, IncompleteType))
+ return true;
+ }
+}
+ }
+ return false;
+}
+
+/// Infer type from a simple sizeof expression.
+QualType inferTypeFromSizeofExpr(const Expr *E) {
+ const Expr *Arg = E->IgnoreParenImpCasts();
+ if (const auto *UET = dyn_cast(Arg)) {
+if (UET->getKind() == UETT_SizeOf) {
+ if (UET->isArgumentType())
+return UET->getArgumentTypeInfo()->getType();
+ else
+return UET->getArgumentExpr()->getType();
+}
+ }
+ return QualType();
+}
+
+/// Infer type from an arithmetic expression involving a sizeof. For example:
+///
+/// malloc(sizeof(MyType) + padding); // infers 'MyType'
+/// malloc(sizeof(MyType) * 32); // infers 'MyType'
+/// malloc(32 * sizeof(MyType)); // infers 'MyType'
+/// malloc(sizeof(MyType) << 1); // infers 'MyType'
+/// ...
+///
+/// More complex arithmetic expressions are supported, but are a heuristic,
e.g.
+/// when considering allocations for structs with flexible array members:
+///
+/// malloc(sizeof(HasFlexArray) + sizeof(int) * 32); // infers
'HasFlexArray'
+///
+QualType inferPossibleTypeFromArithSizeofExpr(const Expr *E) {
+ const Expr *Arg = E->IgnoreParenImpCasts();
+ // The argument is a lone sizeof expression.
+ if (QualType T = inferTypeFromSizeofExpr(Arg); !T.isNull())
+return T;
+ if (const auto *BO = dyn_cast(Arg)) {
+// Argument is an arithmetic expression. Cover common arithmetic patterns
+// involving sizeof.
+switch (BO->getOpcode()) {
+case BO_Add:
+case BO_Div:
+case BO_Mul:
+case BO_Shl:
+case BO_Shr:
+case BO_Sub:
+ if (QualType T = inferPossibleTypeFromArithSizeofExpr(BO->getLHS());
+ !T.isNull())
+return T;
+ if (QualType T = inferPossibleTypeFromArithSizeofExpr(BO->getRHS());
+ !T.isNull())
+return T;
+ break;
+default:
+ break;
+}
+ }
+ return QualType();
+}
+
+/// If the expression E is a reference to a variable, infer the type from a
+/// variable's initializer if it contains a sizeof. Beware, this is a heuristic
+/// and ignores if a variable is later reassigned. For example:
+///
+/// size_t my_size = sizeof(MyType);
+/// void *x = malloc(my_size); // infers 'MyType'
+///
+QualType inferPossibleTypeFromVarInitSizeofExpr(const Expr *E) {
+ const Expr *Arg = E->IgnoreParenImpCasts();
+ i
[llvm-branch-commits] [llvm] [llvm-remarkutil] Introduce filter command (PR #159784)
https://github.com/tobias-stadler edited https://github.com/llvm/llvm-project/pull/159784 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [llvm][mustache] Support setting delimiters in templates (PR #159187)
@@ -296,57 +304,128 @@ void stripTokenBefore(SmallVectorImpl &Tokens,
size_t Idx,
CurrentToken.setIndentation(Indentation);
}
+struct Tag {
+ enum class Kind {
+None,
+Normal, // {{...}}
+Triple, // {{{...}}}
+ };
+
+ Kind TagKind = Kind::None;
+ StringRef Content; // The content between the delimiters.
+ StringRef FullMatch; // The entire tag, including delimiters.
+ size_t StartPosition = StringRef::npos;
+};
+
+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());
evelez7 wrote:
Should `EndPos` be declared outside of the `if` too?
https://github.com/llvm/llvm-project/pull/159187
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [PowerPC] Implement paddis (PR #161572)
https://github.com/lei137 updated
https://github.com/llvm/llvm-project/pull/161572
>From 012b638031fb72d36525234115f9d7b87d8c98e3 Mon Sep 17 00:00:00 2001
From: Lei Huang
Date: Tue, 30 Sep 2025 18:09:31 +
Subject: [PATCH 1/6] [PowerPC] Implement paddis
---
.../Target/PowerPC/AsmParser/PPCAsmParser.cpp | 4 ++
.../PowerPC/MCTargetDesc/PPCAsmBackend.cpp| 9
.../PowerPC/MCTargetDesc/PPCFixupKinds.h | 6 +++
.../PowerPC/MCTargetDesc/PPCInstPrinter.cpp | 12 +
.../PowerPC/MCTargetDesc/PPCInstPrinter.h | 2 +
.../PowerPC/MCTargetDesc/PPCMCCodeEmitter.cpp | 1 +
llvm/lib/Target/PowerPC/PPCInstrFuture.td | 44 +++
llvm/lib/Target/PowerPC/PPCRegisterInfo.td| 19
.../PowerPC/ppc-encoding-ISAFuture.txt| 6 +++
.../PowerPC/ppc64le-encoding-ISAFuture.txt| 6 +++
llvm/test/MC/PowerPC/ppc-encoding-ISAFuture.s | 8
11 files changed, 117 insertions(+)
diff --git a/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
b/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
index 561a9c51b9cc2..b07f95018ca90 100644
--- a/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
+++ b/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
@@ -365,6 +365,10 @@ struct PPCOperand : public MCParsedAsmOperand {
bool isS16ImmX4() const { return isExtImm<16>(/*Signed*/ true, 4); }
bool isS16ImmX16() const { return isExtImm<16>(/*Signed*/ true, 16); }
bool isS17Imm() const { return isExtImm<17>(/*Signed*/ true, 1); }
+ bool isS32Imm() const {
+// TODO: Is ContextImmediate needed?
+return Kind == Expression || isSImm<32>();
+ }
bool isS34Imm() const {
// Once the PC-Rel ABI is finalized, evaluate whether a 34-bit
// ContextImmediate is needed.
diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
index 04b886ae74993..558351b515a2e 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
@@ -47,6 +47,9 @@ static uint64_t adjustFixupValue(unsigned Kind, uint64_t
Value) {
case PPC::fixup_ppc_half16ds:
case PPC::fixup_ppc_half16dq:
return Value & 0xfffc;
+ case PPC::fixup_ppc_pcrel32:
+ case PPC::fixup_ppc_imm32:
+return Value & 0x;
case PPC::fixup_ppc_pcrel34:
case PPC::fixup_ppc_imm34:
return Value & 0x3;
@@ -71,6 +74,8 @@ static unsigned getFixupKindNumBytes(unsigned Kind) {
case PPC::fixup_ppc_br24abs:
case PPC::fixup_ppc_br24_notoc:
return 4;
+ case PPC::fixup_ppc_pcrel32:
+ case PPC::fixup_ppc_imm32:
case PPC::fixup_ppc_pcrel34:
case PPC::fixup_ppc_imm34:
case FK_Data_8:
@@ -154,6 +159,8 @@ MCFixupKindInfo PPCAsmBackend::getFixupKindInfo(MCFixupKind
Kind) const {
{"fixup_ppc_brcond14abs", 16, 14, 0},
{"fixup_ppc_half16", 0, 16, 0},
{"fixup_ppc_half16ds", 0, 14, 0},
+ {"fixup_ppc_pcrel32", 0, 32, 0},
+ {"fixup_ppc_imm32", 0, 32, 0},
{"fixup_ppc_pcrel34", 0, 34, 0},
{"fixup_ppc_imm34", 0, 34, 0},
{"fixup_ppc_nofixup", 0, 0, 0}};
@@ -166,6 +173,8 @@ MCFixupKindInfo PPCAsmBackend::getFixupKindInfo(MCFixupKind
Kind) const {
{"fixup_ppc_brcond14abs", 2, 14, 0},
{"fixup_ppc_half16", 0, 16, 0},
{"fixup_ppc_half16ds", 2, 14, 0},
+ {"fixup_ppc_pcrel32", 0, 32, 0},
+ {"fixup_ppc_imm32", 0, 32, 0},
{"fixup_ppc_pcrel34", 0, 34, 0},
{"fixup_ppc_imm34", 0, 34, 0},
{"fixup_ppc_nofixup", 0, 0, 0}};
diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCFixupKinds.h
b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCFixupKinds.h
index df0c666f5b113..4164b697649cd 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCFixupKinds.h
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCFixupKinds.h
@@ -40,6 +40,12 @@ enum Fixups {
/// instrs like 'std'.
fixup_ppc_half16ds,
+ // A 32-bit fixup corresponding to PC-relative paddis.
+ fixup_ppc_pcrel32,
+
+ // A 32-bit fixup corresponding to Non-PC-relative paddis.
+ fixup_ppc_imm32,
+
// A 34-bit fixup corresponding to PC-relative paddi.
fixup_ppc_pcrel34,
diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
index b27bc3bd49315..e2afb9378cbf0 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
@@ -430,6 +430,18 @@ void PPCInstPrinter::printS16ImmOperand(const MCInst *MI,
unsigned OpNo,
printOperand(MI, OpNo, STI, O);
}
+void PPCInstPrinter::printS32ImmOperand(const MCInst *MI, unsigned OpNo,
+const MCSubtargetInfo &STI,
+raw_ostream &O) {
+ if (MI->getOperand(OpNo).isImm()) {
+long long Value = MI->getOperand(OpNo).getImm();
+assert(isInt<32>(Value) && "Invalid s32imm argument!");
+O << (long long)Value;
+ }
+ else
+printOperand(MI
[llvm-branch-commits] [libc] [llvm] [libc][math] Refactor exp2f16 implementation to header-only in src/__support/math folder. (PR #161993)
bassiounix wrote: > [!WARNING] > This pull request is not mergeable via GitHub because a downstack PR is > open. Once all requirements are satisfied, merge this PR as a stack href="https://app.graphite.dev/github/pr/llvm/llvm-project/161993?utm_source=stack-comment-downstack-mergeability-warning"; > >on Graphite. > https://graphite.dev/docs/merge-pull-requests";>Learn more * **#161993** https://app.graphite.dev/github/pr/llvm/llvm-project/161993?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/161993?utm_source=stack-comment-view-in-graphite"; target="_blank">(View in Graphite) * **#161992** https://app.graphite.dev/github/pr/llvm/llvm-project/161992?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#161297** https://app.graphite.dev/github/pr/llvm/llvm-project/161297?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#161119** https://app.graphite.dev/github/pr/llvm/llvm-project/161119?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#159897** https://app.graphite.dev/github/pr/llvm/llvm-project/159897?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#154868** https://app.graphite.dev/github/pr/llvm/llvm-project/154868?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#154222** https://app.graphite.dev/github/pr/llvm/llvm-project/154222?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#154215** https://app.graphite.dev/github/pr/llvm/llvm-project/154215?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#153582** https://app.graphite.dev/github/pr/llvm/llvm-project/153582?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#153427** https://app.graphite.dev/github/pr/llvm/llvm-project/153427?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#152871** https://app.graphite.dev/github/pr/llvm/llvm-project/152871?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#152069** https://app.graphite.dev/github/pr/llvm/llvm-project/152069?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#151883** https://app.graphite.dev/github/pr/llvm/llvm-project/151883?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#151846** https://app.graphite.dev/github/pr/llvm/llvm-project/151846?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#151837** https://app.graphite.dev/github/pr/llvm/llvm-project/151837?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#151779** https://app.graphite.dev/github/pr/llvm/llvm-project/151779?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#151399** https://app.graphite.dev/github/pr/llvm/llvm-project/151399?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#151012** https://app.graphite.dev/github/pr/llvm/llvm-project/151012?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#150993** https://app.graphite.dev/github/pr/llvm/llvm-project/150993?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#150968** https://app.graphite.dev/github/pr/llvm/llvm-project/150968?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#150868** h
[llvm-branch-commits] [llvm] [AMDGPU] Update code sequence for CU-mode Release Fences in GFX10+ (PR #161638)
https://github.com/Pierre-vh edited https://github.com/llvm/llvm-project/pull/161638 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lldb] 46d71e8 - Revert "Make SBBreakpoint/SBBreakpointLocation.SetCondition(nullptr) work aga…"
Author: Kazu Hirata
Date: 2025-10-08T13:22:12-07:00
New Revision: 46d71e86fca35b77fc4e0ae2c1d76825aad7dc6f
URL:
https://github.com/llvm/llvm-project/commit/46d71e86fca35b77fc4e0ae2c1d76825aad7dc6f
DIFF:
https://github.com/llvm/llvm-project/commit/46d71e86fca35b77fc4e0ae2c1d76825aad7dc6f.diff
LOG: Revert "Make SBBreakpoint/SBBreakpointLocation.SetCondition(nullptr) work
aga…"
This reverts commit f3e2c20a23b11fbe1149e5d2e3631109af6d3238.
Added:
Modified:
lldb/source/API/SBBreakpoint.cpp
lldb/source/API/SBBreakpointLocation.cpp
lldb/unittests/API/CMakeLists.txt
lldb/unittests/Breakpoint/CMakeLists.txt
Removed:
lldb/unittests/API/SBBreakpointClearConditionTest.cpp
diff --git a/lldb/source/API/SBBreakpoint.cpp
b/lldb/source/API/SBBreakpoint.cpp
index 23dba462478c9..07c0a2ea907ba 100644
--- a/lldb/source/API/SBBreakpoint.cpp
+++ b/lldb/source/API/SBBreakpoint.cpp
@@ -275,11 +275,7 @@ void SBBreakpoint::SetCondition(const char *condition) {
if (bkpt_sp) {
std::lock_guard guard(
bkpt_sp->GetTarget().GetAPIMutex());
-// Treat a null pointer as resetting the condition.
-if (!condition)
- bkpt_sp->SetCondition(StopCondition());
-else
- bkpt_sp->SetCondition(StopCondition(condition));
+bkpt_sp->SetCondition(StopCondition(condition));
}
}
@@ -292,10 +288,7 @@ const char *SBBreakpoint::GetCondition() {
std::lock_guard guard(
bkpt_sp->GetTarget().GetAPIMutex());
- StopCondition cond = bkpt_sp->GetCondition();
- if (!cond)
-return nullptr;
- return ConstString(cond.GetText()).GetCString();
+ return ConstString(bkpt_sp->GetCondition().GetText()).GetCString();
}
void SBBreakpoint::SetAutoContinue(bool auto_continue) {
diff --git a/lldb/source/API/SBBreakpointLocation.cpp
b/lldb/source/API/SBBreakpointLocation.cpp
index 2feaa5c805a15..e786435c4f8af 100644
--- a/lldb/source/API/SBBreakpointLocation.cpp
+++ b/lldb/source/API/SBBreakpointLocation.cpp
@@ -160,11 +160,7 @@ void SBBreakpointLocation::SetCondition(const char
*condition) {
if (loc_sp) {
std::lock_guard guard(
loc_sp->GetTarget().GetAPIMutex());
-// Treat a nullptr as clearing the condition
-if (!condition)
- loc_sp->SetCondition(StopCondition());
-else
- loc_sp->SetCondition(StopCondition(condition));
+loc_sp->SetCondition(StopCondition(condition));
}
}
@@ -177,10 +173,7 @@ const char *SBBreakpointLocation::GetCondition() {
std::lock_guard guard(
loc_sp->GetTarget().GetAPIMutex());
- StopCondition cond = loc_sp->GetCondition();
- if (!cond)
-return nullptr;
- return ConstString(cond.GetText()).GetCString();
+ return ConstString(loc_sp->GetCondition().GetText()).GetCString();
}
void SBBreakpointLocation::SetAutoContinue(bool auto_continue) {
diff --git a/lldb/unittests/API/CMakeLists.txt
b/lldb/unittests/API/CMakeLists.txt
index b86054fb353f7..1e778181435b4 100644
--- a/lldb/unittests/API/CMakeLists.txt
+++ b/lldb/unittests/API/CMakeLists.txt
@@ -2,7 +2,6 @@ add_lldb_unittest(APITests
SBCommandInterpreterTest.cpp
SBLineEntryTest.cpp
SBMutexTest.cpp
- SBBreakpointClearConditionTest.cpp
SBAPITEST
diff --git a/lldb/unittests/API/SBBreakpointClearConditionTest.cpp
b/lldb/unittests/API/SBBreakpointClearConditionTest.cpp
deleted file mode 100644
index 993f7f90d97c0..0
--- a/lldb/unittests/API/SBBreakpointClearConditionTest.cpp
+++ /dev/null
@@ -1,69 +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
-//
-//===--===//
-// Use the umbrella header for -Wdocumentation.
-#include "lldb/API/LLDB.h"
-
-#include "TestingSupport/SubsystemRAII.h"
-#include "lldb/API/SBBreakpoint.h"
-#include "lldb/API/SBBreakpointLocation.h"
-#include "lldb/API/SBDebugger.h"
-#include "lldb/API/SBTarget.h"
-#include "gtest/gtest.h"
-#include
-#include
-
-using namespace lldb_private;
-using namespace lldb;
-
-class BreakpointClearConditionTest : public ::testing::Test {
-public:
- void SetUp() override {
-m_sb_debugger = SBDebugger::Create(/*source_init_files=*/false);
- };
-
- void TearDown() override { SBDebugger::Destroy(m_sb_debugger); }
- SBDebugger m_sb_debugger;
- SubsystemRAII subsystems;
-};
-
-template void test_condition(T sb_object) {
- const char *in_cond_str = "Here is a condition";
- sb_object.SetCondition(in_cond_str);
- // Make sure we set the condition correctly:
- const char *out_cond_str = sb_object.GetCondition();
- EXPECT_STREQ(in_cond_str, out_cond_str);
- // Now unset it by passing in nullptr and make sure that works:
- const char *empty_tokens[
[llvm-branch-commits] [llvm] [AArch64] (NFC) Tidy up alignment/formatting in AArch64/AArch64InstrInfo.td (PR #163645)
https://github.com/jthackray updated https://github.com/llvm/llvm-project/pull/163645 >From 9adeac7e8b25f6e8ec47c5d71d1b2fe9ee70ae9d 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] [flang] [flang][OpenMP] Dump requirement clauses/flags in WithOmpDeclarative (PR #163450)
https://github.com/kparzysz updated
https://github.com/llvm/llvm-project/pull/163450
>From 639f10efafc662f28644f71301f40f8c51012cf8 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek
Date: Tue, 14 Oct 2025 15:02:19 -0500
Subject: [PATCH 1/3] [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)
>From f3532248a2569e21ad476d66bd302dfb5d028185 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek
Date: Tue, 14 Oct 2025 15:58:14 -0500
Subject: [PATCH 2/3] format
---
flang/lib/Semantics/symbol.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/flang/lib/Semantics/symbol.cpp b/flang/lib/Semantics/symbol.cpp
index a5f9706a73cf7..2a0ac80d28629 100644
--- a/flang/lib/Semantics/symbol.cpp
+++ b/flang/lib/Semantics/symbol.cpp
@@ -176,7 +176,7 @@ llvm::raw_ostream &operator<<(
os << x;
}
}
- os << static_cast(x);
+ os << static_cast(x);
return os;
}
@@ -608,7 +608,7 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const
Details &details) {
common::visitors{
[&](const UnknownDetails &) {},
[&](const MainProgramDetails &x) {
-os << static_cast(x);
+os << static_cast(x);
},
[&](cons
[llvm-branch-commits] [llvm] [BOLT] Gadget scanner: make use of C++17 features and LLVM helpers (PR #141665)
https://github.com/atrosinenko updated
https://github.com/llvm/llvm-project/pull/141665
>From 12320f045000bae8bedc4783b4e82429c57d0998 Mon Sep 17 00:00:00 2001
From: Anatoly Trosinenko
Date: Tue, 27 May 2025 21:06:03 +0300
Subject: [PATCH] [BOLT] Gadget scanner: make use of C++17 features and LLVM
helpers
Perform trivial syntactical cleanups:
* make use of structured binding declarations
* use LLVM utility functions when appropriate
* omit braces around single expression inside single-line LLVM_DEBUG()
This patch is NFC aside from minor debug output changes.
---
bolt/lib/Passes/PAuthGadgetScanner.cpp| 64 +--
.../AArch64/gs-pauth-debug-output.s | 14 ++--
2 files changed, 37 insertions(+), 41 deletions(-)
diff --git a/bolt/lib/Passes/PAuthGadgetScanner.cpp
b/bolt/lib/Passes/PAuthGadgetScanner.cpp
index 3acc6654115f4..b032561a43274 100644
--- a/bolt/lib/Passes/PAuthGadgetScanner.cpp
+++ b/bolt/lib/Passes/PAuthGadgetScanner.cpp
@@ -88,8 +88,8 @@ class TrackedRegisters {
TrackedRegisters(ArrayRef RegsToTrack)
: Registers(RegsToTrack),
RegToIndexMapping(getMappingSize(RegsToTrack), NoIndex) {
-for (unsigned I = 0; I < RegsToTrack.size(); ++I)
- RegToIndexMapping[RegsToTrack[I]] = I;
+for (auto [MappedIndex, Reg] : llvm::enumerate(RegsToTrack))
+ RegToIndexMapping[Reg] = MappedIndex;
}
ArrayRef getRegisters() const { return Registers; }
@@ -203,9 +203,9 @@ struct SrcState {
SafeToDerefRegs &= StateIn.SafeToDerefRegs;
TrustedRegs &= StateIn.TrustedRegs;
-for (unsigned I = 0; I < LastInstWritingReg.size(); ++I)
- for (const MCInst *J : StateIn.LastInstWritingReg[I])
-LastInstWritingReg[I].insert(J);
+for (auto [ThisSet, OtherSet] :
+ llvm::zip_equal(LastInstWritingReg, StateIn.LastInstWritingReg))
+ ThisSet.insert_range(OtherSet);
return *this;
}
@@ -224,11 +224,9 @@ struct SrcState {
static void printInstsShort(raw_ostream &OS,
ArrayRef Insts) {
OS << "Insts: ";
- for (unsigned I = 0; I < Insts.size(); ++I) {
-auto &Set = Insts[I];
+ for (auto [I, PtrSet] : llvm::enumerate(Insts)) {
OS << "[" << I << "](";
-for (const MCInst *MCInstP : Set)
- OS << MCInstP << " ";
+interleave(PtrSet, OS, " ");
OS << ")";
}
}
@@ -416,8 +414,9 @@ class SrcSafetyAnalysis {
// ... an address can be updated in a safe manner, producing the result
// which is as trusted as the input address.
if (auto DstAndSrc = BC.MIB->analyzeAddressArithmeticsForPtrAuth(Point)) {
- if (Cur.SafeToDerefRegs[DstAndSrc->second])
-Regs.push_back(DstAndSrc->first);
+ auto [DstReg, SrcReg] = *DstAndSrc;
+ if (Cur.SafeToDerefRegs[SrcReg])
+Regs.push_back(DstReg);
}
// Make sure explicit checker sequence keeps register safe-to-dereference
@@ -469,8 +468,9 @@ class SrcSafetyAnalysis {
// ... an address can be updated in a safe manner, producing the result
// which is as trusted as the input address.
if (auto DstAndSrc = BC.MIB->analyzeAddressArithmeticsForPtrAuth(Point)) {
- if (Cur.TrustedRegs[DstAndSrc->second])
-Regs.push_back(DstAndSrc->first);
+ auto [DstReg, SrcReg] = *DstAndSrc;
+ if (Cur.TrustedRegs[SrcReg])
+Regs.push_back(DstReg);
}
return Regs;
@@ -865,9 +865,9 @@ struct DstState {
return (*this = StateIn);
CannotEscapeUnchecked &= StateIn.CannotEscapeUnchecked;
-for (unsigned I = 0; I < FirstInstLeakingReg.size(); ++I)
- for (const MCInst *J : StateIn.FirstInstLeakingReg[I])
-FirstInstLeakingReg[I].insert(J);
+for (auto [ThisSet, OtherSet] :
+ llvm::zip_equal(FirstInstLeakingReg, StateIn.FirstInstLeakingReg))
+ ThisSet.insert_range(OtherSet);
return *this;
}
@@ -1033,8 +1033,7 @@ class DstSafetyAnalysis {
// ... an address can be updated in a safe manner, or
if (auto DstAndSrc = BC.MIB->analyzeAddressArithmeticsForPtrAuth(Inst)) {
- MCPhysReg DstReg, SrcReg;
- std::tie(DstReg, SrcReg) = *DstAndSrc;
+ auto [DstReg, SrcReg] = *DstAndSrc;
// Note that *all* registers containing the derived values must be safe,
// both source and destination ones. No temporaries are supported at now.
if (Cur.CannotEscapeUnchecked[SrcReg] &&
@@ -1074,7 +1073,7 @@ class DstSafetyAnalysis {
// If this instruction terminates the program immediately, no
// authentication oracles are possible past this point.
if (BC.MIB->isTrap(Point)) {
- LLVM_DEBUG({ traceInst(BC, "Trap instruction found", Point); });
+ LLVM_DEBUG(traceInst(BC, "Trap instruction found", Point));
DstState Next(NumRegs, RegsToTrackInstsFor.getNumTrackedRegisters());
Next.CannotEscapeUnchecked.set();
return Next;
@@ -1249,7 +1248,7 @@ class CFGUnawareDstSafetyAnalysis : public
DstSafetyAnalysis,
// starting to analyze Inst.
[llvm-branch-commits] [AllocToken, Clang] Infer type hints from sizeof expressions and casts (PR #156841)
@@ -10,7 +10,7 @@ typedef __typeof(sizeof(int)) size_t;
void *malloc(size_t size);
// CHECK-LABEL: @test_malloc(
-// CHECK: call{{.*}} ptr @__alloc_token_malloc(i64 noundef 4, i64 0)
+// CHECK: call{{.*}} ptr @__alloc_token_malloc(i64 noundef 4, i64
2689373973731826898){{.*}} !alloc_token [[META_INT:![0-9]+]]
melver wrote:
We're using a stable hash, so this should always be the same.
Or do you mean to be able to refer to the same token via e.g. `[[TOKEN_INT]]`?
Though we still want to check the exact value, given it's meant to be stable.
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] [mlir] [mlir][omp] Improve canonloop/iv naming (PR #159773)
https://github.com/Meinersbur edited https://github.com/llvm/llvm-project/pull/159773 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 96782aa - Revert "[PATCH] offload-tunnel-cmake with proper escape (#161552)"
Author: ronlieb
Date: 2025-10-02T16:10:21-04:00
New Revision: 96782aa56ad35494fe21ad5f28dd1557e230fb4d
URL:
https://github.com/llvm/llvm-project/commit/96782aa56ad35494fe21ad5f28dd1557e230fb4d
DIFF:
https://github.com/llvm/llvm-project/commit/96782aa56ad35494fe21ad5f28dd1557e230fb4d.diff
LOG: Revert "[PATCH] offload-tunnel-cmake with proper escape (#161552)"
This reverts commit 3f3a20f654f913f7e251e3bf4bd5a63e73e5571a.
Added:
Modified:
llvm/runtimes/CMakeLists.txt
Removed:
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 6f98eaee241bc..839929204c064 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -507,14 +507,10 @@ if(build_runtimes)
endif()
# Forward user-provived system configuration to runtimes for requirement
introspection.
- # CMAKE_PREFIX_PATH is the search path for CMake packages. In order to pass
through
- # the command line interface, the CMake semicolon separator needs to be
replaced
- # with $
+ # CMAKE_PREFIX_PATH is the search path for CMake packages.
if(CMAKE_PREFIX_PATH)
-string(JOIN "$" escaped_cmake_prefix_path ${CMAKE_PREFIX_PATH})
-list(APPEND extra_cmake_args
"-DCMAKE_PREFIX_PATH=${escaped_cmake_prefix_path}")
+list(APPEND extra_cmake_args "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}")
endif()
-
# CMAKE_PROGRAM_PATH is the search path for executables such as python.
if(CMAKE_PROGRAM_PATH)
list(APPEND extra_cmake_args "-DCMAKE_PROGRAM_PATH=${CMAKE_PROGRAM_PATH}")
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [AllocToken] Make token mode a pass parameter (PR #163634)
https://github.com/melver updated https://github.com/llvm/llvm-project/pull/163634 ___ 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: [MachinePipeliner] Limit the number of stores in BB (#154940) (PR #162639)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/162639 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [llvm][mustache] Simplify debug logging (PR #159193)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/159193 ___ 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)
llvmbot wrote:
@llvm/pr-subscribers-libc
Author: Muhammad Bassiouni (bassiounix)
Changes
Part of
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/162019.diff
9 Files Affected:
- (modified) libc/shared/math.h (+1)
- (added) libc/shared/math/exp2m1f16.h (+29)
- (modified) libc/src/__support/math/CMakeLists.txt (+18)
- (added) libc/src/__support/math/exp2m1f16.h (+180)
- (modified) libc/src/math/generic/CMakeLists.txt (+1-13)
- (modified) libc/src/math/generic/exp2m1f16.cpp (+2-153)
- (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 (+17-1)
``diff
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},
+ // x = 0x1.4fcp-12, exp2m1f16(x) = 0x1.d14p-13 (RZ)
+ {0x0d3fU, 0x0b45U, 1U, 0U, 1U},
+ // x = 0x1.63p-11, exp2m1f16(x) = 0x1.ec4p-12 (RZ)
+
[llvm-branch-commits] [llvm] [AllocToken] Refactor stateless token calculation into Support (PR #163633)
@@ -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::Random:
+// Stateful modes cannot be implemented as a pure function.
+return std::nullopt;
+
+ case AllocTokenMode::TypeHash: {
fmayer wrote:
unnecessary braces
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] [clang] release/21.x: [clang][PAC] Don't try to diagnose use of pointer auth on dependent types #159505 (#159859) (PR #161288)
github-actions[bot] wrote: @ojhunt (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/161288 ___ 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)
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/8] 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] (NFC) Tidy up alignment/formatting in AArch64/AArch64InstrInfo.td (PR #163645)
https://github.com/jthackray edited https://github.com/llvm/llvm-project/pull/163645 ___ 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)
@@ -289,46 +296,47 @@ template
_LIBCPP_HIDE_FROM_ABI void __tree_balance_after_insert(_NodePtr __root,
_NodePtr __x) _NOEXCEPT {
_LIBCPP_ASSERT_INTERNAL(__root != nullptr, "Root of the tree shouldn't be
null");
_LIBCPP_ASSERT_INTERNAL(__x != nullptr, "Can't attach null node to a leaf");
- __x->__is_black_ = __x == __root;
- while (__x != __root && !__x->__parent_unsafe()->__is_black_) {
-// __x->__parent_ != __root because __x->__parent_->__is_black == false
+ using enum __tree_color;
ldionne wrote:
```suggestion
```
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] [flang] [flang][OpenMP] Use OmpDirectiveSpecification in REQUIRES (PR #160595)
https://github.com/kparzysz created
https://github.com/llvm/llvm-project/pull/160595
None
>From 0434e253c1174249f387825527c5cde7414e4d40 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek
Date: Wed, 24 Sep 2025 15:11:43 -0500
Subject: [PATCH] [flang][OpenMP] Use OmpDirectiveSpecification in REQUIRES
---
flang/include/flang/Parser/openmp-utils.h | 4 +--
flang/include/flang/Parser/parse-tree.h | 3 +-
flang/lib/Parser/openmp-parsers.cpp | 4 ++-
flang/lib/Parser/unparse.cpp| 6 ++--
flang/lib/Semantics/check-omp-structure.cpp | 11 ++-
flang/lib/Semantics/resolve-directives.cpp | 2 +-
flang/test/Parser/OpenMP/requires.f90 | 33 +
7 files changed, 45 insertions(+), 18 deletions(-)
create mode 100644 flang/test/Parser/OpenMP/requires.f90
diff --git a/flang/include/flang/Parser/openmp-utils.h
b/flang/include/flang/Parser/openmp-utils.h
index 77c31b939e522..b8f3559097750 100644
--- a/flang/include/flang/Parser/openmp-utils.h
+++ b/flang/include/flang/Parser/openmp-utils.h
@@ -41,7 +41,6 @@ struct ConstructId {
MAKE_CONSTR_ID(OpenMPDeclarativeAllocate, D::OMPD_allocate);
MAKE_CONSTR_ID(OpenMPDeclareReductionConstruct, D::OMPD_declare_reduction);
MAKE_CONSTR_ID(OpenMPExecutableAllocate, D::OMPD_allocate);
-MAKE_CONSTR_ID(OpenMPRequiresConstruct, D::OMPD_requires);
#undef MAKE_CONSTR_ID
@@ -94,8 +93,7 @@ struct DirectiveNameScope {
return std::get(x.t).DirName();
} else if constexpr (std::is_same_v ||
std::is_same_v ||
- std::is_same_v ||
- std::is_same_v) {
+ std::is_same_v) {
return MakeName(std::get(x.t).source, ConstructId::id);
} else {
return GetFromTuple(
diff --git a/flang/include/flang/Parser/parse-tree.h
b/flang/include/flang/Parser/parse-tree.h
index bd55166eb9f80..8b23189bc1e90 100644
--- a/flang/include/flang/Parser/parse-tree.h
+++ b/flang/include/flang/Parser/parse-tree.h
@@ -4991,9 +4991,8 @@ struct OpenMPGroupprivate {
// 2.4 requires -> REQUIRES requires-clause[ [ [,] requires-clause]...]
struct OpenMPRequiresConstruct {
- TUPLE_CLASS_BOILERPLATE(OpenMPRequiresConstruct);
+ WRAPPER_CLASS_BOILERPLATE(OpenMPRequiresConstruct,
OmpDirectiveSpecification);
CharBlock source;
- std::tuple t;
};
// 2.15.2 threadprivate -> THREADPRIVATE (variable-name-list)
diff --git a/flang/lib/Parser/openmp-parsers.cpp
b/flang/lib/Parser/openmp-parsers.cpp
index 5fd3c1768a17f..ea09fe04f07a0 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -1836,7 +1836,9 @@ TYPE_PARSER(sourced( //
// 2.4 Requires construct
TYPE_PARSER(sourced(construct(
-verbatim("REQUIRES"_tok), Parser{})))
+predicated(OmpDirectiveNameParser{},
+IsDirective(llvm::omp::Directive::OMPD_requires)) >=
+Parser{})))
// 2.15.2 Threadprivate directive
TYPE_PARSER(sourced( //
diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index 9812a656092ac..0fbd347e91b18 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -2594,10 +2594,10 @@ class UnparseVisitor {
Put("\n");
EndOpenMP();
}
- void Unparse(const OpenMPRequiresConstruct &y) {
+ void Unparse(const OpenMPRequiresConstruct &x) {
BeginOpenMP();
-Word("!$OMP REQUIRES ");
-Walk(std::get(y.t));
+Word("!$OMP ");
+Walk(x.v);
Put("\n");
EndOpenMP();
}
diff --git a/flang/lib/Semantics/check-omp-structure.cpp
b/flang/lib/Semantics/check-omp-structure.cpp
index 6538e0b794791..223523f2a46ff 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -624,10 +624,6 @@ template struct
DirectiveSpellingVisitor {
checker_(x.v.DirName().source, Directive::OMPD_groupprivate);
return false;
}
- bool Pre(const parser::OpenMPRequiresConstruct &x) {
-checker_(std::get(x.t).source, Directive::OMPD_requires);
-return false;
- }
bool Pre(const parser::OmpBeginDirective &x) {
checker_(x.DirName().source, x.DirId());
return false;
@@ -1498,14 +1494,13 @@ void OmpStructureChecker::Leave(const
parser::OpenMPDepobjConstruct &x) {
}
void OmpStructureChecker::Enter(const parser::OpenMPRequiresConstruct &x) {
- const auto &dir{std::get(x.t)};
- PushContextAndClauseSets(dir.source, llvm::omp::Directive::OMPD_requires);
+ const auto &dirName{x.v.DirName()};
+ PushContextAndClauseSets(dirName.source, dirName.v);
if (visitedAtomicSource_.empty()) {
return;
}
- const auto &clauseList{std::get(x.t)};
- for (const parser::OmpClause &clause : clauseList.v) {
+ for (const parser::OmpClause &clause : x.v.Clauses().v) {
llvm::omp::Clause id{clause.Id()};
if (id == llvm::omp::Clause::OMPC_atomic_default_mem_order) {
parser::MessageFormattedText txt(
diff --git a/flang/lib/Semantics/resolve-directives.cpp
b/flang/lib/Semantics/resolve-directives.cpp
index 7ef211c8b428c..a4c8922
[llvm-branch-commits] [flang] [llvm] [openmp] [Flang] Add standalone tile support (PR #160298)
https://github.com/Meinersbur edited https://github.com/llvm/llvm-project/pull/160298 ___ 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: [SPARC] Prevent meta instructions from being inserted into delay slots (#161111) (PR #161937)
github-actions[bot] wrote: @brad0 (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/161937 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] release/21.x: [compiler-rt][sanitizer] fix msghdr for musl (PR #159551)
https://github.com/deaklajos updated https://github.com/llvm/llvm-project/pull/159551 From 60b10f56319e62415c61e69c67f9c713ed81172e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?De=C3=A1k=20Lajos?= <[email protected]> Date: Tue, 22 Jul 2025 20:31:28 +0200 Subject: [PATCH] [compiler-rt][sanitizer] fix msghdr for musl (#136195) Ran into the issue on Alpine when building with TSAN that `__sanitizer_msghdr` and the `msghdr` provided by musl did not match. This caused lots of tsan reports and an eventual termination of the application by the oom during a `sendmsg`. --- .../sanitizer_platform_limits_posix.h | 24 +++ 1 file changed, 24 insertions(+) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h index f118d53f0df80..24966523f3a02 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h @@ -478,6 +478,30 @@ struct __sanitizer_cmsghdr { int cmsg_level; int cmsg_type; }; +# elif SANITIZER_MUSL +struct __sanitizer_msghdr { + void *msg_name; + unsigned msg_namelen; + struct __sanitizer_iovec *msg_iov; + int msg_iovlen; +#if SANITIZER_WORDSIZE == 64 + int __pad1; +#endif + void *msg_control; + unsigned msg_controllen; +#if SANITIZER_WORDSIZE == 64 + int __pad2; +#endif + int msg_flags; +}; +struct __sanitizer_cmsghdr { + unsigned cmsg_len; +#if SANITIZER_WORDSIZE == 64 + int __pad1; +#endif + int cmsg_level; + int cmsg_type; +}; # else // In POSIX, int msg_iovlen; socklen_t msg_controllen; socklen_t cmsg_len; but // many implementations don't conform to the standard. ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] Utils: Inhibit load/store folding through phis for llvm.protected.field.ptr. (PR #151649)
https://github.com/pcc updated https://github.com/llvm/llvm-project/pull/151649 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [Clang] Move AllocToken frontend options to LangOptions (PR #163635)
https://github.com/melver edited https://github.com/llvm/llvm-project/pull/163635 ___ 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)
@@ -8,15 +8,19 @@ 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, %L1), ptr inttoptr (i32 1 to ptr), ptr inttoptr (i32
1 to ptr), ptr inttoptr (i32 1 to ptr), ptr inttoptr (i32 1 to ptr), ptr
inttoptr (i32 1 to ptr), ptr inttoptr (i32 1 to ptr), ptr inttoptr (i32 1 to
ptr), ptr inttoptr (i32 1 to ptr), ptr inttoptr (i32 1 to ptr)]
+; CHECK: @xblkx.bbs = internal unnamed_addr constant [9 x ptr] [ptr
blockaddress(@indbrtest7, %xlab4x), ptr blockaddress(@indbrtest7, %xlab4x), ptr
blockaddress(@indbrtest7, %v2j), ptr blockaddress(@indbrtest7, %xlab4x), ptr
blockaddress(@indbrtest7, %xlab4x), ptr blockaddress(@indbrtest7, %xlab4x), ptr
blockaddress(@indbrtest7, %xlab4x), ptr blockaddress(@indbrtest7, %xlab4x), ptr
blockaddress(@indbrtest7, %v2j)]
+;.
+define void @indbrtest0(ptr %P, ptr %Q) !prof !0 {
; CHECK-LABEL: @indbrtest0(
; CHECK-NEXT: entry:
; CHECK-NEXT:store ptr blockaddress(@indbrtest0, [[BB0:%.*]]), ptr
[[P:%.*]], align 8
; CHECK-NEXT:store ptr blockaddress(@indbrtest0, [[BB1:%.*]]), ptr [[P]],
align 8
; CHECK-NEXT:store ptr blockaddress(@indbrtest0, [[BB2:%.*]]), ptr [[P]],
align 8
; CHECK-NEXT:call void @foo()
; CHECK-NEXT:[[T:%.*]] = load ptr, ptr [[Q:%.*]], align 8
-; CHECK-NEXT:indirectbr ptr [[T]], [label [[BB0]], label [[BB1]], label
%BB2]
+; CHECK-NEXT:indirectbr ptr [[T]], [label [[BB0]], label [[BB1]], label
%BB2], !prof [[PROF1:![0-9]+]]
alanzhao1 wrote:
Shouldn't the branch weights be summed grouped by destination instead of
dropped here?
If I understand correctly, the purpose of this transformation is to remove
redundant labels in indirectbr statements. As an example,
```
indirectbr ptr %foo [label %L1, label %L2, label %L1]
```
is simplified to
```
indirectbr ptr %foo [label %L1, label %L2]
```
Now assume in the original statement the weights are 1, 1, and 1. This implies
that `%L1` is twice as likely to be branched to compared to `%L2`. The
simplification removes redundant labels, but since nothing else gets changed,
shouldn't the branch weights be 2 and 1 instead of 1 and 1 as the instruction
is identical?
https://github.com/llvm/llvm-project/pull/161747
___
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: [NVPTX] Disable relative lookup tables (#159748) (PR #160064)
https://github.com/dyung closed 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] [BOLT] Gadget scanner: make use of C++17 features and LLVM helpers (PR #141665)
https://github.com/atrosinenko updated
https://github.com/llvm/llvm-project/pull/141665
>From 82b3b3a7e04e6e3dc9c2d0d86b181eef43325d7c Mon Sep 17 00:00:00 2001
From: Anatoly Trosinenko
Date: Tue, 27 May 2025 21:06:03 +0300
Subject: [PATCH] [BOLT] Gadget scanner: make use of C++17 features and LLVM
helpers
Perform trivial syntactical cleanups:
* make use of structured binding declarations
* use LLVM utility functions when appropriate
* omit braces around single expression inside single-line LLVM_DEBUG()
This patch is NFC aside from minor debug output changes.
---
bolt/lib/Passes/PAuthGadgetScanner.cpp| 60 +--
.../AArch64/gs-pauth-debug-output.s | 14 ++---
2 files changed, 35 insertions(+), 39 deletions(-)
diff --git a/bolt/lib/Passes/PAuthGadgetScanner.cpp
b/bolt/lib/Passes/PAuthGadgetScanner.cpp
index 9d22d3c8c6cd7..01b350b2f11fe 100644
--- a/bolt/lib/Passes/PAuthGadgetScanner.cpp
+++ b/bolt/lib/Passes/PAuthGadgetScanner.cpp
@@ -88,8 +88,8 @@ class TrackedRegisters {
TrackedRegisters(ArrayRef RegsToTrack)
: Registers(RegsToTrack),
RegToIndexMapping(getMappingSize(RegsToTrack), NoIndex) {
-for (unsigned I = 0; I < RegsToTrack.size(); ++I)
- RegToIndexMapping[RegsToTrack[I]] = I;
+for (auto [MappedIndex, Reg] : llvm::enumerate(RegsToTrack))
+ RegToIndexMapping[Reg] = MappedIndex;
}
ArrayRef getRegisters() const { return Registers; }
@@ -203,9 +203,9 @@ struct SrcState {
SafeToDerefRegs &= StateIn.SafeToDerefRegs;
TrustedRegs &= StateIn.TrustedRegs;
-for (unsigned I = 0; I < LastInstWritingReg.size(); ++I)
- for (const MCInst *J : StateIn.LastInstWritingReg[I])
-LastInstWritingReg[I].insert(J);
+for (auto [ThisSet, OtherSet] :
+ llvm::zip_equal(LastInstWritingReg, StateIn.LastInstWritingReg))
+ ThisSet.insert_range(OtherSet);
return *this;
}
@@ -224,11 +224,9 @@ struct SrcState {
static void printInstsShort(raw_ostream &OS,
ArrayRef Insts) {
OS << "Insts: ";
- for (unsigned I = 0; I < Insts.size(); ++I) {
-auto &Set = Insts[I];
+ for (auto [I, PtrSet] : llvm::enumerate(Insts)) {
OS << "[" << I << "](";
-for (const MCInst *MCInstP : Set)
- OS << MCInstP << " ";
+interleave(PtrSet, OS, " ");
OS << ")";
}
}
@@ -416,8 +414,9 @@ class SrcSafetyAnalysis {
// ... an address can be updated in a safe manner, producing the result
// which is as trusted as the input address.
if (auto DstAndSrc = BC.MIB->analyzeAddressArithmeticsForPtrAuth(Point)) {
- if (Cur.SafeToDerefRegs[DstAndSrc->second])
-Regs.push_back(DstAndSrc->first);
+ auto [DstReg, SrcReg] = *DstAndSrc;
+ if (Cur.SafeToDerefRegs[SrcReg])
+Regs.push_back(DstReg);
}
// Make sure explicit checker sequence keeps register safe-to-dereference
@@ -469,8 +468,9 @@ class SrcSafetyAnalysis {
// ... an address can be updated in a safe manner, producing the result
// which is as trusted as the input address.
if (auto DstAndSrc = BC.MIB->analyzeAddressArithmeticsForPtrAuth(Point)) {
- if (Cur.TrustedRegs[DstAndSrc->second])
-Regs.push_back(DstAndSrc->first);
+ auto [DstReg, SrcReg] = *DstAndSrc;
+ if (Cur.TrustedRegs[SrcReg])
+Regs.push_back(DstReg);
}
return Regs;
@@ -865,9 +865,9 @@ struct DstState {
return (*this = StateIn);
CannotEscapeUnchecked &= StateIn.CannotEscapeUnchecked;
-for (unsigned I = 0; I < FirstInstLeakingReg.size(); ++I)
- for (const MCInst *J : StateIn.FirstInstLeakingReg[I])
-FirstInstLeakingReg[I].insert(J);
+for (auto [ThisSet, OtherSet] :
+ llvm::zip_equal(FirstInstLeakingReg, StateIn.FirstInstLeakingReg))
+ ThisSet.insert_range(OtherSet);
return *this;
}
@@ -1033,8 +1033,7 @@ class DstSafetyAnalysis {
// ... an address can be updated in a safe manner, or
if (auto DstAndSrc = BC.MIB->analyzeAddressArithmeticsForPtrAuth(Inst)) {
- MCPhysReg DstReg, SrcReg;
- std::tie(DstReg, SrcReg) = *DstAndSrc;
+ auto [DstReg, SrcReg] = *DstAndSrc;
// Note that *all* registers containing the derived values must be safe,
// both source and destination ones. No temporaries are supported at now.
if (Cur.CannotEscapeUnchecked[SrcReg] &&
@@ -1074,7 +1073,7 @@ class DstSafetyAnalysis {
// If this instruction terminates the program immediately, no
// authentication oracles are possible past this point.
if (BC.MIB->isTrap(Point)) {
- LLVM_DEBUG({ traceInst(BC, "Trap instruction found", Point); });
+ LLVM_DEBUG(traceInst(BC, "Trap instruction found", Point));
DstState Next(NumRegs, RegsToTrackInstsFor.getNumTrackedRegisters());
Next.CannotEscapeUnchecked.set();
return Next;
@@ -1249,7 +1248,7 @@ class CFGUnawareDstSafetyAnalysis : public
DstSafetyAnalysis,
// starting to analyze Inst.
[llvm-branch-commits] [clang] [llvm] release/21.x: [RISCV] Reduce RISCV code generation build time (PR #158164)
https://github.com/Steelskin reopened https://github.com/llvm/llvm-project/pull/158164 ___ 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)
https://github.com/melver created https://github.com/llvm/llvm-project/pull/163639 Implement the constexpr evaluation for `__builtin_infer_alloc_token()` in Clang's constant expression evaluators (both in ExprConstant and the new bytecode interpreter). The constant evaluation is only supported for stateless (hash-based) token modes. If a stateful mode like `increment` is used, the evaluation fails, as the token value is not deterministic at compile time. ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] Prepare libcxx and libcxxabi for pointer field protection. (PR #151651)
https://github.com/pcc updated https://github.com/llvm/llvm-project/pull/151651
>From 7820ec4faa7ecb99217569794db9328211a61553 Mon Sep 17 00:00:00 2001
From: Peter Collingbourne
Date: Fri, 10 Oct 2025 16:11:52 -0700
Subject: [PATCH] Address review comments
Created using spr 1.3.6-beta.1
---
libcxx/CMakeLists.txt | 6 +-
libcxx/include/__config | 15 +--
2 files changed, 6 insertions(+), 15 deletions(-)
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index a119850cd808e..3a87029b52980 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -201,7 +201,11 @@ set(LIBCXX_LIBRARY_VERSION "${LIBCXX_ABI_VERSION}.0" CACHE
STRING
For example, -DLIBCXX_LIBRARY_VERSION=x.y will result in the library being
named
libc++.x.y.dylib, along with the usual symlinks pointing to that. On Apple
platforms,
this also controls the linker's 'current_version' property.")
-set(LIBCXX_ABI_NAMESPACE "__${LIBCXX_ABI_VERSION}" CACHE STRING "The inline
ABI namespace used by libc++. It defaults to __n where `n` is the current ABI
version.")
+set(default_abi_namespace "__${LIBCXX_ABI_VERSION}")
+if(NOT LIBCXX_PFP STREQUAL "none")
+ set(default_abi_namespace "${default_abi_namespace}_pfp_${LIBCXX_PFP}")
+endif()
+set(LIBCXX_ABI_NAMESPACE "${default_abi_namespace}" CACHE STRING "The inline
ABI namespace used by libc++. It defaults to __n where `n` is the current ABI
version.")
if (NOT LIBCXX_ABI_NAMESPACE MATCHES "__.*")
message(FATAL_ERROR "LIBCXX_ABI_NAMESPACE must be a reserved identifier, got
'${LIBCXX_ABI_NAMESPACE}'.")
endif()
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 63e6eceabd5ec..7e996bbf92ba0 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -484,21 +484,8 @@ typedef __char32_t char32_t;
#define _LIBCPP_EXCEPTIONS_SIG e
# endif
-# if !_LIBCPP_HAS_EXCEPTIONS
-#define _LIBCPP_EXCEPTIONS_SIG n
-# else
-#define _LIBCPP_EXCEPTIONS_SIG e
-# endif
-
-# if defined(__POINTER_FIELD_PROTECTION__)
-#define _LIBCPP_PFP_SIG p
-# else
-#define _LIBCPP_PFP_SIG
-# endif
-
# define _LIBCPP_ODR_SIGNATURE
\
-_LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_HARDENING_SIG,
_LIBCPP_EXCEPTIONS_SIG), _LIBCPP_PFP_SIG), \
- _LIBCPP_VERSION)
+_LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_HARDENING_SIG,
_LIBCPP_EXCEPTIONS_SIG), _LIBCPP_VERSION)
// This macro marks a symbol as being hidden from libc++'s ABI. This is
achieved
// on two levels:
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] MIRVocabulary changes (PR #161713)
https://github.com/svkeerthy created
https://github.com/llvm/llvm-project/pull/161713
None
>From abf89848938125eca35cb5ec0b6a13a7eea3bd20 Mon Sep 17 00:00:00 2001
From: svkeerthy
Date: Thu, 2 Oct 2025 18:14:53 +
Subject: [PATCH] MIRVocabulary changes
---
llvm/include/llvm/CodeGen/MIR2Vec.h| 31 +++---
llvm/lib/CodeGen/MIR2Vec.cpp | 18 ++-
llvm/unittests/CodeGen/MIR2VecTest.cpp | 28 ++-
3 files changed, 52 insertions(+), 25 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/MIR2Vec.h
b/llvm/include/llvm/CodeGen/MIR2Vec.h
index 8bb47e61624bf..fde61170fde50 100644
--- a/llvm/include/llvm/CodeGen/MIR2Vec.h
+++ b/llvm/include/llvm/CodeGen/MIR2Vec.h
@@ -8,8 +8,8 @@
///
/// \file
/// This file defines the MIR2Vec vocabulary
-/// analysis(MIR2VecVocabLegacyAnalysis), the core mir2vec::Embedder interface
-/// for generating Machine IR embeddings, and related utilities.
+/// analysis(MIR2VecVocabLegacyAnalysis), the core mir2vec::MIREmbedder
+/// interface for generating Machine IR embeddings, and related utilities.
///
/// MIR2Vec extends IR2Vec to support Machine IR embeddings. It represents the
/// LLVM Machine IR as embeddings which can be used as input to machine
learning
@@ -71,25 +71,31 @@ class MIRVocabulary {
unsigned TotalEntries = 0;
} Layout;
+ enum class Section : unsigned { Opcodes = 0, MaxSections };
+
ir2vec::VocabStorage Storage;
mutable std::set UniqueBaseOpcodeNames;
- void generateStorage(const VocabMap &OpcodeMap, const TargetInstrInfo &TII);
- void buildCanonicalOpcodeMapping(const TargetInstrInfo &TII);
+ const TargetInstrInfo &TII;
+ void generateStorage(const VocabMap &OpcodeMap);
+ void buildCanonicalOpcodeMapping();
+
+ /// Get canonical index for a machine opcode
+ unsigned getCanonicalOpcodeIndex(unsigned Opcode) const;
public:
- /// Static helper method for extracting base opcode names (public for
testing)
+ /// Static method for extracting base opcode names (public for testing)
static std::string extractBaseOpcodeName(StringRef InstrName);
- /// Helper method for getting canonical index for base name (public for
- /// testing)
+ /// Get canonical index for base name (public for testing)
unsigned getCanonicalIndexForBaseName(StringRef BaseName) const;
/// Get the string key for a vocabulary entry at the given position
std::string getStringKey(unsigned Pos) const;
- MIRVocabulary() = default;
+ MIRVocabulary() = delete;
MIRVocabulary(VocabMap &&Entries, const TargetInstrInfo *TII);
- MIRVocabulary(ir2vec::VocabStorage &&Storage) : Storage(std::move(Storage))
{}
+ MIRVocabulary(ir2vec::VocabStorage &&Storage, const TargetInstrInfo &TII)
+ : Storage(std::move(Storage)), TII(TII) {}
bool isValid() const {
return UniqueBaseOpcodeNames.size() > 0 &&
@@ -103,11 +109,10 @@ class MIRVocabulary {
}
// Accessor methods
- const Embedding &operator[](unsigned Index) const {
+ const Embedding &operator[](unsigned Opcode) const {
assert(isValid() && "MIR2Vec Vocabulary is invalid");
-assert(Index < Layout.TotalEntries && "Index out of bounds");
-// Fixme: For now, use section 0 for all entries
-return Storage[0][Index];
+unsigned LocalIndex = getCanonicalOpcodeIndex(Opcode);
+return Storage[static_cast(Section::Opcodes)][LocalIndex];
}
// Iterator access
diff --git a/llvm/lib/CodeGen/MIR2Vec.cpp b/llvm/lib/CodeGen/MIR2Vec.cpp
index 18cae0f51e8c3..d1d322dce7d1c 100644
--- a/llvm/lib/CodeGen/MIR2Vec.cpp
+++ b/llvm/lib/CodeGen/MIR2Vec.cpp
@@ -49,18 +49,19 @@ cl::opt OpcWeight("mir2vec-opc-weight",
cl::Optional, cl::init(1.0),
//===--===//
MIRVocabulary::MIRVocabulary(VocabMap &&OpcodeEntries,
- const TargetInstrInfo *TII) {
+ const TargetInstrInfo *TII)
+: TII(*TII) {
// Early return for invalid inputs - creates empty/invalid vocabulary
if (!TII || OpcodeEntries.empty())
return;
- buildCanonicalOpcodeMapping(*TII);
+ buildCanonicalOpcodeMapping();
unsigned CanonicalOpcodeCount = UniqueBaseOpcodeNames.size();
assert(CanonicalOpcodeCount > 0 &&
"No canonical opcodes found for target - invalid vocabulary");
Layout.OperandBase = CanonicalOpcodeCount;
- generateStorage(OpcodeEntries, *TII);
+ generateStorage(OpcodeEntries);
Layout.TotalEntries = Storage.size();
}
@@ -103,6 +104,12 @@ unsigned
MIRVocabulary::getCanonicalIndexForBaseName(StringRef BaseName) const {
return std::distance(UniqueBaseOpcodeNames.begin(), It);
}
+unsigned MIRVocabulary::getCanonicalOpcodeIndex(unsigned Opcode) const {
+ assert(isValid() && "MIR2Vec Vocabulary is invalid");
+ auto BaseOpcode = extractBaseOpcodeName(TII.getName(Opcode));
+ return getCanonicalIndexForBaseName(BaseOpcode);
+}
+
std::string MIRVocabulary::getStringKey(unsigned Pos) co
[llvm-branch-commits] [llvm] [AMDGPU][MC] Do not inline lit()/lit64() operands. (PR #162137)
https://github.com/kosarev updated
https://github.com/llvm/llvm-project/pull/162137
>From 6377b168d3b55467b893c07e3dc8119bdadf544d Mon Sep 17 00:00:00 2001
From: Ivan Kosarev
Date: Fri, 3 Oct 2025 15:16:32 +0100
Subject: [PATCH] [AMDGPU][MC] Do not inline lit()/lit64() operands.
For now treat the modifiers synonymous to each other.
The disassembler side is to be addressed separately.
---
.../AMDGPU/AsmParser/AMDGPUAsmParser.cpp | 85 ++--
.../AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp | 8 +-
.../MCTargetDesc/AMDGPUMCCodeEmitter.cpp | 15 +-
llvm/test/MC/AMDGPU/gfx1250_asm_salu_lit64.s | 3 +-
llvm/test/MC/AMDGPU/literals.s| 384 +-
5 files changed, 417 insertions(+), 78 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index 61072c8d64245..99ba04378ba2e 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -2105,6 +2105,10 @@ bool AMDGPUOperand::isInlinableImm(MVT type) const {
// Only plain immediates are inlinable (e.g. "clamp" attribute is not)
return false;
}
+
+ if (getModifiers().Lit != LitModifier::None)
+return false;
+
// TODO: We should avoid using host float here. It would be better to
// check the float bit values which is what a few other places do.
// We've had bot failures before due to weird NaN support on mips hosts.
@@ -2349,7 +2353,8 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst,
int64_t Val, bool ApplyMo
case AMDGPU::OPERAND_REG_INLINE_C_INT64:
case AMDGPU::OPERAND_REG_INLINE_C_FP64:
case AMDGPU::OPERAND_REG_INLINE_AC_FP64:
- if (AMDGPU::isInlinableLiteral64(Literal.getZExtValue(),
+ if (Lit == LitModifier::None &&
+ AMDGPU::isInlinableLiteral64(Literal.getZExtValue(),
AsmParser->hasInv2PiInlineImm())) {
Inst.addOperand(MCOperand::createImm(Literal.getZExtValue()));
return;
@@ -2386,14 +2391,7 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst,
int64_t Val, bool ApplyMo
Val = Hi_32(Val);
}
}
-
-if (Lit != LitModifier::None) {
- Inst.addOperand(
- MCOperand::createExpr(AMDGPUMCExpr::createLit(Lit, Val, Ctx)));
-} else {
- Inst.addOperand(MCOperand::createImm(Val));
-}
-return;
+break;
}
// We don't allow fp literals in 64-bit integer instructions. It is
@@ -2405,20 +2403,14 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst,
int64_t Val, bool ApplyMo
if (CanUse64BitLiterals && Lit == LitModifier::None &&
(isInt<32>(Val) || isUInt<32>(Val)))
Lit = LitModifier::Lit64;
-
- if (Lit != LitModifier::None) {
-Inst.addOperand(
-MCOperand::createExpr(AMDGPUMCExpr::createLit(Lit, Val, Ctx)));
- } else {
-Inst.addOperand(MCOperand::createImm(Val));
- }
- return;
+ break;
case AMDGPU::OPERAND_REG_IMM_BF16:
case AMDGPU::OPERAND_REG_INLINE_C_BF16:
case AMDGPU::OPERAND_REG_INLINE_C_V2BF16:
case AMDGPU::OPERAND_REG_IMM_V2BF16:
- if (AsmParser->hasInv2PiInlineImm() && Literal == 0x3fc45f306725feed) {
+ if (Lit == LitModifier::None && AsmParser->hasInv2PiInlineImm() &&
+ Literal == 0x3fc45f306725feed) {
// This is the 1/(2*pi) which is going to be truncated to bf16 with the
// loss of precision. The constant represents ideomatic fp32 value of
// 1/(2*pi) = 0.15915494 since bf16 is in fact fp32 with cleared low 16
@@ -2456,14 +2448,19 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst,
int64_t Val, bool ApplyMo
// We allow precision lost but not overflow or underflow. This should be
// checked earlier in isLiteralImm()
- uint64_t ImmVal = FPLiteral.bitcastToAPInt().getZExtValue();
- Inst.addOperand(MCOperand::createImm(ImmVal));
- return;
+ Val = FPLiteral.bitcastToAPInt().getZExtValue();
+ break;
}
default:
llvm_unreachable("invalid operand size");
}
+if (Lit != LitModifier::None) {
+ Inst.addOperand(
+ MCOperand::createExpr(AMDGPUMCExpr::createLit(Lit, Val, Ctx)));
+} else {
+ Inst.addOperand(MCOperand::createImm(Val));
+}
return;
}
@@ -2483,12 +2480,12 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst,
int64_t Val, bool ApplyMo
case AMDGPU::OPERAND_REG_IMM_V2INT32:
case AMDGPU::OPERAND_INLINE_SPLIT_BARRIER_INT32:
case AMDGPU::OPERAND_REG_IMM_NOINLINE_V2FP16:
-Inst.addOperand(MCOperand::createImm(Val));
-return;
+break;
case AMDGPU::OPERAND_REG_IMM_INT64:
case AMDGPU::OPERAND_REG_INLINE_C_INT64:
-if (AMDGPU::isInlinableLiteral64(Val, AsmParser->hasInv2PiInlineImm())) {
+if (Lit == LitModifier::None &&
+AMDGPU::isInlinableLit
[llvm-branch-commits] [mlir] [mlir][omp] Improve canonloop/iv naming (PR #159773)
@@ -77,6 +77,177 @@ struct LLVMPointerPointerLikeModel
};
} // namespace
+/// Generate a name of a canonical loop nest of the format
+/// `(_s_r)*` that describes its nesting inside parent
+/// operations (`_r`) and that operation's region (`_s`). The region
+/// number is omitted if the parent operation has just one region. If a loop
+/// nest just consists of canonical loops nested inside each other, also uses
+/// `d` where is the nesting depth of the loop.
Meinersbur wrote:
Made the comment more detailed. It was correct albeit confusing; "nesting
inside parent operations" meant the region ("r") out of an operation's list of
region arguments, which is some form of nesting.
https://github.com/llvm/llvm-project/pull/159773
___
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 DOT and MLA operations (PR #163161)
@@ -0,0 +1,24 @@
+// RUN: not llvm-mc -triple=aarch64 -show-encoding -mattr=+sve2p2,+f16mm 2>&1
< %s| FileCheck %s
+
+// --//
+// Invalid element width
+
+fmmla z0.b, z0.b, z0.b
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid element width
+// CHECK-NEXT: fmmla z0.b, z0.b, z0.b
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+// --//
+// Negative tests for instructions that are incompatible with movprfx
+
+movprfx z0.h, p0/m, z7.h
jthackray wrote:
Thanks, test not useful so removed.
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] release/21.x: [Hexagon][llvm-objdump] Start a fresh packet at symbol boundaries. (#163466) (PR #163662)
https://github.com/c-rhodes updated
https://github.com/llvm/llvm-project/pull/163662
>From a2e93dce5f2b86b0b95197576791c12787bcf201 Mon Sep 17 00:00:00 2001
From: quic-areg
Date: Wed, 15 Oct 2025 19:11:03 -0500
Subject: [PATCH] [Hexagon][llvm-objdump] Start a fresh packet at symbol
boundaries. (#163466)
Hexagon packets can visually straddle labels when data (e.g. jump
tables) in the text section does not carry end-of-packet bits. In such
cases the next instruction, even at a new symbol, appears to continue
the previous packet.
This patch resets packet state when encountering a new symbol so that
packets at symbol starts are guaranteed to start in their own packet.
(cherry picked from commit 0cdebdaf59d20f34158d97d193381e95a0ba90b0)
---
.../Disassembler/HexagonDisassembler.cpp | 16 +
.../ELF/Hexagon/packet-reset-on-label.s | 23 +++
llvm/tools/llvm-objdump/llvm-objdump.cpp | 8 +++
3 files changed, 47 insertions(+)
create mode 100644
llvm/test/tools/llvm-objdump/ELF/Hexagon/packet-reset-on-label.s
diff --git a/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp
b/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp
index bcddb540d35dc..c48cf5e6353ac 100644
--- a/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp
+++ b/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp
@@ -64,6 +64,10 @@ class HexagonDisassembler : public MCDisassembler {
void remapInstruction(MCInst &Instr) const;
+ Expected onSymbolStart(SymbolInfoTy &Symbol, uint64_t &Size,
+ ArrayRef Bytes,
+ uint64_t Address) const override;
+
private:
bool makeBundle(ArrayRef Bytes, uint64_t Address,
uint64_t &BytesToSkip, raw_ostream &CS) const;
@@ -604,6 +608,18 @@ DecodeStatus
HexagonDisassembler::getSingleInstruction(MCInst &MI, MCInst &MCB,
return Result;
}
+Expected HexagonDisassembler::onSymbolStart(SymbolInfoTy &Symbol,
+ uint64_t &Size,
+ ArrayRef Bytes,
+ uint64_t Address) const {
+ // At the start of a symbol, force a fresh packet by resetting any
+ // in-progress bundle state. This prevents packets from straddling label
+ // boundaries when data (e.g. jump tables) appears in between.
+ Size = 0;
+ resetBundle();
+ return true;
+}
+
static DecodeStatus DecodeRegisterClass(MCInst &Inst, unsigned RegNo,
ArrayRef Table) {
if (RegNo < Table.size()) {
diff --git a/llvm/test/tools/llvm-objdump/ELF/Hexagon/packet-reset-on-label.s
b/llvm/test/tools/llvm-objdump/ELF/Hexagon/packet-reset-on-label.s
new file mode 100644
index 0..02a52bbb3fbd8
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/ELF/Hexagon/packet-reset-on-label.s
@@ -0,0 +1,23 @@
+// RUN: llvm-mc -triple=hexagon -mcpu=hexagonv75 -filetype=obj %s \
+// RUN: | llvm-objdump -d - \
+// RUN: | FileCheck %s
+
+foo:
+ { nop }
+ /// a nop without end-of-packet bits set to simulate data that is
+ /// not a proper packet end.
+ .long 0x7f004000
+bar:
+ { nop
+nop
+ }
+
+// CHECK-LABEL: :
+// CHECK: { nop }
+// CHECK-NEXT: { nop
+
+/// The instruction starting after should start in a new packet.
+// CHECK-LABEL: :
+// CHECK: { nop
+// CHECK-NEXT: nop }
+
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp
b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 74eb9033c8e2c..221b884e0c06c 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -717,11 +717,17 @@ class PrettyPrinter {
} while (!Comments.empty());
FOS.flush();
}
+
+ // Hook invoked when starting to disassemble a symbol at the current
position.
+ // Default is no-op.
+ virtual void onSymbolStart() {}
};
PrettyPrinter PrettyPrinterInst;
class HexagonPrettyPrinter : public PrettyPrinter {
public:
+ void onSymbolStart() override { reset(); }
+
void printLead(ArrayRef Bytes, uint64_t Address,
formatted_raw_ostream &OS) {
if (LeadingAddr)
@@ -2216,6 +,8 @@ disassembleObject(ObjectFile &Obj, const ObjectFile
&DbgObj,
Start += Size;
break;
}
+ // Allow targets to reset any per-symbol state.
+ DT->Printer->onSymbolStart();
formatted_raw_ostream FOS(OS);
Index = Start;
if (SectionAddr < StartAddress)
___
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)
@@ -172,28 +190,21 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl
&gd, unsigned builtinID,
builder.getUInt8Ty(), "bi_alloca", suitableAlignmentInBytes, size);
// Initialize the allocated buffer if required.
-if (builtinID != Builtin::BI__builtin_alloca_uninitialized) {
- // Initialize the alloca with the given size and alignment according to
- // the lang opts. Only the trivial non-initialization is supported for
- // now.
-
- switch (getLangOpts().getTrivialAutoVarInit()) {
- case LangOptions::TrivialAutoVarInitKind::Uninitialized:
-// Nothing to initialize.
-break;
- case LangOptions::TrivialAutoVarInitKind::Zero:
- case LangOptions::TrivialAutoVarInitKind::Pattern:
-cgm.errorNYI("trivial auto var init");
-break;
- }
-}
+if (builtinID != Builtin::BI__builtin_alloca_uninitialized)
+ initializeAlloca(*this, allocaAddr, size, suitableAlignmentInBytes);
// An alloca will always return a pointer to the alloca (stack) address
// space. This address space need not be the same as the AST / Language
// default (e.g. in C / C++ auto vars are in the generic address space). At
// the AST level this is handled within CreateTempAlloca et al., but for
the
// builtin / dynamic alloca we have to handle it here.
assert(!cir::MissingFeatures::addressSpace());
+cir::AddressSpace aas = getCIRAllocaAddressSpace();
+cir::AddressSpace eas = cir::toCIRAddressSpace(
+e->getType()->getPointeeType().getAddressSpace());
+if (eas != aas) {
+ assert(false && "Non-default address space for alloca NYI");
andykaylor wrote:
OK. I'm fine with deferring it.
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] [flang] [llvm] [mlir] [Flang][MLIR][OpenMP] Add explicit shared memory (de-)allocation ops (PR #161862)
@@ -6135,6 +6133,21 @@ static llvm::Function
*getOmpTargetAlloc(llvm::IRBuilderBase &builder,
return func;
}
+static llvm::Value *
+getAllocationSize(llvm::IRBuilderBase &builder,
+ LLVM::ModuleTranslation &moduleTranslation, Type allocatedTy,
+ OperandRange typeparams, OperandRange shape) {
+ llvm::DataLayout dataLayout =
+ moduleTranslation.getLLVMModule()->getDataLayout();
+ llvm::Type *llvmHeapTy = moduleTranslation.convertType(allocatedTy);
+ llvm::TypeSize typeSize = dataLayout.getTypeStoreSize(llvmHeapTy);
skc7 wrote:
getTypeAllocSize() would be better to use here since it considers any alignment
aswell.
https://github.com/llvm/llvm-project/pull/161862
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [llvm][mustache] Avoid extra copy for json strings (PR #159195)
https://github.com/ilovepi updated
https://github.com/llvm/llvm-project/pull/159195
>From 59b5eda10dc04201b5d68ff5af08b5f9f61ddf5a Mon Sep 17 00:00:00 2001
From: Paul Kirth
Date: Mon, 15 Sep 2025 19:54:34 -0700
Subject: [PATCH] [llvm][mustache] Avoid extra copy for json strings
---
llvm/lib/Support/Mustache.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/llvm/lib/Support/Mustache.cpp b/llvm/lib/Support/Mustache.cpp
index eadf4c1f7cda9..30ced31bd7c43 100644
--- a/llvm/lib/Support/Mustache.cpp
+++ b/llvm/lib/Support/Mustache.cpp
@@ -698,8 +698,7 @@ static void toMustacheString(const json::Value &Data,
raw_ostream &OS) {
return;
}
case json::Value::String: {
-auto Str = *Data.getAsString();
-OS << Str.str();
+OS << *Data.getAsString();
return;
}
___
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)
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] [libc] [llvm] [libc][math] Refactor expm1f implementation to header-only in src/__support/math folder. (PR #162131)
https://github.com/bassiounix updated
https://github.com/llvm/llvm-project/pull/162131
>From 20ca47aad3ceb82863ef91cecd5c8956ff6a73a5 Mon Sep 17 00:00:00 2001
From: bassiounix
Date: Mon, 6 Oct 2025 20:55:27 +0300
Subject: [PATCH] [libc][math] Refactor expm1f implementation to header-only in
src/__support/math folder.
---
libc/shared/math.h| 1 +
libc/shared/math/expm1f.h | 23 +++
libc/src/__support/math/CMakeLists.txt| 17 ++
libc/src/__support/math/expm1f.h | 182 ++
libc/src/math/generic/CMakeLists.txt | 11 +-
libc/src/math/generic/expm1f.cpp | 162 +---
libc/test/shared/CMakeLists.txt | 1 +
libc/test/shared/shared_math_test.cpp | 1 +
.../llvm-project-overlay/libc/BUILD.bazel | 24 ++-
9 files changed, 244 insertions(+), 178 deletions(-)
create mode 100644 libc/shared/math/expm1f.h
create mode 100644 libc/src/__support/math/expm1f.h
diff --git a/libc/shared/math.h b/libc/shared/math.h
index 2db1d5501b7b3..70c6d375c22de 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -55,6 +55,7 @@
#include "math/expf.h"
#include "math/expf16.h"
#include "math/expm1.h"
+#include "math/expm1f.h"
#include "math/frexpf.h"
#include "math/frexpf128.h"
#include "math/frexpf16.h"
diff --git a/libc/shared/math/expm1f.h b/libc/shared/math/expm1f.h
new file mode 100644
index 0..e0cf6a846f116
--- /dev/null
+++ b/libc/shared/math/expm1f.h
@@ -0,0 +1,23 @@
+//===-- Shared expm1f 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_EXPM1F_H
+#define LLVM_LIBC_SHARED_MATH_EXPM1F_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/expm1f.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::expm1f;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_EXPM1F_H
diff --git a/libc/src/__support/math/CMakeLists.txt
b/libc/src/__support/math/CMakeLists.txt
index 515b4042cf47e..823c7fe77af1c 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -890,6 +890,23 @@ add_header_library(
libc.src.errno.errno
)
+add_header_library(
+ expm1f
+ HDRS
+expm1f.h
+ DEPENDS
+.common_constants
+libc.src.__support.FPUtil.basic_operations
+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.errno.errno
+)
+
add_header_library(
range_reduction_double
HDRS
diff --git a/libc/src/__support/math/expm1f.h b/libc/src/__support/math/expm1f.h
new file mode 100644
index 0..43e79ae3112dc
--- /dev/null
+++ b/libc/src/__support/math/expm1f.h
@@ -0,0 +1,182 @@
+//===-- Implementation header for expm1f *- 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_EXPM1F_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_EXPM1F_H
+
+#include "common_constants.h" // Lookup tables EXP_M1 and EXP_M2.
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FMA.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/PolyEval.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/FPUtil/nearest_integer.h"
+#include "src/__support/FPUtil/rounding_mode.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h"// LIBC_UNLIKELY
+#include "src/__support/macros/properties/cpu_features.h" //
LIBC_TARGET_CPU_HAS_FMA
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE static constexpr float expm1f(float x) {
+ using namespace common_constants_internal;
+ using FPBits = typename fputil::FPBits;
+ FPBits xbits(x);
+
+ uint32_t x_u = xbits.uintval();
+ uint32_t x_abs = x_u & 0x7fff'U;
+
+#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+ // Exceptional value
+ if (LIBC_UNLIKELY(x_u == 0x3e35'bec5U)) { // x = 0x1.6b7d8ap-3f
+int round_mode = fputil::quick_get_round();
+if (round_mode == FE_TONEAREST || round_mode == FE_UPWARD)
+ re
[llvm-branch-commits] [llvm] [AArch64][llvm] Armv9.7-A: Add support for SVE2p3 CVT operations (PR #163162)
https://github.com/jthackray updated
https://github.com/llvm/llvm-project/pull/163162
>From 9f7b534ca783e2a8dc224a49bfd422f5be6d6468 Mon Sep 17 00:00:00 2001
From: Jonathan Thackray
Date: Fri, 5 Sep 2025 23:47:55 +0100
Subject: [PATCH 1/3] [AArch64][llvm] Armv9.7-A: Add support for SVE2p3 CVT
operations
Add instructions for SVE2p3 CVT operations:
- FCVTZSN
- FCVTZUN
- SCVTF
- SCVTFLT
- UCVTF
- UCVTFLT
as documented here:
* https://developer.arm.com/documentation/ddi0602/2025-09/
*
https://developer.arm.com/documentation/109697/2025_09/2025-Architecture-Extensions
---
.../lib/Target/AArch64/AArch64SVEInstrInfo.td | 9 +
llvm/lib/Target/AArch64/SVEInstrFormats.td| 46 +
.../MC/AArch64/SVE2p3/fcvtz-diagnostics.s | 55 ++
llvm/test/MC/AArch64/SVE2p3/fcvtz.s | 165 ++
.../MC/AArch64/SVE2p3/scvtf-diagnostics.s | 65 +++
llvm/test/MC/AArch64/SVE2p3/scvtf.s | 93 ++
.../MC/AArch64/SVE2p3/ucvtf-diagnostics.s | 65 +++
llvm/test/MC/AArch64/SVE2p3/ucvtf.s | 93 ++
8 files changed, 591 insertions(+)
create mode 100644 llvm/test/MC/AArch64/SVE2p3/fcvtz-diagnostics.s
create mode 100644 llvm/test/MC/AArch64/SVE2p3/fcvtz.s
create mode 100644 llvm/test/MC/AArch64/SVE2p3/scvtf-diagnostics.s
create mode 100644 llvm/test/MC/AArch64/SVE2p3/scvtf.s
create mode 100644 llvm/test/MC/AArch64/SVE2p3/ucvtf-diagnostics.s
create mode 100644 llvm/test/MC/AArch64/SVE2p3/ucvtf.s
diff --git a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
index 2607a5d0c53a1..dfb7bd348e0e0 100644
--- a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
@@ -4639,6 +4639,15 @@ let Predicates = [HasSVE2p3_or_SME2p3] in {
def SDOT_ZZZI_BtoH : sve_intx_dot_by_indexed_elem_x<0b0, "sdot">;
def UDOT_ZZZI_BtoH : sve_intx_dot_by_indexed_elem_x<0b1, "udot">;
+ // SVE2 fp convert, narrow and interleave to integer, rounding toward zero
+ defm FCVTZSN_Z2Z : sve2_fp_to_int_downcvt<"fcvtzsn", 0b0>;
+ defm FCVTZUN_Z2Z : sve2_fp_to_int_downcvt<"fcvtzun", 0b1>;
+
+ // SVE2 signed/unsigned integer convert to floating-point
+ defm SCVTF_ZZ : sve2_int_to_fp_upcvt<"scvtf", 0b00>;
+ defm SCVTFLT_ZZ : sve2_int_to_fp_upcvt<"scvtflt", 0b10>;
+ defm UCVTF_ZZ : sve2_int_to_fp_upcvt<"ucvtf", 0b01>;
+ defm UCVTFLT_ZZ : sve2_int_to_fp_upcvt<"ucvtflt", 0b11>;
} // End HasSME2p3orSVE2p3
//===--===//
diff --git a/llvm/lib/Target/AArch64/SVEInstrFormats.td
b/llvm/lib/Target/AArch64/SVEInstrFormats.td
index 290a86971aff7..24f4aed5b2bd3 100644
--- a/llvm/lib/Target/AArch64/SVEInstrFormats.td
+++ b/llvm/lib/Target/AArch64/SVEInstrFormats.td
@@ -11300,3 +11300,49 @@ class sve_int_mla_cpa
let ElementSize = ZPR64.ElementSize;
}
+
+//===--===//
+// FCVTZSN
+//===--===//
+class sve2_fp_to_int_downcvt size, bit U>
+ : I<(outs ZdRC:$Zd), (ins ZSrcOp:$Zn),
+ asm, "\t$Zd, $Zn", "", []>, Sched<[]> {
+ bits<5> Zd;
+ bits<4> Zn;
+ let Inst{31-24} = 0b01100101;
+ let Inst{23-22} = size;
+ let Inst{21-11} = 0b00110100110;
+ let Inst{10}= U;
+ let Inst{9-6} = Zn;
+ let Inst{5} = 0b0;
+ let Inst{4-0} = Zd;
+}
+
+multiclass sve2_fp_to_int_downcvt {
+ def _HtoB : sve2_fp_to_int_downcvt;
+ def _StoH : sve2_fp_to_int_downcvt;
+ def _DtoS : sve2_fp_to_int_downcvt;
+}
+
+//===--===//
+// SCVTF
+//===--===//
+class sve2_int_to_fp_upcvt size, bits<2> U>
+ : I<(outs ZdRC:$Zd), (ins ZnRC:$Zn),
+ asm, "\t$Zd, $Zn", "", []>, Sched<[]> {
+ bits<5> Zd;
+ bits<5> Zn;
+ let Inst{31-24} = 0b01100101;
+ let Inst{23-22} = size;
+ let Inst{21-12} = 0b001111;
+ let Inst{11-10} = U;
+ let Inst{9-5} = Zn;
+ let Inst{4-0} = Zd;
+}
+
+multiclass sve2_int_to_fp_upcvt U> {
+ def _BtoH : sve2_int_to_fp_upcvt;
+ def _HtoS : sve2_int_to_fp_upcvt;
+ def _StoD : sve2_int_to_fp_upcvt;
+}
diff --git a/llvm/test/MC/AArch64/SVE2p3/fcvtz-diagnostics.s
b/llvm/test/MC/AArch64/SVE2p3/fcvtz-diagnostics.s
new file mode 100644
index 0..bd182e8713e18
--- /dev/null
+++ b/llvm/test/MC/AArch64/SVE2p3/fcvtz-diagnostics.s
@@ -0,0 +1,55 @@
+// RUN: not llvm-mc -triple=aarch64 -show-encoding -mattr=+sve2p3 2>&1 < %s|
FileCheck %s
+
+// --//
+// Invalid operand for instruction
+
+fcvtzsn z0.b, { z0.b, z1.b }
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
+// CHECK-NEXT: fcvtzsn z0.b, { z0.b, z1.b }
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+fcvtzsn z0.h, { z0.h, z1.h }
+// CHECK: [[@LINE-1]]:{{[0-9
[llvm-branch-commits] [llvm] [PowerPC] Implement Elliptic Curve Cryptography (ECC) Instructions (PR #158362)
https://github.com/lei137 closed 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] [Clang] Implement constexpr evaluation for __builtin_infer_alloc_token() (PR #163639)
https://github.com/tbaederr approved this pull request. 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] [libc] [llvm] [libc][math] Refactor exp2m1f implementation to header-only in src/__support/math folder. (PR #162017)
https://github.com/bassiounix created
https://github.com/llvm/llvm-project/pull/162017
None
>From 9b1eeb2df5b2d5a03fb1a58744cf765d1a78cc81 Mon Sep 17 00:00:00 2001
From: bassiounix
Date: Sun, 5 Oct 2025 17:33:45 +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 | 196 ++
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, 260 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..b68304cb1403d
--- /dev/null
+++ b/libc/src/__support/math/exp2m1f.h
@@ -0,0 +1,196 @@
+//===-- 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
[llvm-branch-commits] [flang] [llvm] [mlir] [Flang][MLIR][OpenMP] Add explicit shared memory (de-)allocation ops (PR #161862)
skatrak wrote: PR stack: - #150922 - #150923 - #150924 - #150925 - #150926 - #150927 - #154752 - #161861 - #161862 ◀️ - #161863 - #161864 https://github.com/llvm/llvm-project/pull/161862 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [NFC][Asan] Replace 0 with nullptr in asan_fake_stack (PR #163670)
https://github.com/vitalybuka created https://github.com/llvm/llvm-project/pull/163670 None ___ 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: optionally assume auth traps on failure (PR #139778)
https://github.com/atrosinenko updated
https://github.com/llvm/llvm-project/pull/139778
>From 8dc0489843c88abe4749f3e29775cea04050d925 Mon Sep 17 00:00:00 2001
From: Anatoly Trosinenko
Date: Tue, 13 May 2025 19:50:41 +0300
Subject: [PATCH 1/2] [BOLT] Gadget scanner: optionally assume auth traps on
failure
On AArch64 it is possible for an auth instruction to either return an
invalid address value on failure (without FEAT_FPAC) or generate an
error (with FEAT_FPAC). It thus may be possible to never emit explicit
pointer checks, if the target CPU is known to support FEAT_FPAC.
This commit implements an --auth-traps-on-failure command line option,
which essentially makes "safe-to-dereference" and "trusted" register
properties identical and disables scanning for authentication oracles
completely.
---
bolt/lib/Passes/PAuthGadgetScanner.cpp| 112 +++
.../binary-analysis/AArch64/cmdline-args.test | 1 +
.../AArch64/gs-pauth-authentication-oracles.s | 6 +-
.../binary-analysis/AArch64/gs-pauth-calls.s | 5 +-
.../AArch64/gs-pauth-debug-output.s | 177 ++---
.../AArch64/gs-pauth-jump-table.s | 6 +-
.../AArch64/gs-pauth-signing-oracles.s| 54 ++---
.../AArch64/gs-pauth-tail-calls.s | 184 +-
8 files changed, 318 insertions(+), 227 deletions(-)
diff --git a/bolt/lib/Passes/PAuthGadgetScanner.cpp
b/bolt/lib/Passes/PAuthGadgetScanner.cpp
index 3a6c3e3d925cf..4fc0bf2ae54a9 100644
--- a/bolt/lib/Passes/PAuthGadgetScanner.cpp
+++ b/bolt/lib/Passes/PAuthGadgetScanner.cpp
@@ -14,6 +14,7 @@
#include "bolt/Passes/PAuthGadgetScanner.h"
#include "bolt/Core/ParallelUtilities.h"
#include "bolt/Passes/DataflowAnalysis.h"
+#include "bolt/Utils/CommandLineOpts.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/MC/MCInst.h"
@@ -26,6 +27,11 @@ namespace llvm {
namespace bolt {
namespace PAuthGadgetScanner {
+static cl::opt AuthTrapsOnFailure(
+"auth-traps-on-failure",
+cl::desc("Assume authentication instructions always trap on failure"),
+cl::cat(opts::BinaryAnalysisCategory));
+
[[maybe_unused]] static void traceInst(const BinaryContext &BC, StringRef
Label,
const MCInst &MI) {
dbgs() << " " << Label << ": ";
@@ -364,6 +370,34 @@ class SrcSafetyAnalysis {
return Clobbered;
}
+ std::optional getRegMadeTrustedByChecking(const MCInst &Inst,
+ SrcState Cur) const {
+// This functions cannot return multiple registers. This is never the case
+// on AArch64.
+std::optional RegCheckedByInst =
+BC.MIB->getAuthCheckedReg(Inst, /*MayOverwrite=*/false);
+if (RegCheckedByInst && Cur.SafeToDerefRegs[*RegCheckedByInst])
+ return *RegCheckedByInst;
+
+auto It = CheckerSequenceInfo.find(&Inst);
+if (It == CheckerSequenceInfo.end())
+ return std::nullopt;
+
+MCPhysReg RegCheckedBySequence = It->second.first;
+const MCInst *FirstCheckerInst = It->second.second;
+
+// FirstCheckerInst should belong to the same basic block (see the
+// assertion in DataflowSrcSafetyAnalysis::run()), meaning it was
+// deterministically processed a few steps before this instruction.
+const SrcState &StateBeforeChecker = getStateBefore(*FirstCheckerInst);
+
+// The sequence checks the register, but it should be authenticated before.
+if (!StateBeforeChecker.SafeToDerefRegs[RegCheckedBySequence])
+ return std::nullopt;
+
+return RegCheckedBySequence;
+ }
+
// Returns all registers that can be treated as if they are written by an
// authentication instruction.
SmallVector getRegsMadeSafeToDeref(const MCInst &Point,
@@ -386,18 +420,38 @@ class SrcSafetyAnalysis {
Regs.push_back(DstAndSrc->first);
}
+// Make sure explicit checker sequence keeps register safe-to-dereference
+// when the register would be clobbered according to the regular rules:
+//
+//; LR is safe to dereference here
+//mov x16, x30 ; start of the sequence, LR is s-t-d right before
+//xpaclri ; clobbers LR, LR is not safe anymore
+//cmp x30, x16
+//b.eq 1f; end of the sequence: LR is marked as trusted
+//brk 0x1234
+// 1:
+//; at this point LR would be marked as trusted,
+//; but not safe-to-dereference
+//
+// or even just
+//
+//; X1 is safe to dereference here
+//ldr x0, [x1, #8]!
+//; X1 is trusted here, but it was clobbered due to address write-back
+if (auto CheckedReg = getRegMadeTrustedByChecking(Point, Cur))
+ Regs.push_back(*CheckedReg);
+
return Regs;
}
// Returns all registers made trusted by this instruction.
SmallVector getRegsMadeTrusted(const MCInst &Point,
const SrcState &Cur) const {
+assert(!AuthTrapsOnFailur
[llvm-branch-commits] [clang] [llvm] [HLSL] GetDimensions methods for buffer resources (PR #161929)
hekota wrote: Changing to draft until https://github.com/llvm/llvm-project/issues/163648 is resolved. https://github.com/llvm/llvm-project/pull/161929 ___ 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 libannex_k as build target in LLVM libc. (PR #163869)
https://github.com/bassiounix updated
https://github.com/llvm/llvm-project/pull/163869
>From b99b05c9b3e6226a050649631da6f4d319f1e6eb Mon Sep 17 00:00:00 2001
From: bassiounix
Date: Fri, 17 Oct 2025 00:15:35 +0300
Subject: [PATCH] [libc][annex_k] Add libannex_k as build target in LLVM libc.
---
libc/config/linux/aarch64/entrypoints.txt | 3 +++
libc/config/linux/riscv/entrypoints.txt | 3 +++
libc/config/linux/x86_64/entrypoints.txt | 3 +++
libc/lib/CMakeLists.txt | 9 ++---
4 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/libc/config/linux/aarch64/entrypoints.txt
b/libc/config/linux/aarch64/entrypoints.txt
index 8bf6c44b1d669..d79682cad8b80 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -1,3 +1,5 @@
+set(TARGET_ANNEX_K_ENTRYPOINTS "")
+
set(TARGET_LIBC_ENTRYPOINTS
# ctype.h entrypoints
libc.src.ctype.isalnum
@@ -1177,4 +1179,5 @@ endif()
set(TARGET_LLVMLIBC_ENTRYPOINTS
${TARGET_LIBC_ENTRYPOINTS}
${TARGET_LIBM_ENTRYPOINTS}
+ ${TARGET_ANNEX_K_ENTRYPOINTS}
)
diff --git a/libc/config/linux/riscv/entrypoints.txt
b/libc/config/linux/riscv/entrypoints.txt
index dffccbab9a8e9..fd9bd9d4350eb 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -1,3 +1,5 @@
+set(TARGET_ANNEX_K_ENTRYPOINTS "")
+
set(TARGET_LIBC_ENTRYPOINTS
# ctype.h entrypoints
libc.src.ctype.isalnum
@@ -1323,4 +1325,5 @@ endif()
set(TARGET_LLVMLIBC_ENTRYPOINTS
${TARGET_LIBC_ENTRYPOINTS}
${TARGET_LIBM_ENTRYPOINTS}
+ ${TARGET_ANNEX_K_ENTRYPOINTS}
)
diff --git a/libc/config/linux/x86_64/entrypoints.txt
b/libc/config/linux/x86_64/entrypoints.txt
index b4ab073ec912f..3503b8473ae78 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -1,3 +1,5 @@
+set(TARGET_ANNEX_K_ENTRYPOINTS "")
+
set(TARGET_LIBC_ENTRYPOINTS
# ctype.h entrypoints
libc.src.ctype.isalnum
@@ -1379,4 +1381,5 @@ endif()
set(TARGET_LLVMLIBC_ENTRYPOINTS
${TARGET_LIBC_ENTRYPOINTS}
${TARGET_LIBM_ENTRYPOINTS}
+ ${TARGET_ANNEX_K_ENTRYPOINTS}
)
diff --git a/libc/lib/CMakeLists.txt b/libc/lib/CMakeLists.txt
index ce0b07fb6cb49..6fde2c8fc827d 100644
--- a/libc/lib/CMakeLists.txt
+++ b/libc/lib/CMakeLists.txt
@@ -2,10 +2,13 @@ set(libc_archive_targets "")
set(libc_archive_names "")
set(libc_archive_entrypoint_lists "")
if(LLVM_LIBC_FULL_BUILD)
- list(APPEND libc_archive_names c m)
- list(APPEND libc_archive_targets libc libm)
+ list(APPEND libc_archive_names c m annex_k)
+ list(APPEND libc_archive_targets libc libm libannex_k)
list(APPEND libc_archive_entrypoint_lists
- TARGET_LIBC_ENTRYPOINTS TARGET_LIBM_ENTRYPOINTS)
+ TARGET_LIBC_ENTRYPOINTS
+ TARGET_LIBM_ENTRYPOINTS
+ TARGET_ANNEX_K_ENTRYPOINTS
+ )
else()
list(APPEND libc_archive_names llvmlibc)
list(APPEND libc_archive_targets libc)
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [AMDGPU] SIMemoryLegalizer: Factor out check if memory operations can affect the global AS (PR #160129)
https://github.com/ritter-x2a updated
https://github.com/llvm/llvm-project/pull/160129
>From 9c10c3e64323070347be3cef1baec7bf9b062ba1 Mon Sep 17 00:00:00 2001
From: Fabian Ritter
Date: Mon, 22 Sep 2025 11:20:16 -0400
Subject: [PATCH 1/2] [AMDGPU] SIMemoryLegalizer: Factor out check if memory
operations can affect the global AS
Mostly NFC, and adds an assertion for gfx12 to ensure that no atomic scratch
instructions are present in the case of GloballyAddressableScratch. This should
always hold because of #154710.
---
llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp | 53 +---
1 file changed, 35 insertions(+), 18 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp
b/llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp
index c85d2bb9fe9ae..23133b28a4af8 100644
--- a/llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp
+++ b/llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp
@@ -299,6 +299,10 @@ class SICacheControl {
bool enableNamedBit(const MachineBasicBlock::iterator MI,
AMDGPU::CPol::CPol Bit) const;
+ /// Check if any atomic operation on AS can affect memory accessible via the
+ /// global address space.
+ virtual bool canAffectGlobalAddrSpace(SIAtomicAddrSpace AS) const = 0;
+
public:
/// Create a cache control for the subtarget \p ST.
@@ -403,6 +407,10 @@ class SIGfx6CacheControl : public SICacheControl {
return enableNamedBit(MI, AMDGPU::CPol::SLC);
}
+ bool canAffectGlobalAddrSpace(SIAtomicAddrSpace AS) const override {
+return (AS & SIAtomicAddrSpace::GLOBAL) != SIAtomicAddrSpace::NONE;
+ }
+
public:
SIGfx6CacheControl(const GCNSubtarget &ST) : SICacheControl(ST) {}
@@ -609,6 +617,15 @@ class SIGfx12CacheControl : public SIGfx11CacheControl {
bool setAtomicScope(const MachineBasicBlock::iterator &MI,
SIAtomicScope Scope, SIAtomicAddrSpace AddrSpace) const;
+ bool canAffectGlobalAddrSpace(SIAtomicAddrSpace AS) const override {
+assert((!ST.hasGloballyAddressableScratch() ||
+((AS & SIAtomicAddrSpace::GLOBAL) != SIAtomicAddrSpace::NONE) ||
+(AS & SIAtomicAddrSpace::SCRATCH) == SIAtomicAddrSpace::NONE) &&
+ "scratch instructions should already be replaced by flat "
+ "instructions if GloballyAddressableScratch is enabled");
+return (AS & SIAtomicAddrSpace::GLOBAL) != SIAtomicAddrSpace::NONE;
+ }
+
public:
SIGfx12CacheControl(const GCNSubtarget &ST) : SIGfx11CacheControl(ST) {
// GFX12.0 and GFX12.5 memory models greatly overlap, and in some cases
@@ -1016,7 +1033,7 @@ bool SIGfx6CacheControl::enableLoadCacheBypass(
assert(MI->mayLoad() && !MI->mayStore());
bool Changed = false;
- if ((AddrSpace & SIAtomicAddrSpace::GLOBAL) != SIAtomicAddrSpace::NONE) {
+ if (canAffectGlobalAddrSpace(AddrSpace)) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
case SIAtomicScope::AGENT:
@@ -1239,7 +1256,7 @@ bool
SIGfx6CacheControl::insertAcquire(MachineBasicBlock::iterator &MI,
if (Pos == Position::AFTER)
++MI;
- if ((AddrSpace & SIAtomicAddrSpace::GLOBAL) != SIAtomicAddrSpace::NONE) {
+ if (canAffectGlobalAddrSpace(AddrSpace)) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
case SIAtomicScope::AGENT:
@@ -1299,7 +1316,7 @@ bool
SIGfx7CacheControl::insertAcquire(MachineBasicBlock::iterator &MI,
if (Pos == Position::AFTER)
++MI;
- if ((AddrSpace & SIAtomicAddrSpace::GLOBAL) != SIAtomicAddrSpace::NONE) {
+ if (canAffectGlobalAddrSpace(AddrSpace)) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
case SIAtomicScope::AGENT:
@@ -1336,7 +1353,7 @@ bool SIGfx90ACacheControl::enableLoadCacheBypass(
assert(MI->mayLoad() && !MI->mayStore());
bool Changed = false;
- if ((AddrSpace & SIAtomicAddrSpace::GLOBAL) != SIAtomicAddrSpace::NONE) {
+ if (canAffectGlobalAddrSpace(AddrSpace)) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
case SIAtomicScope::AGENT:
@@ -1378,7 +1395,7 @@ bool SIGfx90ACacheControl::enableRMWCacheBypass(
assert(MI->mayLoad() && MI->mayStore());
bool Changed = false;
- if ((AddrSpace & SIAtomicAddrSpace::GLOBAL) != SIAtomicAddrSpace::NONE) {
+ if (canAffectGlobalAddrSpace(AddrSpace)) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
case SIAtomicScope::AGENT:
@@ -1487,7 +1504,7 @@ bool
SIGfx90ACacheControl::insertAcquire(MachineBasicBlock::iterator &MI,
if (Pos == Position::AFTER)
++MI;
- if ((AddrSpace & SIAtomicAddrSpace::GLOBAL) != SIAtomicAddrSpace::NONE) {
+ if (canAffectGlobalAddrSpace(AddrSpace)) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
// Ensures that following loads will not see stale remote VMEM data or
@@ -1551,7 +1568,7 @@ bool
SIGfx90ACacheControl::insertRelease(MachineBasicBlock::iterator &MI,
if (Pos == Position::AFTER)
++MI;
- if ((AddrSpace & SIAtomicAddrSpace::GLOBAL) != SIAtomicAddrSpace::NONE) {
+ if (canAffectGlobalAddrSpace(AddrSpace)) {
switch (Scope) {
[llvm-branch-commits] [clang] [AllocToken, Clang] Implement TypeHashPointerSplit mode (PR #156840)
@@ -205,6 +231,26 @@ class TypeHashMode : public ModeBase {
}
};
+/// Implementation for TokenMode::TypeHashPointerSplit.
+class TypeHashPointerSplitMode : public TypeHashMode {
+public:
+ using TypeHashMode::TypeHashMode;
+
+ uint64_t operator()(const CallBase &CB, OptimizationRemarkEmitter &ORE) {
+if (MaxTokens == 1)
+ return 0;
+const uint64_t HalfTokens =
+(MaxTokens ? MaxTokens : std::numeric_limits::max()) / 2;
melver wrote:
Fixed - AllocToken base PR:
```
--- a/llvm/lib/Transforms/Instrumentation/AllocToken.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AllocToken.cpp
@@ -139,11 +139,13 @@ MDNode *getAllocTokenMetadata(const CallBase &CB) {
class ModeBase {
public:
- explicit ModeBase(uint64_t MaxTokens) : MaxTokens(MaxTokens) {}
+ explicit ModeBase(const IntegerType &TokenTy, uint64_t MaxTokens)
+ : MaxTokens(MaxTokens ? MaxTokens : TokenTy.getBitMask()) {}
protected:
uint64_t boundedToken(uint64_t Val) const {
-return MaxTokens ? Val % MaxTokens : Val;
+assert(MaxTokens != 0);
+return Val % MaxTokens;
}
[...]
```
This PR change:
```
--- a/llvm/lib/Transforms/Instrumentation/AllocToken.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AllocToken.cpp
@@ -242,8 +242,7 @@ public:
uint64_t operator()(const CallBase &CB, OptimizationRemarkEmitter &ORE) {
if (MaxTokens == 1)
return 0;
-const uint64_t HalfTokens =
-(MaxTokens ? MaxTokens : std::numeric_limits::max()) / 2;
+const uint64_t HalfTokens = MaxTokens / 2;
const auto [N, H] = getHash(CB, ORE);
if (!N) {
// Pick the fallback token (ClFallbackToken), which by default is 0,
[...]
```
https://github.com/llvm/llvm-project/pull/156840
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [llvm][mustache] Optimize accessor splitting with a single pass (PR #159198)
https://github.com/ilovepi updated
https://github.com/llvm/llvm-project/pull/159198
>From 943c6344c2711f861c1669f93eea4a8edf397d74 Mon Sep 17 00:00:00 2001
From: Paul Kirth
Date: Tue, 16 Sep 2025 00:24:43 -0700
Subject: [PATCH] [llvm][mustache] Optimize accessor splitting with a single
pass
The splitMustacheString function previously used a loop of
StringRef::split and StringRef::trim. This was inefficient as
it scanned each segment of the accessor string multiple times.
This change introduces a custom splitAndTrim function that
performs both operations in a single pass over the string,
reducing redundant work and improving performance, most notably
in the number of CPU cycles executed.
Metric | Baseline | Optimized | Change
-- | | - | ---
Time (ms) | 35.57| 35.36 | -0.59%
Cycles | 34.91M | 34.26M| -1.86%
Instructions | 85.54M | 85.24M| -0.35%
Branch Misses | 111.9K | 112.2K| +0.27%
Cache Misses | 242.1K | 239.9K| -0.91%
---
llvm/lib/Support/Mustache.cpp | 34 +++---
1 file changed, 27 insertions(+), 7 deletions(-)
diff --git a/llvm/lib/Support/Mustache.cpp b/llvm/lib/Support/Mustache.cpp
index 4786242cdfba9..8eebeaec11925 100644
--- a/llvm/lib/Support/Mustache.cpp
+++ b/llvm/lib/Support/Mustache.cpp
@@ -34,6 +34,32 @@ static bool isContextFalsey(const json::Value *V) {
return isFalsey(*V);
}
+static void splitAndTrim(StringRef Str, SmallVectorImpl &Tokens) {
+ size_t CurrentPos = 0;
+ while (CurrentPos < Str.size()) {
+// Find the next delimiter.
+size_t DelimiterPos = Str.find('.', CurrentPos);
+
+// If no delimiter is found, process the rest of the string.
+if (DelimiterPos == StringRef::npos) {
+ DelimiterPos = Str.size();
+}
+
+// Get the current part, which may have whitespace.
+StringRef Part = Str.slice(CurrentPos, DelimiterPos);
+
+// Manually trim the part without creating a new string object.
+size_t Start = Part.find_first_not_of(" \t\r\n");
+if (Start != StringRef::npos) {
+ size_t End = Part.find_last_not_of(" \t\r\n");
+ Tokens.push_back(Part.slice(Start, End + 1));
+}
+
+// Move past the delimiter for the next iteration.
+CurrentPos = DelimiterPos + 1;
+ }
+}
+
static Accessor splitMustacheString(StringRef Str, MustacheContext &Ctx) {
// We split the mustache string into an accessor.
// For example:
@@ -46,13 +72,7 @@ static Accessor splitMustacheString(StringRef Str,
MustacheContext &Ctx) {
// It's a literal, so it doesn't need to be saved.
Tokens.push_back(".");
} else {
-while (!Str.empty()) {
- StringRef Part;
- std::tie(Part, Str) = Str.split('.');
- // Each part of the accessor needs to be saved to the arena
- // to ensure it has a stable address.
- Tokens.push_back(Part.trim());
-}
+splitAndTrim(Str, Tokens);
}
// Now, allocate memory for the array of StringRefs in the arena.
StringRef *ArenaTokens = Ctx.Allocator.Allocate(Tokens.size());
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lldb] [lldb][NFC] Refactor StopInfoWatchpoint::PerformAction (PR #163696)
https://github.com/dlav-sc created
https://github.com/llvm/llvm-project/pull/163696
Refactor watchpoint logic 2/2
This patch refactors the StopInfoWatchpoint::PerformAction function. It
leverages the ShouldReport method introduced in the previous patch to
significantly simplify the PerformAction logic.
>From b35eaf0aa8aa9b4de19ca88b101ba950e0b91b0e Mon Sep 17 00:00:00 2001
From: Daniil Avdeev
Date: Mon, 10 Feb 2025 03:16:50 +
Subject: [PATCH] [lldb][NFC] Refactor StopInfoWatchpoint::PerformAction
Refactor watchpoint logic 2/2
This patch refactors the StopInfoWatchpoint::PerformAction function. It
leverages the ShouldReport method introduced in the previous patch to
significantly simplify the PerformAction logic.
---
lldb/include/lldb/Breakpoint/Watchpoint.h | 5 -
lldb/source/Breakpoint/Watchpoint.cpp | 56 ---
lldb/source/Target/StopInfo.cpp | 188 ++
3 files changed, 52 insertions(+), 197 deletions(-)
diff --git a/lldb/include/lldb/Breakpoint/Watchpoint.h
b/lldb/include/lldb/Breakpoint/Watchpoint.h
index 9e7e986e60606..3ca7629750ebb 100644
--- a/lldb/include/lldb/Breakpoint/Watchpoint.h
+++ b/lldb/include/lldb/Breakpoint/Watchpoint.h
@@ -86,7 +86,6 @@ class Watchpoint : public
std::enable_shared_from_this,
void SetDeclInfo(const std::string &str);
std::string GetWatchSpec() const;
void SetWatchSpec(const std::string &str);
- bool WatchedValueReportable(const ExecutionContext &exe_ctx);
// This function determines whether we should report a watchpoint value
// change. Specifically, it checks the watchpoint condition (if present),
@@ -102,7 +101,6 @@ class Watchpoint : public
std::enable_shared_from_this,
// Snapshot management interface.
bool IsWatchVariable() const;
void SetWatchVariable(bool val);
- bool CaptureWatchedValue(const ExecutionContext &exe_ctx);
/// \struct WatchpointVariableContext
/// \brief Represents the context of a watchpoint variable.
@@ -205,7 +203,6 @@ class Watchpoint : public
std::enable_shared_from_this,
private:
friend class Target;
friend class WatchpointList;
- friend class StopInfoWatchpoint; // This needs to call UndoHitCount()
lldb::ValueObjectSP CalculateWatchedValue() const;
@@ -223,8 +220,6 @@ class Watchpoint : public
std::enable_shared_from_this,
m_new_value_sp.reset();
}
- void UndoHitCount() { m_hit_counter.Decrement(); }
-
Target &m_target;
bool m_enabled; // Is this watchpoint enabled
bool m_is_hardware; // Is this a hardware watchpoint
diff --git a/lldb/source/Breakpoint/Watchpoint.cpp
b/lldb/source/Breakpoint/Watchpoint.cpp
index 07d8f64737dc1..5ee8b227428d3 100644
--- a/lldb/source/Breakpoint/Watchpoint.cpp
+++ b/lldb/source/Breakpoint/Watchpoint.cpp
@@ -260,66 +260,10 @@ bool Watchpoint::IsWatchVariable() const { return
m_is_watch_variable; }
void Watchpoint::SetWatchVariable(bool val) { m_is_watch_variable = val; }
-bool Watchpoint::CaptureWatchedValue(const ExecutionContext &exe_ctx) {
- ConstString g_watch_name("$__lldb__watch_value");
- m_old_value_sp = m_new_value_sp;
- Address watch_address(GetLoadAddress());
- if (!m_type.IsValid()) {
-// Don't know how to report new & old values, since we couldn't make a
-// scalar type for this watchpoint. This works around an assert in
-// ValueObjectMemory::Create.
-// FIXME: This should not happen, but if it does in some case we care
about,
-// we can go grab the value raw and print it as unsigned.
-return false;
- }
- m_new_value_sp = ValueObjectMemory::Create(
- exe_ctx.GetBestExecutionContextScope(), g_watch_name.GetStringRef(),
- watch_address, m_type);
- m_new_value_sp = m_new_value_sp->CreateConstantValue(g_watch_name);
- return (m_new_value_sp && m_new_value_sp->GetError().Success());
-}
-
-bool Watchpoint::WatchedValueReportable(const ExecutionContext &exe_ctx) {
- if (!WatchpointModify() || WatchpointRead())
-return true;
- if (!m_type.IsValid())
-return true;
-
- ConstString g_watch_name("$__lldb__watch_value");
- Address watch_address(GetLoadAddress());
- ValueObjectSP newest_valueobj_sp = ValueObjectMemory::Create(
- exe_ctx.GetBestExecutionContextScope(), g_watch_name.GetStringRef(),
- watch_address, m_type);
- newest_valueobj_sp = newest_valueobj_sp->CreateConstantValue(g_watch_name);
- Status error;
-
- DataExtractor new_data;
- DataExtractor old_data;
-
- newest_valueobj_sp->GetData(new_data, error);
- if (error.Fail())
-return true;
- m_new_value_sp->GetData(old_data, error);
- if (error.Fail())
-return true;
-
- if (new_data.GetByteSize() != old_data.GetByteSize() ||
- new_data.GetByteSize() == 0)
-return true;
-
- if (memcmp(new_data.GetDataStart(), old_data.GetDataStart(),
- old_data.GetByteSize()) == 0)
-return false; // Value has not changed, user requested modify watchpoint
-
- return true;
-}
-
// RETURNS - true if we should stop
[llvm-branch-commits] [llvm] AMDGPU: Stop inferring amdgpu-agpr-alloc on irrelevant targets (PR #161957)
https://github.com/arsenm ready_for_review https://github.com/llvm/llvm-project/pull/161957 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] [DirectX] Updating Root Signature Metadata to contain Static Sampler flags (PR #160210)
https://github.com/inbelic commented: I think the intent was to not have any of the lexing/parsing logic in this pr? Could you please update with the complete parsing/lexing testing or remove said logic from this pr https://github.com/llvm/llvm-project/pull/160210 ___ 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 new Advanced SIMD (Neon) instructions (PR #163165)
https://github.com/jthackray updated https://github.com/llvm/llvm-project/pull/163165 >From eede46ada844d6c68a38837a8935a4b0b768a290 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 6730c61552914..d0153c9b49903 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrFormats.td +++ b/llvm/lib/Target/AArch64
[llvm-branch-commits] [clang] e050aee - Revert "[clang][analyzer] Make per-entry-point metric rows uniquely identifiable"
Author: Balazs Benics
Date: 2025-10-03T17:02:00+02:00
New Revision: e050aee00e17e740526688f890462d253ba9fc63
URL:
https://github.com/llvm/llvm-project/commit/e050aee00e17e740526688f890462d253ba9fc63
DIFF:
https://github.com/llvm/llvm-project/commit/e050aee00e17e740526688f890462d253ba9fc63.diff
LOG: Revert "[clang][analyzer] Make per-entry-point metric rows uniquely
identifiable"
This reverts commit cf86ef925d75ef08526fc399a2888673338298b3.
Added:
Modified:
clang/include/clang/StaticAnalyzer/Core/PathSensitive/EntryPointStats.h
clang/lib/StaticAnalyzer/Core/EntryPointStats.cpp
clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
clang/test/Analysis/analyzer-stats/entry-point-stats.cpp
Removed:
diff --git
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/EntryPointStats.h
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/EntryPointStats.h
index 448e40269ca2d..633fb7aa8f72d 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/EntryPointStats.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/EntryPointStats.h
@@ -25,7 +25,7 @@ class EntryPointStat {
public:
llvm::StringLiteral name() const { return Name; }
- static void lockRegistry(llvm::StringRef CPPFileName);
+ static void lockRegistry();
static void takeSnapshot(const Decl *EntryPoint);
static void dumpStatsAsCSV(llvm::raw_ostream &OS);
diff --git a/clang/lib/StaticAnalyzer/Core/EntryPointStats.cpp
b/clang/lib/StaticAnalyzer/Core/EntryPointStats.cpp
index 62ae62f2f2154..b7f9044f65308 100644
--- a/clang/lib/StaticAnalyzer/Core/EntryPointStats.cpp
+++ b/clang/lib/StaticAnalyzer/Core/EntryPointStats.cpp
@@ -9,9 +9,7 @@
#include "clang/StaticAnalyzer/Core/PathSensitive/EntryPointStats.h"
#include "clang/AST/DeclBase.h"
#include "clang/Analysis/AnalysisDeclContext.h"
-#include "clang/Index/USRGeneration.h"
#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/FileSystem.h"
@@ -40,7 +38,6 @@ struct Registry {
};
std::vector Snapshots;
- std::string EscapedCPPFileName;
};
} // namespace
@@ -72,7 +69,7 @@ static void checkStatName(const EntryPointStat *M) {
}
}
-void EntryPointStat::lockRegistry(llvm::StringRef CPPFileName) {
+void EntryPointStat::lockRegistry() {
auto CmpByNames = [](const EntryPointStat *L, const EntryPointStat *R) {
return L->name() < R->name();
};
@@ -81,8 +78,6 @@ void EntryPointStat::lockRegistry(llvm::StringRef
CPPFileName) {
enumerateStatVectors(
[](const auto &Stats) { llvm::for_each(Stats, checkStatName); });
StatsRegistry->IsLocked = true;
- llvm::raw_string_ostream OS(StatsRegistry->EscapedCPPFileName);
- llvm::printEscapedString(CPPFileName, OS);
}
[[maybe_unused]] static bool isRegistered(llvm::StringLiteral Name) {
@@ -149,27 +144,15 @@ static std::vector getStatNames() {
return Ret;
}
-static std::string getUSR(const Decl *D) {
- llvm::SmallVector Buf;
- if (index::generateUSRForDecl(D, Buf)) {
-assert(false && "This should never fail");
-return AnalysisDeclContext::getFunctionName(D);
- }
- return llvm::toStringRef(Buf).str();
-}
-
void Registry::Snapshot::dumpAsCSV(llvm::raw_ostream &OS) const {
OS << '"';
- llvm::printEscapedString(getUSR(EntryPoint), OS);
- OS << "\",\"";
- OS << StatsRegistry->EscapedCPPFileName << "\",\"";
llvm::printEscapedString(
clang::AnalysisDeclContext::getFunctionName(EntryPoint), OS);
- OS << "\",";
+ OS << "\", ";
auto PrintAsBool = [&OS](bool B) { OS << (B ? "true" : "false"); };
- llvm::interleave(BoolStatValues, OS, PrintAsBool, ",");
- OS << ((BoolStatValues.empty() || UnsignedStatValues.empty()) ? "" : ",");
- llvm::interleave(UnsignedStatValues, OS, [&OS](unsigned U) { OS << U; },
",");
+ llvm::interleaveComma(BoolStatValues, OS, PrintAsBool);
+ OS << ((BoolStatValues.empty() || UnsignedStatValues.empty()) ? "" : ", ");
+ llvm::interleaveComma(UnsignedStatValues, OS);
}
static std::vector consumeBoolStats() {
@@ -198,8 +181,8 @@ void EntryPointStat::dumpStatsAsCSV(llvm::StringRef
FileName) {
}
void EntryPointStat::dumpStatsAsCSV(llvm::raw_ostream &OS) {
- OS << "USR,File,DebugName,";
- llvm::interleave(getStatNames(), OS, [&OS](const auto &a) { OS << a; }, ",");
+ OS << "EntryPoint, ";
+ llvm::interleaveComma(getStatNames(), OS);
OS << "\n";
std::vector Rows;
diff --git a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
index cf01e2f37c662..3f296aae0ae5f 100644
--- a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -68,15 +68,6 @@ STAT_MAX(MaxCFGSize, "The maximum number of basic blocks in
a function.");
namespace {
-StringRef getMainFileName(const Co
[llvm-branch-commits] [Clang][CodeGen] Emit !alloc_token for new expressions (PR #162099)
https://github.com/melver edited 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] [lldb] release/21.x: [LLDB][ProcessWindows] Set exit status on instance rather than going through all targets (#159308) (PR #161541)
llvmbot wrote: @DavidSpickett What do you think about merging this PR to the release branch? 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] [llvm] [AllocToken, Clang] Implement __builtin_infer_alloc_token() and llvm.alloc.token.id (PR #156842)
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] [llvm] [llvm][mustache] Avoid extra allocations in parseSection (PR #159199)
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/159199 >From f2768938451155c34f6ef4d41bc8ef21833077e8 Mon Sep 17 00:00:00 2001 From: Paul Kirth Date: Tue, 16 Sep 2025 09:40:04 -0700 Subject: [PATCH] [llvm][mustache] Avoid extra allocations in parseSection We don't need to have extra allocations when concatenating raw bodies. --- llvm/lib/Support/Mustache.cpp | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Support/Mustache.cpp b/llvm/lib/Support/Mustache.cpp index 529dd3ac761c9..1284f78e8757b 100644 --- a/llvm/lib/Support/Mustache.cpp +++ b/llvm/lib/Support/Mustache.cpp @@ -602,9 +602,16 @@ void Parser::parseSection(ASTNode *Parent, ASTNode::Type Ty, size_t Start = CurrentPtr; parseMustache(CurrentNode); const size_t End = CurrentPtr - 1; + + size_t RawBodySize = 0; + for (size_t I = Start; I < End; ++I) +RawBodySize += Tokens[I].RawBody.size(); + SmallString<128> RawBody; - for (std::size_t I = Start; I < End; I++) + RawBody.reserve(RawBodySize); + for (std::size_t I = Start; I < End; ++I) RawBody += Tokens[I].RawBody; + CurrentNode->setRawBody(Ctx.Saver.save(StringRef(RawBody))); Parent->addChild(CurrentNode); } ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [mlir] [mlir][omp] Improve canonloop/iv naming (PR #159773)
@@ -0,0 +1,28 @@ +// RUN: fir-opt %s | FileCheck %s --enable-var-scope tblah wrote: Maybe this test belongs in the MLIR openmp dialect rather than in flang? It could be written with scf.if instead of fir.if etc. In theory at least, the MLIR openmp dialect exists upstream of flang and could have other users. https://github.com/llvm/llvm-project/pull/159773 ___ 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)
https://github.com/atrosinenko updated
https://github.com/llvm/llvm-project/pull/138884
>From b3c37e9785982c2fdcb17e086214d92b3be0bdc9 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 291e31e0e0fdf..a240ca07bd02c 100644
--- a/bolt/include/bolt/Core/MCInstUtils.h
+++ b/bolt/include/bolt/Core/MCInstUtils.h
@@ -101,6 +101,15 @@ class MCInstReference {
/// this function may be called from multithreaded code.
uint64_t computeAddress(const MCCodeEmitter *Emitter = nullptr) const;
+ /// 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;
private:
diff --git a/bolt/include/bolt/Core/MCPlusBuilder.h
b/bolt/include/bolt/Core/MCPlusBuilder.h
index 5b711b0e27bab..8c191b113afbc 100644
--- a/bolt/include/bolt/Core/MCPlusBuilder.h
+++ b/bolt/include/bolt/Core/MCPlusBuilder.h
@@ -15,6 +15,7 @@
#define BOLT_CORE_MCPLUSBUILDER_H
#include "bolt/Core/BinaryBasicBlock.h"
+#include "bolt/Core/MCInstUtils.h"
#include "bolt/Core/MCPlus.h"
#include "bolt/Core/Relocation.h"
#include "llvm/ADT/ArrayRef.h"
@@ -718,6 +719,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 f505bf73c64eb..f07616cdb86b9 100644
--- a/bolt/lib/Core/MCInstUtils.cpp
+++ b/bolt/lib/Core/MCInstUtils.cpp
@@ -84,3 +84,23 @@ raw_ostream &MCInstReference::print(raw_ostream &OS) const {
OS << ">";
return OS;
}
+
+std::optional MCInstReference::getSinglePredecessor() {
+ if (const RefInBB *Ref = tryGetRefInBB()) {
+if (Ref->Index != 0)
+ return MCInstReference(*Ref->BB, Ref->Index - 1);
+
+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 cfe4b6ba785e4..af453a5aa6871 100644
--- a/bolt/lib/Passes/PAuthGadgetScanner.cpp
+++ b/bolt/lib/Passes/PAuthGadgetScanner.cpp
@@ -1364,6 +1364,11 @@ shouldReportUnsafeTailCall(const BinaryContext &BC,
const BinaryFunction
[llvm-branch-commits] Add Nix recipe for collecting linker reproducers. (PR #145789)
@@ -0,0 +1,157 @@
+#===---===//
+#
+# 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 is a Nix recipe for collecting reproducers for benchmarking purposes in
a
+# reproducible way. It works by injecting a linker wrapper that embeds a
+# reproducer tarball into a non-allocated section of every linked object, which
+# generally causes them to be smuggled out of the build tree in a section of
the
+# final binaries. In principle, this technique should let us collect
reproducers
+# from any project packaged by Nix without project-specific knowledge, but as
+# you can see below, many interesting ones need a few hacks.
+#
+# If you have Nix installed, you can build the reproducers with the following
+# command:
+#
+# TMPDIR=/var/tmp nix-build -j6 --log-format bar collect.nix
+#
+# This will result in building several large projects including Chromium and
+# Firefox, which will take some time, and it will also build most of the
+# dependencies for non-native targets. Eventually you will get a result
+# directory containing all the reproducers.
+#
+# The following projects have been tested successfully:
+# - chrome (native only, cross builds fail building the qtbase dependency)
+# - firefox (all targets)
+# - linux-kernel (all targets, requires patched nixpkgs)
+# - ladybird (native only, same problem as chromium)
+# - llvm (all targets)
+
+{
+ nixpkgsDir ? fetchTarball
"https://github.com/NixOS/nixpkgs/archive/992f916556fcfaa94451ebc7fc6e396134bbf5b1.tar.gz";,
+ nixpkgs ? import nixpkgsDir,
+}:
+let
+ reproducerPkgs =
+crossSystem:
+let
+ pkgs = nixpkgs { inherit crossSystem; };
+ # Wraps the given stdenv and lld package into a variant that collects
+ # the reproducer and builds with debug info.
+ reproducerCollectingStdenv =
+stdenv: lld:
+let
+ bintools = stdenv.cc.bintools.override {
+extraBuildCommands = ''
+ wrap ${stdenv.cc.targetPrefix}nix-wrap-lld
${nixpkgsDir}/pkgs/build-support/bintools-wrapper/ld-wrapper.sh
${lld}/bin/ld.lld
+ export lz4=${pkgs.lib.getBin pkgs.buildPackages.lz4}/bin/lz4
+ substituteAll ${./ld-wrapper.sh}
$out/bin/${stdenv.cc.targetPrefix}ld
+ chmod +x $out/bin/${stdenv.cc.targetPrefix}ld
+ substituteAll ${./ld-wrapper.sh}
$out/bin/${stdenv.cc.targetPrefix}ld.lld
+ chmod +x $out/bin/${stdenv.cc.targetPrefix}ld.lld
+'';
+ };
+in
+pkgs.withCFlags [ "-g1" ] (stdenv.override (old: {
+ allowedRequisites = null;
+ cc = stdenv.cc.override { inherit bintools; };
+}));
+ withReproducerCollectingStdenv = pkg: pkg.override {
+stdenv = reproducerCollectingStdenv pkgs.stdenv pkgs.buildPackages.lld;
+ };
+ withReproducerCollectingClangStdenv = pkg: pkg.override {
+clangStdenv = reproducerCollectingStdenv pkgs.clangStdenv
pkgs.buildPackages.lld;
+ };
+in
+{
+ # For benchmarking the linker we want to disable LTO as otherwise we
would
+ # just be benchmarking the LLVM optimizer. Also, we generally want the
+ # package to use the regular stdenv in order to simplify wrapping it.
+ # Firefox normally uses the rustc stdenv but uses the regular one if
+ # LTO is disabled so we kill two birds with one stone by disabling it.
+ # Chromium uses the rustc stdenv unconditionally so we need the stuff
+ # below to make sure that it finds our wrapped stdenv.
+ chrome =
+(pkgs.chromium.override {
+ newScope =
+extra:
+pkgs.newScope (
+ extra
+ // {
+pkgsBuildBuild = {
+ pkg-config = pkgs.pkgsBuildBuild.pkg-config;
+ rustc = {
+llvmPackages = rec {
+ stdenv = reproducerCollectingStdenv
pkgs.pkgsBuildBuild.rustc.llvmPackages.stdenv
pkgs.pkgsBuildBuild.rustc.llvmPackages.lld;
+ bintools = stdenv.cc.bintools;
+};
+ };
+};
+ }
+);
+ pkgs = {
+rustc = {
+ llvmPackages = {
+stdenv = reproducerCollectingStdenv
pkgs.rustc.llvmPackages.stdenv pkgs.rustc.llvmPackages.lld;
+ };
+};
+ };
+}).browser.overrideAttrs
+ (old: {
+configurePhase =
+ old.configurePhase
+ + ''
+echo use_thin_lto = false >> out/Release/args.gn
+echo is_cfi = false >> out/Release/args.gn
+ '';
+
[llvm-branch-commits] [llvm] RegAllocGreedy: Check if copied lanes are live in trySplitAroundHintReg (PR #160424)
llvmbot wrote:
@llvm/pr-subscribers-backend-x86
Author: Matt Arsenault (arsenm)
Changes
For subregister copies, do a subregister live check instead of checking
the main range. Doesn't do much yet, the split analysis still does not
track live ranges.
---
Full diff: https://github.com/llvm/llvm-project/pull/160424.diff
4 Files Affected:
- (modified) llvm/lib/CodeGen/RegAllocGreedy.cpp (+22-2)
- (modified) llvm/test/CodeGen/SystemZ/fp-cmp-04.ll (+2-2)
- (modified) llvm/test/CodeGen/X86/fshl.ll (+40-41)
- (modified) llvm/test/CodeGen/X86/fshr.ll (+45-45)
``diff
diff --git a/llvm/lib/CodeGen/RegAllocGreedy.cpp
b/llvm/lib/CodeGen/RegAllocGreedy.cpp
index 8e6cf3e6b51b3..6e0585b2e9e55 100644
--- a/llvm/lib/CodeGen/RegAllocGreedy.cpp
+++ b/llvm/lib/CodeGen/RegAllocGreedy.cpp
@@ -1406,8 +1406,28 @@ bool RAGreedy::trySplitAroundHintReg(MCPhysReg Hint,
continue;
// Check if VirtReg interferes with OtherReg after this COPY instruction.
-if (!IsDef && VirtReg.liveAt(LIS->getInstructionIndex(Instr).getRegSlot()))
- continue;
+if (Opnd.readsReg()) {
+ SlotIndex Index = LIS->getInstructionIndex(Instr).getRegSlot();
+
+ if (SubReg) {
+LaneBitmask Mask = TRI->getSubRegIndexLaneMask(SubReg);
+if (IsDef)
+ Mask = ~Mask;
+
+if (any_of(VirtReg.subranges(), [=](const LiveInterval::SubRange &S) {
+ if ((S.LaneMask & Mask).any()) {
+if (S.liveAt(Index))
+ return true;
+ }
+ return false;
+})) {
+ continue;
+}
+ } else {
+if (VirtReg.liveAt(Index))
+ continue;
+ }
+}
MCRegister OtherPhysReg =
OtherReg.isPhysical() ? OtherReg.asMCReg() : VRM->getPhys(OtherReg);
diff --git a/llvm/test/CodeGen/SystemZ/fp-cmp-04.ll
b/llvm/test/CodeGen/SystemZ/fp-cmp-04.ll
index d3d641357ae58..eb7c1b632dba9 100644
--- a/llvm/test/CodeGen/SystemZ/fp-cmp-04.ll
+++ b/llvm/test/CodeGen/SystemZ/fp-cmp-04.ll
@@ -235,7 +235,7 @@ define half @f12_half(half %dummy, half %val, ptr %dest) {
; CHECK-NEXT: blah %f0
; CHECK-NEXT: #NO_APP
; CHECK-NEXT: brasl %r14, __extendhfsf2@PLT
-; CHECK-NEXT: ltebr %f0, %f0
+; CHECK-NEXT: ltebr %f1, %f0
; CHECK-NEXT: jl .LBB11_2
; CHECK-NEXT:# %bb.1:
; CHECK-NEXT: lgdr %r0, %f8
@@ -344,7 +344,7 @@ define half @f15_half(half %val, half %dummy, ptr %dest) {
; CHECK-NEXT: blah %f2
; CHECK-NEXT: #NO_APP
; CHECK-NEXT: brasl %r14, __extendhfsf2@PLT
-; CHECK-NEXT: ltebr %f0, %f0
+; CHECK-NEXT: ltebr %f1, %f0
; CHECK-NEXT: jl .LBB15_2
; CHECK-NEXT:# %bb.1:
; CHECK-NEXT: lgdr %r0, %f8
diff --git a/llvm/test/CodeGen/X86/fshl.ll b/llvm/test/CodeGen/X86/fshl.ll
index ec1b8a3c8d6d9..f998128af95f8 100644
--- a/llvm/test/CodeGen/X86/fshl.ll
+++ b/llvm/test/CodeGen/X86/fshl.ll
@@ -335,84 +335,83 @@ define i128 @var_shift_i128(i128 %x, i128 %y, i128 %z)
nounwind {
; X86-SLOW-NEXT:pushl %esi
; X86-SLOW-NEXT:andl $-16, %esp
; X86-SLOW-NEXT:subl $32, %esp
-; X86-SLOW-NEXT:movl 24(%ebp), %esi
+; X86-SLOW-NEXT:movl 24(%ebp), %edi
; X86-SLOW-NEXT:movl 28(%ebp), %eax
; X86-SLOW-NEXT:movl 48(%ebp), %edx
; X86-SLOW-NEXT:movl 56(%ebp), %ecx
; X86-SLOW-NEXT:testb $64, %cl
-; X86-SLOW-NEXT:movl 52(%ebp), %edi
+; X86-SLOW-NEXT:movl 52(%ebp), %ebx
; X86-SLOW-NEXT:jne .LBB6_1
; X86-SLOW-NEXT: # %bb.2:
; X86-SLOW-NEXT:movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
-; X86-SLOW-NEXT:movl %esi, %edx
-; X86-SLOW-NEXT:movl 32(%ebp), %esi
-; X86-SLOW-NEXT:movl %edi, %ecx
-; X86-SLOW-NEXT:movl %eax, %edi
+; X86-SLOW-NEXT:movl %edi, %edx
+; X86-SLOW-NEXT:movl 32(%ebp), %edi
+; X86-SLOW-NEXT:movl %ebx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
+; X86-SLOW-NEXT:movl %eax, %ebx
; X86-SLOW-NEXT:movl 36(%ebp), %eax
; X86-SLOW-NEXT:jmp .LBB6_3
; X86-SLOW-NEXT: .LBB6_1:
; X86-SLOW-NEXT:movl 40(%ebp), %ecx
; X86-SLOW-NEXT:movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
; X86-SLOW-NEXT:movl 44(%ebp), %ecx
+; X86-SLOW-NEXT:movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
; X86-SLOW-NEXT: .LBB6_3:
-; X86-SLOW-NEXT:movl 56(%ebp), %ebx
-; X86-SLOW-NEXT:testb $32, %bl
+; X86-SLOW-NEXT:movl 56(%ebp), %ecx
+; X86-SLOW-NEXT:testb $32, %cl
; X86-SLOW-NEXT:jne .LBB6_4
; X86-SLOW-NEXT: # %bb.5:
-; X86-SLOW-NEXT:movl %ecx, %ebx
; X86-SLOW-NEXT:movl %edi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
-; X86-SLOW-NEXT:movl %esi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
+; X86-SLOW-NEXT:movl %edx, %edi
+; X86-SLOW-NEXT:movl {{[-0-9]+}}(%e{{[sb]}}p), %esi # 4-byte Reload
; X86-SLOW-NEXT:movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
; X86-SLOW-NEXT:jmp .LBB6_6
; X86-SLOW-NEXT: .LBB6_4:
-; X86-SLOW-NEXT:movl %esi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
; X86-SLOW-NEXT:movl %edi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
-; X86-SLOW-NEXT:movl %edx
[llvm-branch-commits] [libc] [libc][stdlib][annex_k] Add abort_handler_s. (PR #163309)
https://github.com/bassiounix updated https://github.com/llvm/llvm-project/pull/163309 >From d4fdba1879a048a932e86abda7daf7253a1162d0 Mon Sep 17 00:00:00 2001 From: bassiounix Date: Tue, 14 Oct 2025 00:42:14 +0300 Subject: [PATCH] [libc][annex_k] Add abort_handler_s. --- libc/config/linux/aarch64/entrypoints.txt| 5 ++- libc/config/linux/riscv/entrypoints.txt | 5 ++- libc/config/linux/x86_64/entrypoints.txt | 5 ++- libc/include/CMakeLists.txt | 1 + libc/include/stdlib.yaml | 14 ++- libc/src/__support/CMakeLists.txt| 1 + libc/src/__support/annex_k/CMakeLists.txt| 12 ++ libc/src/__support/annex_k/abort_handler_s.h | 43 libc/src/stdlib/CMakeLists.txt | 10 + libc/src/stdlib/abort_handler_s.cpp | 20 + libc/src/stdlib/abort_handler_s.h| 22 ++ 11 files changed, 134 insertions(+), 4 deletions(-) create mode 100644 libc/src/__support/annex_k/CMakeLists.txt create mode 100644 libc/src/__support/annex_k/abort_handler_s.h create mode 100644 libc/src/stdlib/abort_handler_s.cpp create mode 100644 libc/src/stdlib/abort_handler_s.h diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt index d79682cad8b80..b86d3f22afec1 100644 --- a/libc/config/linux/aarch64/entrypoints.txt +++ b/libc/config/linux/aarch64/entrypoints.txt @@ -1,4 +1,7 @@ -set(TARGET_ANNEX_K_ENTRYPOINTS "") +set(TARGET_ANNEX_K_ENTRYPOINTS +# stdlib.h entrypoints +libc.src.stdlib.abort_handler_s +) set(TARGET_LIBC_ENTRYPOINTS # ctype.h entrypoints diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt index fd9bd9d4350eb..fb0fbe9c456c9 100644 --- a/libc/config/linux/riscv/entrypoints.txt +++ b/libc/config/linux/riscv/entrypoints.txt @@ -1,4 +1,7 @@ -set(TARGET_ANNEX_K_ENTRYPOINTS "") +set(TARGET_ANNEX_K_ENTRYPOINTS +# stdlib.h entrypoints +libc.src.stdlib.abort_handler_s +) set(TARGET_LIBC_ENTRYPOINTS # ctype.h entrypoints diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt index 3503b8473ae78..f9d2379570c3b 100644 --- a/libc/config/linux/x86_64/entrypoints.txt +++ b/libc/config/linux/x86_64/entrypoints.txt @@ -1,4 +1,7 @@ -set(TARGET_ANNEX_K_ENTRYPOINTS "") +set(TARGET_ANNEX_K_ENTRYPOINTS +# stdlib.h entrypoints +libc.src.stdlib.abort_handler_s +) set(TARGET_LIBC_ENTRYPOINTS # ctype.h entrypoints diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt index 3266b57bc8ecd..7ef6940763519 100644 --- a/libc/include/CMakeLists.txt +++ b/libc/include/CMakeLists.txt @@ -368,6 +368,7 @@ add_header_macro( .llvm-libc-types.__search_compare_t .llvm-libc-types.constraint_handler_t .llvm-libc-types.div_t +.llvm-libc-types.errno_t .llvm-libc-types.ldiv_t .llvm-libc-types.lldiv_t .llvm-libc-types.locale_t diff --git a/libc/include/stdlib.yaml b/libc/include/stdlib.yaml index 29fd6bc3a1e75..050cf246decf6 100644 --- a/libc/include/stdlib.yaml +++ b/libc/include/stdlib.yaml @@ -5,7 +5,9 @@ standards: merge_yaml_files: - stdlib-malloc.yaml macros: - - macro_name: NULL + - macro_name: 'LIBC_HAS_ANNEX_K' +macro_header: annex-k-macros.h + - macro_name: 'NULL' macro_header: null-macro.h types: - type_name: __atexithandler_t @@ -14,6 +16,7 @@ types: - type_name: __search_compare_t - type_name: constraint_handler_t - type_name: div_t + - type_name: errno_t - type_name: ldiv_t - type_name: lldiv_t - type_name: locale_t @@ -181,6 +184,15 @@ functions: return_type: int arguments: - type: void + - name: abort_handler_s +standards: + - stdc +return_type: void +arguments: + - type: const char *__restrict + - type: void *__restrict + - type: errno_t +guard: 'LIBC_HAS_ANNEX_K' - name: srand standards: - stdc diff --git a/libc/src/__support/CMakeLists.txt b/libc/src/__support/CMakeLists.txt index 0ef09a9b8c9d0..b71a56826156b 100644 --- a/libc/src/__support/CMakeLists.txt +++ b/libc/src/__support/CMakeLists.txt @@ -1,3 +1,4 @@ +add_subdirectory(annex_k) add_subdirectory(CPP) add_subdirectory(macros) diff --git a/libc/src/__support/annex_k/CMakeLists.txt b/libc/src/__support/annex_k/CMakeLists.txt new file mode 100644 index 0..78f5b3cddebd7 --- /dev/null +++ b/libc/src/__support/annex_k/CMakeLists.txt @@ -0,0 +1,12 @@ +add_header_library( + abort_handler_s + HDRS +abort_handler_s.h + DEPENDS +libc.hdr.stdio_macros +libc.hdr.types.errno_t +libc.src.__support.macros.config +libc.src.__support.macros.attributes +libc.src.__support.OSUtil.osutil +libc.src.stdlib.abort +) diff --git a/libc/src/__support/annex_k/abort_handler_s.h b/libc/src/__support/annex_k/abort_handler_s.h new file mode 100644 index 0..dca3dcc2d9825 --- /dev/null
[llvm-branch-commits] [llvm] [IR2Vec] Refactor MIR vocabulary to use opcode-based indexing (PR #161713)
https://github.com/svkeerthy updated
https://github.com/llvm/llvm-project/pull/161713
>From 671c686b3277940ef5a0b20e1916313e58dc9f84 Mon Sep 17 00:00:00 2001
From: svkeerthy
Date: Thu, 2 Oct 2025 18:14:53 +
Subject: [PATCH] MIRVocabulary changes
---
llvm/include/llvm/CodeGen/MIR2Vec.h| 31 +---
llvm/lib/CodeGen/MIR2Vec.cpp | 18 ++
llvm/unittests/CodeGen/MIR2VecTest.cpp | 50 --
3 files changed, 62 insertions(+), 37 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/MIR2Vec.h
b/llvm/include/llvm/CodeGen/MIR2Vec.h
index 0ccb24448a678..ea68b4594a2ad 100644
--- a/llvm/include/llvm/CodeGen/MIR2Vec.h
+++ b/llvm/include/llvm/CodeGen/MIR2Vec.h
@@ -8,8 +8,8 @@
///
/// \file
/// This file defines the MIR2Vec vocabulary
-/// analysis(MIR2VecVocabLegacyAnalysis), the core mir2vec::Embedder interface
-/// for generating Machine IR embeddings, and related utilities.
+/// analysis(MIR2VecVocabLegacyAnalysis), the core mir2vec::MIREmbedder
+/// interface for generating Machine IR embeddings, and related utilities.
///
/// MIR2Vec extends IR2Vec to support Machine IR embeddings. It represents the
/// LLVM Machine IR as embeddings which can be used as input to machine
learning
@@ -71,25 +71,31 @@ class MIRVocabulary {
size_t TotalEntries = 0;
} Layout;
+ enum class Section : unsigned { Opcodes = 0, MaxSections };
+
ir2vec::VocabStorage Storage;
mutable std::set UniqueBaseOpcodeNames;
- void generateStorage(const VocabMap &OpcodeMap, const TargetInstrInfo &TII);
- void buildCanonicalOpcodeMapping(const TargetInstrInfo &TII);
+ const TargetInstrInfo &TII;
+ void generateStorage(const VocabMap &OpcodeMap);
+ void buildCanonicalOpcodeMapping();
+
+ /// Get canonical index for a machine opcode
+ unsigned getCanonicalOpcodeIndex(unsigned Opcode) const;
public:
- /// Static helper method for extracting base opcode names (public for
testing)
+ /// Static method for extracting base opcode names (public for testing)
static std::string extractBaseOpcodeName(StringRef InstrName);
- /// Helper method for getting canonical index for base name (public for
- /// testing)
+ /// Get canonical index for base name (public for testing)
unsigned getCanonicalIndexForBaseName(StringRef BaseName) const;
/// Get the string key for a vocabulary entry at the given position
std::string getStringKey(unsigned Pos) const;
- MIRVocabulary() = default;
+ MIRVocabulary() = delete;
MIRVocabulary(VocabMap &&Entries, const TargetInstrInfo *TII);
- MIRVocabulary(ir2vec::VocabStorage &&Storage) : Storage(std::move(Storage))
{}
+ MIRVocabulary(ir2vec::VocabStorage &&Storage, const TargetInstrInfo &TII)
+ : Storage(std::move(Storage)), TII(TII) {}
bool isValid() const {
return UniqueBaseOpcodeNames.size() > 0 &&
@@ -103,11 +109,10 @@ class MIRVocabulary {
}
// Accessor methods
- const Embedding &operator[](unsigned Index) const {
+ const Embedding &operator[](unsigned Opcode) const {
assert(isValid() && "MIR2Vec Vocabulary is invalid");
-assert(Index < Layout.TotalEntries && "Index out of bounds");
-// Fixme: For now, use section 0 for all entries
-return Storage[0][Index];
+unsigned LocalIndex = getCanonicalOpcodeIndex(Opcode);
+return Storage[static_cast(Section::Opcodes)][LocalIndex];
}
// Iterator access
diff --git a/llvm/lib/CodeGen/MIR2Vec.cpp b/llvm/lib/CodeGen/MIR2Vec.cpp
index 83c5646629b48..87565c0c77115 100644
--- a/llvm/lib/CodeGen/MIR2Vec.cpp
+++ b/llvm/lib/CodeGen/MIR2Vec.cpp
@@ -49,20 +49,21 @@ cl::opt OpcWeight("mir2vec-opc-weight",
cl::Optional, cl::init(1.0),
//===--===//
MIRVocabulary::MIRVocabulary(VocabMap &&OpcodeEntries,
- const TargetInstrInfo *TII) {
+ const TargetInstrInfo *TII)
+: TII(*TII) {
// Fixme: Use static factory methods for creating vocabularies instead of
// public constructors
// Early return for invalid inputs - creates empty/invalid vocabulary
if (!TII || OpcodeEntries.empty())
return;
- buildCanonicalOpcodeMapping(*TII);
+ buildCanonicalOpcodeMapping();
unsigned CanonicalOpcodeCount = UniqueBaseOpcodeNames.size();
assert(CanonicalOpcodeCount > 0 &&
"No canonical opcodes found for target - invalid vocabulary");
Layout.OperandBase = CanonicalOpcodeCount;
- generateStorage(OpcodeEntries, *TII);
+ generateStorage(OpcodeEntries);
Layout.TotalEntries = Storage.size();
}
@@ -105,6 +106,12 @@ unsigned
MIRVocabulary::getCanonicalIndexForBaseName(StringRef BaseName) const {
return std::distance(UniqueBaseOpcodeNames.begin(), It);
}
+unsigned MIRVocabulary::getCanonicalOpcodeIndex(unsigned Opcode) const {
+ assert(isValid() && "MIR2Vec Vocabulary is invalid");
+ auto BaseOpcode = extractBaseOpcodeName(TII.getName(Opcode));
+ return getCanonicalIndexForB
[llvm-branch-commits] [llvm] [PowerPC] Implement paddis (PR #161572)
https://github.com/lei137 created
https://github.com/llvm/llvm-project/pull/161572
None
>From ea6d743c7a6c572053b360fc4eee2dedad681b21 Mon Sep 17 00:00:00 2001
From: Lei Huang
Date: Tue, 30 Sep 2025 18:09:31 +
Subject: [PATCH] [PowerPC] Implement paddis
---
.../Target/PowerPC/AsmParser/PPCAsmParser.cpp | 7 +++
.../PowerPC/MCTargetDesc/PPCAsmBackend.cpp| 9
.../PowerPC/MCTargetDesc/PPCFixupKinds.h | 6 +++
.../PowerPC/MCTargetDesc/PPCInstPrinter.cpp | 12 +
.../PowerPC/MCTargetDesc/PPCInstPrinter.h | 2 +
.../PowerPC/MCTargetDesc/PPCMCCodeEmitter.cpp | 1 +
llvm/lib/Target/PowerPC/PPCInstrFuture.td | 44 +++
llvm/lib/Target/PowerPC/PPCRegisterInfo.td| 19
.../PowerPC/ppc-encoding-ISAFuture.txt| 6 +++
.../PowerPC/ppc64le-encoding-ISAFuture.txt| 6 +++
llvm/test/MC/PowerPC/ppc-encoding-ISAFuture.s | 8
11 files changed, 120 insertions(+)
diff --git a/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
b/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
index 1fc475dc6cb7e..d09bd9d38d585 100644
--- a/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
+++ b/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
@@ -388,6 +388,13 @@ struct PPCOperand : public MCParsedAsmOperand {
return Kind == Expression ||
(Kind == Immediate && isInt<34>(getImm()) && (getImm() & 15) == 0);
}
+
+ bool isS32Imm() const {
+// Once the PC-Rel ABI is finalized, evaluate whether a 32-bit
+// ContextImmediate is needed.
+return Kind == Expression || (Kind == Immediate && isInt<32>(getImm()));
+ }
+
bool isS34Imm() const {
// Once the PC-Rel ABI is finalized, evaluate whether a 34-bit
// ContextImmediate is needed.
diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
index 04b886ae74993..558351b515a2e 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
@@ -47,6 +47,9 @@ static uint64_t adjustFixupValue(unsigned Kind, uint64_t
Value) {
case PPC::fixup_ppc_half16ds:
case PPC::fixup_ppc_half16dq:
return Value & 0xfffc;
+ case PPC::fixup_ppc_pcrel32:
+ case PPC::fixup_ppc_imm32:
+return Value & 0x;
case PPC::fixup_ppc_pcrel34:
case PPC::fixup_ppc_imm34:
return Value & 0x3;
@@ -71,6 +74,8 @@ static unsigned getFixupKindNumBytes(unsigned Kind) {
case PPC::fixup_ppc_br24abs:
case PPC::fixup_ppc_br24_notoc:
return 4;
+ case PPC::fixup_ppc_pcrel32:
+ case PPC::fixup_ppc_imm32:
case PPC::fixup_ppc_pcrel34:
case PPC::fixup_ppc_imm34:
case FK_Data_8:
@@ -154,6 +159,8 @@ MCFixupKindInfo PPCAsmBackend::getFixupKindInfo(MCFixupKind
Kind) const {
{"fixup_ppc_brcond14abs", 16, 14, 0},
{"fixup_ppc_half16", 0, 16, 0},
{"fixup_ppc_half16ds", 0, 14, 0},
+ {"fixup_ppc_pcrel32", 0, 32, 0},
+ {"fixup_ppc_imm32", 0, 32, 0},
{"fixup_ppc_pcrel34", 0, 34, 0},
{"fixup_ppc_imm34", 0, 34, 0},
{"fixup_ppc_nofixup", 0, 0, 0}};
@@ -166,6 +173,8 @@ MCFixupKindInfo PPCAsmBackend::getFixupKindInfo(MCFixupKind
Kind) const {
{"fixup_ppc_brcond14abs", 2, 14, 0},
{"fixup_ppc_half16", 0, 16, 0},
{"fixup_ppc_half16ds", 2, 14, 0},
+ {"fixup_ppc_pcrel32", 0, 32, 0},
+ {"fixup_ppc_imm32", 0, 32, 0},
{"fixup_ppc_pcrel34", 0, 34, 0},
{"fixup_ppc_imm34", 0, 34, 0},
{"fixup_ppc_nofixup", 0, 0, 0}};
diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCFixupKinds.h
b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCFixupKinds.h
index df0c666f5b113..4164b697649cd 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCFixupKinds.h
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCFixupKinds.h
@@ -40,6 +40,12 @@ enum Fixups {
/// instrs like 'std'.
fixup_ppc_half16ds,
+ // A 32-bit fixup corresponding to PC-relative paddis.
+ fixup_ppc_pcrel32,
+
+ // A 32-bit fixup corresponding to Non-PC-relative paddis.
+ fixup_ppc_imm32,
+
// A 34-bit fixup corresponding to PC-relative paddi.
fixup_ppc_pcrel34,
diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
index b27bc3bd49315..e2afb9378cbf0 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
@@ -430,6 +430,18 @@ void PPCInstPrinter::printS16ImmOperand(const MCInst *MI,
unsigned OpNo,
printOperand(MI, OpNo, STI, O);
}
+void PPCInstPrinter::printS32ImmOperand(const MCInst *MI, unsigned OpNo,
+const MCSubtargetInfo &STI,
+raw_ostream &O) {
+ if (MI->getOperand(OpNo).isImm()) {
+long long Value = MI->getOperand(OpNo).getImm();
+assert(isInt<32>(Value) && "Invalid s32imm argument!");
+O << (long long)Value;
+ }
+ else
+printOperand(
[llvm-branch-commits] [libc] [libc][stdlib][annex_k] Add ignore_handler_s. (PR #163313)
https://github.com/bassiounix updated
https://github.com/llvm/llvm-project/pull/163313
>From 08051a7dd114dcbd50b65de627f291cb9b699383 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] [libc] [libc][stdlib][annex_k] Add set_constraint_handler_s. (PR #163320)
https://github.com/bassiounix updated
https://github.com/llvm/llvm-project/pull/163320
>From c46a87bbadeb7a3293e5febe7e5a0b62d94102d5 Mon Sep 17 00:00:00 2001
From: bassiounix
Date: Tue, 14 Oct 2025 07:06:06 +0300
Subject: [PATCH] [libc][stdlib][annex_k] Add set_constraint_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/stdlib.yaml | 7 +
libc/src/stdlib/CMakeLists.txt | 11
libc/src/stdlib/set_constraint_handler_s.cpp | 28
libc/src/stdlib/set_constraint_handler_s.h | 21 +++
7 files changed, 70 insertions(+)
create mode 100644 libc/src/stdlib/set_constraint_handler_s.cpp
create mode 100644 libc/src/stdlib/set_constraint_handler_s.h
diff --git a/libc/config/linux/aarch64/entrypoints.txt
b/libc/config/linux/aarch64/entrypoints.txt
index b2b3789cc2f60..a6493467d2143 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -2,6 +2,7 @@ set(TARGET_ANNEX_K_ENTRYPOINTS
# stdlib.h entrypoints
libc.src.stdlib.abort_handler_s
libc.src.stdlib.ignore_handler_s
+libc.src.stdlib.set_constraint_handler_s
)
set(TARGET_LIBC_ENTRYPOINTS
diff --git a/libc/config/linux/riscv/entrypoints.txt
b/libc/config/linux/riscv/entrypoints.txt
index 5d92b112272fb..b19641a0a656b 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -2,6 +2,7 @@ set(TARGET_ANNEX_K_ENTRYPOINTS
# stdlib.h entrypoints
libc.src.stdlib.abort_handler_s
libc.src.stdlib.ignore_handler_s
+libc.src.stdlib.set_constraint_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 4cb412ae7c526..12e81121a1a01 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -2,6 +2,7 @@ set(TARGET_ANNEX_K_ENTRYPOINTS
# stdlib.h entrypoints
libc.src.stdlib.abort_handler_s
libc.src.stdlib.ignore_handler_s
+libc.src.stdlib.set_constraint_handler_s
)
set(TARGET_LIBC_ENTRYPOINTS
diff --git a/libc/include/stdlib.yaml b/libc/include/stdlib.yaml
index 7c3b113a62415..49d45f105fe7a 100644
--- a/libc/include/stdlib.yaml
+++ b/libc/include/stdlib.yaml
@@ -202,6 +202,13 @@ functions:
- type: void *__restrict
- type: errno_t
guard: 'LIBC_HAS_ANNEX_K'
+ - name: set_constraint_handler_s
+standards:
+ - stdc
+return_type: constraint_handler_t
+arguments:
+ - type: constraint_handler_t
+guard: 'LIBC_HAS_ANNEX_K'
- name: srand
standards:
- stdc
diff --git a/libc/src/stdlib/CMakeLists.txt b/libc/src/stdlib/CMakeLists.txt
index 5efd7f13ff3ee..c380657300cfe 100644
--- a/libc/src/stdlib/CMakeLists.txt
+++ b/libc/src/stdlib/CMakeLists.txt
@@ -664,6 +664,17 @@ add_entrypoint_object(
.${LIBC_TARGET_OS}.system
)
+add_entrypoint_object(
+ set_constraint_handler_s
+ SRCS
+set_constraint_handler_s.cpp
+ HDRS
+set_constraint_handler_s.h
+ DEPENDS
+libc.src.__support.annex_k.abort_handler_s
+libc.src.__support.annex_k.libc_constraint_handler
+)
+
add_entrypoint_object(
ignore_handler_s
HDRS
diff --git a/libc/src/stdlib/set_constraint_handler_s.cpp
b/libc/src/stdlib/set_constraint_handler_s.cpp
new file mode 100644
index 0..d3a16d77e3b0a
--- /dev/null
+++ b/libc/src/stdlib/set_constraint_handler_s.cpp
@@ -0,0 +1,28 @@
+//===-- Implementation of set_constraint_handler_s
===//
+//
+// 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 "set_constraint_handler_s.h"
+#include "src/__support/annex_k/abort_handler_s.h"
+#include "src/__support/annex_k/libc_constraint_handler.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(constraint_handler_t, set_constraint_handler_s,
+ (constraint_handler_t handler)) {
+ auto previous_handler = annex_k::libc_constraint_handler;
+
+ if (!handler) {
+annex_k::libc_constraint_handler = &annex_k::abort_handler_s;
+ } else {
+annex_k::libc_constraint_handler = handler;
+ }
+
+ return previous_handler;
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/stdlib/set_constraint_handler_s.h
b/libc/src/stdlib/set_constraint_handler_s.h
new file mode 100644
index 0..f5c6e01712ef0
--- /dev/null
+++ b/libc/src/stdlib/set_constraint_handler_s.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for set_constraint_handler_s --*- C++
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// S
[llvm-branch-commits] ELF: Use preprocessed relocations for EhInputSection scanning (PR #161091)
@@ -1574,6 +1569,13 @@ void RelocationScanner::scanOne(typename
Relocs::const_iterator &i) {
}
}
+ scanOneAux(i, expr, type, offset, sym, addend);
+}
+
+template
+void RelocationScanner::scanOneAux(RelIt &i, RelExpr expr, RelType type,
smithp35 wrote:
IIUC this is the common tail between scanEhSection and scanSection.
As .ehframe sections describe code sections, I wouldn't expect to see any GOT
generating or TLS relocations. Could we call processAux directly from
scanEhSection instead of calling scanOneAux. Then we could fold this part back
into scanOne.
https://github.com/llvm/llvm-project/pull/161091
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [AllocToken, Clang] Implement TypeHashPointerSplit mode (PR #156840)
@@ -1272,18 +1272,84 @@ void CodeGenFunction::EmitBoundsCheckImpl(const Expr
*E, llvm::Value *Bound,
EmitCheck(std::make_pair(Check, CheckKind), CheckHandler, StaticData, Index);
}
+static bool
+typeContainsPointer(QualType T,
+llvm::SmallPtrSet &VisitedRD,
+bool &IncompleteType) {
+ QualType CanonicalType = T.getCanonicalType();
+ if (CanonicalType->isPointerType())
+return true; // base case
+
+ // Look through typedef chain to check for special types.
+ for (QualType CurrentT = T; const auto *TT = CurrentT->getAs();
+ CurrentT = TT->getDecl()->getUnderlyingType()) {
+const IdentifierInfo *II = TT->getDecl()->getIdentifier();
+if (!II)
+ continue;
+// Special Case: Syntactically uintptr_t is not a pointer; semantically,
+// however, very likely used as such. Therefore, classify uintptr_t as a
+// pointer, too.
+if (II->isStr("uintptr_t"))
+ return true;
+ }
+
+ // The type is an array; check the element type.
+ if (const ArrayType *AT = dyn_cast(CanonicalType))
+return typeContainsPointer(AT->getElementType(), VisitedRD,
IncompleteType);
+ // The type is a struct, class, or union.
+ if (const RecordDecl *RD = CanonicalType->getAsRecordDecl()) {
+if (!RD->isCompleteDefinition()) {
+ IncompleteType = true;
+ return false;
+}
+if (!VisitedRD.insert(RD).second)
+ return false; // already visited
+// Check all fields.
+for (const FieldDecl *Field : RD->fields()) {
+ if (typeContainsPointer(Field->getType(), VisitedRD, IncompleteType))
+return true;
+}
+// For C++ classes, also check base classes.
+if (const CXXRecordDecl *CXXRD = dyn_cast(RD)) {
+ // Polymorphic types require a vptr.
+ if (CXXRD->isPolymorphic())
+return true;
+ for (const CXXBaseSpecifier &Base : CXXRD->bases()) {
+if (typeContainsPointer(Base.getType(), VisitedRD, IncompleteType))
+ return true;
+ }
+}
+ }
+ return false;
+}
+
void CodeGenFunction::EmitAllocToken(llvm::CallBase *CB, QualType AllocType) {
assert(SanOpts.has(SanitizerKind::AllocToken) &&
"Only needed with -fsanitize=alloc-token");
+ llvm::MDBuilder MDB(getLLVMContext());
+
+ // Get unique type name.
PrintingPolicy Policy(CGM.getContext().getLangOpts());
Policy.SuppressTagKeyword = true;
Policy.FullyQualifiedName = true;
std::string TypeName = AllocType.getCanonicalType().getAsString(Policy);
- auto *TypeMDS = llvm::MDString::get(CGM.getLLVMContext(), TypeName);
+ auto *TypeNameMD = MDB.createString(TypeName);
+
+ // Check if QualType contains a pointer. Implements a simple DFS to
+ // recursively check if a type contains a pointer type.
+ llvm::SmallPtrSet VisitedRD;
+ bool IncompleteType = false;
+ const bool ContainsPtr =
+ typeContainsPointer(AllocType, VisitedRD, IncompleteType);
zmodem wrote:
Great, thanks for checking!
https://github.com/llvm/llvm-project/pull/156840
___
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)
https://github.com/RiverDave updated
https://github.com/llvm/llvm-project/pull/161212
>From e446b4723e7df94f057d20a9ad0fdc28964bb2fd Mon Sep 17 00:00:00 2001
From: David Rivera
Date: Mon, 29 Sep 2025 11:05:44 -0400
Subject: [PATCH 1/2] [CIR] Upstream AddressSpace casting support
---
.../CIR/Dialect/Builder/CIRBaseBuilder.h | 9 +++
clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp | 41 +++
clang/lib/CIR/CodeGen/CIRGenExpr.cpp | 19 +-
clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp| 22 ++
clang/lib/CIR/CodeGen/CIRGenFunction.h| 4 ++
clang/lib/CIR/CodeGen/CIRGenModule.cpp| 17 +
clang/lib/CIR/CodeGen/CIRGenModule.h | 6 ++
clang/lib/CIR/CodeGen/CIRGenTypes.cpp | 2 +-
clang/lib/CIR/CodeGen/TargetInfo.cpp | 13
clang/lib/CIR/CodeGen/TargetInfo.h| 12
clang/test/CIR/address-space-conversion.cpp | 68 +++
11 files changed, 195 insertions(+), 18 deletions(-)
create mode 100644 clang/test/CIR/address-space-conversion.cpp
diff --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
index cef8624e65d57..bf4a9b8438982 100644
--- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
+++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
@@ -424,6 +424,15 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
return createBitcast(src, getPointerTo(newPointeeTy));
}
+ mlir::Value createAddrSpaceCast(mlir::Location loc, mlir::Value src,
+ mlir::Type newTy) {
+return createCast(loc, cir::CastKind::address_space, src, newTy);
+ }
+
+ mlir::Value createAddrSpaceCast(mlir::Value src, mlir::Type newTy) {
+return createAddrSpaceCast(src.getLoc(), src, newTy);
+ }
+
//======//
// Binary Operators
//======//
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
index cf17de144f4d9..95e392d860518 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
@@ -58,6 +58,24 @@ static RValue emitBuiltinBitOp(CIRGenFunction &cgf, const
CallExpr *e,
return RValue::get(result);
}
+// Initialize the alloca with the given size and alignment according to the
lang
+// opts. Supporting only the trivial non-initialization for now.
+static void initializeAlloca(CIRGenFunction &CGF,
+ [[maybe_unused]] mlir::Value AllocaAddr,
+ [[maybe_unused]] mlir::Value Size,
+ [[maybe_unused]] CharUnits AlignmentInBytes) {
+
+ switch (CGF.getLangOpts().getTrivialAutoVarInit()) {
+ case LangOptions::TrivialAutoVarInitKind::Uninitialized:
+// Nothing to initialize.
+return;
+ case LangOptions::TrivialAutoVarInitKind::Zero:
+ case LangOptions::TrivialAutoVarInitKind::Pattern:
+assert(false && "unexpected trivial auto var init kind NYI");
+return;
+ }
+}
+
RValue CIRGenFunction::emitRotate(const CallExpr *e, bool isRotateLeft) {
mlir::Value input = emitScalarExpr(e->getArg(0));
mlir::Value amount = emitScalarExpr(e->getArg(1));
@@ -172,21 +190,8 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl
&gd, unsigned builtinID,
builder.getUInt8Ty(), "bi_alloca", suitableAlignmentInBytes, size);
// Initialize the allocated buffer if required.
-if (builtinID != Builtin::BI__builtin_alloca_uninitialized) {
- // Initialize the alloca with the given size and alignment according to
- // the lang opts. Only the trivial non-initialization is supported for
- // now.
-
- switch (getLangOpts().getTrivialAutoVarInit()) {
- case LangOptions::TrivialAutoVarInitKind::Uninitialized:
-// Nothing to initialize.
-break;
- case LangOptions::TrivialAutoVarInitKind::Zero:
- case LangOptions::TrivialAutoVarInitKind::Pattern:
-cgm.errorNYI("trivial auto var init");
-break;
- }
-}
+if (builtinID != Builtin::BI__builtin_alloca_uninitialized)
+ initializeAlloca(*this, allocaAddr, size, suitableAlignmentInBytes);
// An alloca will always return a pointer to the alloca (stack) address
// space. This address space need not be the same as the AST / Language
@@ -194,6 +199,12 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl
&gd, unsigned builtinID,
// the AST level this is handled within CreateTempAlloca et al., but for
the
// builtin / dynamic alloca we have to handle it here.
assert(!cir::MissingFeatures::addressSpace());
+cir::AddressSpace aas = getCIRAllocaAddressSpace();
+cir::AddressSpace eas = cir::toCIRAddressSpace(
+e->getType()->getPointeeType().getAddressSpace());
+if (eas != aas) {
+ assert(false && "Non-default add
[llvm-branch-commits] [clang-tools-extra] [clang-doc] create namespace names according to their paths (PR #162886)
llvmbot wrote:
@llvm/pr-subscribers-clang-tools-extra
Author: Erick Velez (evelez7)
Changes
Namespace filenames didn't consider their paths, so foo::tools would use
the same file as bar::tools. Now we consider their paths to avoid that
problem.
---
Full diff: https://github.com/llvm/llvm-project/pull/162886.diff
3 Files Affected:
- (modified) clang-tools-extra/clang-doc/JSONGenerator.cpp (+7-1)
- (added) clang-tools-extra/test/clang-doc/json/multiple-namespaces.cpp (+20)
- (modified) clang-tools-extra/test/clang-doc/json/nested-namespace.cpp (+1-1)
``diff
diff --git a/clang-tools-extra/clang-doc/JSONGenerator.cpp
b/clang-tools-extra/clang-doc/JSONGenerator.cpp
index 1b08b1791b6eb..df816d78d77fe 100644
--- a/clang-tools-extra/clang-doc/JSONGenerator.cpp
+++ b/clang-tools-extra/clang-doc/JSONGenerator.cpp
@@ -584,7 +584,13 @@ static SmallString<16> determineFileName(Info *I,
SmallString<128> &Path) {
FileName = RecordSymbolInfo->MangledName;
} else if (I->USR == GlobalNamespace)
FileName = "index";
- else
+ else if (I->IT == InfoType::IT_namespace) {
+for (const auto &NS : I->Namespace) {
+ FileName += NS.Name;
+ FileName += "_";
+}
+FileName += I->Name;
+ } else
FileName = I->Name;
sys::path::append(Path, FileName + ".json");
return FileName;
diff --git a/clang-tools-extra/test/clang-doc/json/multiple-namespaces.cpp
b/clang-tools-extra/test/clang-doc/json/multiple-namespaces.cpp
new file mode 100644
index 0..04fcfc1dc0a85
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/json/multiple-namespaces.cpp
@@ -0,0 +1,20 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --output=%t --format=json --executor=standalone %s
+// RUN: FileCheck %s < %t/json/foo_tools.json --check-prefix=CHECK-FOO
+// RUN: FileCheck %s < %t/json/bar_tools.json --check-prefix=CHECK-BAR
+
+namespace foo {
+ namespace tools {
+class FooTools {};
+ } // namespace tools
+} // namespace foo
+
+namespace bar {
+ namespace tools {
+class BarTools {};
+ } // namespace tools
+} // namespace bar
+
+// CHECK-FOO: "Name": "tools"
+
+// CHECK-BAR: "Name": "tools"
diff --git a/clang-tools-extra/test/clang-doc/json/nested-namespace.cpp
b/clang-tools-extra/test/clang-doc/json/nested-namespace.cpp
index b19afc1885104..cf19e1e34a818 100644
--- a/clang-tools-extra/test/clang-doc/json/nested-namespace.cpp
+++ b/clang-tools-extra/test/clang-doc/json/nested-namespace.cpp
@@ -1,7 +1,7 @@
// RUN: rm -rf %t && mkdir -p %t
// RUN: clang-doc --output=%t --format=json --executor=standalone %s
// RUN: FileCheck %s < %t/json/nested.json --check-prefix=NESTED
-// RUN: FileCheck %s < %t/json/inner.json --check-prefix=INNER
+// RUN: FileCheck %s < %t/json/nested_inner.json --check-prefix=INNER
namespace nested {
int Global;
``
https://github.com/llvm/llvm-project/pull/162886
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [LV] Add ExtNegatedMulAccReduction expression type (PR #160154)
https://github.com/SamTebbs33 created
https://github.com/llvm/llvm-project/pull/160154
This PR adds the ExtNegatedMulAccReduction expression type for
VPExpressionRecipe so that extend-multiply-accumulate reductions with a negated
multiply can be bundled.
Stacked PRs:
1. https://github.com/llvm/llvm-project/pull/156976
2. -> This
3. https://github.com/llvm/llvm-project/pull/147302
>From 1e26f885620a00e9733102c36dd626552cb9dda5 Mon Sep 17 00:00:00 2001
From: Sam Tebbs
Date: Mon, 22 Sep 2025 17:16:40 +0100
Subject: [PATCH] [LV] Add ExtNegatedMulAccReduction expression type
This PR adds the ExtNegatedMulAccReduction expression type for
VPExpressionRecipe so that extend-multiply-accumulate reductions with a
negated multiply can be bundled.
Stacked PRs:
1. https://github.com/llvm/llvm-project/pull/156976
2. -> This
3. https://github.com/llvm/llvm-project/pull/147302
---
llvm/lib/Transforms/Vectorize/VPlan.h | 11 ++
.../lib/Transforms/Vectorize/VPlanRecipes.cpp | 31 -
.../Transforms/Vectorize/VPlanTransforms.cpp | 46 ---
.../vplan-printing-reductions.ll | 121 ++
4 files changed, 192 insertions(+), 17 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h
b/llvm/lib/Transforms/Vectorize/VPlan.h
index e6f6067bc9df3..1cb0c889528ec 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -2989,6 +2989,12 @@ class VPExpressionRecipe : public VPSingleDefRecipe {
/// vector operands, performing a reduction.add on the result, and adding
/// the scalar result to a chain.
MulAccReduction,
+/// Represent an inloop multiply-accumulate reduction, multiplying the
+/// extended vector operands, negating the multiplication, performing a
+/// reduction.add
+/// on the result, and adding
+/// the scalar result to a chain.
+ExtNegatedMulAccReduction,
};
/// Type of the expression.
@@ -3012,6 +3018,11 @@ class VPExpressionRecipe : public VPSingleDefRecipe {
VPWidenRecipe *Mul, VPReductionRecipe *Red)
: VPExpressionRecipe(ExpressionTypes::ExtMulAccReduction,
{Ext0, Ext1, Mul, Red}) {}
+ VPExpressionRecipe(VPWidenCastRecipe *Ext0, VPWidenCastRecipe *Ext1,
+ VPWidenRecipe *Mul, VPWidenRecipe *Sub,
+ VPReductionRecipe *Red)
+ : VPExpressionRecipe(ExpressionTypes::ExtNegatedMulAccReduction,
+ {Ext0, Ext1, Mul, Sub, Red}) {}
~VPExpressionRecipe() override {
SmallSet ExpressionRecipesSeen;
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 4568d4f37a751..02be0db102547 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -2861,12 +2861,17 @@ InstructionCost
VPExpressionRecipe::computeCost(ElementCount VF,
return Ctx.TTI.getMulAccReductionCost(false, Opcode, RedTy, SrcVecTy,
Ctx.CostKind);
- case ExpressionTypes::ExtMulAccReduction:
+ case ExpressionTypes::ExtNegatedMulAccReduction:
+ case ExpressionTypes::ExtMulAccReduction: {
+if (ExpressionType == ExpressionTypes::ExtNegatedMulAccReduction &&
+Opcode == Instruction::Add)
+ Opcode = Instruction::Sub;
return Ctx.TTI.getMulAccReductionCost(
cast(ExpressionRecipes.front())->getOpcode() ==
Instruction::ZExt,
Opcode, RedTy, SrcVecTy, Ctx.CostKind);
}
+ }
llvm_unreachable("Unknown VPExpressionRecipe::ExpressionTypes enum");
}
@@ -2912,6 +2917,30 @@ void VPExpressionRecipe::print(raw_ostream &O, const
Twine &Indent,
O << ")";
break;
}
+ case ExpressionTypes::ExtNegatedMulAccReduction: {
+getOperand(getNumOperands() - 1)->printAsOperand(O, SlotTracker);
+O << " + reduce."
+ << Instruction::getOpcodeName(
+ RecurrenceDescriptor::getOpcode(Red->getRecurrenceKind()))
+ << " (sub (0, mul";
+auto *Mul = cast(ExpressionRecipes[2]);
+Mul->printFlags(O);
+O << "(";
+getOperand(0)->printAsOperand(O, SlotTracker);
+auto *Ext0 = cast(ExpressionRecipes[0]);
+O << " " << Instruction::getOpcodeName(Ext0->getOpcode()) << " to "
+ << *Ext0->getResultType() << "), (";
+getOperand(1)->printAsOperand(O, SlotTracker);
+auto *Ext1 = cast(ExpressionRecipes[1]);
+O << " " << Instruction::getOpcodeName(Ext1->getOpcode()) << " to "
+ << *Ext1->getResultType() << ")";
+if (Red->isConditional()) {
+ O << ", ";
+ Red->getCondOp()->printAsOperand(O, SlotTracker);
+}
+O << "))";
+break;
+ }
case ExpressionTypes::MulAccReduction:
case ExpressionTypes::ExtMulAccReduction: {
getOperand(getNumOperands() - 1)->printAsOperand(O, SlotTracker);
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 1f6b8
[llvm-branch-commits] [libc] 0181877 - Revert "[libc] Enable intermediate computation in float for baremetal (#163622)"
Author: Petr Hosek
Date: 2025-10-15T23:46:01-07:00
New Revision: 0181877abd214ba3f0010fb85773874d27e498fd
URL:
https://github.com/llvm/llvm-project/commit/0181877abd214ba3f0010fb85773874d27e498fd
DIFF:
https://github.com/llvm/llvm-project/commit/0181877abd214ba3f0010fb85773874d27e498fd.diff
LOG: Revert "[libc] Enable intermediate computation in float for baremetal
(#163622)"
This reverts commit 49f03eed05192312bcede7f9dce5daf24edd422a.
Added:
Modified:
libc/config/baremetal/config.json
Removed:
diff --git a/libc/config/baremetal/config.json
b/libc/config/baremetal/config.json
index ffb4fe6487fdc..796b1d8ed1398 100644
--- a/libc/config/baremetal/config.json
+++ b/libc/config/baremetal/config.json
@@ -36,7 +36,7 @@
},
"math": {
"LIBC_CONF_MATH_OPTIMIZATIONS": {
- "value": "(LIBC_MATH_SKIP_ACCURATE_PASS | LIBC_MATH_SMALL_TABLES |
LIBC_MATH_INTERMEDIATE_COMP_IN_FLOAT)"
+ "value": "(LIBC_MATH_SKIP_ACCURATE_PASS | LIBC_MATH_SMALL_TABLES)"
}
},
"general": {
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [MC] Pass through MCDecodedPseudoProbe::print ShowName param (PR #162557)
https://github.com/aaupov closed 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] [StaticDataLayout] Factor out a helper function for section prefix eligibility and use it in both optimizer and codegen (PR #162348)
https://github.com/mingmingl-llvm 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] [AArch64][SME] Support split ZPR and PPR area allocation (PR #142392)
@@ -0,0 +1,527 @@
+# RUN: llc -mattr=+sve -aarch64-stack-hazard-in-non-streaming
-aarch64-split-sve-objects -aarch64-streaming-hazard-size=1024
-mtriple=aarch64-none-linux-gnu -run-pass=prologepilog %s -o - | FileCheck %s
+# RUN: llc -mtriple=aarch64-none-linux-gnu -mattr=+sve
-aarch64-stack-hazard-in-non-streaming -aarch64-split-sve-objects
-aarch64-streaming-hazard-size=1024 -start-before=prologepilog %s -o - |
FileCheck %s --check-prefix=ASM
+# RUN: llc -mtriple=aarch64-none-linux-gnu -mattr=+sve
-aarch64-stack-hazard-in-non-streaming -aarch64-split-sve-objects
-aarch64-streaming-hazard-size=1024 -start-before=prologepilog %s -filetype=obj
-o %t
+# RUN: llvm-objdump --dwarf=frames %t | FileCheck %s --check-prefix=UNWINDINFO
+# RUN: rm -rf %t
+#
+# Test allocation and deallocation of SVE objects on the stack with
+# split-sve-objects (and hazard padding) enabled. This also tests using a
+# combination of scalable and non-scalable offsets to access the SVE on the
+# stack.
+#
+# With split-sve-objects (which implies hazard padding) the SVE area is split
+# into PPR and ZPR areas with (fixed-size) hazard padding between them. The PPR
+# area holds all scalable predicate callee saves and locals, and the ZPR area
+# holds all scalable vector callee saves and locals. Additionally, any FPR
+# callee save is promoted to a ZPR callee save (to avoid needing additional
+# hazard padding in the callee save area).
+#
+# +-+
+# | stack arg |
+# +-+ <- SP before call
+# | Callee Saves|
+# | Frame record| (if available)
+# |-| <- FP (if available)
+# | PPR area |
+# |-|
+# |/| hazard padding
+# |-|
+# | ZPR area |
+# +-+
+# | : |
+# | Stack objs |
+# | : |
+# +-+ <- SP after call and frame-setup
+#
+--- |
+
+ define void @test_allocate_split_sve() uwtable { entry: unreachable }
+ define void @test_allocate_split_sve_realigned() uwtable { entry:
unreachable }
+ define void @test_address_split_sve() uwtable { entry: unreachable }
+ define void @test_address_split_sve_fp() uwtable { entry: unreachable }
+ define aarch64_sve_vector_pcs void @save_restore_ppr_zpr() uwtable { entry:
unreachable }
+
+...
+---
+# +--+
+# |scratchreg| // x29 is used as scratch reg.
+# |--|
+# | %stack.0 | // scalable predicate of n * 12 bytes, aligned to 16 bytes
+# | | // to be materialized with 1*ADDVL (<=> n * 16 bytes)
+# |--|
+# |//| // hazard padding (1024 bytes) -- part of PPR locals area
+# |//| // Note: This is currently not included in the "stackSize"
+# +--+
+# | %stack.0 | // scalable SVE object of n * 18 bytes, aligned to 16 bytes,
+# | | // to be materialized with 2*ADDVL (<=> 2 * n * 16 bytes)
+# +--+
+# |//| // hazard padding (1024 bytes)
+# |--|
+# | %stack.1 | // not scalable
+# +--+ <- SP
+
+# CHECK-LABEL: name: test_allocate_split_sve
+# CHECK: stackSize: 1056
+
+# CHECK: bb.0.entry:
+# CHECK: liveins: $z0, $p0, $fp
+# CHECK: early-clobber $sp = frame-setup STRXpre killed $fp, $sp, -16 ::
(store (s64) into %stack.4)
+# CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 16
+# CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $w29, -16
+# CHECK-NEXT: $sp = frame-setup SUBXri $sp, 1024, 0
+# CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 1040
+# CHECK-NEXT: $sp = frame-setup ADDVL_XXI $sp, -1, implicit $vg
+# CHECK-NEXT: frame-setup CFI_INSTRUCTION escape 0x0f, 0x09, 0x8f, 0x90, 0x08,
0x92, 0x2e, 0x00, 0x38, 0x1e, 0x22
+# CHECK-NEXT: $sp = frame-setup SUBXri $sp, 1040, 0
+# CHECK-NEXT: frame-setup CFI_INSTRUCTION escape 0x0f, 0x09, 0x8f, 0xa0, 0x10,
0x92, 0x2e, 0x00, 0x38, 0x1e, 0x22
+# CHECK-NEXT: $sp = frame-setup ADDVL_XXI $sp, -2, implicit $vg
+# CHECK-NEXT: frame-setup CFI_INSTRUCTION escape 0x0f, 0x09, 0x8f, 0xa0, 0x10,
0x92, 0x2e, 0x00, 0x48, 0x1e, 0x22
+#
+# CHECK-NEXT: $x8 = ADDXri $sp, 1040, 0
+# CHECK-NEXT: $x8 = ADDPL_XXI $x8, 7, implicit $vg
+# CHECK-NEXT: STR_ZXI $z0, killed $x8, 0 :: (store () into
%stack.0)
+# CHECK-NEXT: $x8 = ADDXri $sp, 2064, 0
+# CHECK-NEXT: STR_PXI $p0, killed $x8, 18 :: (store () into
%stack.1)
+#
+# CHECK-NEXT: $sp = frame-destroy ADDVL_XXI $sp, 2, implicit $vg
+# CHECK-NEXT: frame-destroy CFI_INSTRUCTION escape 0x0f, 0x09, 0x8f, 0xa0,
0x10, 0x92, 0x2e, 0x00, 0x38, 0x1e, 0x22
+# CHECK-NEXT: $sp = frame-destroy ADDXri $sp, 1024, 0
+# CHECK-NEXT: frame-destroy CFI_INSTRUCTION escape 0x0f, 0x09, 0x8f, 0xa0,
0x08, 0x92, 0x2e, 0x00, 0x38, 0x1e, 0x22
+# CHECK-NEXT: $sp = frame-destroy ADDVL_XXI $sp, 1, implicit $vg
+# CHECK-NEXT: frame-destroy CFI_INSTRUCTION def_cfa $wsp, 1056
+# CHECK-NEXT: $sp = frame-destroy ADDXri $sp, 1040, 0
+# CHECK-NEXT: frame-destroy CFI_INSTRUCTION def_cfa_offset 16
+# CHECK-NEXT: early-clobber $sp, $
[llvm-branch-commits] [clang] release/21.x: [clang][PAC] Don't try to diagnose use of pointer auth on dependent types #159505 (#159859) (PR #161288)
https://github.com/dyung updated
https://github.com/llvm/llvm-project/pull/161288
>From a867bd53e86173e6e1b9f40960133e72ff206414 Mon Sep 17 00:00:00 2001
From: Oliver Hunt
Date: Fri, 19 Sep 2025 19:34:09 -0600
Subject: [PATCH] [clang][PAC] Don't try to diagnose use of pointer auth on
dependent types #159505 (#159859)
We can't give a correct answer for dependent types, so for now just
report no ptrauth involves if the type being queried is dependent. In
future we may want to distinguigh the `None` vs `Dependent` cases but
that does not seem warranted for now.
Fixes #159505
(cherry picked from commit f6c711b426300d2f8b914fc7debe6d09c026740e)
---
clang/lib/AST/ASTContext.cpp | 3 ++
clang/test/SemaCXX/ptrauth-type-traits.cpp | 38 +-
2 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 92d1b536e474b..862f1d5741c5b 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1725,6 +1725,9 @@ ASTContext::PointerAuthContent
ASTContext::findPointerAuthContent(QualType T) {
assert(isPointerAuthenticationAvailable());
T = T.getCanonicalType();
+ if (T->isDependentType())
+return PointerAuthContent::None;
+
if (T.hasAddressDiscriminatedPointerAuth())
return PointerAuthContent::AddressDiscriminatedData;
const RecordDecl *RD = T->getAsRecordDecl();
diff --git a/clang/test/SemaCXX/ptrauth-type-traits.cpp
b/clang/test/SemaCXX/ptrauth-type-traits.cpp
index aefbd63fa1677..a81ef1cce25b6 100644
--- a/clang/test/SemaCXX/ptrauth-type-traits.cpp
+++ b/clang/test/SemaCXX/ptrauth-type-traits.cpp
@@ -8,13 +8,14 @@
// expected-no-diagnostics
#ifdef __PTRAUTH__
-
+#define PTRAUTH_ENABLED 1
#define NonAddressDiscriminatedVTablePtrAttr \
[[clang::ptrauth_vtable_pointer(process_independent,
no_address_discrimination, no_extra_discrimination)]]
#define AddressDiscriminatedVTablePtrAttr \
[[clang::ptrauth_vtable_pointer(process_independent, address_discrimination,
no_extra_discrimination)]]
#define ADDR_DISC_ENABLED true
#else
+#define PTRAUTH_ENABLED 0
#define NonAddressDiscriminatedVTablePtrAttr
#define AddressDiscriminatedVTablePtrAttr
#define ADDR_DISC_ENABLED false
@@ -399,3 +400,38 @@
static_assert(!ASSIGNABLE_WRAPPER(RelocatableAddressDiscriminatedPrimaryBase));
static_assert(!ASSIGNABLE_WRAPPER(RelocatableAddressDiscriminatedSecondaryBase));
static_assert(!ASSIGNABLE_WRAPPER(EmbdeddedAddressDiscriminatedPolymorphicClass));
static_assert(!ASSIGNABLE_WRAPPER(RelocatableEmbdeddedAddressDiscriminatedPolymorphicClass));
+
+namespace GH159505 {
+ class A {
+virtual void f();
+ };
+
+ template struct B {
+class C : A {
+ A a[N];
+} d;
+ };
+
+ template struct C {
+void *__ptrauth(1,1,1) ptr[N];
+static_assert(PTRAUTH_ENABLED != __is_trivially_copyable(decltype(ptr)));
+ };
+ template struct D {
+T ptr;
+static_assert(isPtrauth != __is_trivially_copyable(decltype(ptr)));
+ };
+
+
+ template using Ptr = T * __ptrauth(1,1,1);
+ template void test() {
+static_assert(PTRAUTH_ENABLED != __is_trivially_copyable(Ptr));
+ }
+
+ auto f = test;
+ static_assert(!__is_trivially_copyable(B<1>));
+ static_assert(PTRAUTH_ENABLED != __is_trivially_copyable(C<1>));
+
+
+ D d_void;
+ D d_void_ptrauth;
+}
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [AArch64][SME] Reshuffle emit[prologue|epilogue]() for splitSVEObjects (NFCI) (PR #161217)
@@ -708,85 +708,75 @@ void AArch64PrologueEmitter::emitPrologue() {
if (AFL.windowsRequiresStackProbe(MF, NumBytes + RealignmentPadding))
emitWindowsStackProbe(AfterGPRSavesI, DL, NumBytes, RealignmentPadding);
- MachineBasicBlock::iterator CalleeSavesEnd = AfterGPRSavesI;
-
StackOffset PPRCalleeSavesSize =
StackOffset::getScalable(AFI->getPPRCalleeSavedStackSize());
StackOffset ZPRCalleeSavesSize =
StackOffset::getScalable(AFI->getZPRCalleeSavedStackSize());
StackOffset SVECalleeSavesSize = PPRCalleeSavesSize + ZPRCalleeSavesSize;
StackOffset PPRLocalsSize = AFL.getPPRStackSize(MF) - PPRCalleeSavesSize;
StackOffset ZPRLocalsSize = AFL.getZPRStackSize(MF) - ZPRCalleeSavesSize;
+ std::optional ZPRCalleeSavesBegin,
+ ZPRCalleeSavesEnd, PPRCalleeSavesBegin, PPRCalleeSavesEnd;
sdesmalen-arm wrote:
These are not used/needed in this patch.
https://github.com/llvm/llvm-project/pull/161217
___
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)
@@ -0,0 +1,750 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 +; RUN: llc < %s -mtriple=aarch64 -mattr=+sve2 -aarch64-stack-hazard-in-non-streaming -aarch64-split-sve-objects -aarch64-streaming-hazard-size=1024 | FileCheck %s +; RUN: llc < %s -mtriple=aarch64 -mattr=+sve2 -aarch64-stack-hazard-in-non-streaming -aarch64-split-sve-objects -aarch64-streaming-hazard-size=1024 -pass-remarks-analysis=stack-frame-layout 2>&1 >/dev/null | FileCheck %s --check-prefixes=CHECK-FRAMELAYOUT + sdesmalen-arm wrote: Can you also add a test with realignment (e.g. using an alloca with alignment > 16), and also a test with stack probing? 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] [AllocToken, Clang] Infer type hints from sizeof expressions and casts (PR #156841)
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1-fsanitize=alloc-token -fsanitize-alloc-token-extended
-falloc-token-max=2147483647 -triple x86_64-linux-gnu -x c -emit-llvm %s -o - |
FileCheck %s
+// RUN: %clang_cc1 -O -fsanitize=alloc-token -fsanitize-alloc-token-extended
-falloc-token-max=2147483647 -triple x86_64-linux-gnu -x c -emit-llvm %s -o - |
FileCheck %s
+
+typedef __typeof(sizeof(int)) size_t;
+typedef size_t gfp_t;
+
+void *custom_malloc(size_t size) __attribute__((malloc));
+void *__kmalloc(size_t size, gfp_t flags) __attribute__((alloc_size(1)));
+
+void *sink;
+
+// CHECK-LABEL: @test_nonlibcall_alloc(
+void test_nonlibcall_alloc() {
+ // CHECK: call{{.*}} ptr @__alloc_token_custom_malloc(i64 noundef 4, i64
{{[1-9][0-9]*}})
zmodem wrote:
The regex assumes the token is non-zero, but is that guaranteed? (Also in the
other test)
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] release/21.x: [clang-format] Fix bugs in annotating arrows and square… (PR #161052)
https://github.com/mydeveloperday approved this pull request. https://github.com/llvm/llvm-project/pull/161052 ___ 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)
@@ -0,0 +1,176 @@
+// RUN: not llvm-mc -triple=aarch64 -show-encoding -mattr=+sme2p3 2>&1 < %s|
FileCheck %s
+
+// --//
+// Invalid element width
+
+luti6 z0.h, zt0, z0
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
+// CHECK-NEXT: luti6 z0.h, zt0, z0
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+luti6 z0.s, zt0, z0
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid element width
+// CHECK-NEXT: luti6 z0.s, zt0, z0
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+luti6 z0.d, zt0, z0
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid element width
+// CHECK-NEXT: luti6 z0.d, zt0, z0
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+// --//
+// Negative tests for instructions that are incompatible with movprfx
+
+movprfx z0.h, p0/m, z7.h
+luti6 z0.b, zt0, z0
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: instruction is unpredictable when
following a movprfx, suggest replacing movprfx with mov
+// CHECK-NEXT: luti6 z0.b, zt0, z0
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+movprfx z0, z7
+luti6 z0.b, zt0, z0
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: instruction is unpredictable when
following a movprfx, suggest replacing movprfx with mov
+// CHECK-NEXT: luti6 z0.b, zt0, z0
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+// --//
+// Invalid vectors/mis-matched registers/invalid index
+
+luti6 { z0.h - z5.h }, { z0.h, z1.h }, { z0, z1 }[0]
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid number of vectors
+// CHECK-NEXT: luti6 { z0.h - z5.h }, { z0.h, z1.h }, { z0, z1 }[0]
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+luti6 { z0.b - z3.h }, { z0.h, z1.h }, { z0, z1 }[0]
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: mismatched register size suffix
+// CHECK-NEXT: luti6 { z0.b - z3.h }, { z0.h, z1.h }, { z0, z1 }[0]
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+luti6 { z0.h - z3.h }, { z0.h, z1.h }, { z0, z1 }[2]
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: vector lane must be an integer in
range [0, 1].
+// CHECK-NEXT: luti6 { z0.h - z3.h }, { z0.h, z1.h }, { z0, z1 }[2]
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+// --//
+// Negative tests for instructions that are incompatible with movprfx
+
+movprfx z0.h, p0/m, z7.h
+luti6 { z0.h - z3.h }, { z0.h, z1.h }, { z0, z1 }[0]
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: instruction is unpredictable when
following a movprfx, suggest replacing movprfx with mov
+// CHECK-NEXT: luti6 { z0.h - z3.h }, { z0.h, z1.h }, { z0, z1 }[0]
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+movprfx z0, z7
+luti6 { z0.h - z3.h }, { z0.h, z1.h }, { z0, z1 }[0]
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: instruction is unpredictable when
following a movprfx, suggest replacing movprfx with mov
+// CHECK-NEXT: luti6 { z0.h - z3.h }, { z0.h, z1.h }, { z0, z1 }[0]
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+// --//
+// Wrong striding/registers/index
+
+luti6 { z0.h, z4.h, z8.h, z13.h }, { z0.h, z1.h }, { z0, z1 }[0]
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: registers must have the same
sequential stride
+// CHECK-NEXT: luti6 { z0.h, z4.h, z8.h, z13.h }, { z0.h, z1.h }, { z0, z1 }[0]
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+luti6 { z1.h, z2.h, z3.h, z4.h }, { z0.h, z1.h }, { z0, z1 }[0]
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid vector list, expected list
with 4 consecutive SVE vectors, where the first vector is a multiple of 4 and
with matching element types
+// CHECK-NEXT: luti6 { z1.h, z2.h, z3.h, z4.h }, { z0.h, z1.h }, { z0, z1 }[0]
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+luti6 { z0.b, z4.h, z8.h, z12.h }, { z0.h, z1.h }, { z0, z1 }[0]
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: mismatched register size suffix
+// CHECK-NEXT: luti6 { z0.b, z4.h, z8.h, z12.h }, { z0.h, z1.h }, { z0, z1 }[0]
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+luti6 { z0.h, z4.h, z8.h, z12.h }, { z0.h, z1.h }, { z0, z1 }[2]
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: vector lane must be an integer in
range [0, 1].
+// CHECK-NEXT: luti6 { z0.h, z4.h, z8.h, z12.h }, { z0.h, z1.h }, { z0, z1 }[2]
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+// --//
+// Negative tests for instructions that are incompatible with movprfx
+
+movprfx z0.h, p0/m, z7.h
+luti6 { z0.h, z4.h, z8.h, z12.h }, { z0.h, z1.h }, { z0, z1 }[0]
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: instruction is unpredictable when
following a movprfx, suggest replacing movprfx with mov
+// CHECK-NEXT: luti6 { z0.h, z4.h, z8.h, z12.h }, { z0.h, z1.h }, { z0, z1 }[0]
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+movprfx z0, z7
+luti6 { z0.h, z4.h, z8.h, z12.h }, { z0.h, z1.h }, { z0, z1 }[0]
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: instruction is unpr
[llvm-branch-commits] [libc] [libc][annex_k] Add libc_constraint_handler. (PR #163315)
https://github.com/bassiounix updated
https://github.com/llvm/llvm-project/pull/163315
>From c7bce13f10f55494f7700f450ba956bf193156d0 Mon Sep 17 00:00:00 2001
From: bassiounix
Date: Tue, 14 Oct 2025 06:38:29 +0300
Subject: [PATCH] [libc][annex_k] Add libc_constraint_handler.
---
libc/src/__support/annex_k/CMakeLists.txt | 9 +++
.../annex_k/libc_constraint_handler.h | 26 +++
2 files changed, 35 insertions(+)
create mode 100644 libc/src/__support/annex_k/libc_constraint_handler.h
diff --git a/libc/src/__support/annex_k/CMakeLists.txt
b/libc/src/__support/annex_k/CMakeLists.txt
index 78f5b3cddebd7..8eb65f2469b4f 100644
--- a/libc/src/__support/annex_k/CMakeLists.txt
+++ b/libc/src/__support/annex_k/CMakeLists.txt
@@ -10,3 +10,12 @@ add_header_library(
libc.src.__support.OSUtil.osutil
libc.src.stdlib.abort
)
+
+add_header_library(
+ libc_constraint_handler
+ HDRS
+libc_constraint_handler.h
+ DEPENDS
+.abort_handler_s
+libc.hdr.types.constraint_handler_t
+)
diff --git a/libc/src/__support/annex_k/libc_constraint_handler.h
b/libc/src/__support/annex_k/libc_constraint_handler.h
new file mode 100644
index 0..db01c8dd940a0
--- /dev/null
+++ b/libc/src/__support/annex_k/libc_constraint_handler.h
@@ -0,0 +1,26 @@
+//===-- Static header for libc_constraint_handler ---*- 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_ANNEX_K_LIBC_CONSTRAINT_HANDLER_H
+#define LLVM_LIBC_SRC___SUPPORT_ANNEX_K_LIBC_CONSTRAINT_HANDLER_H
+
+#include "abort_handler_s.h"
+#include "hdr/types/constraint_handler_t.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace annex_k {
+
+LIBC_INLINE static constraint_handler_t libc_constraint_handler =
+&abort_handler_s;
+
+} // namespace annex_k
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_ANNEX_K_LIBC_CONSTRAINT_HANDLER_H
___
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)
https://github.com/bassiounix updated
https://github.com/llvm/llvm-project/pull/161993
>From 7f96a609a0598657529ff53dd456d2ffcee15312 Mon Sep 17 00:00:00 2001
From: bassiounix
Date: Sun, 5 Oct 2025 06:48:10 +0300
Subject: [PATCH] [libc][math] Refactor exp2f16 implementation to header-only
in src/__support/math folder.
---
libc/shared/math.h| 1 +
libc/shared/math/exp2f16.h| 29 +
libc/src/__support/math/CMakeLists.txt| 14 +++
libc/src/__support/math/exp2f16.h | 111 ++
libc/src/math/generic/CMakeLists.txt | 10 +-
libc/src/math/generic/exp2f16.cpp | 86 +-
libc/test/shared/CMakeLists.txt | 1 +
libc/test/shared/shared_math_test.cpp | 2 +-
.../llvm-project-overlay/libc/BUILD.bazel | 18 ++-
9 files changed, 177 insertions(+), 95 deletions(-)
create mode 100644 libc/shared/math/exp2f16.h
create mode 100644 libc/src/__support/math/exp2f16.h
diff --git a/libc/shared/math.h b/libc/shared/math.h
index 1262fa6f682d0..8bff70f1c5336 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -49,6 +49,7 @@
#include "math/exp10m1f16.h"
#include "math/exp2.h"
#include "math/exp2f.h"
+#include "math/exp2f16.h"
#include "math/expf.h"
#include "math/expf16.h"
#include "math/frexpf.h"
diff --git a/libc/shared/math/exp2f16.h b/libc/shared/math/exp2f16.h
new file mode 100644
index 0..f799511efb0d7
--- /dev/null
+++ b/libc/shared/math/exp2f16.h
@@ -0,0 +1,29 @@
+//===-- Shared exp2f16 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_EXP2F16_H
+#define LLVM_LIBC_SHARED_MATH_EXP2F16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+#include "shared/libc_common.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/exp2f16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::exp2f16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_EXP2F16_H
diff --git a/libc/src/__support/math/CMakeLists.txt
b/libc/src/__support/math/CMakeLists.txt
index 203ebb4bf1760..185900efa7354 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -753,6 +753,20 @@ add_header_library(
libc.src.errno.errno
)
+add_header_library(
+ exp2f16
+ HDRS
+exp2f16.h
+ DEPENDS
+.expxf16_utils
+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.rounding_mode
+libc.src.__support.macros.optimization
+)
+
add_header_library(
exp10
HDRS
diff --git a/libc/src/__support/math/exp2f16.h
b/libc/src/__support/math/exp2f16.h
new file mode 100644
index 0..599ba0f5411bd
--- /dev/null
+++ b/libc/src/__support/math/exp2f16.h
@@ -0,0 +1,111 @@
+//===-- Implementation header for exp2f16 ---*- 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_EXP2F16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_EXP2F16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "expxf16_utils.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/cast.h"
+#include "src/__support/FPUtil/except_value_utils.h"
+#include "src/__support/FPUtil/rounding_mode.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE static constexpr float16 exp2f16(float16 x) {
+
+#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+ constexpr fputil::ExceptValues EXP2F16_EXCEPTS = {{
+ // (input, RZ output, RU offset, RD offset, RN offset)
+ // x = 0x1.714p-11, exp2f16(x) = 0x1p+0 (RZ)
+ {0x11c5U, 0x3c00U, 1U, 0U, 1U},
+ // x = -0x1.558p-4, exp2f16(x) = 0x1.e34p-1 (RZ)
+ {0xad56U, 0x3b8dU, 1U, 0U, 0U},
+ // x = -0x1.d5cp-4, exp2f16(x) = 0x1.d8cp-1 (RZ)
+ {0xaf57U, 0x3b63U, 1U, 0U, 0U},
+ }};
+#endif // !LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+
+ using namespace math::expxf16_internal;
+ using FPBits = fputil::FPBits;
+ FPBits x_bits(x);
+
+ uint16_t x_u = x_bits.uintval();
+ uin
