[llvm-branch-commits] [llvm] release/21.x: [sancov] Fix stack-depth tracking to use debug locations (#162428) (PR #162697)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/162697 ___ 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 7909f20b039349592242f267aa7f14fd98b9a441 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] [llvm] [llvm][mustache] Avoid extra allocations in parseSection (PR #159199)
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/159199 >From 7909f20b039349592242f267aa7f14fd98b9a441 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] [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 9afa122c047a96ec430e7c09065e70d0307d6591 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 6089b41def163..529dd3ac761c9 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] [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 9afa122c047a96ec430e7c09065e70d0307d6591 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 6089b41def163..529dd3ac761c9 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] [llvm] [LV] Use VPReductionRecipe for partial reductions (PR #147513)
https://github.com/SamTebbs33 edited https://github.com/llvm/llvm-project/pull/147513 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [DA] Add tests for nsw doesn't hold on entier iteration (PR #162281)
https://github.com/kasuga-fj updated
https://github.com/llvm/llvm-project/pull/162281
>From 5eeaf558673b5e5e129bc2899260e5ec659e04e3 Mon Sep 17 00:00:00 2001
From: Ryotaro Kasuga
Date: Tue, 7 Oct 2025 12:56:14 +
Subject: [PATCH] [DA] Add tests for nsw doesn't hold on entier iteration
---
.../monotonicity-loop-guard.ll| 142 ++
1 file changed, 142 insertions(+)
create mode 100644
llvm/test/Analysis/DependenceAnalysis/monotonicity-loop-guard.ll
diff --git a/llvm/test/Analysis/DependenceAnalysis/monotonicity-loop-guard.ll
b/llvm/test/Analysis/DependenceAnalysis/monotonicity-loop-guard.ll
new file mode 100644
index 0..290cf3a5336ce
--- /dev/null
+++ b/llvm/test/Analysis/DependenceAnalysis/monotonicity-loop-guard.ll
@@ -0,0 +1,142 @@
+; NOTE: Assertions have been autogenerated by
utils/update_analyze_test_checks.py UTC_ARGS: --version 6
+; RUN: opt < %s -disable-output -passes="print"
-da-dump-monotonicity-report \
+; RUN: -da-enable-monotonicity-check 2>&1 | FileCheck %s
+
+; for (i = 0; i < 9223372036854775806; i++)
+; if (i < 2147483640)
+; for (j = 0; j < 2147483640; j++)
+; a[i + j * 4294967296] = 0;
+;
+; FIXME: This is not monotonic. The nsw flag is valid under
+; the condition i < 2147483640, not for all i.
+define void @nsw_under_loop_guard0(ptr %a) {
+; CHECK-LABEL: 'nsw_under_loop_guard0'
+; CHECK-NEXT: Monotonicity check:
+; CHECK-NEXT:Inst: store i8 0, ptr %idx, align 1
+; CHECK-NEXT: Expr:
{{\{\{}}0,+,1}<%loop.i.header>,+,4294967296}<%loop.j>
+; CHECK-NEXT: Monotonicity: MultiSignedMonotonic
+; CHECK-EMPTY:
+; CHECK-NEXT: Src: store i8 0, ptr %idx, align 1 --> Dst: store i8 0, ptr
%idx, align 1
+; CHECK-NEXT:da analyze - none!
+;
+entry:
+ br label %loop.i.header
+
+loop.i.header:
+ %i = phi i64 [ 0 , %entry ], [ %i.next, %loop.i.latch ]
+ br label %loop.j.pr
+
+loop.j.pr:
+ %guard.j = icmp slt i64 %i, 2147483640
+ br i1 %guard.j, label %loop.j, label %exit
+
+loop.j:
+ %j = phi i64 [ 0, %loop.j.pr ], [ %j.next, %loop.j ]
+ %val = phi i64 [ %i, %loop.j.pr ], [ %val.next, %loop.j ]
+ %j.next = add nsw i64 %j, 1
+ %idx = getelementptr inbounds i8, ptr %a, i64 %val
+ store i8 0, ptr %idx
+ %val.next = add nsw i64 %val, 4294967296
+ %exitcond.j = icmp eq i64 %j.next, 2147483640
+ br i1 %exitcond.j, label %loop.i.latch, label %loop.j
+
+loop.i.latch:
+ %i.next = add nsw i64 %i, 1
+ %exitcond.i = icmp eq i64 %i.next, 9223372036854775806
+ br i1 %exitcond.i, label %exit, label %loop.i.header
+
+exit:
+ ret void
+}
+
+; for (i = 0; i < 100; i++)
+; if (i < 1000)
+; for (j = 0; j < 100; j++)
+; a[i + j] = 0;
+;
+; The loop guard is always true, so the nsw flag is valid for all i.
+define void @nsw_under_loop_guard1(ptr %a) {
+; CHECK-LABEL: 'nsw_under_loop_guard1'
+; CHECK-NEXT: Monotonicity check:
+; CHECK-NEXT:Inst: store i8 0, ptr %idx, align 1
+; CHECK-NEXT: Expr:
{{\{\{}}0,+,1}<%loop.i.header>,+,1}<%loop.j>
+; CHECK-NEXT: Monotonicity: MultiSignedMonotonic
+; CHECK-EMPTY:
+; CHECK-NEXT: Src: store i8 0, ptr %idx, align 1 --> Dst: store i8 0, ptr
%idx, align 1
+; CHECK-NEXT:da analyze - output [* *]!
+;
+entry:
+ br label %loop.i.header
+
+loop.i.header:
+ %i = phi i64 [ 0 , %entry ], [ %i.next, %loop.i.latch ]
+ br label %loop.j.pr
+
+loop.j.pr:
+ %guard.j = icmp slt i64 %i, 1000
+ br i1 %guard.j, label %loop.j, label %exit
+
+loop.j:
+ %j = phi i64 [ 0, %loop.j.pr ], [ %j.next, %loop.j ]
+ %val = phi i64 [ %i, %loop.j.pr ], [ %val.next, %loop.j ]
+ %j.next = add nsw i64 %j, 1
+ %idx = getelementptr inbounds i8, ptr %a, i64 %val
+ store i8 0, ptr %idx
+ %val.next = add nsw i64 %val, 1
+ %exitcond.j = icmp eq i64 %j.next, 100
+ br i1 %exitcond.j, label %loop.i.latch, label %loop.j
+
+loop.i.latch:
+ %i.next = add nsw i64 %i, 1
+ %exitcond.i = icmp eq i64 %i.next, 100
+ br i1 %exitcond.i, label %exit, label %loop.i.header
+
+exit:
+ ret void
+}
+
+; for (i = 0; i < n; i++)
+; if (i < m)
+; for (j = 0; j < k; j++)
+; a[i + j] = 0;
+;
+; The nsw flag may valid under the condition i < k.
+define void @nsw_under_loop_guard2(ptr %a, i64 %n, i64 %m, i64 %k) {
+; CHECK-LABEL: 'nsw_under_loop_guard2'
+; CHECK-NEXT: Monotonicity check:
+; CHECK-NEXT:Inst: store i8 0, ptr %idx, align 1
+; CHECK-NEXT: Expr:
{{\{\{}}0,+,1}<%loop.i.header>,+,1}<%loop.j>
+; CHECK-NEXT: Monotonicity: MultiSignedMonotonic
+; CHECK-EMPTY:
+; CHECK-NEXT: Src: store i8 0, ptr %idx, align 1 --> Dst: store i8 0, ptr
%idx, align 1
+; CHECK-NEXT:da analyze - output [* *]!
+;
+entry:
+ br label %loop.i.header
+
+loop.i.header:
+ %i = phi i64 [ 0 , %entry ], [ %i.next, %loop.i.latch ]
+ br label %loop.j.pr
+
+loop.j.pr:
+ %guard.j = icmp slt i64 %i, %m
+ br i1 %guard.j, label %loop.j, label %exit
+
+loop.j:
+ %j = phi i64 [ 0, %loop.j.pr ], [ %j.next, %loop.j ]
+ %val = phi i64 [ %i, %loop.j.pr ], [ %val.next, %loop.j ]
+ %j.next = add nsw
[llvm-branch-commits] [lld] ELF: Add support for relocating R_AARCH64_FUNCINIT64. (PR #156564)
llvmbot wrote:
@llvm/pr-subscribers-lld
Author: Peter Collingbourne (pcc)
Changes
R_AARCH64_FUNCINIT64 is a dynamic relocation type for relocating
word-sized data in the output file using the return value of
a function. An R_AARCH64_FUNCINIT64 shall be relocated as an
R_AARCH64_IRELATIVE with the target symbol address if the target
symbol is non-preemptible, and it shall be a usage error to relocate an
R_AARCH64_FUNCINIT64 with a preemptible or STT_GNU_IFUNC target symbol.
The initial use case for this relocation type shall be for emitting
global variable field initializers for structure protection. With
structure protection, the relocation value computation is tied to the
compiler implementation in such a way that it would not be reasonable to
define a relocation type for it (for example, it may involve computing
a hash using a compiler-determined algorithm), hence the need for the
computation to be implemented as code in the binary.
Part of the AArch64 psABI extension:
https://github.com/ARM-software/abi-aa/issues/340
---
Full diff: https://github.com/llvm/llvm-project/pull/156564.diff
5 Files Affected:
- (modified) lld/ELF/Arch/AArch64.cpp (+4-1)
- (modified) lld/ELF/Relocations.cpp (+19-2)
- (modified) lld/ELF/Target.h (+1)
- (added) lld/test/ELF/aarch64-funcinit64-invalid.s (+18)
- (added) lld/test/ELF/aarch64-funcinit64.s (+19)
``diff
diff --git a/lld/ELF/Arch/AArch64.cpp b/lld/ELF/Arch/AArch64.cpp
index 2a97df4785ecb..7a7b8380fc533 100644
--- a/lld/ELF/Arch/AArch64.cpp
+++ b/lld/ELF/Arch/AArch64.cpp
@@ -114,6 +114,7 @@ AArch64::AArch64(Ctx &ctx) : TargetInfo(ctx) {
copyRel = R_AARCH64_COPY;
relativeRel = R_AARCH64_RELATIVE;
iRelativeRel = R_AARCH64_IRELATIVE;
+ iRelSymbolicRel = R_AARCH64_FUNCINIT64;
gotRel = R_AARCH64_GLOB_DAT;
pltRel = R_AARCH64_JUMP_SLOT;
symbolicRel = R_AARCH64_ABS64;
@@ -137,6 +138,7 @@ RelExpr AArch64::getRelExpr(RelType type, const Symbol &s,
case R_AARCH64_ABS16:
case R_AARCH64_ABS32:
case R_AARCH64_ABS64:
+ case R_AARCH64_FUNCINIT64:
case R_AARCH64_ADD_ABS_LO12_NC:
case R_AARCH64_LDST128_ABS_LO12_NC:
case R_AARCH64_LDST16_ABS_LO12_NC:
@@ -267,7 +269,8 @@ bool AArch64::usesOnlyLowPageBits(RelType type) const {
}
RelType AArch64::getDynRel(RelType type) const {
- if (type == R_AARCH64_ABS64 || type == R_AARCH64_AUTH_ABS64)
+ if (type == R_AARCH64_ABS64 || type == R_AARCH64_AUTH_ABS64 ||
+ type == R_AARCH64_FUNCINIT64)
return type;
return R_AARCH64_NONE;
}
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 84b9b5e983662..e702b6f03fb19 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -968,8 +968,8 @@ bool RelocationScanner::isStaticLinkTimeConstant(RelExpr e,
RelType type,
// only the low bits are used.
if (e == R_GOT || e == R_PLT)
return ctx.target->usesOnlyLowPageBits(type) || !ctx.arg.isPic;
- // R_AARCH64_AUTH_ABS64 requires a dynamic relocation.
- if (e == RE_AARCH64_AUTH)
+ // R_AARCH64_AUTH_ABS64 and iRelSymbolicRel require a dynamic relocation.
+ if (e == RE_AARCH64_AUTH || type == ctx.target->iRelSymbolicRel)
return false;
// The behavior of an undefined weak reference is implementation defined.
@@ -1142,6 +1142,23 @@ void RelocationScanner::process(RelExpr expr, RelType
type, uint64_t offset,
}
return;
}
+ if (LLVM_UNLIKELY(type == ctx.target->iRelSymbolicRel)) {
+if (sym.isPreemptible) {
+ auto diag = Err(ctx);
+ diag << "relocation " << type
+ << " cannot be used against preemptible symbol '" << &sym <<
"'";
+ printLocation(diag, *sec, sym, offset);
+} else if (isIfunc) {
+ auto diag = Err(ctx);
+ diag << "relocation " << type
+ << " cannot be used against ifunc symbol '" << &sym << "'";
+ printLocation(diag, *sec, sym, offset);
+} else {
+ part.relaDyn->addReloc({ctx.target->iRelativeRel, sec, offset, false,
+ sym, addend, R_ABS});
+ return;
+}
+ }
part.relaDyn->addSymbolReloc(rel, *sec, offset, sym, addend, type);
// MIPS ABI turns using of GOT and dynamic relocations inside out.
diff --git a/lld/ELF/Target.h b/lld/ELF/Target.h
index 9f0605138a4fb..f68ddf0e02a94 100644
--- a/lld/ELF/Target.h
+++ b/lld/ELF/Target.h
@@ -135,6 +135,7 @@ class TargetInfo {
RelType relativeRel = 0;
RelType iRelativeRel = 0;
RelType symbolicRel = 0;
+ RelType iRelSymbolicRel = 0;
RelType tlsDescRel = 0;
RelType tlsGotRel = 0;
RelType tlsModuleIndexRel = 0;
diff --git a/lld/test/ELF/aarch64-funcinit64-invalid.s
b/lld/test/ELF/aarch64-funcinit64-invalid.s
new file mode 100644
index 0..4577db7429773
--- /dev/null
+++ b/lld/test/ELF/aarch64-funcinit64-invalid.s
@@ -0,0 +1,18 @@
+# REQUIRES: aarch64
+
+# RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t.o
+# RUN: not ld.lld %t.o -o %t 2>&1 |
[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] [libc++] Annotate classes with _LIBCPP_PFP to enable pointer field protection (PR #151652)
https://github.com/pcc updated https://github.com/llvm/llvm-project/pull/151652 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] Implement a simple e2e test for PFP. (PR #151655)
https://github.com/pcc updated https://github.com/llvm/llvm-project/pull/151655 ___ 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)
clementval wrote: > > Question: I followed the Destroy design from OpenACC.td and also passed the > > original value. I am wondering if that it is needed > > This issue was previously discussed > [here](https://github.com/llvm/llvm-project/pull/156545#discussion_r2317296732), > and my reasoning is based on the principles of consistency, generality, and > flexibility: > > * Consistency: All recipe regions take "original" as the first argument, > ensuring uniformity across the design. > * Generality: If a dialect does not encode sufficient information within its > private variable to destroy it, the necessary type information can be > retrieved from the original variable. While this is not crucial for CIR, FIR, > and memref, it provides a robust fallback. > * Flexibility: Including the original variable allows for custom recipe > bodies. For example, if a runtime listener call is embedded within the recipe > body, it could report both the address of the original variable and the > private copy upon destruction. Although this is also a weaker argument, it > highlights potential use cases. > > Moreover, the additional argument will be effectively a no-op after recipe > materialization if the dialect-specific recipe implementation does not > require it, thus incurring no cost. However, should we need to incorporate > this in the future, it would involve considerable rework and IR test > modifications. > > Since we are revisiting this design decision, I would like to either get > buy-in or agree to change it and remove the extra argument now. @erichkeane > @clementval I was more to remove it in the previous PR but I'm fine with either choice. 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] [flang] [mlir] [flang][OpenACC] generate Destroy region to free memory of private and firstprivate if needed (PR #162702)
https://github.com/razvanlupusoru edited 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] [flang] [mlir] [flang][OpenACC] generate Destroy region to free memory of private and firstprivate if needed (PR #162702)
@@ -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, razvanlupusoru wrote: nit: Please swap the declaration order with generatePrivateInit - looks "off" to me to have destroy first. 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] [clang] [llvm] [HLSL] GetDimensions methods for buffer resources (PR #161929)
https://github.com/hekota updated
https://github.com/llvm/llvm-project/pull/161929
>From e50918910a0ce590228c6ecacd4ff2a578da6f58 Mon Sep 17 00:00:00 2001
From: Helena Kotas
Date: Fri, 3 Oct 2025 17:33:19 -0700
Subject: [PATCH 1/3] [HLSL] GetDimensions methods for buffer resources
Adds GetDimensions methods on all supported buffer resources.
---
clang/include/clang/Basic/Builtins.td | 12 +++
clang/lib/CodeGen/CGHLSLBuiltins.cpp | 61 ++
clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp | 81 ++-
clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.h | 2 +
clang/lib/Sema/HLSLExternalSemaSource.cpp | 11 +++
clang/lib/Sema/SemaHLSL.cpp | 18 +
.../test/AST/HLSL/ByteAddressBuffers-AST.hlsl | 14
.../test/AST/HLSL/StructuredBuffers-AST.hlsl | 22 +
clang/test/AST/HLSL/TypedBuffers-AST.hlsl | 14
.../resources/ByteAddressBuffers-methods.hlsl | 47 +++
.../StructuredBuffers-methods-lib.hlsl| 53 +++-
.../StructuredBuffers-methods-ps.hlsl | 37 +
.../resources/TypedBuffers-methods.hlsl | 34
llvm/include/llvm/IR/IntrinsicsDirectX.td | 4 +
14 files changed, 406 insertions(+), 4 deletions(-)
create mode 100644
clang/test/CodeGenHLSL/resources/ByteAddressBuffers-methods.hlsl
diff --git a/clang/include/clang/Basic/Builtins.td
b/clang/include/clang/Basic/Builtins.td
index 468121f7d20ab..0b1587be51217 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4951,6 +4951,18 @@ def HLSLResourceNonUniformIndex :
LangBuiltin<"HLSL_LANG"> {
let Prototype = "uint32_t(uint32_t)";
}
+def HLSLResourceGetDimensions : LangBuiltin<"HLSL_LANG"> {
+ let Spellings = ["__builtin_hlsl_buffer_getdimensions"];
+ let Attributes = [NoThrow];
+ let Prototype = "void(...)";
+}
+
+def HLSLResourceGetStride : LangBuiltin<"HLSL_LANG"> {
+ let Spellings = ["__builtin_hlsl_buffer_getstride"];
+ let Attributes = [NoThrow];
+ let Prototype = "void(...)";
+}
+
def HLSLAll : LangBuiltin<"HLSL_LANG"> {
let Spellings = ["__builtin_hlsl_all"];
let Attributes = [NoThrow, Const];
diff --git a/clang/lib/CodeGen/CGHLSLBuiltins.cpp
b/clang/lib/CodeGen/CGHLSLBuiltins.cpp
index 6c0fc8d7f07be..373153e01c128 100644
--- a/clang/lib/CodeGen/CGHLSLBuiltins.cpp
+++ b/clang/lib/CodeGen/CGHLSLBuiltins.cpp
@@ -160,6 +160,58 @@ static Value *handleHlslSplitdouble(const CallExpr *E,
CodeGenFunction *CGF) {
return LastInst;
}
+static Value *emitDXILGetDimensions(CodeGenFunction *CGF, Value *Handle,
+Value *MipLevel, LValue *OutArg0,
+LValue *OutArg1 = nullptr,
+LValue *OutArg2 = nullptr,
+LValue *OutArg3 = nullptr) {
+ assert(OutArg0 && "first output argument is required");
+
+ llvm::Type *I32 = CGF->Int32Ty;
+ StructType *RetTy = llvm::StructType::get(I32, I32, I32, I32);
+
+ CallInst *CI = CGF->Builder.CreateIntrinsic(
+ RetTy, llvm::Intrinsic::dx_resource_getdimensions,
+ ArrayRef{Handle, MipLevel});
+
+ Value *LastInst = nullptr;
+ unsigned OutArgIndex = 0;
+ for (LValue *OutArg : {OutArg0, OutArg1, OutArg2, OutArg3}) {
+if (OutArg) {
+ Value *OutArgVal = CGF->Builder.CreateExtractValue(CI, OutArgIndex);
+ LastInst = CGF->Builder.CreateStore(OutArgVal, OutArg->getAddress());
+}
+++OutArgIndex;
+ }
+ assert(LastInst && "no output argument stored?");
+ return LastInst;
+}
+
+static Value *emitBufferGetDimensions(CodeGenFunction *CGF, Value *Handle,
+ LValue &Dim) {
+ // Generate the call to get the buffer dimension.
+ switch (CGF->CGM.getTarget().getTriple().getArch()) {
+ case llvm::Triple::dxil:
+return emitDXILGetDimensions(CGF, Handle, PoisonValue::get(CGF->Int32Ty),
+ &Dim);
+break;
+ case llvm::Triple::spirv:
+llvm_unreachable("SPIR-V GetDimensions codegen not implemented yet.");
+ default:
+llvm_unreachable("GetDimensions not supported by target architecture");
+ }
+}
+
+static Value *emitBufferStride(CodeGenFunction *CGF, const Expr *HandleExpr,
+ LValue &Stride) {
+ // Figure out the stride of the buffer elements from the handle type.
+ auto *HandleTy =
+ cast(HandleExpr->getType().getTypePtr());
+ QualType ElementTy = HandleTy->getContainedType();
+ Value *StrideValue = CGF->getTypeSize(ElementTy);
+ return CGF->Builder.CreateStore(StrideValue, Stride.getAddress());
+}
+
// Return dot product intrinsic that corresponds to the QT scalar type
static Intrinsic::ID getDotProductIntrinsic(CGHLSLRuntime &RT, QualType QT) {
if (QT->isFloatingType())
@@ -359,6 +411,15 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned
BuiltinID,
RetTy, CGM.getHLSLRuntime().getNonUniformResourceIndexIntrinsic(),
ArrayRef{IndexOp}
[llvm-branch-commits] [llvm] [InstCombine] Mark as unknown the branch weights of packed integer selecting shifts (PR #162726)
https://github.com/mtrofin edited https://github.com/llvm/llvm-project/pull/162726 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
