[llvm-branch-commits] [llvm] [AMDGPU][NFC] Mark GEPs in flat offset folding tests as inbounds (PR #131994)

2025-10-08 Thread Fabian Ritter via llvm-branch-commits

ritter-x2a wrote:

Closed in favor of a future PR building on #162477

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


[llvm-branch-commits] [llvm] [AMDGPU][SDAG] Only fold flat offsets if they are inbounds (PR #132353)

2025-10-08 Thread Fabian Ritter via llvm-branch-commits

ritter-x2a wrote:

Closed in favor of a future PR building on #162477

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


[llvm-branch-commits] [NFC][SpecialCaseList] Use BumpPtrAllocator to own strings (PR #162304)

2025-10-08 Thread Qinkun Bao via llvm-branch-commits

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


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


[llvm-branch-commits] [llvm] [LV] Bundle (partial) reductions with a mul of a constant (PR #162503)

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

llvmbot wrote:




@llvm/pr-subscribers-llvm-transforms

Author: Sam Tebbs (SamTebbs33)


Changes

A reduction (including partial reductions) with a multiply of a constant value 
can be bundled by first converting it from `reduce.add(mul(ext, const))` to 
`reduce.add(mul(ext, ext(const)))` as long as it is safe to extend the constant.

This PR adds such bundling by first truncating the constant to the source type 
of the other extend, then extending it to the destination type of the extend. 
The first truncate is necessary so that the types of each extend's operand are 
then the same, and the call to canConstantBeExtended proves that the extend 
following a truncate is safe to do. The truncate is removed by optimisations.

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


2 Files Affected:

- (modified) llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp (+26) 
- (modified) llvm/test/Transforms/LoopVectorize/vplan-printing-reductions.ll 
(+266) 


``diff
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp 
b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 24426c1a53835..4bf2eb3765080 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -3597,6 +3597,32 @@ 
tryToMatchAndCreateMulAccumulateReduction(VPReductionRecipe *Red,
 dyn_cast_if_present(B->getDefiningRecipe());
 auto *Mul = cast(VecOp->getDefiningRecipe());
 
+// Match reduce.add(mul(ext, const)) and convert it to
+// reduce.add(mul(ext, ext(const)))
+if (RecipeA && !RecipeB && B->isLiveIn()) {
+  Type *NarrowTy = Ctx.Types.inferScalarType(RecipeA->getOperand(0));
+  Instruction::CastOps ExtOpc = RecipeA->getOpcode();
+  auto *Const = dyn_cast(B->getLiveInIRValue());
+  if (Const &&
+  llvm::canConstantBeExtended(
+  Const, NarrowTy, TTI::getPartialReductionExtendKind(ExtOpc))) {
+// The truncate ensures that the type of each extended operand is the
+// same, and it's been proven that the constant can be extended from
+// NarrowTy safely. Necessary since RecipeA's extended operand would be
+// e.g. an i8, while the const will likely be an i32. This will be
+// elided by later optimisations.
+auto *Trunc =
+new VPWidenCastRecipe(Instruction::CastOps::Trunc, B, NarrowTy);
+Trunc->insertBefore(*RecipeA->getParent(),
+std::next(RecipeA->getIterator()));
+
+Type *WideTy = Ctx.Types.inferScalarType(RecipeA);
+RecipeB = new VPWidenCastRecipe(ExtOpc, Trunc, WideTy);
+RecipeB->insertAfter(Trunc);
+Mul->setOperand(1, RecipeB);
+  }
+}
+
 // Match reduce.add/sub(mul(ext, ext)).
 if (RecipeA && RecipeB && match(RecipeA, m_ZExtOrSExt(m_VPValue())) &&
 match(RecipeB, m_ZExtOrSExt(m_VPValue())) &&
diff --git a/llvm/test/Transforms/LoopVectorize/vplan-printing-reductions.ll 
b/llvm/test/Transforms/LoopVectorize/vplan-printing-reductions.ll
index 06b044872c217..ddae9007b7620 100644
--- a/llvm/test/Transforms/LoopVectorize/vplan-printing-reductions.ll
+++ b/llvm/test/Transforms/LoopVectorize/vplan-printing-reductions.ll
@@ -800,3 +800,269 @@ exit:
   %r.0.lcssa = phi i64 [ %rdx.next, %loop ]
   ret i64 %r.0.lcssa
 }
+
+define i32 @print_mulacc_extended_const(ptr %start, ptr %end) {
+; CHECK-LABEL: 'print_mulacc_extended_const'
+; CHECK:   VPlan 'Initial VPlan for VF={4},UF>=1' {
+; CHECK-NEXT:  Live-in vp<%0> = VF
+; CHECK-NEXT:  Live-in vp<%1> = VF * UF
+; CHECK-NEXT:  Live-in vp<%2> = vector-trip-count
+; CHECK-NEXT:  vp<%3> = original trip-count
+; CHECK-EMPTY:
+; CHECK-NEXT:  ir-bb:
+; CHECK-NEXT:EMIT vp<%3> = EXPAND SCEV (1 + (-1 * (ptrtoint ptr %start to 
i64)) + (ptrtoint ptr %end to i64))
+; CHECK-NEXT:  Successor(s): scalar.ph, vector.ph
+; CHECK-EMPTY:
+; CHECK-NEXT:  vector.ph:
+; CHECK-NEXT:vp<%4> = DERIVED-IV ir<%start> + vp<%2> * ir<1>
+; CHECK-NEXT:EMIT vp<%5> = reduction-start-vector ir<0>, ir<0>, ir<1>
+; CHECK-NEXT:  Successor(s): vector loop
+; CHECK-EMPTY:
+; CHECK-NEXT:   vector loop: {
+; CHECK-NEXT:vector.body:
+; CHECK-NEXT:  EMIT vp<%6> = CANONICAL-INDUCTION ir<0>, vp<%index.next>
+; CHECK-NEXT:  WIDEN-REDUCTION-PHI ir<%red> = phi vp<%5>, vp<%9>
+; CHECK-NEXT:  vp<%7> = SCALAR-STEPS vp<%6>, ir<1>, vp<%0>
+; CHECK-NEXT:  EMIT vp<%next.gep> = ptradd ir<%start>, vp<%7>
+; CHECK-NEXT:  vp<%8> = vector-pointer vp<%next.gep>
+; CHECK-NEXT:  WIDEN ir<%l> = load vp<%8>
+; CHECK-NEXT:  EXPRESSION vp<%9> = ir<%red> + reduce.add (mul (ir<%l> zext 
to i32), (ir<63> zext to i32))
+; CHECK-NEXT:  EMIT vp<%index.next> = add nuw vp<%6>, vp<%1>
+; CHECK-NEXT:  EMIT branch-on-count vp<%index.next>, vp<%2>
+; CHECK-NEXT:No successors
+; CHECK-NEXT:  }
+; CHECK-NEXT:  Successor(s): middle.block
+; CHECK-EMPTY:
+; CHECK-NEXT:  middle.block:
+; CHECK-NEXT:EMIT vp<%11> = compute-red

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

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

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


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


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

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

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


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


[llvm-branch-commits] [llvm] release/21.x: [llvm] Support building with c++23 (#154372) (PR #162510)

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

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


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

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


@@ -75,7 +75,7 @@ bool StaticDataAnnotator::runOnModule(Module &M) {
 
   bool Changed = false;
   for (auto &GV : M.globals()) {
-if (GV.isDeclarationForLinker())
+if (!llvm::memprof::IsAnnotationOK(GV))

mingmingl-llvm wrote:

> But are the effects of this change and the other one I mentioned earlier not 
> observable by tests?

Yeah, the test coverage is limited to [1] before. Improved the test coverage 
now, PTAL, thanks!


[1] 
https://github.com/llvm/llvm-project/blob/139a6bf0e448ebd7ef9bd1c26aa92018d90f8add/llvm/test/Transforms/PGOProfile/data-access-profile.ll#L28-L29

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] [BOLT] Extend Inliner to work on functions with Pointer Autentication (PR #162458)

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

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

* **#162458** https://app.graphite.dev/github/pr/llvm/llvm-project/162458?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/162458?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#162251** https://app.graphite.dev/github/pr/llvm/llvm-project/162251?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* `main`




This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn 
more about https://stacking.dev/?utm_source=stack-comment";>stacking.


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


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

2025-10-08 Thread David Spickett via llvm-branch-commits

DavidSpickett wrote:

Well I think we needed a release manager to agree with us agreeing to merge it, 
perhaps it wasn't in the right state for them to see it.

I believe @c-rhodes is handling 21.1.4, they have the final say here I think.

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] release/21.x: [llvm] Support building with c++23 (#154372) (PR #162510)

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

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

Backport 5d0294fcb61560a228e230e8a477fc44746ec62b

Requested by: @frederick-vs-ja

>From e1315b14a444097c6c3aff6d62d4b1974c4c54ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kyle=20Kr=C3=BCger?=
 <[email protected]>
Date: Fri, 29 Aug 2025 14:52:07 +0200
Subject: [PATCH] [llvm] Support building with c++23 (#154372)

closes #154331

This PR addresses all minimum changes needed to compile LLVM and MLIR
with the c++23 standard.
It is a work in progress and to be reviewed for better methods of
handling the parts of the build broken by c++23.

(cherry picked from commit 5d0294fcb61560a228e230e8a477fc44746ec62b)
---
 .../llvm/CodeGen/MachineFunctionAnalysis.h  |  2 +-
 .../llvm/CodeGen/ResourcePriorityQueue.h|  1 +
 llvm/include/llvm/DebugInfo/GSYM/GsymContext.h  |  1 +
 .../DebugInfo/PDB/ConcreteSymbolEnumerator.h|  1 +
 llvm/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h |  1 +
 .../llvm/DebugInfo/PDB/Native/InputFile.h   |  6 +++---
 llvm/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h |  2 +-
 .../llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h   |  1 +
 .../llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h  |  2 ++
 llvm/include/llvm/MC/MCGOFFStreamer.h   |  4 +---
 llvm/lib/CodeGen/LiveDebugVariables.cpp | 12 ++--
 llvm/lib/CodeGen/MachineFunctionAnalysis.cpp|  4 
 .../SelectionDAG/ResourcePriorityQueue.cpp  |  2 ++
 llvm/lib/DebugInfo/GSYM/GsymContext.cpp |  1 +
 llvm/lib/DebugInfo/PDB/Native/InputFile.cpp |  5 +
 llvm/lib/DebugInfo/PDB/PDBSymbolTypeBuiltin.cpp |  6 ++
 llvm/lib/MC/MCGOFFStreamer.cpp  |  6 ++
 llvm/lib/ObjCopy/ELF/ELFObject.cpp  |  3 +++
 llvm/lib/ObjCopy/ELF/ELFObject.h|  3 ++-
 llvm/lib/Remarks/BitstreamRemarkParser.cpp  |  2 ++
 llvm/lib/Remarks/BitstreamRemarkParser.h|  3 +--
 llvm/lib/TableGen/TGParser.cpp  |  8 
 llvm/lib/TableGen/TGParser.h| 10 --
 .../RISCV/MCTargetDesc/RISCVELFStreamer.cpp |  6 ++
 .../RISCV/MCTargetDesc/RISCVELFStreamer.h   |  3 +--
 llvm/tools/dsymutil/DebugMap.cpp|  5 +
 llvm/tools/dsymutil/DebugMap.h  |  4 +---
 llvm/tools/llvm-cov/SourceCoverageView.cpp  | 17 +
 llvm/tools/llvm-cov/SourceCoverageView.h| 15 ---
 .../Common/GlobalISel/GlobalISelMatchTable.cpp  | 13 +
 .../Common/GlobalISel/GlobalISelMatchTable.h| 14 --
 31 files changed, 114 insertions(+), 49 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h 
b/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h
index 98a60c987bbe3..f67d2032ff5cf 100644
--- a/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h
+++ b/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h
@@ -36,7 +36,7 @@ class MachineFunctionAnalysis
 std::unique_ptr MF;
 
   public:
-Result(std::unique_ptr MF) : MF(std::move(MF)) {}
+Result(std::unique_ptr MF);
 MachineFunction &getMF() { return *MF; };
 LLVM_ABI bool invalidate(Function &, const PreservedAnalyses &PA,
  FunctionAnalysisManager::Invalidator &);
diff --git a/llvm/include/llvm/CodeGen/ResourcePriorityQueue.h 
b/llvm/include/llvm/CodeGen/ResourcePriorityQueue.h
index bd63dd8756210..c15bc677ae53f 100644
--- a/llvm/include/llvm/CodeGen/ResourcePriorityQueue.h
+++ b/llvm/include/llvm/CodeGen/ResourcePriorityQueue.h
@@ -75,6 +75,7 @@ namespace llvm {
 
   public:
 ResourcePriorityQueue(SelectionDAGISel *IS);
+~ResourcePriorityQueue();
 
 bool isBottomUp() const override { return false; }
 
diff --git a/llvm/include/llvm/DebugInfo/GSYM/GsymContext.h 
b/llvm/include/llvm/DebugInfo/GSYM/GsymContext.h
index 9c04ff63c8059..07d599cf9b5c6 100644
--- a/llvm/include/llvm/DebugInfo/GSYM/GsymContext.h
+++ b/llvm/include/llvm/DebugInfo/GSYM/GsymContext.h
@@ -30,6 +30,7 @@ class GsymReader;
 class GsymContext : public DIContext {
 public:
   GsymContext(std::unique_ptr Reader);
+  ~GsymContext();
 
   GsymContext(GsymContext &) = delete;
   GsymContext &operator=(GsymContext &) = delete;
diff --git a/llvm/include/llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h 
b/llvm/include/llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h
index 49ba20af72636..fccea2c65ba14 100644
--- a/llvm/include/llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h
+++ b/llvm/include/llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h
@@ -10,6 +10,7 @@
 #define LLVM_DEBUGINFO_PDB_CONCRETESYMBOLENUMERATOR_H
 
 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
+#include "llvm/DebugInfo/PDB/PDBSymbol.h"
 #include "llvm/DebugInfo/PDB/PDBTypes.h"
 #include "llvm/Support/Casting.h"
 #include 
diff --git a/llvm/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h 
b/llvm/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h
index 7e15433b839ed..aec93c928a760 100644
--- a/llvm/include/llvm/DebugInfo/PDB/I

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

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


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

vitalybuka wrote:

To be fair, I don't know how important indirection here.
Inderection inside of matches makes a difference as those array can be  large 

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


[llvm-branch-commits] [NFC][SpecialCaseList] Hide more details in private section (PR #162302)

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

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/162302


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


[llvm-branch-commits] [NFC][SpecialCaseList] Hide more details in private section (PR #162302)

2025-10-08 Thread Thurston Dang via llvm-branch-commits

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


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


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

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

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


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


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

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


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

fmayer wrote:

isn't that just hand-rolled virtual calls?

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


[llvm-branch-commits] [llvm] [DirectX] Making sure we always parse, validate and verify Flags (PR #162171)

2025-10-08 Thread Justin Bogner via llvm-branch-commits

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


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


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

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


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

vitalybuka wrote:

Yes, to keep move semantics.

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


[llvm-branch-commits] Add Nix recipe for collecting linker reproducers. (PR #145789)

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


@@ -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; };

pcc wrote:

Done

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


[llvm-branch-commits] Add Nix recipe for collecting linker reproducers. (PR #145789)

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

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


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


[llvm-branch-commits] Add Nix recipe for collecting linker reproducers. (PR #145789)

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


@@ -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] Add Nix recipe for collecting linker reproducers. (PR #145789)

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


@@ -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] Add Nix recipe for collecting linker reproducers. (PR #145789)

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


@@ -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] [AllocToken, Clang] Implement __builtin_infer_alloc_token() and llvm.alloc.token.id (PR #156842)

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

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

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

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

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

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