[llvm-branch-commits] [llvm] AMDGPU: Try constant fold after folding immediate (PR #141862)

2025-06-09 Thread Matt Arsenault via llvm-branch-commits

arsenm wrote:

### Merge activity

* **Jun 10, 2:36 AM UTC**: A user started a stack merge that includes this pull 
request via 
[Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/141862).


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


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

2025-06-09 Thread Shilei Tian via llvm-branch-commits

shiltian wrote:

Is this PR part of a stack or something?

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


[llvm-branch-commits] [MSAN] handle AVX vpermi2var (PR #143463)

2025-06-09 Thread Thurston Dang via llvm-branch-commits

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


[llvm-branch-commits] [MSAN] handle AVX vpermi2var (PR #143463)

2025-06-09 Thread Thurston Dang via llvm-branch-commits

https://github.com/thurstond requested changes to this pull request.

Please add assertions and more tests (comments inline).

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


[llvm-branch-commits] [MSAN] handle AVX vpermi2var (PR #143463)

2025-06-09 Thread Thurston Dang via llvm-branch-commits


@@ -5130,6 +5149,26 @@ struct MemorySanitizerVisitor : public 
InstVisitor {
   handleAVXVpermilvar(I);
   break;
 }
+case Intrinsic::x86_avx512_vpermi2var_d_128:
+case Intrinsic::x86_avx512_vpermi2var_d_256:
+case Intrinsic::x86_avx512_vpermi2var_d_512:
+case Intrinsic::x86_avx512_vpermi2var_hi_128:
+case Intrinsic::x86_avx512_vpermi2var_hi_256:
+case Intrinsic::x86_avx512_vpermi2var_hi_512:
+case Intrinsic::x86_avx512_vpermi2var_pd_128:
+case Intrinsic::x86_avx512_vpermi2var_pd_256:
+case Intrinsic::x86_avx512_vpermi2var_pd_512:
+case Intrinsic::x86_avx512_vpermi2var_ps_128:
+case Intrinsic::x86_avx512_vpermi2var_ps_256:
+case Intrinsic::x86_avx512_vpermi2var_ps_512:
+case Intrinsic::x86_avx512_vpermi2var_q_128:
+case Intrinsic::x86_avx512_vpermi2var_q_256:
+case Intrinsic::x86_avx512_vpermi2var_q_512:
+case Intrinsic::x86_avx512_vpermi2var_qi_128:
+case Intrinsic::x86_avx512_vpermi2var_qi_256:
+case Intrinsic::x86_avx512_vpermi2var_qi_512:
+  handleAVXVpermil2var(I);

thurstond wrote:

Please precommit tests to cover all these instructions.
(AFAICS the tests only cover llvm.x86.avx512.vpermi2var.d.512, 
llvm.x86.avx512.vpermi2var.pd.512, llvm.x86.avx512.vpermi2var.ps.512, 
llvm.x86.avx512.vpermi2var.q.512.)


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


[llvm-branch-commits] [MSAN] handle AVX vpermi2var (PR #143463)

2025-06-09 Thread Thurston Dang via llvm-branch-commits


@@ -4175,6 +4175,25 @@ struct MemorySanitizerVisitor : public 
InstVisitor {
 setShadow(&I, IRB.CreateBitCast(CI, getShadowTy(&I)));
 setOriginForNaryOp(I);
   }
+  // Instrument AVX permutation intrinsic.
+  // We apply the same permutation (argument index 1) to the shadows.
+  void handleAVXVpermil2var(IntrinsicInst &I) {
+IRBuilder<> IRB(&I);

thurstond wrote:

Please add some assertions that check whether the instruction is suitable for 
this handler:

- number of operands
- type and size of each operand
- relation of input and output operands

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


[llvm-branch-commits] [MSAN] handle assorted AVX permutations (PR #143462)

2025-06-09 Thread Thurston Dang via llvm-branch-commits

https://github.com/thurstond requested changes to this pull request.

Please add assertions and more tests (comments inline).

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


[llvm-branch-commits] [MSAN] handle assorted AVX permutations (PR #143462)

2025-06-09 Thread Thurston Dang via llvm-branch-commits

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


[llvm-branch-commits] [MSAN] handle assorted AVX permutations (PR #143462)

2025-06-09 Thread Thurston Dang via llvm-branch-commits


@@ -4161,7 +4161,7 @@ struct MemorySanitizerVisitor : public 
InstVisitor {
 
   // Instrument AVX permutation intrinsic.
   // We apply the same permutation (argument index 1) to the shadow.
-  void handleAVXVpermilvar(IntrinsicInst &I) {
+  void handleAVXPermutation(IntrinsicInst &I) {

thurstond wrote:

Since this function is being used for many more cases, please augment it with 
assertions that check whether the instruction is suitable for this handler:
- number of operands
- type and size of each operand
- relation of input and output operands

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


[llvm-branch-commits] [MSAN] handle assorted AVX permutations (PR #143462)

2025-06-09 Thread Thurston Dang via llvm-branch-commits


@@ -5139,14 +5139,30 @@ struct MemorySanitizerVisitor : public 
InstVisitor {
   assert(Success);
   break;
 }
-
+case Intrinsic::x86_avx2_permd:
+case Intrinsic::x86_avx2_permps:
+case Intrinsic::x86_ssse3_pshuf_b_128:
+case Intrinsic::x86_avx2_pshuf_b:
+case Intrinsic::x86_avx512_pshuf_b_512:
+case Intrinsic::x86_avx512_permvar_df_256:
+case Intrinsic::x86_avx512_permvar_df_512:
+case Intrinsic::x86_avx512_permvar_di_256:
+case Intrinsic::x86_avx512_permvar_di_512:
+case Intrinsic::x86_avx512_permvar_hi_128:
+case Intrinsic::x86_avx512_permvar_hi_256:
+case Intrinsic::x86_avx512_permvar_hi_512:
+case Intrinsic::x86_avx512_permvar_qi_128:
+case Intrinsic::x86_avx512_permvar_qi_256:
+case Intrinsic::x86_avx512_permvar_qi_512:
+case Intrinsic::x86_avx512_permvar_sf_512:
+case Intrinsic::x86_avx512_permvar_si_512:

thurstond wrote:

Please precommit tests to cover all these instructions.
(AFAICS the tests only cover llvm.x86.avx2.permd, llvm.x86.avx2.permps, 
llvm.x86.avx2.pshuf.b, llvm.x86.avx512.permvar.df.512, 
llvm.x86.avx512.permvar.di.512, llvm.x86.avx512.permvar.sf.512, 
llvm.x86.avx512.permvar.si.512.)

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


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

2025-06-09 Thread Alexander Richardson via llvm-branch-commits

arichardson wrote:

> Is this PR part of a stack or something?

Yes there are follow-up change to make better use of the new instruction but 
this one can be reviewed standalone. The `spr` tool doesn't auto link related 
PRs, I can add some comments to link them here.

#139601 #139423

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


[llvm-branch-commits] [IRTranslator] Handle ptrtoaddr (PR #139601)

2025-06-09 Thread Jessica Clarke via llvm-branch-commits


@@ -1583,6 +1583,26 @@ bool IRTranslator::translateCast(unsigned Opcode, const 
User &U,
   return true;
 }
 
+bool IRTranslator::translatePtrToAddr(const User &U,
+  MachineIRBuilder &MIRBuilder) {
+  if (containsBF16Type(U))
+return false;
+
+  uint32_t Flags = 0;
+  if (const Instruction *I = dyn_cast(&U))
+Flags = MachineInstr::copyFlagsFromInstruction(*I);
+
+  Register Op = getOrCreateVReg(*U.getOperand(0));
+  Type *PtrTy = U.getOperand(0)->getType();
+  LLT AddrTy = getLLTForType(*DL->getIndexType(PtrTy), *DL);
+  auto IntPtrTy = getLLTForType(*DL->getIntPtrType(PtrTy), *DL);
+  auto PtrToInt = MIRBuilder.buildPtrToInt(IntPtrTy, Op);

jrtc27 wrote:

We'd need a G_PTRTOADDR for CHERI given we can't do ptrtoint as it's defined 
upstream

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


[llvm-branch-commits] [clang] 28174b6 - Revert "[alpha.webkit.NoUnretainedMemberChecker] Recognize NS_REQUIRES_PROPER…"

2025-06-09 Thread via llvm-branch-commits

Author: Ryosuke Niwa
Date: 2025-06-09T20:55:54-07:00
New Revision: 28174b68fd035a5d62b68c48cc07b5334e2c3ab9

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

LOG: Revert "[alpha.webkit.NoUnretainedMemberChecker] Recognize 
NS_REQUIRES_PROPER…"

This reverts commit 0123ee51ef3290466c6d743aac2932b23655aa04.

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp
clang/test/Analysis/Checkers/WebKit/objc-mock-types.h
clang/test/Analysis/Checkers/WebKit/unretained-members-arc.mm
clang/test/Analysis/Checkers/WebKit/unretained-members.mm

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index 72199af2f80a5..cd33476344a34 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -236,7 +236,6 @@ std::optional isUnchecked(const QualType T) {
 void RetainTypeChecker::visitTranslationUnitDecl(
 const TranslationUnitDecl *TUD) {
   IsARCEnabled = TUD->getLangOpts().ObjCAutoRefCount;
-  DefaultSynthProperties = TUD->getLangOpts().ObjCDefaultSynthProperties;
 }
 
 void RetainTypeChecker::visitTypedef(const TypedefDecl *TD) {

diff  --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
index 3c9560cb8059b..f9fcfe9878d54 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
@@ -76,14 +76,12 @@ class RetainTypeChecker {
   llvm::DenseSet CFPointees;
   llvm::DenseSet RecordlessTypes;
   bool IsARCEnabled{false};
-  bool DefaultSynthProperties{true};
 
 public:
   void visitTranslationUnitDecl(const TranslationUnitDecl *);
   void visitTypedef(const TypedefDecl *);
   bool isUnretained(const QualType, bool ignoreARC = false);
   bool isARCEnabled() const { return IsARCEnabled; }
-  bool defaultSynthProperties() const { return DefaultSynthProperties; }
 };
 
 /// \returns true if \p Class is NS or CF objects AND not retained, false if

diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp
index 8faf6a219450a..b1350b9093021 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp
@@ -28,7 +28,6 @@ class RawPtrRefMemberChecker
 private:
   BugType Bug;
   mutable BugReporter *BR;
-  mutable llvm::DenseSet IvarDeclsToIgnore;
 
 protected:
   mutable std::optional RTC;
@@ -37,8 +36,7 @@ class RawPtrRefMemberChecker
   RawPtrRefMemberChecker(const char *description)
   : Bug(this, description, "WebKit coding guidelines") {}
 
-  virtual std::optional isUnsafePtr(QualType,
-  bool ignoreARC = false) const = 0;
+  virtual std::optional isUnsafePtr(QualType) const = 0;
   virtual const char *typeName() const = 0;
   virtual const char *invariant() const = 0;
 
@@ -140,8 +138,6 @@ class RawPtrRefMemberChecker
   return;
 }
 if (auto *ID = dyn_cast(CD)) {
-  for (auto *PropImpl : ID->property_impls())
-visitPropImpl(CD, PropImpl);
   for (auto *Ivar : ID->ivars())
 visitIvarDecl(CD, Ivar);
   return;
@@ -152,10 +148,6 @@ class RawPtrRefMemberChecker
  const ObjCIvarDecl *Ivar) const {
 if (BR->getSourceManager().isInSystemHeader(Ivar->getLocation()))
   return;
-
-if (IvarDeclsToIgnore.contains(Ivar))
-  return;
-
 auto QT = Ivar->getType();
 const Type *IvarType = QT.getTypePtrOrNull();
 if (!IvarType)
@@ -165,8 +157,6 @@ class RawPtrRefMemberChecker
 if (!IsUnsafePtr || !*IsUnsafePtr)
   return;
 
-IvarDeclsToIgnore.insert(Ivar);
-
 if (auto *MemberCXXRD = IvarType->getPointeeCXXRecordDecl())
   reportBug(Ivar, IvarType, MemberCXXRD, CD);
 else if (auto *ObjCDecl = getObjCDecl(IvarType))
@@ -177,15 +167,13 @@ class RawPtrRefMemberChecker
  const ObjCPropertyDecl *PD) const {
 if (BR->getSourceManager().isInSystemHeader(PD->getLocation()))
   return;
+auto QT = PD->getType();
+const Type *PropType = QT.getTypePtrOrNull();
+if (!PropType)
+  return;
 
-if (const ObjCInterfaceDecl *ID = dyn_cast(CD)) {
-  if (!RTC || !RTC->defaultSynthProperties() ||
-  ID->isObjCRequiresPropertyDefs())
-return;
-}
-
-auto [IsUnsafe, PropType] = isPropImplUns

[llvm-branch-commits] [llvm] [IR2Vec] Minor vocab changes and exposing weights (PR #143200)

2025-06-09 Thread S. VenkataKeerthy via llvm-branch-commits

https://github.com/svkeerthy updated 
https://github.com/llvm/llvm-project/pull/143200

>From d3468ab37c05d4796661f13d61fffe31bcf47ba5 Mon Sep 17 00:00:00 2001
From: svkeerthy 
Date: Fri, 6 Jun 2025 20:32:32 +
Subject: [PATCH] Vocab changes1

---
 llvm/include/llvm/Analysis/IR2Vec.h|  10 ++
 llvm/lib/Analysis/IR2Vec.cpp   |  82 +--
 llvm/unittests/Analysis/IR2VecTest.cpp | 137 ++---
 3 files changed, 163 insertions(+), 66 deletions(-)

diff --git a/llvm/include/llvm/Analysis/IR2Vec.h 
b/llvm/include/llvm/Analysis/IR2Vec.h
index 3e7e31aac0f6d..dbce8ebe5e103 100644
--- a/llvm/include/llvm/Analysis/IR2Vec.h
+++ b/llvm/include/llvm/Analysis/IR2Vec.h
@@ -31,7 +31,9 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/JSON.h"
 #include 
 
 namespace llvm {
@@ -43,6 +45,7 @@ class Function;
 class Type;
 class Value;
 class raw_ostream;
+class LLVMContext;
 
 /// IR2Vec computes two kinds of embeddings: Symbolic and Flow-aware.
 /// Symbolic embeddings capture the "syntactic" and "statistical correlation"
@@ -53,6 +56,11 @@ class raw_ostream;
 enum class IR2VecKind { Symbolic };
 
 namespace ir2vec {
+
+LLVM_ABI extern cl::opt OpcWeight;
+LLVM_ABI extern cl::opt TypeWeight;
+LLVM_ABI extern cl::opt ArgWeight;
+
 /// Embedding is a ADT that wraps std::vector. It provides
 /// additional functionality for arithmetic and comparison operations.
 /// It is meant to be used *like* std::vector but is more restrictive
@@ -226,10 +234,12 @@ class IR2VecVocabResult {
 class IR2VecVocabAnalysis : public AnalysisInfoMixin {
   ir2vec::Vocab Vocabulary;
   Error readVocabulary();
+  void emitError(Error Err, LLVMContext &Ctx);
 
 public:
   static AnalysisKey Key;
   IR2VecVocabAnalysis() = default;
+  explicit IR2VecVocabAnalysis(ir2vec::Vocab &&Vocab);
   using Result = IR2VecVocabResult;
   Result run(Module &M, ModuleAnalysisManager &MAM);
 };
diff --git a/llvm/lib/Analysis/IR2Vec.cpp b/llvm/lib/Analysis/IR2Vec.cpp
index 25ce35d4ace37..2ad65c2f40c33 100644
--- a/llvm/lib/Analysis/IR2Vec.cpp
+++ b/llvm/lib/Analysis/IR2Vec.cpp
@@ -16,13 +16,11 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
-#include "llvm/Support/JSON.h"
 #include "llvm/Support/MemoryBuffer.h"
 
 using namespace llvm;
@@ -33,6 +31,8 @@ using namespace ir2vec;
 STATISTIC(VocabMissCounter,
   "Number of lookups to entites not present in the vocabulary");
 
+namespace llvm {
+namespace ir2vec {
 static cl::OptionCategory IR2VecCategory("IR2Vec Options");
 
 // FIXME: Use a default vocab when not specified
@@ -40,18 +40,20 @@ static cl::opt
 VocabFile("ir2vec-vocab-path", cl::Optional,
   cl::desc("Path to the vocabulary file for IR2Vec"), cl::init(""),
   cl::cat(IR2VecCategory));
-static cl::opt OpcWeight("ir2vec-opc-weight", cl::Optional,
-cl::init(1.0),
-cl::desc("Weight for opcode embeddings"),
-cl::cat(IR2VecCategory));
-static cl::opt TypeWeight("ir2vec-type-weight", cl::Optional,
- cl::init(0.5),
- cl::desc("Weight for type embeddings"),
- cl::cat(IR2VecCategory));
-static cl::opt ArgWeight("ir2vec-arg-weight", cl::Optional,
-cl::init(0.2),
-cl::desc("Weight for argument embeddings"),
-cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt OpcWeight("ir2vec-opc-weight", cl::Optional,
+  cl::init(1.0),
+  cl::desc("Weight for opcode embeddings"),
+  cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt TypeWeight("ir2vec-type-weight", cl::Optional,
+   cl::init(0.5),
+   cl::desc("Weight for type embeddings"),
+   cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt ArgWeight("ir2vec-arg-weight", cl::Optional,
+  cl::init(0.2),
+  cl::desc("Weight for argument embeddings"),
+  cl::cat(IR2VecCategory));
+} // namespace ir2vec
+} // namespace llvm
 
 AnalysisKey IR2VecVocabAnalysis::Key;
 
@@ -251,9 +253,9 @@ bool IR2VecVocabResult::invalidate(
 // by auto-generating a default vocabulary during the build time.
 Error IR2VecVocabAnalysis::readVocabulary() {
   auto BufOrError = MemoryBuffer::getFileOrSTDIN(VocabFile, /*IsText=*/true);
-  if (!BufOrError) {
+  if (!B

[llvm-branch-commits] [llvm] [IR2Vec] Minor vocab changes and exposing weights (PR #143200)

2025-06-09 Thread S. VenkataKeerthy via llvm-branch-commits

https://github.com/svkeerthy updated 
https://github.com/llvm/llvm-project/pull/143200

>From d3468ab37c05d4796661f13d61fffe31bcf47ba5 Mon Sep 17 00:00:00 2001
From: svkeerthy 
Date: Fri, 6 Jun 2025 20:32:32 +
Subject: [PATCH] Vocab changes1

---
 llvm/include/llvm/Analysis/IR2Vec.h|  10 ++
 llvm/lib/Analysis/IR2Vec.cpp   |  82 +--
 llvm/unittests/Analysis/IR2VecTest.cpp | 137 ++---
 3 files changed, 163 insertions(+), 66 deletions(-)

diff --git a/llvm/include/llvm/Analysis/IR2Vec.h 
b/llvm/include/llvm/Analysis/IR2Vec.h
index 3e7e31aac0f6d..dbce8ebe5e103 100644
--- a/llvm/include/llvm/Analysis/IR2Vec.h
+++ b/llvm/include/llvm/Analysis/IR2Vec.h
@@ -31,7 +31,9 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/JSON.h"
 #include 
 
 namespace llvm {
@@ -43,6 +45,7 @@ class Function;
 class Type;
 class Value;
 class raw_ostream;
+class LLVMContext;
 
 /// IR2Vec computes two kinds of embeddings: Symbolic and Flow-aware.
 /// Symbolic embeddings capture the "syntactic" and "statistical correlation"
@@ -53,6 +56,11 @@ class raw_ostream;
 enum class IR2VecKind { Symbolic };
 
 namespace ir2vec {
+
+LLVM_ABI extern cl::opt OpcWeight;
+LLVM_ABI extern cl::opt TypeWeight;
+LLVM_ABI extern cl::opt ArgWeight;
+
 /// Embedding is a ADT that wraps std::vector. It provides
 /// additional functionality for arithmetic and comparison operations.
 /// It is meant to be used *like* std::vector but is more restrictive
@@ -226,10 +234,12 @@ class IR2VecVocabResult {
 class IR2VecVocabAnalysis : public AnalysisInfoMixin {
   ir2vec::Vocab Vocabulary;
   Error readVocabulary();
+  void emitError(Error Err, LLVMContext &Ctx);
 
 public:
   static AnalysisKey Key;
   IR2VecVocabAnalysis() = default;
+  explicit IR2VecVocabAnalysis(ir2vec::Vocab &&Vocab);
   using Result = IR2VecVocabResult;
   Result run(Module &M, ModuleAnalysisManager &MAM);
 };
diff --git a/llvm/lib/Analysis/IR2Vec.cpp b/llvm/lib/Analysis/IR2Vec.cpp
index 25ce35d4ace37..2ad65c2f40c33 100644
--- a/llvm/lib/Analysis/IR2Vec.cpp
+++ b/llvm/lib/Analysis/IR2Vec.cpp
@@ -16,13 +16,11 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
-#include "llvm/Support/JSON.h"
 #include "llvm/Support/MemoryBuffer.h"
 
 using namespace llvm;
@@ -33,6 +31,8 @@ using namespace ir2vec;
 STATISTIC(VocabMissCounter,
   "Number of lookups to entites not present in the vocabulary");
 
+namespace llvm {
+namespace ir2vec {
 static cl::OptionCategory IR2VecCategory("IR2Vec Options");
 
 // FIXME: Use a default vocab when not specified
@@ -40,18 +40,20 @@ static cl::opt
 VocabFile("ir2vec-vocab-path", cl::Optional,
   cl::desc("Path to the vocabulary file for IR2Vec"), cl::init(""),
   cl::cat(IR2VecCategory));
-static cl::opt OpcWeight("ir2vec-opc-weight", cl::Optional,
-cl::init(1.0),
-cl::desc("Weight for opcode embeddings"),
-cl::cat(IR2VecCategory));
-static cl::opt TypeWeight("ir2vec-type-weight", cl::Optional,
- cl::init(0.5),
- cl::desc("Weight for type embeddings"),
- cl::cat(IR2VecCategory));
-static cl::opt ArgWeight("ir2vec-arg-weight", cl::Optional,
-cl::init(0.2),
-cl::desc("Weight for argument embeddings"),
-cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt OpcWeight("ir2vec-opc-weight", cl::Optional,
+  cl::init(1.0),
+  cl::desc("Weight for opcode embeddings"),
+  cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt TypeWeight("ir2vec-type-weight", cl::Optional,
+   cl::init(0.5),
+   cl::desc("Weight for type embeddings"),
+   cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt ArgWeight("ir2vec-arg-weight", cl::Optional,
+  cl::init(0.2),
+  cl::desc("Weight for argument embeddings"),
+  cl::cat(IR2VecCategory));
+} // namespace ir2vec
+} // namespace llvm
 
 AnalysisKey IR2VecVocabAnalysis::Key;
 
@@ -251,9 +253,9 @@ bool IR2VecVocabResult::invalidate(
 // by auto-generating a default vocabulary during the build time.
 Error IR2VecVocabAnalysis::readVocabulary() {
   auto BufOrError = MemoryBuffer::getFileOrSTDIN(VocabFile, /*IsText=*/true);
-  if (!BufOrError) {
+  if (!B

[llvm-branch-commits] [clang-tools-extra] [clang-doc] add namespaces to JSON generator (PR #143209)

2025-06-09 Thread Paul Kirth via llvm-branch-commits


@@ -171,5 +171,78 @@ TEST(JSONGeneratorTest, emitRecordJSON) {
 })raw";
   EXPECT_EQ(Expected, Actual.str());
 }
+
+TEST(JSONGeneratorTest, emitNamespaceJSON) {
+  NamespaceInfo I;
+  I.Name = "Namespace";
+  I.Path = "path/to/A";
+  I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
+
+  I.Children.Namespaces.emplace_back(
+  EmptySID, "ChildNamespace", InfoType::IT_namespace,
+  "path::to::A::Namespace::ChildNamespace", "path/to/A/Namespace");
+  I.Children.Records.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record,
+  "path::to::A::Namespace::ChildStruct",
+  "path/to/A/Namespace");
+  I.Children.Functions.emplace_back();
+  I.Children.Functions.back().Name = "OneFunction";
+  I.Children.Functions.back().Access = AccessSpecifier::AS_none;
+  I.Children.Enums.emplace_back();
+  I.Children.Enums.back().Name = "OneEnum";
+
+  auto G = getJSONGenerator();
+  assert(G);
+  std::string Buffer;
+  llvm::raw_string_ostream Actual(Buffer);
+  auto Err = G->generateDocForInfo(&I, Actual, ClangDocContext());
+  assert(!Err);
+  std::string Expected = R"raw({
+  "Enums": [
+{
+  "Name": "OneEnum",
+  "Scoped": false,
+  "USR": ""
+}
+  ],
+  "Functions": [
+{
+  "IsStatic": false,
+  "Name": "OneFunction",
+  "ReturnType": {
+"IsBuiltIn": false,
+"IsTemplate": false,
+"Name": "",
+"QualName": "",
+"USR": ""
+  },
+  "USR": ""
+}
+  ],
+  "Name": "Namespace",
+  "Namespace": [
+"A"
+  ],
+  "NamespacePath": "path/to/A/Namespace",

ilovepi wrote:

OK, that makes sense. Your proposed updates sound good, so lets go with that.

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


[llvm-branch-commits] [llvm] [IR2Vec] Minor vocab changes and exposing weights (PR #143200)

2025-06-09 Thread S. VenkataKeerthy via llvm-branch-commits

https://github.com/svkeerthy updated 
https://github.com/llvm/llvm-project/pull/143200

>From 96e4a8b7faac3855a552ca52ff227bfc677cc6be Mon Sep 17 00:00:00 2001
From: svkeerthy 
Date: Fri, 6 Jun 2025 20:32:32 +
Subject: [PATCH] Vocab changes1

---
 llvm/include/llvm/Analysis/IR2Vec.h|  12 ++-
 llvm/lib/Analysis/IR2Vec.cpp   |  82 +--
 llvm/unittests/Analysis/IR2VecTest.cpp | 137 ++---
 3 files changed, 164 insertions(+), 67 deletions(-)

diff --git a/llvm/include/llvm/Analysis/IR2Vec.h 
b/llvm/include/llvm/Analysis/IR2Vec.h
index b12a4eeaec3e8..7976cc7470d5b 100644
--- a/llvm/include/llvm/Analysis/IR2Vec.h
+++ b/llvm/include/llvm/Analysis/IR2Vec.h
@@ -31,7 +31,9 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/JSON.h"
 #include 
 
 namespace llvm {
@@ -43,6 +45,7 @@ class Function;
 class Type;
 class Value;
 class raw_ostream;
+class LLVMContext;
 
 /// IR2Vec computes two kinds of embeddings: Symbolic and Flow-aware.
 /// Symbolic embeddings capture the "syntactic" and "statistical correlation"
@@ -53,7 +56,12 @@ class raw_ostream;
 enum class IR2VecKind { Symbolic };
 
 namespace ir2vec {
-/// Embedding is a datavtype that wraps std::vector. It provides
+
+LLVM_ABI extern cl::opt OpcWeight;
+LLVM_ABI extern cl::opt TypeWeight;
+LLVM_ABI extern cl::opt ArgWeight;
+
+/// Embedding is a datatype that wraps std::vector. It provides
 /// additional functionality for arithmetic and comparison operations.
 /// It is meant to be used *like* std::vector but is more restrictive
 /// in the sense that it does not allow the user to change the size of the
@@ -226,10 +234,12 @@ class IR2VecVocabResult {
 class IR2VecVocabAnalysis : public AnalysisInfoMixin {
   ir2vec::Vocab Vocabulary;
   Error readVocabulary();
+  void emitError(Error Err, LLVMContext &Ctx);
 
 public:
   static AnalysisKey Key;
   IR2VecVocabAnalysis() = default;
+  explicit IR2VecVocabAnalysis(ir2vec::Vocab &&Vocab);
   using Result = IR2VecVocabResult;
   Result run(Module &M, ModuleAnalysisManager &MAM);
 };
diff --git a/llvm/lib/Analysis/IR2Vec.cpp b/llvm/lib/Analysis/IR2Vec.cpp
index 25ce35d4ace37..2ad65c2f40c33 100644
--- a/llvm/lib/Analysis/IR2Vec.cpp
+++ b/llvm/lib/Analysis/IR2Vec.cpp
@@ -16,13 +16,11 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
-#include "llvm/Support/JSON.h"
 #include "llvm/Support/MemoryBuffer.h"
 
 using namespace llvm;
@@ -33,6 +31,8 @@ using namespace ir2vec;
 STATISTIC(VocabMissCounter,
   "Number of lookups to entites not present in the vocabulary");
 
+namespace llvm {
+namespace ir2vec {
 static cl::OptionCategory IR2VecCategory("IR2Vec Options");
 
 // FIXME: Use a default vocab when not specified
@@ -40,18 +40,20 @@ static cl::opt
 VocabFile("ir2vec-vocab-path", cl::Optional,
   cl::desc("Path to the vocabulary file for IR2Vec"), cl::init(""),
   cl::cat(IR2VecCategory));
-static cl::opt OpcWeight("ir2vec-opc-weight", cl::Optional,
-cl::init(1.0),
-cl::desc("Weight for opcode embeddings"),
-cl::cat(IR2VecCategory));
-static cl::opt TypeWeight("ir2vec-type-weight", cl::Optional,
- cl::init(0.5),
- cl::desc("Weight for type embeddings"),
- cl::cat(IR2VecCategory));
-static cl::opt ArgWeight("ir2vec-arg-weight", cl::Optional,
-cl::init(0.2),
-cl::desc("Weight for argument embeddings"),
-cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt OpcWeight("ir2vec-opc-weight", cl::Optional,
+  cl::init(1.0),
+  cl::desc("Weight for opcode embeddings"),
+  cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt TypeWeight("ir2vec-type-weight", cl::Optional,
+   cl::init(0.5),
+   cl::desc("Weight for type embeddings"),
+   cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt ArgWeight("ir2vec-arg-weight", cl::Optional,
+  cl::init(0.2),
+  cl::desc("Weight for argument embeddings"),
+  cl::cat(IR2VecCategory));
+} // namespace ir2vec
+} // namespace llvm
 
 AnalysisKey IR2VecVocabAnalysis::Key;
 
@@ -251,9 +253,9 @@ bool IR2VecVocabResult::invalidate(
 // by auto-generating a default vocabulary during the build time.
 Error IR

[llvm-branch-commits] [llvm] [IR2Vec] Minor vocab changes and exposing weights (PR #143200)

2025-06-09 Thread S. VenkataKeerthy via llvm-branch-commits

https://github.com/svkeerthy updated 
https://github.com/llvm/llvm-project/pull/143200

>From 96e4a8b7faac3855a552ca52ff227bfc677cc6be Mon Sep 17 00:00:00 2001
From: svkeerthy 
Date: Fri, 6 Jun 2025 20:32:32 +
Subject: [PATCH] Vocab changes1

---
 llvm/include/llvm/Analysis/IR2Vec.h|  12 ++-
 llvm/lib/Analysis/IR2Vec.cpp   |  82 +--
 llvm/unittests/Analysis/IR2VecTest.cpp | 137 ++---
 3 files changed, 164 insertions(+), 67 deletions(-)

diff --git a/llvm/include/llvm/Analysis/IR2Vec.h 
b/llvm/include/llvm/Analysis/IR2Vec.h
index b12a4eeaec3e8..7976cc7470d5b 100644
--- a/llvm/include/llvm/Analysis/IR2Vec.h
+++ b/llvm/include/llvm/Analysis/IR2Vec.h
@@ -31,7 +31,9 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/JSON.h"
 #include 
 
 namespace llvm {
@@ -43,6 +45,7 @@ class Function;
 class Type;
 class Value;
 class raw_ostream;
+class LLVMContext;
 
 /// IR2Vec computes two kinds of embeddings: Symbolic and Flow-aware.
 /// Symbolic embeddings capture the "syntactic" and "statistical correlation"
@@ -53,7 +56,12 @@ class raw_ostream;
 enum class IR2VecKind { Symbolic };
 
 namespace ir2vec {
-/// Embedding is a datavtype that wraps std::vector. It provides
+
+LLVM_ABI extern cl::opt OpcWeight;
+LLVM_ABI extern cl::opt TypeWeight;
+LLVM_ABI extern cl::opt ArgWeight;
+
+/// Embedding is a datatype that wraps std::vector. It provides
 /// additional functionality for arithmetic and comparison operations.
 /// It is meant to be used *like* std::vector but is more restrictive
 /// in the sense that it does not allow the user to change the size of the
@@ -226,10 +234,12 @@ class IR2VecVocabResult {
 class IR2VecVocabAnalysis : public AnalysisInfoMixin {
   ir2vec::Vocab Vocabulary;
   Error readVocabulary();
+  void emitError(Error Err, LLVMContext &Ctx);
 
 public:
   static AnalysisKey Key;
   IR2VecVocabAnalysis() = default;
+  explicit IR2VecVocabAnalysis(ir2vec::Vocab &&Vocab);
   using Result = IR2VecVocabResult;
   Result run(Module &M, ModuleAnalysisManager &MAM);
 };
diff --git a/llvm/lib/Analysis/IR2Vec.cpp b/llvm/lib/Analysis/IR2Vec.cpp
index 25ce35d4ace37..2ad65c2f40c33 100644
--- a/llvm/lib/Analysis/IR2Vec.cpp
+++ b/llvm/lib/Analysis/IR2Vec.cpp
@@ -16,13 +16,11 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
-#include "llvm/Support/JSON.h"
 #include "llvm/Support/MemoryBuffer.h"
 
 using namespace llvm;
@@ -33,6 +31,8 @@ using namespace ir2vec;
 STATISTIC(VocabMissCounter,
   "Number of lookups to entites not present in the vocabulary");
 
+namespace llvm {
+namespace ir2vec {
 static cl::OptionCategory IR2VecCategory("IR2Vec Options");
 
 // FIXME: Use a default vocab when not specified
@@ -40,18 +40,20 @@ static cl::opt
 VocabFile("ir2vec-vocab-path", cl::Optional,
   cl::desc("Path to the vocabulary file for IR2Vec"), cl::init(""),
   cl::cat(IR2VecCategory));
-static cl::opt OpcWeight("ir2vec-opc-weight", cl::Optional,
-cl::init(1.0),
-cl::desc("Weight for opcode embeddings"),
-cl::cat(IR2VecCategory));
-static cl::opt TypeWeight("ir2vec-type-weight", cl::Optional,
- cl::init(0.5),
- cl::desc("Weight for type embeddings"),
- cl::cat(IR2VecCategory));
-static cl::opt ArgWeight("ir2vec-arg-weight", cl::Optional,
-cl::init(0.2),
-cl::desc("Weight for argument embeddings"),
-cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt OpcWeight("ir2vec-opc-weight", cl::Optional,
+  cl::init(1.0),
+  cl::desc("Weight for opcode embeddings"),
+  cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt TypeWeight("ir2vec-type-weight", cl::Optional,
+   cl::init(0.5),
+   cl::desc("Weight for type embeddings"),
+   cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt ArgWeight("ir2vec-arg-weight", cl::Optional,
+  cl::init(0.2),
+  cl::desc("Weight for argument embeddings"),
+  cl::cat(IR2VecCategory));
+} // namespace ir2vec
+} // namespace llvm
 
 AnalysisKey IR2VecVocabAnalysis::Key;
 
@@ -251,9 +253,9 @@ bool IR2VecVocabResult::invalidate(
 // by auto-generating a default vocabulary during the build time.
 Error IR

[llvm-branch-commits] [clang-tools-extra] [clang-doc] add namespaces to JSON generator (PR #143209)

2025-06-09 Thread Paul Kirth via llvm-branch-commits

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

LGTM. This seems like its in order, assuming CI is happy.

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


[llvm-branch-commits] [llvm] [RISCV] Support memcmp expansion for vectors (PR #114517)

2025-06-09 Thread Pengcheng Wang via llvm-branch-commits


@@ -2512,9 +2512,11 @@ bool RISCVTTIImpl::isProfitableToSinkOperands(
 RISCVTTIImpl::TTI::MemCmpExpansionOptions
 RISCVTTIImpl::enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const {
   TTI::MemCmpExpansionOptions Options;
+  // Here we assume that a core that has implemented unaligned vector access
+  // should also have implemented unaligned scalar access.

wangpc-pp wrote:

Hmmm, you are right that we only generate vle8.v here. I will change that.

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


[llvm-branch-commits] [llvm] [IR2Vec] Minor vocab changes and exposing weights (PR #143200)

2025-06-09 Thread Aiden Grossman via llvm-branch-commits


@@ -53,7 +56,12 @@ class raw_ostream;
 enum class IR2VecKind { Symbolic };
 
 namespace ir2vec {
-/// Embedding is a datavtype that wraps std::vector. It provides
+
+LLVM_ABI extern cl::opt OpcWeight;

boomanaiden154 wrote:

Why do these need an `LLVM_ABI` tag?

If this is actually needed, this seems like something that should be split out 
of this patch.

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


[llvm-branch-commits] [llvm] [IR2Vec] Consider only reachable BBs and non-debug instructions (PR #143476)

2025-06-09 Thread S. VenkataKeerthy via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [CI] Migrate to runtimes build (PR #142696)

2025-06-09 Thread Aiden Grossman via llvm-branch-commits

https://github.com/boomanaiden154 updated 
https://github.com/llvm/llvm-project/pull/142696

>From 360e723b51ee201603f72b56859cd7c6d6faec24 Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Thu, 5 Jun 2025 06:51:37 +
Subject: [PATCH 1/2] feedback

Created using spr 1.3.4
---
 .ci/compute_projects.py | 17 +
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/.ci/compute_projects.py b/.ci/compute_projects.py
index b12b729eadd3f..8134e1e2c29fb 100644
--- a/.ci/compute_projects.py
+++ b/.ci/compute_projects.py
@@ -145,22 +145,15 @@ def _add_dependencies(projects: Set[str], runtimes: 
Set[str]) -> Set[str]:
 
 
 def _exclude_projects(current_projects: Set[str], platform: str) -> Set[str]:
-new_project_set = set(current_projects)
 if platform == "Linux":
-for to_exclude in EXCLUDE_LINUX:
-if to_exclude in new_project_set:
-new_project_set.remove(to_exclude)
+to_exclude = EXCLUDE_LINUX
 elif platform == "Windows":
-for to_exclude in EXCLUDE_WINDOWS:
-if to_exclude in new_project_set:
-new_project_set.remove(to_exclude)
+to_exclude = EXCLUDE_WINDOWS
 elif platform == "Darwin":
-for to_exclude in EXCLUDE_MAC:
-if to_exclude in new_project_set:
-new_project_set.remove(to_exclude)
+to_exclude = EXCLUDE_MAC
 else:
-raise ValueError("Unexpected platform.")
-return new_project_set
+raise ValueError(f"Unexpected platform: {platform}")
+return current_projects.difference(to_exclude)
 
 
 def _compute_projects_to_test(modified_projects: Set[str], platform: str) -> 
Set[str]:

>From 26a48b3ba70c829862788335f4b5b610dfd5dd3a Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Thu, 5 Jun 2025 08:55:00 +
Subject: [PATCH 2/2] feedback

Created using spr 1.3.4
---
 .ci/compute_projects.py | 20 ++--
 .ci/compute_projects_test.py| 32 
 .ci/monolithic-linux.sh |  8 
 .github/workflows/premerge.yaml |  4 ++--
 4 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/.ci/compute_projects.py b/.ci/compute_projects.py
index 8134e1e2c29fb..50a64cb15a937 100644
--- a/.ci/compute_projects.py
+++ b/.ci/compute_projects.py
@@ -66,7 +66,7 @@
 DEPENDENT_RUNTIMES_TO_TEST = {
 "clang": {"compiler-rt"},
 }
-DEPENDENT_RUNTIMES_TO_TEST_MULTICONFIG = {
+DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG = {
 "llvm": {"libcxx", "libcxxabi", "libunwind"},
 "clang": {"libcxx", "libcxxabi", "libunwind"},
 ".ci": {"libcxx", "libcxxabi", "libunwind"},
@@ -201,15 +201,15 @@ def _compute_runtimes_to_test(modified_projects: 
Set[str], platform: str) -> Set
 return _exclude_projects(runtimes_to_test, platform)
 
 
-def _compute_runtimes_to_test_multiconfig(
+def _compute_runtimes_to_test_needs_reconfig(
 modified_projects: Set[str], platform: str
 ) -> Set[str]:
 runtimes_to_test = set()
 for modified_project in modified_projects:
-if modified_project not in DEPENDENT_RUNTIMES_TO_TEST_MULTICONFIG:
+if modified_project not in DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG:
 continue
 runtimes_to_test.update(
-DEPENDENT_RUNTIMES_TO_TEST_MULTICONFIG[modified_project]
+DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG[modified_project]
 )
 return _exclude_projects(runtimes_to_test, platform)
 
@@ -246,17 +246,17 @@ def get_env_variables(modified_files: list[str], 
platform: str) -> Set[str]:
 modified_projects = _get_modified_projects(modified_files)
 projects_to_test = _compute_projects_to_test(modified_projects, platform)
 runtimes_to_test = _compute_runtimes_to_test(modified_projects, platform)
-runtimes_to_test_multiconfig = _compute_runtimes_to_test_multiconfig(
+runtimes_to_test_needs_reconfig = _compute_runtimes_to_test_needs_reconfig(
 modified_projects, platform
 )
 runtimes_to_build = _compute_runtimes_to_build(
-runtimes_to_test | runtimes_to_test_multiconfig, modified_projects, 
platform
+runtimes_to_test | runtimes_to_test_needs_reconfig, modified_projects, 
platform
 )
 projects_to_build = _compute_projects_to_build(projects_to_test, 
runtimes_to_build)
 projects_check_targets = _compute_project_check_targets(projects_to_test)
 runtimes_check_targets = _compute_project_check_targets(runtimes_to_test)
-runtimes_check_targets_multiconfig = _compute_project_check_targets(
-runtimes_to_test_multiconfig
+runtimes_check_targets_needs_reconfig = _compute_project_check_targets(
+runtimes_to_test_needs_reconfig
 )
 # We use a semicolon to separate the projects/runtimes as they get passed
 # to the CMake invocation and thus we need to use the CMake list separator
@@ -267,8 +267,8 @@ def get_env_variables(modified_files: list[str], platform: 
str) -> Set[str]:
 "project_chec

[llvm-branch-commits] [llvm] [CI] Migrate to runtimes build (PR #142696)

2025-06-09 Thread Aiden Grossman via llvm-branch-commits

https://github.com/boomanaiden154 updated 
https://github.com/llvm/llvm-project/pull/142696

>From 360e723b51ee201603f72b56859cd7c6d6faec24 Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Thu, 5 Jun 2025 06:51:37 +
Subject: [PATCH 1/2] feedback

Created using spr 1.3.4
---
 .ci/compute_projects.py | 17 +
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/.ci/compute_projects.py b/.ci/compute_projects.py
index b12b729eadd3f..8134e1e2c29fb 100644
--- a/.ci/compute_projects.py
+++ b/.ci/compute_projects.py
@@ -145,22 +145,15 @@ def _add_dependencies(projects: Set[str], runtimes: 
Set[str]) -> Set[str]:
 
 
 def _exclude_projects(current_projects: Set[str], platform: str) -> Set[str]:
-new_project_set = set(current_projects)
 if platform == "Linux":
-for to_exclude in EXCLUDE_LINUX:
-if to_exclude in new_project_set:
-new_project_set.remove(to_exclude)
+to_exclude = EXCLUDE_LINUX
 elif platform == "Windows":
-for to_exclude in EXCLUDE_WINDOWS:
-if to_exclude in new_project_set:
-new_project_set.remove(to_exclude)
+to_exclude = EXCLUDE_WINDOWS
 elif platform == "Darwin":
-for to_exclude in EXCLUDE_MAC:
-if to_exclude in new_project_set:
-new_project_set.remove(to_exclude)
+to_exclude = EXCLUDE_MAC
 else:
-raise ValueError("Unexpected platform.")
-return new_project_set
+raise ValueError(f"Unexpected platform: {platform}")
+return current_projects.difference(to_exclude)
 
 
 def _compute_projects_to_test(modified_projects: Set[str], platform: str) -> 
Set[str]:

>From 26a48b3ba70c829862788335f4b5b610dfd5dd3a Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Thu, 5 Jun 2025 08:55:00 +
Subject: [PATCH 2/2] feedback

Created using spr 1.3.4
---
 .ci/compute_projects.py | 20 ++--
 .ci/compute_projects_test.py| 32 
 .ci/monolithic-linux.sh |  8 
 .github/workflows/premerge.yaml |  4 ++--
 4 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/.ci/compute_projects.py b/.ci/compute_projects.py
index 8134e1e2c29fb..50a64cb15a937 100644
--- a/.ci/compute_projects.py
+++ b/.ci/compute_projects.py
@@ -66,7 +66,7 @@
 DEPENDENT_RUNTIMES_TO_TEST = {
 "clang": {"compiler-rt"},
 }
-DEPENDENT_RUNTIMES_TO_TEST_MULTICONFIG = {
+DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG = {
 "llvm": {"libcxx", "libcxxabi", "libunwind"},
 "clang": {"libcxx", "libcxxabi", "libunwind"},
 ".ci": {"libcxx", "libcxxabi", "libunwind"},
@@ -201,15 +201,15 @@ def _compute_runtimes_to_test(modified_projects: 
Set[str], platform: str) -> Set
 return _exclude_projects(runtimes_to_test, platform)
 
 
-def _compute_runtimes_to_test_multiconfig(
+def _compute_runtimes_to_test_needs_reconfig(
 modified_projects: Set[str], platform: str
 ) -> Set[str]:
 runtimes_to_test = set()
 for modified_project in modified_projects:
-if modified_project not in DEPENDENT_RUNTIMES_TO_TEST_MULTICONFIG:
+if modified_project not in DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG:
 continue
 runtimes_to_test.update(
-DEPENDENT_RUNTIMES_TO_TEST_MULTICONFIG[modified_project]
+DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG[modified_project]
 )
 return _exclude_projects(runtimes_to_test, platform)
 
@@ -246,17 +246,17 @@ def get_env_variables(modified_files: list[str], 
platform: str) -> Set[str]:
 modified_projects = _get_modified_projects(modified_files)
 projects_to_test = _compute_projects_to_test(modified_projects, platform)
 runtimes_to_test = _compute_runtimes_to_test(modified_projects, platform)
-runtimes_to_test_multiconfig = _compute_runtimes_to_test_multiconfig(
+runtimes_to_test_needs_reconfig = _compute_runtimes_to_test_needs_reconfig(
 modified_projects, platform
 )
 runtimes_to_build = _compute_runtimes_to_build(
-runtimes_to_test | runtimes_to_test_multiconfig, modified_projects, 
platform
+runtimes_to_test | runtimes_to_test_needs_reconfig, modified_projects, 
platform
 )
 projects_to_build = _compute_projects_to_build(projects_to_test, 
runtimes_to_build)
 projects_check_targets = _compute_project_check_targets(projects_to_test)
 runtimes_check_targets = _compute_project_check_targets(runtimes_to_test)
-runtimes_check_targets_multiconfig = _compute_project_check_targets(
-runtimes_to_test_multiconfig
+runtimes_check_targets_needs_reconfig = _compute_project_check_targets(
+runtimes_to_test_needs_reconfig
 )
 # We use a semicolon to separate the projects/runtimes as they get passed
 # to the CMake invocation and thus we need to use the CMake list separator
@@ -267,8 +267,8 @@ def get_env_variables(modified_files: list[str], platform: 
str) -> Set[str]:
 "project_chec

[llvm-branch-commits] [llvm] AMDGPU: Try constant fold after folding immediate (PR #141862)

2025-06-09 Thread Shilei Tian via llvm-branch-commits

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


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


[llvm-branch-commits] [llvm] DAG: Move soft float predicate management into RuntimeLibcalls (PR #142905)

2025-06-09 Thread Matt Arsenault via llvm-branch-commits


@@ -11,12 +11,48 @@
 using namespace llvm;
 using namespace RTLIB;
 
+void RuntimeLibcallsInfo::initSoftFloatCmpLibcallPredicates() {
+  std::fill(SoftFloatCompareLibcallPredicates,

arsenm wrote:

Actually we can drop this initialization altogether, I did that in one of the 
parallel patches 

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


[llvm-branch-commits] [GISelValueTracking] Use representation size for G_PTRTOINT src width (PR #139608)

2025-06-09 Thread Alexander Richardson via llvm-branch-commits

arichardson wrote:

Looks like this was fixed while I was busy with other things - 
https://github.com/llvm/llvm-project/pull/140213 changed this code to drop the 
invalid width usage. I'll update this PR to just add a test for the ptrtoint 
case.

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


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

2025-06-09 Thread Alexander Richardson via llvm-branch-commits


@@ -0,0 +1,14 @@
+; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s

arichardson wrote:

I see 79 tests that use this, but can drop if you think it makes sense.

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


[llvm-branch-commits] [GISelValueTracking] Add test case for G_PTRTOINT (PR #139608)

2025-06-09 Thread Alexander Richardson via llvm-branch-commits

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


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [GISelValueTracking] Add test case for G_PTRTOINT (PR #139608)

2025-06-09 Thread Alexander Richardson via llvm-branch-commits

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


[llvm-branch-commits] [GISelValueTracking] Add test case for G_PTRTOINT (PR #139608)

2025-06-09 Thread Alexander Richardson via llvm-branch-commits

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


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


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

2025-06-09 Thread Alexander Richardson via llvm-branch-commits

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

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

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

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

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


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

2025-06-09 Thread Alexander Richardson via llvm-branch-commits

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

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

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

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

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


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

2025-06-09 Thread Alexander Richardson via llvm-branch-commits

arichardson wrote:

Sorry for the delay here. Updated and hopefully addressed outstanding feedback

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


[llvm-branch-commits] [clang-tools-extra] [clang-doc] add namespaces to JSON generator (PR #143209)

2025-06-09 Thread Erick Velez via llvm-branch-commits

https://github.com/evelez7 updated 
https://github.com/llvm/llvm-project/pull/143209

>From dd5653605e838e7df8ade308f0cfff1d0113790a Mon Sep 17 00:00:00 2001
From: Erick Velez 
Date: Tue, 3 Jun 2025 11:39:48 -0700
Subject: [PATCH] [clang-doc] add namespaces to JSON generator

---
 clang-tools-extra/clang-doc/JSONGenerator.cpp |  34 ++
 clang-tools-extra/clang-doc/Serialize.cpp |   1 +
 .../clang-doc/json/function-specifiers.cpp|  25 
 .../test/clang-doc/json/namespace.cpp | 107 ++
 .../unittests/clang-doc/JSONGeneratorTest.cpp |  72 
 5 files changed, 239 insertions(+)
 create mode 100644 
clang-tools-extra/test/clang-doc/json/function-specifiers.cpp
 create mode 100644 clang-tools-extra/test/clang-doc/json/namespace.cpp

diff --git a/clang-tools-extra/clang-doc/JSONGenerator.cpp 
b/clang-tools-extra/clang-doc/JSONGenerator.cpp
index 086da09165329..0f7cbafcf5135 100644
--- a/clang-tools-extra/clang-doc/JSONGenerator.cpp
+++ b/clang-tools-extra/clang-doc/JSONGenerator.cpp
@@ -440,6 +440,39 @@ static void serializeInfo(const RecordInfo &I, 
json::Object &Obj,
   serializeCommonChildren(I.Children, Obj, RepositoryUrl);
 }
 
+static void serializeInfo(const NamespaceInfo &I, json::Object &Obj,
+  std::optional RepositoryUrl) {
+  serializeCommonAttributes(I, Obj, RepositoryUrl);
+
+  if (!I.Children.Namespaces.empty()) {
+json::Value NamespacesArray = Array();
+auto &NamespacesArrayRef = *NamespacesArray.getAsArray();
+NamespacesArrayRef.reserve(I.Children.Namespaces.size());
+for (auto &Namespace : I.Children.Namespaces) {
+  json::Value NamespaceVal = Object();
+  auto &NamespaceObj = *NamespaceVal.getAsObject();
+  serializeReference(Namespace, NamespaceObj);
+  NamespacesArrayRef.push_back(NamespaceVal);
+}
+Obj["Namespaces"] = NamespacesArray;
+  }
+
+  if (!I.Children.Functions.empty()) {
+json::Value FunctionsArray = Array();
+auto &FunctionsArrayRef = *FunctionsArray.getAsArray();
+FunctionsArrayRef.reserve(I.Children.Functions.size());
+for (const auto &Function : I.Children.Functions) {
+  json::Value FunctionVal = Object();
+  auto &FunctionObj = *FunctionVal.getAsObject();
+  serializeInfo(Function, FunctionObj, RepositoryUrl);
+  FunctionsArrayRef.push_back(FunctionVal);
+}
+Obj["Functions"] = FunctionsArray;
+  }
+
+  serializeCommonChildren(I.Children, Obj, RepositoryUrl);
+}
+
 Error JSONGenerator::generateDocs(
 StringRef RootDir, llvm::StringMap> Infos,
 const ClangDocContext &CDCtx) {
@@ -482,6 +515,7 @@ Error JSONGenerator::generateDocForInfo(Info *I, 
raw_ostream &OS,
 
   switch (I->IT) {
   case InfoType::IT_namespace:
+serializeInfo(*static_cast(I), Obj, CDCtx.RepositoryUrl);
 break;
   case InfoType::IT_record:
 serializeInfo(*static_cast(I), Obj, CDCtx.RepositoryUrl);
diff --git a/clang-tools-extra/clang-doc/Serialize.cpp 
b/clang-tools-extra/clang-doc/Serialize.cpp
index 462001b3f3027..3cda38115ff7f 100644
--- a/clang-tools-extra/clang-doc/Serialize.cpp
+++ b/clang-tools-extra/clang-doc/Serialize.cpp
@@ -742,6 +742,7 @@ static void populateFunctionInfo(FunctionInfo &I, const 
FunctionDecl *D,
   I.ReturnType = getTypeInfoForType(D->getReturnType(), LO);
   I.Prototype = getFunctionPrototype(D);
   parseParameters(I, D);
+  I.IsStatic = D->isStatic();
 
   populateTemplateParameters(I.Template, D);
 
diff --git a/clang-tools-extra/test/clang-doc/json/function-specifiers.cpp 
b/clang-tools-extra/test/clang-doc/json/function-specifiers.cpp
new file mode 100644
index 0..7005fb7b3e66e
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/json/function-specifiers.cpp
@@ -0,0 +1,25 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --output=%t --format=json --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/index.json
+
+static void myFunction() {}
+
+void noExceptFunction() noexcept {}
+
+inline void inlineFunction() {}
+
+extern void externFunction() {}
+
+constexpr void constexprFunction() {}
+
+// CHECK:  "Functions": [
+// CHECK-NEXT:   {
+// CHECK:  "IsStatic": true,
+// COM:FIXME: Emit ExceptionSpecificationType
+// CHECK-NOT:  "ExceptionSpecifcation" : "noexcept",
+// COM:FIXME: Emit inline
+// CHECK-NOT:  "IsInline": true,
+// COM:FIXME: Emit extern
+// CHECK-NOT:  "IsExtern": true,
+// COM:FIXME: Emit constexpr
+// CHECK-NOT:  "IsConstexpr": true,
diff --git a/clang-tools-extra/test/clang-doc/json/namespace.cpp 
b/clang-tools-extra/test/clang-doc/json/namespace.cpp
new file mode 100644
index 0..928864be1feb0
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/json/namespace.cpp
@@ -0,0 +1,107 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --output=%t --format=json --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/inde

[llvm-branch-commits] [clang-tools-extra] [clang-doc] add namespaces to JSON generator (PR #143209)

2025-06-09 Thread Erick Velez via llvm-branch-commits

https://github.com/evelez7 updated 
https://github.com/llvm/llvm-project/pull/143209

>From dd5653605e838e7df8ade308f0cfff1d0113790a Mon Sep 17 00:00:00 2001
From: Erick Velez 
Date: Tue, 3 Jun 2025 11:39:48 -0700
Subject: [PATCH] [clang-doc] add namespaces to JSON generator

---
 clang-tools-extra/clang-doc/JSONGenerator.cpp |  34 ++
 clang-tools-extra/clang-doc/Serialize.cpp |   1 +
 .../clang-doc/json/function-specifiers.cpp|  25 
 .../test/clang-doc/json/namespace.cpp | 107 ++
 .../unittests/clang-doc/JSONGeneratorTest.cpp |  72 
 5 files changed, 239 insertions(+)
 create mode 100644 
clang-tools-extra/test/clang-doc/json/function-specifiers.cpp
 create mode 100644 clang-tools-extra/test/clang-doc/json/namespace.cpp

diff --git a/clang-tools-extra/clang-doc/JSONGenerator.cpp 
b/clang-tools-extra/clang-doc/JSONGenerator.cpp
index 086da09165329..0f7cbafcf5135 100644
--- a/clang-tools-extra/clang-doc/JSONGenerator.cpp
+++ b/clang-tools-extra/clang-doc/JSONGenerator.cpp
@@ -440,6 +440,39 @@ static void serializeInfo(const RecordInfo &I, 
json::Object &Obj,
   serializeCommonChildren(I.Children, Obj, RepositoryUrl);
 }
 
+static void serializeInfo(const NamespaceInfo &I, json::Object &Obj,
+  std::optional RepositoryUrl) {
+  serializeCommonAttributes(I, Obj, RepositoryUrl);
+
+  if (!I.Children.Namespaces.empty()) {
+json::Value NamespacesArray = Array();
+auto &NamespacesArrayRef = *NamespacesArray.getAsArray();
+NamespacesArrayRef.reserve(I.Children.Namespaces.size());
+for (auto &Namespace : I.Children.Namespaces) {
+  json::Value NamespaceVal = Object();
+  auto &NamespaceObj = *NamespaceVal.getAsObject();
+  serializeReference(Namespace, NamespaceObj);
+  NamespacesArrayRef.push_back(NamespaceVal);
+}
+Obj["Namespaces"] = NamespacesArray;
+  }
+
+  if (!I.Children.Functions.empty()) {
+json::Value FunctionsArray = Array();
+auto &FunctionsArrayRef = *FunctionsArray.getAsArray();
+FunctionsArrayRef.reserve(I.Children.Functions.size());
+for (const auto &Function : I.Children.Functions) {
+  json::Value FunctionVal = Object();
+  auto &FunctionObj = *FunctionVal.getAsObject();
+  serializeInfo(Function, FunctionObj, RepositoryUrl);
+  FunctionsArrayRef.push_back(FunctionVal);
+}
+Obj["Functions"] = FunctionsArray;
+  }
+
+  serializeCommonChildren(I.Children, Obj, RepositoryUrl);
+}
+
 Error JSONGenerator::generateDocs(
 StringRef RootDir, llvm::StringMap> Infos,
 const ClangDocContext &CDCtx) {
@@ -482,6 +515,7 @@ Error JSONGenerator::generateDocForInfo(Info *I, 
raw_ostream &OS,
 
   switch (I->IT) {
   case InfoType::IT_namespace:
+serializeInfo(*static_cast(I), Obj, CDCtx.RepositoryUrl);
 break;
   case InfoType::IT_record:
 serializeInfo(*static_cast(I), Obj, CDCtx.RepositoryUrl);
diff --git a/clang-tools-extra/clang-doc/Serialize.cpp 
b/clang-tools-extra/clang-doc/Serialize.cpp
index 462001b3f3027..3cda38115ff7f 100644
--- a/clang-tools-extra/clang-doc/Serialize.cpp
+++ b/clang-tools-extra/clang-doc/Serialize.cpp
@@ -742,6 +742,7 @@ static void populateFunctionInfo(FunctionInfo &I, const 
FunctionDecl *D,
   I.ReturnType = getTypeInfoForType(D->getReturnType(), LO);
   I.Prototype = getFunctionPrototype(D);
   parseParameters(I, D);
+  I.IsStatic = D->isStatic();
 
   populateTemplateParameters(I.Template, D);
 
diff --git a/clang-tools-extra/test/clang-doc/json/function-specifiers.cpp 
b/clang-tools-extra/test/clang-doc/json/function-specifiers.cpp
new file mode 100644
index 0..7005fb7b3e66e
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/json/function-specifiers.cpp
@@ -0,0 +1,25 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --output=%t --format=json --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/index.json
+
+static void myFunction() {}
+
+void noExceptFunction() noexcept {}
+
+inline void inlineFunction() {}
+
+extern void externFunction() {}
+
+constexpr void constexprFunction() {}
+
+// CHECK:  "Functions": [
+// CHECK-NEXT:   {
+// CHECK:  "IsStatic": true,
+// COM:FIXME: Emit ExceptionSpecificationType
+// CHECK-NOT:  "ExceptionSpecifcation" : "noexcept",
+// COM:FIXME: Emit inline
+// CHECK-NOT:  "IsInline": true,
+// COM:FIXME: Emit extern
+// CHECK-NOT:  "IsExtern": true,
+// COM:FIXME: Emit constexpr
+// CHECK-NOT:  "IsConstexpr": true,
diff --git a/clang-tools-extra/test/clang-doc/json/namespace.cpp 
b/clang-tools-extra/test/clang-doc/json/namespace.cpp
new file mode 100644
index 0..928864be1feb0
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/json/namespace.cpp
@@ -0,0 +1,107 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --output=%t --format=json --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/inde

[llvm-branch-commits] [MSAN] handle AVX vpermi2var (PR #143463)

2025-06-09 Thread Florian Mayer via llvm-branch-commits

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

None


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [MSAN] handle AVX vpermi2var (PR #143463)

2025-06-09 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Florian Mayer (fmayer)


Changes



---

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


3 Files Affected:

- (modified) llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp (+39) 
- (modified) 
llvm/test/Instrumentation/MemorySanitizer/X86/avx512-intrinsics-upgrade.ll 
(+148-112) 
- (modified) llvm/test/Instrumentation/MemorySanitizer/X86/avx512-intrinsics.ll 
(+147-111) 


``diff
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp 
b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index 4d8dda7098aea..e05ea8b759e0b 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -4175,6 +4175,25 @@ struct MemorySanitizerVisitor : public 
InstVisitor {
 setShadow(&I, IRB.CreateBitCast(CI, getShadowTy(&I)));
 setOriginForNaryOp(I);
   }
+  // Instrument AVX permutation intrinsic.
+  // We apply the same permutation (argument index 1) to the shadows.
+  void handleAVXVpermil2var(IntrinsicInst &I) {
+IRBuilder<> IRB(&I);
+Value *AShadow = getShadow(&I, 0);
+Value *Idx = I.getArgOperand(1);
+Value *BShadow = getShadow(&I, 2);
+insertShadowCheck(Idx, &I);
+
+// Shadows are integer-ish types but some intrinsics require a
+// different (e.g., floating-point) type.
+AShadow = IRB.CreateBitCast(AShadow, I.getArgOperand(0)->getType());
+BShadow = IRB.CreateBitCast(BShadow, I.getArgOperand(2)->getType());
+CallInst *CI = IRB.CreateIntrinsic(I.getType(), I.getIntrinsicID(),
+   {AShadow, Idx, BShadow});
+
+setShadow(&I, IRB.CreateBitCast(CI, getShadowTy(&I)));
+setOriginForNaryOp(I);
+  }
 
   // Instrument BMI / BMI2 intrinsics.
   // All of these intrinsics are Z = I(X, Y)
@@ -5130,6 +5149,26 @@ struct MemorySanitizerVisitor : public 
InstVisitor {
   handleAVXVpermilvar(I);
   break;
 }
+case Intrinsic::x86_avx512_vpermi2var_d_128:
+case Intrinsic::x86_avx512_vpermi2var_d_256:
+case Intrinsic::x86_avx512_vpermi2var_d_512:
+case Intrinsic::x86_avx512_vpermi2var_hi_128:
+case Intrinsic::x86_avx512_vpermi2var_hi_256:
+case Intrinsic::x86_avx512_vpermi2var_hi_512:
+case Intrinsic::x86_avx512_vpermi2var_pd_128:
+case Intrinsic::x86_avx512_vpermi2var_pd_256:
+case Intrinsic::x86_avx512_vpermi2var_pd_512:
+case Intrinsic::x86_avx512_vpermi2var_ps_128:
+case Intrinsic::x86_avx512_vpermi2var_ps_256:
+case Intrinsic::x86_avx512_vpermi2var_ps_512:
+case Intrinsic::x86_avx512_vpermi2var_q_128:
+case Intrinsic::x86_avx512_vpermi2var_q_256:
+case Intrinsic::x86_avx512_vpermi2var_q_512:
+case Intrinsic::x86_avx512_vpermi2var_qi_128:
+case Intrinsic::x86_avx512_vpermi2var_qi_256:
+case Intrinsic::x86_avx512_vpermi2var_qi_512:
+  handleAVXVpermil2var(I);
+  break;
 
 case Intrinsic::x86_avx512fp16_mask_add_sh_round:
 case Intrinsic::x86_avx512fp16_mask_sub_sh_round:
diff --git 
a/llvm/test/Instrumentation/MemorySanitizer/X86/avx512-intrinsics-upgrade.ll 
b/llvm/test/Instrumentation/MemorySanitizer/X86/avx512-intrinsics-upgrade.ll
index 5aeaa1221cd21..96f82c4d49a0a 100644
--- a/llvm/test/Instrumentation/MemorySanitizer/X86/avx512-intrinsics-upgrade.ll
+++ b/llvm/test/Instrumentation/MemorySanitizer/X86/avx512-intrinsics-upgrade.ll
@@ -13700,8 +13700,8 @@ define <16 x 
i32>@test_int_x86_avx512_vpermi2var_d_512(<16 x i32> %x0, <16 x i32
 ; CHECK-LABEL: @test_int_x86_avx512_vpermi2var_d_512(
 ; CHECK-NEXT:[[TMP1:%.*]] = load i64, ptr inttoptr (i64 add (i64 ptrtoint 
(ptr @__msan_param_tls to i64), i64 128) to ptr), align 8
 ; CHECK-NEXT:[[TMP2:%.*]] = load <16 x i32>, ptr @__msan_param_tls, align 8
-; CHECK-NEXT:[[TMP3:%.*]] = load <16 x i32>, ptr inttoptr (i64 add (i64 
ptrtoint (ptr @__msan_param_tls to i64), i64 64) to ptr), align 8
 ; CHECK-NEXT:[[TMP4:%.*]] = load <16 x i32>, ptr inttoptr (i64 add (i64 
ptrtoint (ptr @__msan_param_tls to i64), i64 136) to ptr), align 8
+; CHECK-NEXT:[[TMP14:%.*]] = load <16 x i32>, ptr inttoptr (i64 add (i64 
ptrtoint (ptr @__msan_param_tls to i64), i64 64) to ptr), align 8
 ; CHECK-NEXT:call void @llvm.donothing()
 ; CHECK-NEXT:[[_MSCMP:%.*]] = icmp ne i64 [[TMP1]], 0
 ; CHECK-NEXT:br i1 [[_MSCMP]], label [[TMP5:%.*]], label [[TMP6:%.*]], 
!prof [[PROF1]]
@@ -13714,9 +13714,15 @@ define <16 x 
i32>@test_int_x86_avx512_vpermi2var_d_512(<16 x i32> %x0, <16 x i32
 ; CHECK-NEXT:[[TMP8:%.*]] = xor i64 [[TMP7]], 87960930222080
 ; CHECK-NEXT:[[TMP9:%.*]] = inttoptr i64 [[TMP8]] to ptr
 ; CHECK-NEXT:[[_MSLD:%.*]] = load <16 x i32>, ptr [[TMP9]], align 64
-; CHECK-NEXT:[[_MSPROP:%.*]] = or <16 x i32> [[TMP2]], [[TMP3]]
-; CHECK-NEXT:[[_MSPROP1:%.*]] = or <16 x i32> [[_MSPROP]], [[TMP4]]
-; CHECK-NEXT:[[TMP10:%.*]] =

[llvm-branch-commits] [MSAN] handle assorted AVX permutations (PR #143462)

2025-06-09 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Florian Mayer (fmayer)


Changes



---

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


5 Files Affected:

- (modified) llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp (+19-3) 
- (modified) 
llvm/test/Instrumentation/MemorySanitizer/X86/avx2-intrinsics-x86.ll (+26-12) 
- (modified) 
llvm/test/Instrumentation/MemorySanitizer/X86/avx512-intrinsics-upgrade.ll 
(+106-64) 
- (modified) llvm/test/Instrumentation/MemorySanitizer/X86/avx512-intrinsics.ll 
(+106-64) 
- (modified) 
llvm/test/Instrumentation/MemorySanitizer/i386/avx2-intrinsics-i386.ll (+26-12) 


``diff
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp 
b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index e05ea8b759e0b..3f78416e5655a 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -4161,7 +4161,7 @@ struct MemorySanitizerVisitor : public 
InstVisitor {
 
   // Instrument AVX permutation intrinsic.
   // We apply the same permutation (argument index 1) to the shadow.
-  void handleAVXVpermilvar(IntrinsicInst &I) {
+  void handleAVXPermutation(IntrinsicInst &I) {
 IRBuilder<> IRB(&I);
 Value *Shadow = getShadow(&I, 0);
 insertShadowCheck(I.getArgOperand(1), &I);
@@ -5139,14 +5139,30 @@ struct MemorySanitizerVisitor : public 
InstVisitor {
   assert(Success);
   break;
 }
-
+case Intrinsic::x86_avx2_permd:
+case Intrinsic::x86_avx2_permps:
+case Intrinsic::x86_ssse3_pshuf_b_128:
+case Intrinsic::x86_avx2_pshuf_b:
+case Intrinsic::x86_avx512_pshuf_b_512:
+case Intrinsic::x86_avx512_permvar_df_256:
+case Intrinsic::x86_avx512_permvar_df_512:
+case Intrinsic::x86_avx512_permvar_di_256:
+case Intrinsic::x86_avx512_permvar_di_512:
+case Intrinsic::x86_avx512_permvar_hi_128:
+case Intrinsic::x86_avx512_permvar_hi_256:
+case Intrinsic::x86_avx512_permvar_hi_512:
+case Intrinsic::x86_avx512_permvar_qi_128:
+case Intrinsic::x86_avx512_permvar_qi_256:
+case Intrinsic::x86_avx512_permvar_qi_512:
+case Intrinsic::x86_avx512_permvar_sf_512:
+case Intrinsic::x86_avx512_permvar_si_512:
 case Intrinsic::x86_avx_vpermilvar_pd:
 case Intrinsic::x86_avx_vpermilvar_pd_256:
 case Intrinsic::x86_avx512_vpermilvar_pd_512:
 case Intrinsic::x86_avx_vpermilvar_ps:
 case Intrinsic::x86_avx_vpermilvar_ps_256:
 case Intrinsic::x86_avx512_vpermilvar_ps_512: {
-  handleAVXVpermilvar(I);
+  handleAVXPermutation(I);
   break;
 }
 case Intrinsic::x86_avx512_vpermi2var_d_128:
diff --git 
a/llvm/test/Instrumentation/MemorySanitizer/X86/avx2-intrinsics-x86.ll 
b/llvm/test/Instrumentation/MemorySanitizer/X86/avx2-intrinsics-x86.ll
index f916130fe53e5..9649f2dc71f1f 100644
--- a/llvm/test/Instrumentation/MemorySanitizer/X86/avx2-intrinsics-x86.ll
+++ b/llvm/test/Instrumentation/MemorySanitizer/X86/avx2-intrinsics-x86.ll
@@ -740,8 +740,15 @@ define <32 x i8> @test_x86_avx2_pshuf_b(<32 x i8> %a0, <32 
x i8> %a1) #0 {
 ; CHECK-NEXT:[[TMP1:%.*]] = load <32 x i8>, ptr @__msan_param_tls, align 8
 ; CHECK-NEXT:[[TMP2:%.*]] = load <32 x i8>, ptr inttoptr (i64 add (i64 
ptrtoint (ptr @__msan_param_tls to i64), i64 32) to ptr), align 8
 ; CHECK-NEXT:call void @llvm.donothing()
-; CHECK-NEXT:[[_MSPROP:%.*]] = or <32 x i8> [[TMP1]], [[TMP2]]
-; CHECK-NEXT:[[RES:%.*]] = call <32 x i8> @llvm.x86.avx2.pshuf.b(<32 x i8> 
[[A0:%.*]], <32 x i8> [[A1:%.*]])
+; CHECK-NEXT:[[_MSPROP:%.*]] = call <32 x i8> @llvm.x86.avx2.pshuf.b(<32 x 
i8> [[TMP1]], <32 x i8> [[A1:%.*]])
+; CHECK-NEXT:[[TMP4:%.*]] = bitcast <32 x i8> [[TMP2]] to i256
+; CHECK-NEXT:[[_MSCMP:%.*]] = icmp ne i256 [[TMP4]], 0
+; CHECK-NEXT:br i1 [[_MSCMP]], label [[TMP5:%.*]], label [[TMP6:%.*]], 
!prof [[PROF1]]
+; CHECK:   5:
+; CHECK-NEXT:call void @__msan_warning_noreturn() #[[ATTR6]]
+; CHECK-NEXT:unreachable
+; CHECK:   6:
+; CHECK-NEXT:[[RES:%.*]] = call <32 x i8> @llvm.x86.avx2.pshuf.b(<32 x i8> 
[[A0:%.*]], <32 x i8> [[A1]])
 ; CHECK-NEXT:store <32 x i8> [[_MSPROP]], ptr @__msan_retval_tls, align 8
 ; CHECK-NEXT:ret <32 x i8> [[RES]]
 ;
@@ -969,8 +976,15 @@ define <8 x i32> @test_x86_avx2_permd(<8 x i32> %a0, <8 x 
i32> %a1) #0 {
 ; CHECK-NEXT:[[TMP1:%.*]] = load <8 x i32>, ptr @__msan_param_tls, align 8
 ; CHECK-NEXT:[[TMP2:%.*]] = load <8 x i32>, ptr inttoptr (i64 add (i64 
ptrtoint (ptr @__msan_param_tls to i64), i64 32) to ptr), align 8
 ; CHECK-NEXT:call void @llvm.donothing()
-; CHECK-NEXT:[[_MSPROP:%.*]] = or <8 x i32> [[TMP1]], [[TMP2]]
-; CHECK-NEXT:[[RES:%.*]] = call <8 x i32> @llvm.x86.avx2.permd(<8 x i32> 
[[A0:%.*]], <8 x i32> [[A1:%.*]])
+; CHECK-NEXT:[[_MSPROP:%.*]] = call <8 x i32> @llvm.x86.avx2.permd(<8 x 
i32> [[TMP1]], <8 x i32>

[llvm-branch-commits] [MSAN] handle assorted AVX permutations (PR #143462)

2025-06-09 Thread Florian Mayer via llvm-branch-commits

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

None


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang-tools-extra] [clang-doc] add namespaces to JSON generator (PR #143209)

2025-06-09 Thread Erick Velez via llvm-branch-commits


@@ -0,0 +1,108 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --output=%t --format=json --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/index.json
+
+class MyClass {};
+
+void myFunction(int Param);
+
+namespace NestedNamespace {
+} // namespace NestedNamespace
+
+// FIXME: Global variables are not mapped or serialized.
+static int Global;
+
+enum Color {
+  RED,
+  GREEN,
+  BLUE = 5
+};
+
+typedef int MyTypedef;
+
+// CHECK:   { 
+// CHECK-NEXT:"Enums": [
+// CHECK-NEXT:  {
+// CHECK-NEXT:"Location": {
+// CHECK-NEXT:  "Filename": "{{.*}}namespace.cpp",
+// CHECK-NEXT:  "LineNumber": 15
+// CHECK-NEXT:},
+// CHECK-NEXT:"Members": [
+// CHECK-NEXT:  {
+// CHECK-NEXT:"Name": "RED",
+// CHECK-NEXT:"Value": "0"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  {
+// CHECK-NEXT:"Name": "GREEN",
+// CHECK-NEXT:"Value": "1"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  {
+// CHECK-NEXT:"Name": "BLUE",
+// CHECK-NEXT:"ValueExpr": "5"
+// CHECK-NEXT:  }
+// CHECK-NEXT:],
+// CHECK-NEXT:"Name": "Color",
+// CHECK-NEXT:"Scoped": false,
+// CHECK-NEXT:"USR": "{{[0-9A-F]*}}"
+// CHECK-NEXT:  }
+// CHECK-NEXT:],
+// CHECK-NEXT:   "Functions": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "IsStatic": false,
+// CHECK-NEXT:   "Name": "myFunction",
+// CHECK-NEXT:   "Params": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "Name": "Param",
+// CHECK-NEXT:   "Type": "int"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "ReturnType": {
+// CHECK-NEXT: "IsBuiltIn": false,
+// CHECK-NEXT: "IsTemplate": false,
+// CHECK-NEXT: "Name": "void",
+// CHECK-NEXT: "QualName": "void",
+// CHECK-NEXT: "USR": ""

evelez7 wrote:

Yes those USRs are fixed.

`IsBuiltIn` is set in Serialize.cpp and I just checked in gdb. `IsBuiltIn` is 
true for `void` but it gets emitted to its default value. I'm not sure how it 
works but I have a feeling the bitcode reader doesn't properly serialize 
everything.

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


[llvm-branch-commits] [clang-tools-extra] [clang-doc] add namespaces to JSON generator (PR #143209)

2025-06-09 Thread Erick Velez via llvm-branch-commits


@@ -0,0 +1,25 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --output=%t --format=json --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/index.json
+
+static void myFunction() {}
+
+void noExceptFunction() noexcept {}
+
+inline void inlineFunction() {}
+
+extern void externFunction() {}
+
+constexpr void constexprFunction() {}
+
+// CHECK:  "Functions": [
+// CHECK-NEXT:   {
+// CHECK:  "IsStatic": true,

evelez7 wrote:

Yeah this was motivated by convenience. The functions are serialized in order, 
so I know that the first entry to be checked will be the static function. 
Hence, the `"IsStatic": true` check. The contents of an object are serialized 
alphabetically, so I haven't figured how to check the name first, since that 
comes after all the `Is` fields.

That would be useful. I can investigate this more.

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


[llvm-branch-commits] [llvm] [AMDGPU] Autogenerate bitop3 asm and dags. NFCI. (PR #143430)

2025-06-09 Thread Matt Arsenault via llvm-branch-commits

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


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


[llvm-branch-commits] [llvm] [AMDGPU] Autogenerate dst bytesel asm. NFCI. (PR #143429)

2025-06-09 Thread Matt Arsenault via llvm-branch-commits

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


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


[llvm-branch-commits] [clang-tools-extra] [clang-doc] add namespaces to JSON generator (PR #143209)

2025-06-09 Thread Paul Kirth via llvm-branch-commits


@@ -171,5 +171,78 @@ TEST(JSONGeneratorTest, emitRecordJSON) {
 })raw";
   EXPECT_EQ(Expected, Actual.str());
 }
+
+TEST(JSONGeneratorTest, emitNamespaceJSON) {
+  NamespaceInfo I;
+  I.Name = "Namespace";
+  I.Path = "path/to/A";
+  I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
+
+  I.Children.Namespaces.emplace_back(
+  EmptySID, "ChildNamespace", InfoType::IT_namespace,
+  "path::to::A::Namespace::ChildNamespace", "path/to/A/Namespace");
+  I.Children.Records.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record,
+  "path::to::A::Namespace::ChildStruct",
+  "path/to/A/Namespace");
+  I.Children.Functions.emplace_back();
+  I.Children.Functions.back().Name = "OneFunction";
+  I.Children.Functions.back().Access = AccessSpecifier::AS_none;
+  I.Children.Enums.emplace_back();
+  I.Children.Enums.back().Name = "OneEnum";
+
+  auto G = getJSONGenerator();
+  assert(G);
+  std::string Buffer;
+  llvm::raw_string_ostream Actual(Buffer);
+  auto Err = G->generateDocForInfo(&I, Actual, ClangDocContext());
+  assert(!Err);
+  std::string Expected = R"raw({
+  "Enums": [
+{
+  "Name": "OneEnum",
+  "Scoped": false,
+  "USR": ""
+}
+  ],
+  "Functions": [
+{
+  "IsStatic": false,
+  "Name": "OneFunction",
+  "ReturnType": {
+"IsBuiltIn": false,
+"IsTemplate": false,
+"Name": "",
+"QualName": "",
+"USR": ""
+  },
+  "USR": ""
+}
+  ],
+  "Name": "Namespace",
+  "Namespace": [
+"A"
+  ],
+  "NamespacePath": "path/to/A/Namespace",

ilovepi wrote:

Are these file paths going to work on Windows?

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


[llvm-branch-commits] [clang-tools-extra] [clang-doc] add namespaces to JSON generator (PR #143209)

2025-06-09 Thread Paul Kirth via llvm-branch-commits


@@ -171,5 +171,78 @@ TEST(JSONGeneratorTest, emitRecordJSON) {
 })raw";
   EXPECT_EQ(Expected, Actual.str());
 }
+
+TEST(JSONGeneratorTest, emitNamespaceJSON) {
+  NamespaceInfo I;
+  I.Name = "Namespace";
+  I.Path = "path/to/A";
+  I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
+
+  I.Children.Namespaces.emplace_back(
+  EmptySID, "ChildNamespace", InfoType::IT_namespace,
+  "path::to::A::Namespace::ChildNamespace", "path/to/A/Namespace");
+  I.Children.Records.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record,
+  "path::to::A::Namespace::ChildStruct",
+  "path/to/A/Namespace");
+  I.Children.Functions.emplace_back();
+  I.Children.Functions.back().Name = "OneFunction";
+  I.Children.Functions.back().Access = AccessSpecifier::AS_none;
+  I.Children.Enums.emplace_back();
+  I.Children.Enums.back().Name = "OneEnum";
+
+  auto G = getJSONGenerator();
+  assert(G);
+  std::string Buffer;
+  llvm::raw_string_ostream Actual(Buffer);
+  auto Err = G->generateDocForInfo(&I, Actual, ClangDocContext());
+  assert(!Err);
+  std::string Expected = R"raw({
+  "Enums": [
+{
+  "Name": "OneEnum",
+  "Scoped": false,
+  "USR": ""
+}
+  ],
+  "Functions": [
+{
+  "IsStatic": false,
+  "Name": "OneFunction",
+  "ReturnType": {
+"IsBuiltIn": false,
+"IsTemplate": false,
+"Name": "",
+"QualName": "",
+"USR": ""
+  },
+  "USR": ""
+}
+  ],
+  "Name": "Namespace",
+  "Namespace": [
+"A"
+  ],
+  "NamespacePath": "path/to/A/Namespace",

ilovepi wrote:

```
C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-doc\json\class.cpp:166:16:
 error: CHECK-NEXT: expected string not found in input
# | // CHECK-NEXT: "Path": "GlobalNamespace/MyClass",
# |^
# | :169:24: note: scanning from here
# |  "Name": "NestedClass",
# |^
# | :170:2: note: possible intended match here
# |  "Path": "GlobalNamespace\\MyClass",
# |  ^
```
>From the bot, it looks like its not. Depending on how you expect that field to 
>be used, I could see you go one of two ways.

1. You want to use the path as a real filesystem path, in which case, you'd 
update the test to check for either separator.
2. It's more an abstract/logical distinction, and you intend to use it similar 
to a URL, in which case you can always make it POSIX style.


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


[llvm-branch-commits] [clang-tools-extra] [clang-doc] add namespaces to JSON generator (PR #143209)

2025-06-09 Thread Erick Velez via llvm-branch-commits


@@ -171,5 +171,78 @@ TEST(JSONGeneratorTest, emitRecordJSON) {
 })raw";
   EXPECT_EQ(Expected, Actual.str());
 }
+
+TEST(JSONGeneratorTest, emitNamespaceJSON) {
+  NamespaceInfo I;
+  I.Name = "Namespace";
+  I.Path = "path/to/A";
+  I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
+
+  I.Children.Namespaces.emplace_back(
+  EmptySID, "ChildNamespace", InfoType::IT_namespace,
+  "path::to::A::Namespace::ChildNamespace", "path/to/A/Namespace");
+  I.Children.Records.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record,
+  "path::to::A::Namespace::ChildStruct",
+  "path/to/A/Namespace");
+  I.Children.Functions.emplace_back();
+  I.Children.Functions.back().Name = "OneFunction";
+  I.Children.Functions.back().Access = AccessSpecifier::AS_none;
+  I.Children.Enums.emplace_back();
+  I.Children.Enums.back().Name = "OneEnum";
+
+  auto G = getJSONGenerator();
+  assert(G);
+  std::string Buffer;
+  llvm::raw_string_ostream Actual(Buffer);
+  auto Err = G->generateDocForInfo(&I, Actual, ClangDocContext());
+  assert(!Err);
+  std::string Expected = R"raw({
+  "Enums": [
+{
+  "Name": "OneEnum",
+  "Scoped": false,
+  "USR": ""
+}
+  ],
+  "Functions": [
+{
+  "IsStatic": false,
+  "Name": "OneFunction",
+  "ReturnType": {
+"IsBuiltIn": false,
+"IsTemplate": false,
+"Name": "",
+"QualName": "",
+"USR": ""
+  },
+  "USR": ""
+}
+  ],
+  "Name": "Namespace",
+  "Namespace": [
+"A"
+  ],
+  "NamespacePath": "path/to/A/Namespace",

evelez7 wrote:

I've been trying to figure this out and I am inclined to remove this field 
altogether (in fact I have the changes staged right now). I copied the Mustache 
behavior from here: 

https://github.com/llvm/llvm-project/blob/4e6896244f4129a22e311f7f6290a595b6f03b75/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp#L473-L475

And I use this behavior in the initial JSON generator patch as well because 
Mustache does it for all entities:

https://github.com/llvm/llvm-project/blob/b567c6cc7c80ca567bf664ded8ead0a744813e52/clang-tools-extra/clang-doc/JSONGenerator.cpp#L201-L203

I think this behavior is **incorrect** for the JSON generator and a mistake on 
my part. References already have their own Path fields and I think that's what 
should be emitted, not a relative file path for linking documents. If the JSON 
ends up being fed to an HTML generator, then I think the HTML generator should 
construct its own paths for linking. @ilovepi

It was also incorrect because instead of checking for the proper `path/to/A/r`, 
the test was emitting checking for the filename link (something like 
`../index.json`) which was again an oversight by me.

As for Windows, yes it's particularly nasty for unit tests because I can't use 
the nice regex stuff (`{{[.*]}}` in there, so I'm figuring that out. I don't 
know how YAML solved it. 

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


[llvm-branch-commits] [clang-tools-extra] [clang-doc] add namespaces to JSON generator (PR #143209)

2025-06-09 Thread Erick Velez via llvm-branch-commits


@@ -171,5 +171,78 @@ TEST(JSONGeneratorTest, emitRecordJSON) {
 })raw";
   EXPECT_EQ(Expected, Actual.str());
 }
+
+TEST(JSONGeneratorTest, emitNamespaceJSON) {
+  NamespaceInfo I;
+  I.Name = "Namespace";
+  I.Path = "path/to/A";
+  I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
+
+  I.Children.Namespaces.emplace_back(
+  EmptySID, "ChildNamespace", InfoType::IT_namespace,
+  "path::to::A::Namespace::ChildNamespace", "path/to/A/Namespace");
+  I.Children.Records.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record,
+  "path::to::A::Namespace::ChildStruct",
+  "path/to/A/Namespace");
+  I.Children.Functions.emplace_back();
+  I.Children.Functions.back().Name = "OneFunction";
+  I.Children.Functions.back().Access = AccessSpecifier::AS_none;
+  I.Children.Enums.emplace_back();
+  I.Children.Enums.back().Name = "OneEnum";
+
+  auto G = getJSONGenerator();
+  assert(G);
+  std::string Buffer;
+  llvm::raw_string_ostream Actual(Buffer);
+  auto Err = G->generateDocForInfo(&I, Actual, ClangDocContext());
+  assert(!Err);
+  std::string Expected = R"raw({
+  "Enums": [
+{
+  "Name": "OneEnum",
+  "Scoped": false,
+  "USR": ""
+}
+  ],
+  "Functions": [
+{
+  "IsStatic": false,
+  "Name": "OneFunction",
+  "ReturnType": {
+"IsBuiltIn": false,
+"IsTemplate": false,
+"Name": "",
+"QualName": "",
+"USR": ""
+  },
+  "USR": ""
+}
+  ],
+  "Name": "Namespace",
+  "Namespace": [
+"A"
+  ],
+  "NamespacePath": "path/to/A/Namespace",

evelez7 wrote:

Also this "NamespacePath" is not generated by any other generator besides 
Mustache and it's not currently used in any Mustache templates.

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


[llvm-branch-commits] [clang-tools-extra] [clang-doc] add namespaces to JSON generator (PR #143209)

2025-06-09 Thread Erick Velez via llvm-branch-commits

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


[llvm-branch-commits] [clang-tools-extra] [clang-doc] add namespaces to JSON generator (PR #143209)

2025-06-09 Thread Erick Velez via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [DirectX] Add static sampler support to root signature and fix descriptor range flags (PR #143422)

2025-06-09 Thread via llvm-branch-commits

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

>From 26c7ccab57c53cffd545277555f131fae50520d9 Mon Sep 17 00:00:00 2001
From: joaosaffran 
Date: Wed, 4 Jun 2025 21:42:20 +
Subject: [PATCH 1/6] adding metadata support for static samplers

---
 llvm/lib/MC/DXContainerRootSignature.cpp  | 42 +
 llvm/lib/Target/DirectX/DXILRootSignature.cpp | 89 +++
 llvm/lib/Target/DirectX/DXILRootSignature.h   |  1 +
 .../RootSignature-StaticSamplers.ll   | 42 +
 4 files changed, 157 insertions(+), 17 deletions(-)
 create mode 100644 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers.ll

diff --git a/llvm/lib/MC/DXContainerRootSignature.cpp 
b/llvm/lib/MC/DXContainerRootSignature.cpp
index 6c71823a51f85..d67babf13a432 100644
--- a/llvm/lib/MC/DXContainerRootSignature.cpp
+++ b/llvm/lib/MC/DXContainerRootSignature.cpp
@@ -9,6 +9,7 @@
 #include "llvm/MC/DXContainerRootSignature.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/EndianStream.h"
+#include 
 
 using namespace llvm;
 using namespace llvm::mcdxbc;
@@ -71,12 +72,16 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
   BOS.reserveExtraSpace(getSize());
 
   const uint32_t NumParameters = ParametersContainer.size();
-
+  const uint32_t NumSamplers = StaticSamplers.size();
   support::endian::write(BOS, Version, llvm::endianness::little);
   support::endian::write(BOS, NumParameters, llvm::endianness::little);
   support::endian::write(BOS, RootParameterOffset, llvm::endianness::little);
-  support::endian::write(BOS, NumStaticSamplers, llvm::endianness::little);
-  support::endian::write(BOS, StaticSamplersOffset, llvm::endianness::little);
+  support::endian::write(BOS, NumSamplers, llvm::endianness::little);
+  uint32_t SSO = StaticSamplersOffset;
+  if (NumSamplers > 0)
+SSO = writePlaceholder(BOS);
+  else
+support::endian::write(BOS, SSO, llvm::endianness::little);
   support::endian::write(BOS, Flags, llvm::endianness::little);
 
   SmallVector ParamsOffsets;
@@ -142,20 +147,23 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
 }
 }
   }
-  for (const auto &S : StaticSamplers) {
-support::endian::write(BOS, S.Filter, llvm::endianness::little);
-support::endian::write(BOS, S.AddressU, llvm::endianness::little);
-support::endian::write(BOS, S.AddressV, llvm::endianness::little);
-support::endian::write(BOS, S.AddressW, llvm::endianness::little);
-support::endian::write(BOS, S.MipLODBias, llvm::endianness::little);
-support::endian::write(BOS, S.MaxAnisotropy, llvm::endianness::little);
-support::endian::write(BOS, S.ComparisonFunc, llvm::endianness::little);
-support::endian::write(BOS, S.BorderColor, llvm::endianness::little);
-support::endian::write(BOS, S.MinLOD, llvm::endianness::little);
-support::endian::write(BOS, S.MaxLOD, llvm::endianness::little);
-support::endian::write(BOS, S.ShaderRegister, llvm::endianness::little);
-support::endian::write(BOS, S.RegisterSpace, llvm::endianness::little);
-support::endian::write(BOS, S.ShaderVisibility, llvm::endianness::little);
+  if (NumSamplers > 0) {
+rewriteOffsetToCurrentByte(BOS, SSO);
+for (const auto &S : StaticSamplers) {
+  support::endian::write(BOS, S.Filter, llvm::endianness::little);
+  support::endian::write(BOS, S.AddressU, llvm::endianness::little);
+  support::endian::write(BOS, S.AddressV, llvm::endianness::little);
+  support::endian::write(BOS, S.AddressW, llvm::endianness::little);
+  support::endian::write(BOS, S.MipLODBias, llvm::endianness::little);
+  support::endian::write(BOS, S.MaxAnisotropy, llvm::endianness::little);
+  support::endian::write(BOS, S.ComparisonFunc, llvm::endianness::little);
+  support::endian::write(BOS, S.BorderColor, llvm::endianness::little);
+  support::endian::write(BOS, S.MinLOD, llvm::endianness::little);
+  support::endian::write(BOS, S.MaxLOD, llvm::endianness::little);
+  support::endian::write(BOS, S.ShaderRegister, llvm::endianness::little);
+  support::endian::write(BOS, S.RegisterSpace, llvm::endianness::little);
+  support::endian::write(BOS, S.ShaderVisibility, 
llvm::endianness::little);
+}
   }
   assert(Storage.size() == getSize());
   OS.write(Storage.data(), Storage.size());
diff --git a/llvm/lib/Target/DirectX/DXILRootSignature.cpp 
b/llvm/lib/Target/DirectX/DXILRootSignature.cpp
index 38bf9e008f1fe..8c85042bb7307 100644
--- a/llvm/lib/Target/DirectX/DXILRootSignature.cpp
+++ b/llvm/lib/Target/DirectX/DXILRootSignature.cpp
@@ -12,6 +12,7 @@
 
//===--===//
 #include "DXILRootSignature.h"
 #include "DirectX.h"
+#include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Analysis/DXILMetadataAnalysis.h"
@@ -55,6 +56,13 @@ static std::optional extractMdIntValue(MDNode 
*

[llvm-branch-commits] [lld] ELF: Add branch-to-branch optimization. (PR #138366)

2025-06-09 Thread Peter Collingbourne via llvm-branch-commits

pcc wrote:

@MaskRay ping.

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


[llvm-branch-commits] [llvm] [IR2Vec] Consider only reachable BBs and non-debug instructions (PR #143476)

2025-06-09 Thread S. VenkataKeerthy via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [IR2Vec] Consider only reachable BBs and non-debug instructions (PR #143476)

2025-06-09 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-analysis

Author: S. VenkataKeerthy (svkeerthy)


Changes

Changes to consider BBs that are reachable from the entry block. Similarly we 
skip debug instruction while computing the embeddings.

(Tracking issue - #141817)

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


3 Files Affected:

- (modified) llvm/lib/Analysis/IR2Vec.cpp (+11-4) 
- (added) llvm/test/Analysis/IR2Vec/dbg-inst.ll (+13) 
- (added) llvm/test/Analysis/IR2Vec/unreachable.ll (+42) 


``diff
diff --git a/llvm/lib/Analysis/IR2Vec.cpp b/llvm/lib/Analysis/IR2Vec.cpp
index 2ad65c2f40c33..8a392e0709c7f 100644
--- a/llvm/lib/Analysis/IR2Vec.cpp
+++ b/llvm/lib/Analysis/IR2Vec.cpp
@@ -13,7 +13,10 @@
 
 #include "llvm/Analysis/IR2Vec.h"
 
+#include "llvm/ADT/PostOrderIterator.h"
 #include "llvm/ADT/Statistic.h"
+#include "llvm/IR/CFG.h"
+#include "llvm/IR/Function.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/Support/Debug.h"
@@ -193,7 +196,8 @@ Embedding SymbolicEmbedder::getOperandEmbedding(const Value 
*Op) const {
 void SymbolicEmbedder::computeEmbeddings(const BasicBlock &BB) const {
   Embedding BBVector(Dimension, 0);
 
-  for (const auto &I : BB) {
+  // We consider only the non-debug and non-pseudo instructions
+  for (const auto &I : BB.instructionsWithoutDebug()) {
 Embedding InstVector(Dimension, 0);
 
 const auto OpcVec = lookupVocab(I.getOpcodeName());
@@ -218,9 +222,12 @@ void SymbolicEmbedder::computeEmbeddings(const BasicBlock 
&BB) const {
 void SymbolicEmbedder::computeEmbeddings() const {
   if (F.isDeclaration())
 return;
-  for (const auto &BB : F) {
-computeEmbeddings(BB);
-FuncVector += BBVecMap[&BB];
+
+  // Consider only the basic blocks that are reachable from entry
+  ReversePostOrderTraversal RPOT(&F);
+  for (const BasicBlock *BB : RPOT) {
+computeEmbeddings(*BB);
+FuncVector += BBVecMap[BB];
   }
 }
 
diff --git a/llvm/test/Analysis/IR2Vec/dbg-inst.ll 
b/llvm/test/Analysis/IR2Vec/dbg-inst.ll
new file mode 100644
index 0..0f486b0ba6a52
--- /dev/null
+++ b/llvm/test/Analysis/IR2Vec/dbg-inst.ll
@@ -0,0 +1,13 @@
+; RUN: opt -passes='print' -o /dev/null 
-ir2vec-vocab-path=%S/Inputs/dummy_3D_vocab.json %s 2>&1 | FileCheck %s
+
+define void @bar2(ptr %foo)  {
+  store i32 0, ptr %foo, align 4
+  tail call void @llvm.dbg.value(metadata !{}, i64 0, metadata !{}, metadata 
!{})
+  ret void
+}
+
+declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind 
readnone
+
+; CHECK: Instruction vectors:
+; CHECK-NEXT: Instruction:   store i32 0, ptr %foo, align 4 [ 7.00  8.00  9.00 
]
+; CHECK-NEXT: Instruction:   ret void [ 0.00  0.00  0.00 ]
diff --git a/llvm/test/Analysis/IR2Vec/unreachable.ll 
b/llvm/test/Analysis/IR2Vec/unreachable.ll
new file mode 100644
index 0..370fe6881d6ce
--- /dev/null
+++ b/llvm/test/Analysis/IR2Vec/unreachable.ll
@@ -0,0 +1,42 @@
+; RUN: opt -passes='print' -o /dev/null 
-ir2vec-vocab-path=%S/Inputs/dummy_3D_vocab.json %s 2>&1 | FileCheck %s
+
+define dso_local i32 @abc(i32 noundef %a, i32 noundef %b) #0 {
+entry:
+  %retval = alloca i32, align 4
+  %a.addr = alloca i32, align 4
+  %b.addr = alloca i32, align 4
+  store i32 %a, ptr %a.addr, align 4
+  store i32 %b, ptr %b.addr, align 4
+  %0 = load i32, ptr %a.addr, align 4
+  %1 = load i32, ptr %b.addr, align 4
+  %cmp = icmp sgt i32 %0, %1
+  br i1 %cmp, label %if.then, label %if.else
+
+if.then:  ; preds = %entry
+  %2 = load i32, ptr %b.addr, align 4
+  store i32 %2, ptr %retval, align 4
+  br label %return
+
+if.else:  ; preds = %entry
+  %3 = load i32, ptr %a.addr, align 4
+  store i32 %3, ptr %retval, align 4
+  br label %return
+
+unreachable:  ; Unreachable
+  store i32 0, ptr %retval, align 4
+  br label %return
+
+return:   ; preds = %if.else, %if.then
+  %4 = load i32, ptr %retval, align 4
+  ret i32 %4
+}
+
+; CHECK: Basic block vectors:
+; CHECK-NEXT: Basic block: entry:
+; CHECK-NEXT:  [ 25.00 32.00 39.00 ]
+; CHECK-NEXT: Basic block: if.then:
+; CHECK-NEXT:  [ 11.00 13.00 15.00 ]
+; CHECK-NEXT: Basic block: if.else:
+; CHECK-NEXT:  [ 11.00 13.00 15.00 ]
+; CHECK-NEXT: Basic block: return:
+; CHECK-NEXT:  [ 4.00 5.00 6.00 ]

``




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


[llvm-branch-commits] [llvm] [CI] Cleanup buildkite test report script (PR #143480)

2025-06-09 Thread Aiden Grossman via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [MLIniner][IR2Vec] Integrating IR2Vec with MLInliner (PR #143479)

2025-06-09 Thread S. VenkataKeerthy via llvm-branch-commits

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


[llvm-branch-commits] [llvm] reachable BB (PR #143476)

2025-06-09 Thread S. VenkataKeerthy via llvm-branch-commits

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

* **#143476** https://app.graphite.dev/github/pr/llvm/llvm-project/143476?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/143476?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#143200** https://app.graphite.dev/github/pr/llvm/llvm-project/143200?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#143197** https://app.graphite.dev/github/pr/llvm/llvm-project/143197?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/143476
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [MLIniner][IR2Vec] Integrating IR2Vec with MLInliner (PR #143479)

2025-06-09 Thread S. VenkataKeerthy via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [MLIniner][IR2Vec] Integrating IR2Vec with MLInliner (PR #143479)

2025-06-09 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-analysis

Author: S. VenkataKeerthy (svkeerthy)


Changes

Changes to use Symbolic embeddings in MLInliner. 

(Fixes #141836, Tracking issue - #141817)

---

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


10 Files Affected:

- (modified) llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h (+21-5) 
- (modified) llvm/include/llvm/Analysis/IR2Vec.h (+1-1) 
- (modified) llvm/include/llvm/Analysis/InlineAdvisor.h (+3) 
- (modified) llvm/include/llvm/Analysis/InlineModelFeatureMaps.h (+5-1) 
- (modified) llvm/include/llvm/Analysis/MLInlineAdvisor.h (+1) 
- (modified) llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp (+112-3) 
- (modified) llvm/lib/Analysis/IR2Vec.cpp (+2-2) 
- (modified) llvm/lib/Analysis/InlineAdvisor.cpp (+29) 
- (modified) llvm/lib/Analysis/MLInlineAdvisor.cpp (+33-1) 
- (modified) llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp 
(+154-25) 


``diff
diff --git a/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h 
b/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
index babb6d9d6cf0c..06dbfc35a5294 100644
--- a/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
+++ b/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
@@ -15,6 +15,7 @@
 #define LLVM_ANALYSIS_FUNCTIONPROPERTIESANALYSIS_H
 
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/Analysis/IR2Vec.h"
 #include "llvm/IR/Dominators.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/Support/Compiler.h"
@@ -32,17 +33,19 @@ class FunctionPropertiesInfo {
   void updateAggregateStats(const Function &F, const LoopInfo &LI);
   void reIncludeBB(const BasicBlock &BB);
 
+  ir2vec::Embedding FunctionEmbedding = ir2vec::Embedding(0.0);
+  std::optional IR2VecVocab;
+
 public:
   LLVM_ABI static FunctionPropertiesInfo
   getFunctionPropertiesInfo(const Function &F, const DominatorTree &DT,
-const LoopInfo &LI);
+const LoopInfo &LI,
+const IR2VecVocabResult *VocabResult);
 
   LLVM_ABI static FunctionPropertiesInfo
   getFunctionPropertiesInfo(Function &F, FunctionAnalysisManager &FAM);
 
-  bool operator==(const FunctionPropertiesInfo &FPI) const {
-return std::memcmp(this, &FPI, sizeof(FunctionPropertiesInfo)) == 0;
-  }
+  bool operator==(const FunctionPropertiesInfo &FPI) const;
 
   bool operator!=(const FunctionPropertiesInfo &FPI) const {
 return !(*this == FPI);
@@ -137,6 +140,19 @@ class FunctionPropertiesInfo {
   int64_t CallReturnsVectorPointerCount = 0;
   int64_t CallWithManyArgumentsCount = 0;
   int64_t CallWithPointerArgumentCount = 0;
+
+  const ir2vec::Embedding &getFunctionEmbedding() const {
+return FunctionEmbedding;
+  }
+
+  const std::optional &getIR2VecVocab() const {
+return IR2VecVocab;
+  }
+
+  // Helper intended to be useful for unittests
+  void setFunctionEmbeddingForTest(const ir2vec::Embedding &Embedding) {
+FunctionEmbedding = Embedding;
+  }
 };
 
 // Analysis pass
@@ -192,7 +208,7 @@ class FunctionPropertiesUpdater {
 
   DominatorTree &getUpdatedDominatorTree(FunctionAnalysisManager &FAM) const;
 
-  DenseSet Successors;
+  DenseSet Successors, CallUsers;
 
   // Edges we might potentially need to remove from the dominator tree.
   SmallVector DomTreeUpdates;
diff --git a/llvm/include/llvm/Analysis/IR2Vec.h 
b/llvm/include/llvm/Analysis/IR2Vec.h
index 7976cc7470d5b..3f44c650e640d 100644
--- a/llvm/include/llvm/Analysis/IR2Vec.h
+++ b/llvm/include/llvm/Analysis/IR2Vec.h
@@ -239,7 +239,7 @@ class IR2VecVocabAnalysis : public 
AnalysisInfoMixin {
 public:
   static AnalysisKey Key;
   IR2VecVocabAnalysis() = default;
-  explicit IR2VecVocabAnalysis(ir2vec::Vocab &&Vocab);
+  explicit IR2VecVocabAnalysis(ir2vec::Vocab Vocab);
   using Result = IR2VecVocabResult;
   Result run(Module &M, ModuleAnalysisManager &MAM);
 };
diff --git a/llvm/include/llvm/Analysis/InlineAdvisor.h 
b/llvm/include/llvm/Analysis/InlineAdvisor.h
index 9d15136e81d10..d2cad4717cbdb 100644
--- a/llvm/include/llvm/Analysis/InlineAdvisor.h
+++ b/llvm/include/llvm/Analysis/InlineAdvisor.h
@@ -331,6 +331,9 @@ class InlineAdvisorAnalysis : public 
AnalysisInfoMixin {
   };
 
   Result run(Module &M, ModuleAnalysisManager &MAM) { return Result(M, MAM); }
+
+private:
+  static bool initializeIR2VecVocab(Module &M, ModuleAnalysisManager &MAM);
 };
 
 /// Printer pass for the InlineAdvisorAnalysis results.
diff --git a/llvm/include/llvm/Analysis/InlineModelFeatureMaps.h 
b/llvm/include/llvm/Analysis/InlineModelFeatureMaps.h
index 961d5091bf9f3..91d3378565fc5 100644
--- a/llvm/include/llvm/Analysis/InlineModelFeatureMaps.h
+++ b/llvm/include/llvm/Analysis/InlineModelFeatureMaps.h
@@ -142,6 +142,10 @@ enum class FeatureIndex : size_t {
   INLINE_FEATURE_ITERATOR(POPULATE_INDICES)
 #undef POPULATE_INDICES
 
+// IR2Vec embeddings
+  callee_embedding,
+  caller_embedding,
+
   NumberOfFeatures
 };

[llvm-branch-commits] [llvm] reachable BB (PR #143476)

2025-06-09 Thread S. VenkataKeerthy via llvm-branch-commits

https://github.com/svkeerthy created 
https://github.com/llvm/llvm-project/pull/143476

None

>From 79060df5f6ebb7f13bd88dd3128800790433a224 Mon Sep 17 00:00:00 2001
From: svkeerthy 
Date: Tue, 10 Jun 2025 04:49:59 +
Subject: [PATCH] reachable BB

---
 llvm/lib/Analysis/IR2Vec.cpp | 15 ++---
 llvm/test/Analysis/IR2Vec/dbg-inst.ll| 13 
 llvm/test/Analysis/IR2Vec/unreachable.ll | 42 
 3 files changed, 66 insertions(+), 4 deletions(-)
 create mode 100644 llvm/test/Analysis/IR2Vec/dbg-inst.ll
 create mode 100644 llvm/test/Analysis/IR2Vec/unreachable.ll

diff --git a/llvm/lib/Analysis/IR2Vec.cpp b/llvm/lib/Analysis/IR2Vec.cpp
index 2ad65c2f40c33..8a392e0709c7f 100644
--- a/llvm/lib/Analysis/IR2Vec.cpp
+++ b/llvm/lib/Analysis/IR2Vec.cpp
@@ -13,7 +13,10 @@
 
 #include "llvm/Analysis/IR2Vec.h"
 
+#include "llvm/ADT/PostOrderIterator.h"
 #include "llvm/ADT/Statistic.h"
+#include "llvm/IR/CFG.h"
+#include "llvm/IR/Function.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/Support/Debug.h"
@@ -193,7 +196,8 @@ Embedding SymbolicEmbedder::getOperandEmbedding(const Value 
*Op) const {
 void SymbolicEmbedder::computeEmbeddings(const BasicBlock &BB) const {
   Embedding BBVector(Dimension, 0);
 
-  for (const auto &I : BB) {
+  // We consider only the non-debug and non-pseudo instructions
+  for (const auto &I : BB.instructionsWithoutDebug()) {
 Embedding InstVector(Dimension, 0);
 
 const auto OpcVec = lookupVocab(I.getOpcodeName());
@@ -218,9 +222,12 @@ void SymbolicEmbedder::computeEmbeddings(const BasicBlock 
&BB) const {
 void SymbolicEmbedder::computeEmbeddings() const {
   if (F.isDeclaration())
 return;
-  for (const auto &BB : F) {
-computeEmbeddings(BB);
-FuncVector += BBVecMap[&BB];
+
+  // Consider only the basic blocks that are reachable from entry
+  ReversePostOrderTraversal RPOT(&F);
+  for (const BasicBlock *BB : RPOT) {
+computeEmbeddings(*BB);
+FuncVector += BBVecMap[BB];
   }
 }
 
diff --git a/llvm/test/Analysis/IR2Vec/dbg-inst.ll 
b/llvm/test/Analysis/IR2Vec/dbg-inst.ll
new file mode 100644
index 0..0f486b0ba6a52
--- /dev/null
+++ b/llvm/test/Analysis/IR2Vec/dbg-inst.ll
@@ -0,0 +1,13 @@
+; RUN: opt -passes='print' -o /dev/null 
-ir2vec-vocab-path=%S/Inputs/dummy_3D_vocab.json %s 2>&1 | FileCheck %s
+
+define void @bar2(ptr %foo)  {
+  store i32 0, ptr %foo, align 4
+  tail call void @llvm.dbg.value(metadata !{}, i64 0, metadata !{}, metadata 
!{})
+  ret void
+}
+
+declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind 
readnone
+
+; CHECK: Instruction vectors:
+; CHECK-NEXT: Instruction:   store i32 0, ptr %foo, align 4 [ 7.00  8.00  9.00 
]
+; CHECK-NEXT: Instruction:   ret void [ 0.00  0.00  0.00 ]
diff --git a/llvm/test/Analysis/IR2Vec/unreachable.ll 
b/llvm/test/Analysis/IR2Vec/unreachable.ll
new file mode 100644
index 0..370fe6881d6ce
--- /dev/null
+++ b/llvm/test/Analysis/IR2Vec/unreachable.ll
@@ -0,0 +1,42 @@
+; RUN: opt -passes='print' -o /dev/null 
-ir2vec-vocab-path=%S/Inputs/dummy_3D_vocab.json %s 2>&1 | FileCheck %s
+
+define dso_local i32 @abc(i32 noundef %a, i32 noundef %b) #0 {
+entry:
+  %retval = alloca i32, align 4
+  %a.addr = alloca i32, align 4
+  %b.addr = alloca i32, align 4
+  store i32 %a, ptr %a.addr, align 4
+  store i32 %b, ptr %b.addr, align 4
+  %0 = load i32, ptr %a.addr, align 4
+  %1 = load i32, ptr %b.addr, align 4
+  %cmp = icmp sgt i32 %0, %1
+  br i1 %cmp, label %if.then, label %if.else
+
+if.then:  ; preds = %entry
+  %2 = load i32, ptr %b.addr, align 4
+  store i32 %2, ptr %retval, align 4
+  br label %return
+
+if.else:  ; preds = %entry
+  %3 = load i32, ptr %a.addr, align 4
+  store i32 %3, ptr %retval, align 4
+  br label %return
+
+unreachable:  ; Unreachable
+  store i32 0, ptr %retval, align 4
+  br label %return
+
+return:   ; preds = %if.else, %if.then
+  %4 = load i32, ptr %retval, align 4
+  ret i32 %4
+}
+
+; CHECK: Basic block vectors:
+; CHECK-NEXT: Basic block: entry:
+; CHECK-NEXT:  [ 25.00 32.00 39.00 ]
+; CHECK-NEXT: Basic block: if.then:
+; CHECK-NEXT:  [ 11.00 13.00 15.00 ]
+; CHECK-NEXT: Basic block: if.else:
+; CHECK-NEXT:  [ 11.00 13.00 15.00 ]
+; CHECK-NEXT: Basic block: return:
+; CHECK-NEXT:  [ 4.00 5.00 6.00 ]

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [MLIniner][IR2Vec] Integrating IR2Vec with MLInliner (PR #143479)

2025-06-09 Thread S. VenkataKeerthy via llvm-branch-commits

https://github.com/svkeerthy created 
https://github.com/llvm/llvm-project/pull/143479

None

>From 58c85ec93a7d81e89ef9d9dd594aa50056e36559 Mon Sep 17 00:00:00 2001
From: svkeerthy 
Date: Tue, 10 Jun 2025 05:40:38 +
Subject: [PATCH] [MLIniner][IR2Vec] Integrating IR2Vec with MLInliner

---
 .../Analysis/FunctionPropertiesAnalysis.h |  26 ++-
 llvm/include/llvm/Analysis/IR2Vec.h   |   2 +-
 llvm/include/llvm/Analysis/InlineAdvisor.h|   3 +
 .../llvm/Analysis/InlineModelFeatureMaps.h|   6 +-
 llvm/include/llvm/Analysis/MLInlineAdvisor.h  |   1 +
 .../Analysis/FunctionPropertiesAnalysis.cpp   | 115 ++-
 llvm/lib/Analysis/IR2Vec.cpp  |   4 +-
 llvm/lib/Analysis/InlineAdvisor.cpp   |  29 +++
 llvm/lib/Analysis/MLInlineAdvisor.cpp |  34 +++-
 .../FunctionPropertiesAnalysisTest.cpp| 179 +++---
 10 files changed, 361 insertions(+), 38 deletions(-)

diff --git a/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h 
b/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
index babb6d9d6cf0c..06dbfc35a5294 100644
--- a/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
+++ b/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
@@ -15,6 +15,7 @@
 #define LLVM_ANALYSIS_FUNCTIONPROPERTIESANALYSIS_H
 
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/Analysis/IR2Vec.h"
 #include "llvm/IR/Dominators.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/Support/Compiler.h"
@@ -32,17 +33,19 @@ class FunctionPropertiesInfo {
   void updateAggregateStats(const Function &F, const LoopInfo &LI);
   void reIncludeBB(const BasicBlock &BB);
 
+  ir2vec::Embedding FunctionEmbedding = ir2vec::Embedding(0.0);
+  std::optional IR2VecVocab;
+
 public:
   LLVM_ABI static FunctionPropertiesInfo
   getFunctionPropertiesInfo(const Function &F, const DominatorTree &DT,
-const LoopInfo &LI);
+const LoopInfo &LI,
+const IR2VecVocabResult *VocabResult);
 
   LLVM_ABI static FunctionPropertiesInfo
   getFunctionPropertiesInfo(Function &F, FunctionAnalysisManager &FAM);
 
-  bool operator==(const FunctionPropertiesInfo &FPI) const {
-return std::memcmp(this, &FPI, sizeof(FunctionPropertiesInfo)) == 0;
-  }
+  bool operator==(const FunctionPropertiesInfo &FPI) const;
 
   bool operator!=(const FunctionPropertiesInfo &FPI) const {
 return !(*this == FPI);
@@ -137,6 +140,19 @@ class FunctionPropertiesInfo {
   int64_t CallReturnsVectorPointerCount = 0;
   int64_t CallWithManyArgumentsCount = 0;
   int64_t CallWithPointerArgumentCount = 0;
+
+  const ir2vec::Embedding &getFunctionEmbedding() const {
+return FunctionEmbedding;
+  }
+
+  const std::optional &getIR2VecVocab() const {
+return IR2VecVocab;
+  }
+
+  // Helper intended to be useful for unittests
+  void setFunctionEmbeddingForTest(const ir2vec::Embedding &Embedding) {
+FunctionEmbedding = Embedding;
+  }
 };
 
 // Analysis pass
@@ -192,7 +208,7 @@ class FunctionPropertiesUpdater {
 
   DominatorTree &getUpdatedDominatorTree(FunctionAnalysisManager &FAM) const;
 
-  DenseSet Successors;
+  DenseSet Successors, CallUsers;
 
   // Edges we might potentially need to remove from the dominator tree.
   SmallVector DomTreeUpdates;
diff --git a/llvm/include/llvm/Analysis/IR2Vec.h 
b/llvm/include/llvm/Analysis/IR2Vec.h
index 7976cc7470d5b..3f44c650e640d 100644
--- a/llvm/include/llvm/Analysis/IR2Vec.h
+++ b/llvm/include/llvm/Analysis/IR2Vec.h
@@ -239,7 +239,7 @@ class IR2VecVocabAnalysis : public 
AnalysisInfoMixin {
 public:
   static AnalysisKey Key;
   IR2VecVocabAnalysis() = default;
-  explicit IR2VecVocabAnalysis(ir2vec::Vocab &&Vocab);
+  explicit IR2VecVocabAnalysis(ir2vec::Vocab Vocab);
   using Result = IR2VecVocabResult;
   Result run(Module &M, ModuleAnalysisManager &MAM);
 };
diff --git a/llvm/include/llvm/Analysis/InlineAdvisor.h 
b/llvm/include/llvm/Analysis/InlineAdvisor.h
index 9d15136e81d10..d2cad4717cbdb 100644
--- a/llvm/include/llvm/Analysis/InlineAdvisor.h
+++ b/llvm/include/llvm/Analysis/InlineAdvisor.h
@@ -331,6 +331,9 @@ class InlineAdvisorAnalysis : public 
AnalysisInfoMixin {
   };
 
   Result run(Module &M, ModuleAnalysisManager &MAM) { return Result(M, MAM); }
+
+private:
+  static bool initializeIR2VecVocab(Module &M, ModuleAnalysisManager &MAM);
 };
 
 /// Printer pass for the InlineAdvisorAnalysis results.
diff --git a/llvm/include/llvm/Analysis/InlineModelFeatureMaps.h 
b/llvm/include/llvm/Analysis/InlineModelFeatureMaps.h
index 961d5091bf9f3..91d3378565fc5 100644
--- a/llvm/include/llvm/Analysis/InlineModelFeatureMaps.h
+++ b/llvm/include/llvm/Analysis/InlineModelFeatureMaps.h
@@ -142,6 +142,10 @@ enum class FeatureIndex : size_t {
   INLINE_FEATURE_ITERATOR(POPULATE_INDICES)
 #undef POPULATE_INDICES
 
+// IR2Vec embeddings
+  callee_embedding,
+  caller_embedding,
+
   NumberOfFeatures
 };
 // clang-format on
@@ -154,7 +158,7 @@ inlineCostFeatureToMlFeature(InlineCos

[llvm-branch-commits] [llvm] [MLIniner][IR2Vec] Integrating IR2Vec with MLInliner (PR #143479)

2025-06-09 Thread S. VenkataKeerthy via llvm-branch-commits

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

* **#143479** https://app.graphite.dev/github/pr/llvm/llvm-project/143479?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/143479?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#143476** https://app.graphite.dev/github/pr/llvm/llvm-project/143476?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#143200** https://app.graphite.dev/github/pr/llvm/llvm-project/143200?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#143197** https://app.graphite.dev/github/pr/llvm/llvm-project/143197?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/143479
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [CI] Refactor out some early exits in compute_projects (PR #143478)

2025-06-09 Thread Aiden Grossman via llvm-branch-commits

https://github.com/boomanaiden154 created 
https://github.com/llvm/llvm-project/pull/143478

I have a habit of using early exits given it is in the LLVM coding
standards, but most of the early exits used within this script were
trivial and actually adding complexity. These are all instances where we
only perform one operation after the early exit, so removing the early
exit means less lines of code and arguably more readable code.



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [CI] Cleanup buildkite test report script (PR #143480)

2025-06-09 Thread Aiden Grossman via llvm-branch-commits

https://github.com/boomanaiden154 created 
https://github.com/llvm/llvm-project/pull/143480

This patch removes the generate_test_report_buildkite script entrypoint
as we no longer need it now that buildkite has been sunsetted. Also
remove the calls in the monolithic-* scripts given they are adding
complexity for no value.



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [IR2Vec] Consider only reachable BBs and non-debug instructions (PR #143476)

2025-06-09 Thread S. VenkataKeerthy via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [CI] Cleanup buildkite test report script (PR #143480)

2025-06-09 Thread Aiden Grossman via llvm-branch-commits

https://github.com/boomanaiden154 updated 
https://github.com/llvm/llvm-project/pull/143480

>From 4a2932807356182b03566460492a2dc17c023a85 Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Mon, 9 Jun 2025 22:45:18 -0700
Subject: [PATCH] update

Created using spr 1.3.6
---
 .ci/generate-buildkite-pipeline-premerge | 131 ---
 1 file changed, 131 deletions(-)
 delete mode 100755 .ci/generate-buildkite-pipeline-premerge

diff --git a/.ci/generate-buildkite-pipeline-premerge 
b/.ci/generate-buildkite-pipeline-premerge
deleted file mode 100755
index 5e5f916f35b72..0
--- a/.ci/generate-buildkite-pipeline-premerge
+++ /dev/null
@@ -1,131 +0,0 @@
-#!/usr/bin/env bash
-#===--===##
-#
-# 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 generates a Buildkite pipeline that triggers the various CI jobs 
for
-# the LLVM project during pre-commit CI.
-#
-# See https://buildkite.com/docs/agent/v3/cli-pipeline#pipeline-format.
-#
-# As this outputs a yaml file, it's possible to log messages to stderr or
-# prefix with "#".
-
-
-set -eu
-set -o pipefail
-
-# Environment variables script works with:
-
-# Set by buildkite
-: ${BUILDKITE_PULL_REQUEST_BASE_BRANCH:=}
-: ${BUILDKITE_COMMIT:=}
-: ${BUILDKITE_BRANCH:=}
-# Fetch origin to have an up to date merge base for the diff.
-git fetch origin
-# List of files affected by this commit
-: ${MODIFIED_FILES:=$(git diff --name-only 
origin/${BUILDKITE_PULL_REQUEST_BASE_BRANCH}...HEAD)}
-# Filter rules for generic windows tests
-: ${WINDOWS_AGENTS:='{"queue": "windows"}'}
-# Filter rules for generic linux tests
-: ${LINUX_AGENTS:='{"queue": "linux"}'}
-
-reviewID="$(git log --format=%B -n 1 | sed -nE 
's/^Review-ID:[[:space:]]*(.+)$/\1/p')"
-if [[ "${reviewID}" != "" ]]; then
-  buildMessage="https://llvm.org/${reviewID}";
-else
-  buildMessage="Push to branch ${BUILDKITE_BRANCH}"
-fi
-
-cat <&2
-echo "$MODIFIED_FILES" >&2
-modified_dirs=$(echo "$MODIFIED_FILES" | cut -d'/' -f1 | sort -u)
-echo "Directories modified:" >&2
-echo "$modified_dirs" >&2
-
-# Project specific pipelines.
-
-# If libc++ or one of the runtimes directories changed.
-if echo "$modified_dirs" | grep -q -E 
"^(libcxx|libcxxabi|libunwind|runtimes|cmake)$"; then
-  cat 

[llvm-branch-commits] [llvm] [IR2Vec] Consider only reachable BBs and non-debug instructions (PR #143476)

2025-06-09 Thread S. VenkataKeerthy via llvm-branch-commits

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


[llvm-branch-commits] [CI] Use Github Native Groups in monolithic-* scripts (PR #143481)

2025-06-09 Thread Aiden Grossman via llvm-branch-commits

https://github.com/boomanaiden154 created 
https://github.com/llvm/llvm-project/pull/143481

This patch updates monolithic-linux.sh and monolithic-windows.sh to emit
expandable groups in the Github logs. The syntax this replaces
originally worked to produce the same functionality on Buildkite, but
Github uses a different syntax.

https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#grouping-log-lines



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [IR2Vec] Minor vocab changes and exposing weights (PR #143200)

2025-06-09 Thread S. VenkataKeerthy via llvm-branch-commits

https://github.com/svkeerthy updated 
https://github.com/llvm/llvm-project/pull/143200

>From 750cb2f730cb1f8d38fc29fa63b92efd53b82eac Mon Sep 17 00:00:00 2001
From: svkeerthy 
Date: Fri, 6 Jun 2025 20:32:32 +
Subject: [PATCH] Vocab changes1

---
 llvm/include/llvm/Analysis/IR2Vec.h|  10 ++
 llvm/lib/Analysis/IR2Vec.cpp   |  78 +-
 llvm/unittests/Analysis/IR2VecTest.cpp | 137 ++---
 3 files changed, 163 insertions(+), 62 deletions(-)

diff --git a/llvm/include/llvm/Analysis/IR2Vec.h 
b/llvm/include/llvm/Analysis/IR2Vec.h
index 05f87e311d8a2..953b630d98c2b 100644
--- a/llvm/include/llvm/Analysis/IR2Vec.h
+++ b/llvm/include/llvm/Analysis/IR2Vec.h
@@ -31,7 +31,9 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/JSON.h"
 #include 
 
 namespace llvm {
@@ -43,6 +45,7 @@ class Function;
 class Type;
 class Value;
 class raw_ostream;
+class LLVMContext;
 
 /// IR2Vec computes two kinds of embeddings: Symbolic and Flow-aware.
 /// Symbolic embeddings capture the "syntactic" and "statistical correlation"
@@ -53,6 +56,11 @@ class raw_ostream;
 enum class IR2VecKind { Symbolic };
 
 namespace ir2vec {
+
+LLVM_ABI extern cl::opt OpcWeight;
+LLVM_ABI extern cl::opt TypeWeight;
+LLVM_ABI extern cl::opt ArgWeight;
+
 /// Embedding is a ADT that wraps std::vector. It provides
 /// additional functionality for arithmetic and comparison operations.
 struct Embedding : public std::vector {
@@ -187,10 +195,12 @@ class IR2VecVocabResult {
 class IR2VecVocabAnalysis : public AnalysisInfoMixin {
   ir2vec::Vocab Vocabulary;
   Error readVocabulary();
+  void emitError(Error Err, LLVMContext &Ctx);
 
 public:
   static AnalysisKey Key;
   IR2VecVocabAnalysis() = default;
+  explicit IR2VecVocabAnalysis(ir2vec::Vocab &&Vocab);
   using Result = IR2VecVocabResult;
   Result run(Module &M, ModuleAnalysisManager &MAM);
 };
diff --git a/llvm/lib/Analysis/IR2Vec.cpp b/llvm/lib/Analysis/IR2Vec.cpp
index 74f2c4f34644a..0bc3a68448ead 100644
--- a/llvm/lib/Analysis/IR2Vec.cpp
+++ b/llvm/lib/Analysis/IR2Vec.cpp
@@ -16,13 +16,11 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
-#include "llvm/Support/JSON.h"
 #include "llvm/Support/MemoryBuffer.h"
 
 using namespace llvm;
@@ -33,6 +31,8 @@ using namespace ir2vec;
 STATISTIC(VocabMissCounter,
   "Number of lookups to entites not present in the vocabulary");
 
+namespace llvm {
+namespace ir2vec {
 static cl::OptionCategory IR2VecCategory("IR2Vec Options");
 
 // FIXME: Use a default vocab when not specified
@@ -40,18 +40,20 @@ static cl::opt
 VocabFile("ir2vec-vocab-path", cl::Optional,
   cl::desc("Path to the vocabulary file for IR2Vec"), cl::init(""),
   cl::cat(IR2VecCategory));
-static cl::opt OpcWeight("ir2vec-opc-weight", cl::Optional,
-cl::init(1.0),
-cl::desc("Weight for opcode embeddings"),
-cl::cat(IR2VecCategory));
-static cl::opt TypeWeight("ir2vec-type-weight", cl::Optional,
- cl::init(0.5),
- cl::desc("Weight for type embeddings"),
- cl::cat(IR2VecCategory));
-static cl::opt ArgWeight("ir2vec-arg-weight", cl::Optional,
-cl::init(0.2),
-cl::desc("Weight for argument embeddings"),
-cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt OpcWeight("ir2vec-opc-weight", cl::Optional,
+  cl::init(1.0),
+  cl::desc("Weight for opcode embeddings"),
+  cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt TypeWeight("ir2vec-type-weight", cl::Optional,
+   cl::init(0.5),
+   cl::desc("Weight for type embeddings"),
+   cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt ArgWeight("ir2vec-arg-weight", cl::Optional,
+  cl::init(0.2),
+  cl::desc("Weight for argument embeddings"),
+  cl::cat(IR2VecCategory));
+} // namespace ir2vec
+} // namespace llvm
 
 AnalysisKey IR2VecVocabAnalysis::Key;
 
@@ -254,35 +256,57 @@ Error IR2VecVocabAnalysis::readVocabulary() {
 return createStringError(errc::illegal_byte_sequence,
  "Unable to parse the vocabulary");
   }
-  assert(Vocabulary.size() > 0 && "Vocabulary is empty");
+
+  if (Vocabulary.empty()) {
+return createString

[llvm-branch-commits] [llvm] [IR2Vec] Minor vocab changes and exposing weights (PR #143200)

2025-06-09 Thread S. VenkataKeerthy via llvm-branch-commits

https://github.com/svkeerthy updated 
https://github.com/llvm/llvm-project/pull/143200

>From 750cb2f730cb1f8d38fc29fa63b92efd53b82eac Mon Sep 17 00:00:00 2001
From: svkeerthy 
Date: Fri, 6 Jun 2025 20:32:32 +
Subject: [PATCH] Vocab changes1

---
 llvm/include/llvm/Analysis/IR2Vec.h|  10 ++
 llvm/lib/Analysis/IR2Vec.cpp   |  78 +-
 llvm/unittests/Analysis/IR2VecTest.cpp | 137 ++---
 3 files changed, 163 insertions(+), 62 deletions(-)

diff --git a/llvm/include/llvm/Analysis/IR2Vec.h 
b/llvm/include/llvm/Analysis/IR2Vec.h
index 05f87e311d8a2..953b630d98c2b 100644
--- a/llvm/include/llvm/Analysis/IR2Vec.h
+++ b/llvm/include/llvm/Analysis/IR2Vec.h
@@ -31,7 +31,9 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/JSON.h"
 #include 
 
 namespace llvm {
@@ -43,6 +45,7 @@ class Function;
 class Type;
 class Value;
 class raw_ostream;
+class LLVMContext;
 
 /// IR2Vec computes two kinds of embeddings: Symbolic and Flow-aware.
 /// Symbolic embeddings capture the "syntactic" and "statistical correlation"
@@ -53,6 +56,11 @@ class raw_ostream;
 enum class IR2VecKind { Symbolic };
 
 namespace ir2vec {
+
+LLVM_ABI extern cl::opt OpcWeight;
+LLVM_ABI extern cl::opt TypeWeight;
+LLVM_ABI extern cl::opt ArgWeight;
+
 /// Embedding is a ADT that wraps std::vector. It provides
 /// additional functionality for arithmetic and comparison operations.
 struct Embedding : public std::vector {
@@ -187,10 +195,12 @@ class IR2VecVocabResult {
 class IR2VecVocabAnalysis : public AnalysisInfoMixin {
   ir2vec::Vocab Vocabulary;
   Error readVocabulary();
+  void emitError(Error Err, LLVMContext &Ctx);
 
 public:
   static AnalysisKey Key;
   IR2VecVocabAnalysis() = default;
+  explicit IR2VecVocabAnalysis(ir2vec::Vocab &&Vocab);
   using Result = IR2VecVocabResult;
   Result run(Module &M, ModuleAnalysisManager &MAM);
 };
diff --git a/llvm/lib/Analysis/IR2Vec.cpp b/llvm/lib/Analysis/IR2Vec.cpp
index 74f2c4f34644a..0bc3a68448ead 100644
--- a/llvm/lib/Analysis/IR2Vec.cpp
+++ b/llvm/lib/Analysis/IR2Vec.cpp
@@ -16,13 +16,11 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
-#include "llvm/Support/JSON.h"
 #include "llvm/Support/MemoryBuffer.h"
 
 using namespace llvm;
@@ -33,6 +31,8 @@ using namespace ir2vec;
 STATISTIC(VocabMissCounter,
   "Number of lookups to entites not present in the vocabulary");
 
+namespace llvm {
+namespace ir2vec {
 static cl::OptionCategory IR2VecCategory("IR2Vec Options");
 
 // FIXME: Use a default vocab when not specified
@@ -40,18 +40,20 @@ static cl::opt
 VocabFile("ir2vec-vocab-path", cl::Optional,
   cl::desc("Path to the vocabulary file for IR2Vec"), cl::init(""),
   cl::cat(IR2VecCategory));
-static cl::opt OpcWeight("ir2vec-opc-weight", cl::Optional,
-cl::init(1.0),
-cl::desc("Weight for opcode embeddings"),
-cl::cat(IR2VecCategory));
-static cl::opt TypeWeight("ir2vec-type-weight", cl::Optional,
- cl::init(0.5),
- cl::desc("Weight for type embeddings"),
- cl::cat(IR2VecCategory));
-static cl::opt ArgWeight("ir2vec-arg-weight", cl::Optional,
-cl::init(0.2),
-cl::desc("Weight for argument embeddings"),
-cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt OpcWeight("ir2vec-opc-weight", cl::Optional,
+  cl::init(1.0),
+  cl::desc("Weight for opcode embeddings"),
+  cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt TypeWeight("ir2vec-type-weight", cl::Optional,
+   cl::init(0.5),
+   cl::desc("Weight for type embeddings"),
+   cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt ArgWeight("ir2vec-arg-weight", cl::Optional,
+  cl::init(0.2),
+  cl::desc("Weight for argument embeddings"),
+  cl::cat(IR2VecCategory));
+} // namespace ir2vec
+} // namespace llvm
 
 AnalysisKey IR2VecVocabAnalysis::Key;
 
@@ -254,35 +256,57 @@ Error IR2VecVocabAnalysis::readVocabulary() {
 return createStringError(errc::illegal_byte_sequence,
  "Unable to parse the vocabulary");
   }
-  assert(Vocabulary.size() > 0 && "Vocabulary is empty");
+
+  if (Vocabulary.empty()) {
+return createString

[llvm-branch-commits] [llvm] [IR2Vec] Minor vocab changes and exposing weights (PR #143200)

2025-06-09 Thread S. VenkataKeerthy via llvm-branch-commits


@@ -83,9 +85,10 @@ void Embedding::scaleAndAdd(const Embedding &Src, float 
Factor) {
 bool Embedding::approximatelyEquals(const Embedding &RHS,
 double Tolerance) const {
   assert(this->size() == RHS.size() && "Vectors must have the same dimension");
-  for (size_t i = 0; i < this->size(); ++i)
+  for (size_t i = 0; i < this->size(); ++i) {

svkeerthy wrote:

Yes, done

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


[llvm-branch-commits] [llvm] [IR2Vec] Minor vocab changes and exposing weights (PR #143200)

2025-06-09 Thread S. VenkataKeerthy via llvm-branch-commits

https://github.com/svkeerthy updated 
https://github.com/llvm/llvm-project/pull/143200

>From c1842ec938d27261a0b18bc9bcbb20328713f20a Mon Sep 17 00:00:00 2001
From: svkeerthy 
Date: Fri, 6 Jun 2025 20:32:32 +
Subject: [PATCH] Vocab changes1

---
 llvm/include/llvm/Analysis/IR2Vec.h|  10 ++
 llvm/lib/Analysis/IR2Vec.cpp   |  82 +--
 llvm/unittests/Analysis/IR2VecTest.cpp | 137 ++---
 3 files changed, 163 insertions(+), 66 deletions(-)

diff --git a/llvm/include/llvm/Analysis/IR2Vec.h 
b/llvm/include/llvm/Analysis/IR2Vec.h
index 05f87e311d8a2..953b630d98c2b 100644
--- a/llvm/include/llvm/Analysis/IR2Vec.h
+++ b/llvm/include/llvm/Analysis/IR2Vec.h
@@ -31,7 +31,9 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/JSON.h"
 #include 
 
 namespace llvm {
@@ -43,6 +45,7 @@ class Function;
 class Type;
 class Value;
 class raw_ostream;
+class LLVMContext;
 
 /// IR2Vec computes two kinds of embeddings: Symbolic and Flow-aware.
 /// Symbolic embeddings capture the "syntactic" and "statistical correlation"
@@ -53,6 +56,11 @@ class raw_ostream;
 enum class IR2VecKind { Symbolic };
 
 namespace ir2vec {
+
+LLVM_ABI extern cl::opt OpcWeight;
+LLVM_ABI extern cl::opt TypeWeight;
+LLVM_ABI extern cl::opt ArgWeight;
+
 /// Embedding is a ADT that wraps std::vector. It provides
 /// additional functionality for arithmetic and comparison operations.
 struct Embedding : public std::vector {
@@ -187,10 +195,12 @@ class IR2VecVocabResult {
 class IR2VecVocabAnalysis : public AnalysisInfoMixin {
   ir2vec::Vocab Vocabulary;
   Error readVocabulary();
+  void emitError(Error Err, LLVMContext &Ctx);
 
 public:
   static AnalysisKey Key;
   IR2VecVocabAnalysis() = default;
+  explicit IR2VecVocabAnalysis(ir2vec::Vocab &&Vocab);
   using Result = IR2VecVocabResult;
   Result run(Module &M, ModuleAnalysisManager &MAM);
 };
diff --git a/llvm/lib/Analysis/IR2Vec.cpp b/llvm/lib/Analysis/IR2Vec.cpp
index 74f2c4f34644a..d6c7d6524c61d 100644
--- a/llvm/lib/Analysis/IR2Vec.cpp
+++ b/llvm/lib/Analysis/IR2Vec.cpp
@@ -16,13 +16,11 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
-#include "llvm/Support/JSON.h"
 #include "llvm/Support/MemoryBuffer.h"
 
 using namespace llvm;
@@ -33,6 +31,8 @@ using namespace ir2vec;
 STATISTIC(VocabMissCounter,
   "Number of lookups to entites not present in the vocabulary");
 
+namespace llvm {
+namespace ir2vec {
 static cl::OptionCategory IR2VecCategory("IR2Vec Options");
 
 // FIXME: Use a default vocab when not specified
@@ -40,18 +40,20 @@ static cl::opt
 VocabFile("ir2vec-vocab-path", cl::Optional,
   cl::desc("Path to the vocabulary file for IR2Vec"), cl::init(""),
   cl::cat(IR2VecCategory));
-static cl::opt OpcWeight("ir2vec-opc-weight", cl::Optional,
-cl::init(1.0),
-cl::desc("Weight for opcode embeddings"),
-cl::cat(IR2VecCategory));
-static cl::opt TypeWeight("ir2vec-type-weight", cl::Optional,
- cl::init(0.5),
- cl::desc("Weight for type embeddings"),
- cl::cat(IR2VecCategory));
-static cl::opt ArgWeight("ir2vec-arg-weight", cl::Optional,
-cl::init(0.2),
-cl::desc("Weight for argument embeddings"),
-cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt OpcWeight("ir2vec-opc-weight", cl::Optional,
+  cl::init(1.0),
+  cl::desc("Weight for opcode embeddings"),
+  cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt TypeWeight("ir2vec-type-weight", cl::Optional,
+   cl::init(0.5),
+   cl::desc("Weight for type embeddings"),
+   cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt ArgWeight("ir2vec-arg-weight", cl::Optional,
+  cl::init(0.2),
+  cl::desc("Weight for argument embeddings"),
+  cl::cat(IR2VecCategory));
+} // namespace ir2vec
+} // namespace llvm
 
 AnalysisKey IR2VecVocabAnalysis::Key;
 
@@ -240,9 +242,9 @@ bool IR2VecVocabResult::invalidate(
 // by auto-generating a default vocabulary during the build time.
 Error IR2VecVocabAnalysis::readVocabulary() {
   auto BufOrError = MemoryBuffer::getFileOrSTDIN(VocabFile, /*IsText=*/true);
-  if (!BufOrError) {
+  if (!BufOrError)
 return createF

[llvm-branch-commits] [llvm] [DirectX] Add static sampler support to root signature and fix descriptor range flags (PR #143422)

2025-06-09 Thread via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [DirectX] Add static sampler support to root signature and fix descriptor range flags (PR #143422)

2025-06-09 Thread via llvm-branch-commits

https://github.com/joaosaffran created 
https://github.com/llvm/llvm-project/pull/143422

This patch introduces the following changes to the DirectX container 
implementation:

1. Add static sampler support to root signatures:
   - Implement parsing and validation of static sampler parameters
   - Add verification for sampler attributes (filter, addressing, LOD, etc.)
   - Update root signature writing to handle static samplers
   - Add test coverage for static sampler validation

Testing:
- Added new test files for static sampler validation
- Added tests for all possible invalid sampler parameters
- Existing root signature tests continue to pass

>From 26c7ccab57c53cffd545277555f131fae50520d9 Mon Sep 17 00:00:00 2001
From: joaosaffran 
Date: Wed, 4 Jun 2025 21:42:20 +
Subject: [PATCH 1/5] adding metadata support for static samplers

---
 llvm/lib/MC/DXContainerRootSignature.cpp  | 42 +
 llvm/lib/Target/DirectX/DXILRootSignature.cpp | 89 +++
 llvm/lib/Target/DirectX/DXILRootSignature.h   |  1 +
 .../RootSignature-StaticSamplers.ll   | 42 +
 4 files changed, 157 insertions(+), 17 deletions(-)
 create mode 100644 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers.ll

diff --git a/llvm/lib/MC/DXContainerRootSignature.cpp 
b/llvm/lib/MC/DXContainerRootSignature.cpp
index 6c71823a51f85..d67babf13a432 100644
--- a/llvm/lib/MC/DXContainerRootSignature.cpp
+++ b/llvm/lib/MC/DXContainerRootSignature.cpp
@@ -9,6 +9,7 @@
 #include "llvm/MC/DXContainerRootSignature.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/EndianStream.h"
+#include 
 
 using namespace llvm;
 using namespace llvm::mcdxbc;
@@ -71,12 +72,16 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
   BOS.reserveExtraSpace(getSize());
 
   const uint32_t NumParameters = ParametersContainer.size();
-
+  const uint32_t NumSamplers = StaticSamplers.size();
   support::endian::write(BOS, Version, llvm::endianness::little);
   support::endian::write(BOS, NumParameters, llvm::endianness::little);
   support::endian::write(BOS, RootParameterOffset, llvm::endianness::little);
-  support::endian::write(BOS, NumStaticSamplers, llvm::endianness::little);
-  support::endian::write(BOS, StaticSamplersOffset, llvm::endianness::little);
+  support::endian::write(BOS, NumSamplers, llvm::endianness::little);
+  uint32_t SSO = StaticSamplersOffset;
+  if (NumSamplers > 0)
+SSO = writePlaceholder(BOS);
+  else
+support::endian::write(BOS, SSO, llvm::endianness::little);
   support::endian::write(BOS, Flags, llvm::endianness::little);
 
   SmallVector ParamsOffsets;
@@ -142,20 +147,23 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
 }
 }
   }
-  for (const auto &S : StaticSamplers) {
-support::endian::write(BOS, S.Filter, llvm::endianness::little);
-support::endian::write(BOS, S.AddressU, llvm::endianness::little);
-support::endian::write(BOS, S.AddressV, llvm::endianness::little);
-support::endian::write(BOS, S.AddressW, llvm::endianness::little);
-support::endian::write(BOS, S.MipLODBias, llvm::endianness::little);
-support::endian::write(BOS, S.MaxAnisotropy, llvm::endianness::little);
-support::endian::write(BOS, S.ComparisonFunc, llvm::endianness::little);
-support::endian::write(BOS, S.BorderColor, llvm::endianness::little);
-support::endian::write(BOS, S.MinLOD, llvm::endianness::little);
-support::endian::write(BOS, S.MaxLOD, llvm::endianness::little);
-support::endian::write(BOS, S.ShaderRegister, llvm::endianness::little);
-support::endian::write(BOS, S.RegisterSpace, llvm::endianness::little);
-support::endian::write(BOS, S.ShaderVisibility, llvm::endianness::little);
+  if (NumSamplers > 0) {
+rewriteOffsetToCurrentByte(BOS, SSO);
+for (const auto &S : StaticSamplers) {
+  support::endian::write(BOS, S.Filter, llvm::endianness::little);
+  support::endian::write(BOS, S.AddressU, llvm::endianness::little);
+  support::endian::write(BOS, S.AddressV, llvm::endianness::little);
+  support::endian::write(BOS, S.AddressW, llvm::endianness::little);
+  support::endian::write(BOS, S.MipLODBias, llvm::endianness::little);
+  support::endian::write(BOS, S.MaxAnisotropy, llvm::endianness::little);
+  support::endian::write(BOS, S.ComparisonFunc, llvm::endianness::little);
+  support::endian::write(BOS, S.BorderColor, llvm::endianness::little);
+  support::endian::write(BOS, S.MinLOD, llvm::endianness::little);
+  support::endian::write(BOS, S.MaxLOD, llvm::endianness::little);
+  support::endian::write(BOS, S.ShaderRegister, llvm::endianness::little);
+  support::endian::write(BOS, S.RegisterSpace, llvm::endianness::little);
+  support::endian::write(BOS, S.ShaderVisibility, 
llvm::endianness::little);
+}
   }
   assert(Storage.size() == getSize());
   OS.write(Storage.data(), Storage.size());
diff --git a/llvm/lib/Target/DirectX/DXILRootSignature.

[llvm-branch-commits] [llvm] release/20.x: [AArch64][SME] Fix accessing the emergency spill slot with hazard padding (#142190) (PR #142741)

2025-06-09 Thread Eli Friedman via llvm-branch-commits

https://github.com/efriedma-quic approved this pull request.

LGTM

I think this makes sense for the branch: it fixes a miscompile with hazard 
padding, and it's clearly a no-op if hazard padding is disabled.

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


[llvm-branch-commits] [llvm] [DirectX] Add static sampler support to root signature and fix descriptor range flags (PR #143422)

2025-06-09 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-mc

Author: None (joaosaffran)


Changes

This patch introduces the following changes to the DirectX container 
implementation:

1. Add static sampler support to root signatures:
   - Implement parsing and validation of static sampler parameters
   - Add verification for sampler attributes (filter, addressing, LOD, etc.)
   - Update root signature writing to handle static samplers
   - Add test coverage for static sampler validation

Testing:
- Added new test files for static sampler validation
- Added tests for all possible invalid sampler parameters
- Existing root signature tests continue to pass

---

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


17 Files Affected:

- (modified) llvm/lib/MC/DXContainerRootSignature.cpp (+24-17) 
- (modified) llvm/lib/Target/DirectX/DXILRootSignature.cpp (+253) 
- (modified) llvm/lib/Target/DirectX/DXILRootSignature.h (+1) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-AddressU.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-AddressV.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-AddressW.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-BorderColor.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-ComparisonFunc.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-Filter.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-MaxAnisotropy.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-MaxLod.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-MinLod.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-MinLopBias.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-RegisterSpace.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-ShaderRegister.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-ShaderVisibility.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers.ll (+42) 


``diff
diff --git a/llvm/lib/MC/DXContainerRootSignature.cpp 
b/llvm/lib/MC/DXContainerRootSignature.cpp
index 6c71823a51f85..77d648a739b87 100644
--- a/llvm/lib/MC/DXContainerRootSignature.cpp
+++ b/llvm/lib/MC/DXContainerRootSignature.cpp
@@ -71,12 +71,16 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
   BOS.reserveExtraSpace(getSize());
 
   const uint32_t NumParameters = ParametersContainer.size();
-
+  const uint32_t NumSamplers = StaticSamplers.size();
   support::endian::write(BOS, Version, llvm::endianness::little);
   support::endian::write(BOS, NumParameters, llvm::endianness::little);
   support::endian::write(BOS, RootParameterOffset, llvm::endianness::little);
-  support::endian::write(BOS, NumStaticSamplers, llvm::endianness::little);
-  support::endian::write(BOS, StaticSamplersOffset, llvm::endianness::little);
+  support::endian::write(BOS, NumSamplers, llvm::endianness::little);
+  uint32_t SSO = StaticSamplersOffset;
+  if (NumSamplers > 0)
+SSO = writePlaceholder(BOS);
+  else
+support::endian::write(BOS, SSO, llvm::endianness::little);
   support::endian::write(BOS, Flags, llvm::endianness::little);
 
   SmallVector ParamsOffsets;
@@ -142,20 +146,23 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
 }
 }
   }
-  for (const auto &S : StaticSamplers) {
-support::endian::write(BOS, S.Filter, llvm::endianness::little);
-support::endian::write(BOS, S.AddressU, llvm::endianness::little);
-support::endian::write(BOS, S.AddressV, llvm::endianness::little);
-support::endian::write(BOS, S.AddressW, llvm::endianness::little);
-support::endian::write(BOS, S.MipLODBias, llvm::endianness::little);
-support::endian::write(BOS, S.MaxAnisotropy, llvm::endianness::little);
-support::endian::write(BOS, S.ComparisonFunc, llvm::endianness::little);
-support::endian::write(BOS, S.BorderColor, llvm::endianness::little);
-support::endian::write(BOS, S.MinLOD, llvm::endianness::little);
-support::endian::write(BOS, S.MaxLOD, llvm::endianness::little);
-support::endian::write(BOS, S.ShaderRegister, llvm::endianness::little);
-support::endian::write(BOS, S.RegisterSpace, llvm::endianness::little);
-support::endian::write(BOS, S.ShaderVisibility, llvm::endianness::little);
+  if (NumSamplers > 0) {
+rewriteOffsetToCurrentByte(BOS, SSO);
+for (const auto &S : StaticSamplers) {
+  support::endian::write(BOS, S.Filter, llvm::endianness::little);

[llvm-branch-commits] [llvm] [DirectX] Add static sampler support to root signature and fix descriptor range flags (PR #143422)

2025-06-09 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-directx

Author: None (joaosaffran)


Changes

This patch introduces the following changes to the DirectX container 
implementation:

1. Add static sampler support to root signatures:
   - Implement parsing and validation of static sampler parameters
   - Add verification for sampler attributes (filter, addressing, LOD, etc.)
   - Update root signature writing to handle static samplers
   - Add test coverage for static sampler validation

Testing:
- Added new test files for static sampler validation
- Added tests for all possible invalid sampler parameters
- Existing root signature tests continue to pass

---

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


17 Files Affected:

- (modified) llvm/lib/MC/DXContainerRootSignature.cpp (+24-17) 
- (modified) llvm/lib/Target/DirectX/DXILRootSignature.cpp (+253) 
- (modified) llvm/lib/Target/DirectX/DXILRootSignature.h (+1) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-AddressU.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-AddressV.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-AddressW.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-BorderColor.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-ComparisonFunc.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-Filter.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-MaxAnisotropy.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-MaxLod.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-MinLod.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-MinLopBias.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-RegisterSpace.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-ShaderRegister.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-ShaderVisibility.ll
 (+19) 
- (added) 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers.ll (+42) 


``diff
diff --git a/llvm/lib/MC/DXContainerRootSignature.cpp 
b/llvm/lib/MC/DXContainerRootSignature.cpp
index 6c71823a51f85..77d648a739b87 100644
--- a/llvm/lib/MC/DXContainerRootSignature.cpp
+++ b/llvm/lib/MC/DXContainerRootSignature.cpp
@@ -71,12 +71,16 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
   BOS.reserveExtraSpace(getSize());
 
   const uint32_t NumParameters = ParametersContainer.size();
-
+  const uint32_t NumSamplers = StaticSamplers.size();
   support::endian::write(BOS, Version, llvm::endianness::little);
   support::endian::write(BOS, NumParameters, llvm::endianness::little);
   support::endian::write(BOS, RootParameterOffset, llvm::endianness::little);
-  support::endian::write(BOS, NumStaticSamplers, llvm::endianness::little);
-  support::endian::write(BOS, StaticSamplersOffset, llvm::endianness::little);
+  support::endian::write(BOS, NumSamplers, llvm::endianness::little);
+  uint32_t SSO = StaticSamplersOffset;
+  if (NumSamplers > 0)
+SSO = writePlaceholder(BOS);
+  else
+support::endian::write(BOS, SSO, llvm::endianness::little);
   support::endian::write(BOS, Flags, llvm::endianness::little);
 
   SmallVector ParamsOffsets;
@@ -142,20 +146,23 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
 }
 }
   }
-  for (const auto &S : StaticSamplers) {
-support::endian::write(BOS, S.Filter, llvm::endianness::little);
-support::endian::write(BOS, S.AddressU, llvm::endianness::little);
-support::endian::write(BOS, S.AddressV, llvm::endianness::little);
-support::endian::write(BOS, S.AddressW, llvm::endianness::little);
-support::endian::write(BOS, S.MipLODBias, llvm::endianness::little);
-support::endian::write(BOS, S.MaxAnisotropy, llvm::endianness::little);
-support::endian::write(BOS, S.ComparisonFunc, llvm::endianness::little);
-support::endian::write(BOS, S.BorderColor, llvm::endianness::little);
-support::endian::write(BOS, S.MinLOD, llvm::endianness::little);
-support::endian::write(BOS, S.MaxLOD, llvm::endianness::little);
-support::endian::write(BOS, S.ShaderRegister, llvm::endianness::little);
-support::endian::write(BOS, S.RegisterSpace, llvm::endianness::little);
-support::endian::write(BOS, S.ShaderVisibility, llvm::endianness::little);
+  if (NumSamplers > 0) {
+rewriteOffsetToCurrentByte(BOS, SSO);
+for (const auto &S : StaticSamplers) {
+  support::endian::write(BOS, S.Filter, llvm::endianne

[llvm-branch-commits] [llvm] [AMDGPU] Autogenerate dst bytesel asm. NFCI. (PR #143429)

2025-06-09 Thread Stanislav Mekhanoshin via llvm-branch-commits

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

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


[llvm-branch-commits] [llvm] [AMDGPU] Autogenerate dst bytesel asm. NFCI. (PR #143429)

2025-06-09 Thread Stanislav Mekhanoshin via llvm-branch-commits

https://github.com/rampitec created 
https://github.com/llvm/llvm-project/pull/143429

Needed for future t16 support.

>From 3c462dc48271923cf466e0e0c2c86f26bb69eb11 Mon Sep 17 00:00:00 2001
From: Stanislav Mekhanoshin 
Date: Mon, 9 Jun 2025 11:53:11 -0700
Subject: [PATCH] [AMDGPU] Autogenerate dst bytesel asm. NFCI.

Needed for future t16 support.
---
 llvm/lib/Target/AMDGPU/SIInstrInfo.td  | 18 --
 llvm/lib/Target/AMDGPU/VOP3Instructions.td |  2 ++
 llvm/lib/Target/AMDGPU/VOPInstructions.td  |  9 +
 3 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.td 
b/llvm/lib/Target/AMDGPU/SIInstrInfo.td
index 9c1d82b50c1a5..a78440dc7a1f4 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.td
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.td
@@ -2034,11 +2034,13 @@ class getInsVOP3P  {
+   Operand Src0Mod, Operand Src1Mod, Operand Src2Mod,
+   bit HasFP8ByteSel = 0, bit HasFP8DstByteSel = 0> {
   dag ret = getInsVOP3Base.ret;
+Src0Mod, Src1Mod, Src2Mod, /*HasOpSel=*/1,
+HasFP8ByteSel, HasFP8DstByteSel>.ret;
 }
 
 class getInsDPPBase  {
+   bit Src2HasMods,
+   bit HasByteSel = 0> {
   string dst = "$vdst";
 
   string isrc0 = !if(!eq(NumSrcArgs, 1), "$src0", "$src0,");
@@ -2263,9 +2266,10 @@ class getAsmVOP3OpSel  {
@@ -2630,7 +2634,8 @@ class VOPProfile  _ArgVT, bit 
_EnableClamp = 0> {
Src0PackedMod, Src1PackedMod, 
Src2PackedMod>.ret;
   field dag InsVOP3OpSel = getInsVOP3OpSel.ret;
+Src0Mod, Src1Mod, Src2Mod,
+HasFP8ByteSel, HasFP8DstByteSel>.ret;
   field dag InsDPP = !if(HasExtDPP,
  getInsDPP.ret,
@@ -2680,7 +2685,8 @@ class VOPProfile  _ArgVT, bit 
_EnableClamp = 0> {
   HasOMod,
   HasSrc0FloatMods,
   HasSrc1FloatMods,
-  HasSrc2FloatMods>.ret;
+  HasSrc2FloatMods,
+  HasFP8ByteSel>.ret;
   field string AsmVOP3DPP = getAsmVOP3DPP.ret;
   field string AsmVOP3DPP16 = getAsmVOP3DPP16.ret;
   field string AsmVOP3DPP8 = getAsmVOP3DPP8.ret;
diff --git a/llvm/lib/Target/AMDGPU/VOP3Instructions.td 
b/llvm/lib/Target/AMDGPU/VOP3Instructions.td
index a2672d71cb43c..046cce73ff761 100644
--- a/llvm/lib/Target/AMDGPU/VOP3Instructions.td
+++ b/llvm/lib/Target/AMDGPU/VOP3Instructions.td
@@ -1055,6 +1055,7 @@ class 
VOP3_CVT_SCALE_FP4FP8BF8_F32_TiedInput_Profile : VOP3_Profil
 
 class VOP3_CVT_SCALE_FP4_F32_TiedInput_Profile : 
VOP3_CVT_SCALE_FP4FP8BF8_F32_TiedInput_Profile {
   let HasFP8DstByteSel = 1;
+  let HasFP8ByteSel = 0; // It works as a dst-bytesel, but does not have 
byte_sel operand.
 }
 
 class VOP3_CVT_SCALE_SR_F8BF8_F16BF16F32_TiedInput_Profile : 
VOP3_CVT_SCALE_FP4FP8BF8_F32_TiedInput_Profile {
@@ -1063,6 +1064,7 @@ class 
VOP3_CVT_SCALE_SR_F8BF8_F16BF16F32_TiedInput_Profile : VOP3_
   FP32InputMods:$src2_modifiers, Src2RC64:$src2,
   VGPR_32:$vdst_in, op_sel0:$op_sel);
   let HasFP8DstByteSel = 1;
+  let HasFP8ByteSel = 0; // It works as a dst-bytesel, but does not have 
byte_sel operand.
 }
 
 
diff --git a/llvm/lib/Target/AMDGPU/VOPInstructions.td 
b/llvm/lib/Target/AMDGPU/VOPInstructions.td
index 952ee2fe2c955..4cd845aaa5497 100644
--- a/llvm/lib/Target/AMDGPU/VOPInstructions.td
+++ b/llvm/lib/Target/AMDGPU/VOPInstructions.td
@@ -1478,6 +1478,9 @@ class VOP3_Profile_Base : VO
   let HasOpSel = !if(Features.HasOpSel, 1, P.HasOpSel);
   let IsMAI= !if(Features.IsMAI,1, P.IsMAI);
   let IsPacked = !if(Features.IsPacked, 1, P.IsPacked);
+  let HasFP8SrcByteSel = P.HasFP8SrcByteSel;
+  let HasFP8DstByteSel = P.HasFP8DstByteSel;
+  let HasOMod = P.HasOMod;
 
   let HasModifiers =
   !if (Features.IsMAI, 0,
@@ -1494,6 +1497,9 @@ class VOP3_Profile_True16 :
   let HasOpSel = !if(Features.HasOpSel, 1, P.HasOpSel);
   let IsMAI= !if(Features.IsMAI,1, P.IsMAI);
   let IsPacked = !if(Features.IsPacked, 1, P.IsPacked);
+  let HasFP8SrcByteSel = P.HasFP8SrcByteSel;
+  let HasFP8DstByteSel = P.HasFP8DstByteSel;
+  let HasOMod = P.HasOMod;
 
   let HasModifiers =
   !if (Features.IsMAI, 0,
@@ -1506,6 +1512,9 @@ class VOP3_Profile_Fake16 :
   let HasOpSel = !if(Features.HasOpSel, 1, P.HasOpSel);
   let IsMAI= !if(Features.IsMAI,1, P.IsMAI);
   let IsPacked = !if(Features.IsPacked, 1, P.IsPacked);
+  let HasFP8SrcByteSel = P.HasFP8SrcByteSel;
+  let HasFP8DstByteSel = P.HasFP8DstByteSel;
+  let HasOMod = P.HasOMod;
 
   let HasModifiers =
   !if (Features.IsMAI, 0,

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.ll

[llvm-branch-commits] [llvm] [AMDGPU] Autogenerate bitop3 asm and dags. NFCI. (PR #143430)

2025-06-09 Thread Stanislav Mekhanoshin via llvm-branch-commits

https://github.com/rampitec created 
https://github.com/llvm/llvm-project/pull/143430

None

>From 1d58dc465ebd0049e9f4d6b9c32b65b72b88be3e Mon Sep 17 00:00:00 2001
From: Stanislav Mekhanoshin 
Date: Mon, 9 Jun 2025 12:47:55 -0700
Subject: [PATCH] [AMDGPU] Autogenerate bitop3 asm and dags. NFCI.

---
 llvm/lib/Target/AMDGPU/SIInstrInfo.td  | 38 +-
 llvm/lib/Target/AMDGPU/VOP3Instructions.td | 13 +---
 2 files changed, 24 insertions(+), 27 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.td 
b/llvm/lib/Target/AMDGPU/SIInstrInfo.td
index a78440dc7a1f4..2c20475726a48 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.td
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.td
@@ -1973,7 +1973,8 @@ class getIns64  {
+bit HasFP8ByteSel = 0, bit HasFP8DstByteSel = 0,
+bit HasBitOp3 = 0> {
   dag src0 = !if(!ge(NumSrcArgs, 1),
  !if (HasModifiers,
   (ins Src0Mod:$src0_modifiers, Src0RC:$src0),
@@ -1999,21 +2000,23 @@ class getIns64  {
+bit HasFP8ByteSel = 0, bit HasFP8DstByteSel = 0, bit HasBitOp3 
= 0> {
   // getInst64 handles clamp and omod. implicit mutex between vop3p and omod
   dag base = getIns64 .ret;
   dag opsel = (ins op_sel0:$op_sel);
-  dag ret = !con(base, !if(HasOpSel, opsel, (ins)));
+  dag bitop3 = (ins bitop3_0:$bitop3);
+  dag ret = !con(base, !if(HasBitOp3, bitop3, (ins)), !if(HasOpSel, opsel, 
(ins)));
 }
 
 class getInsVOP3P  {
+   bit HasFP8ByteSel = 0, bit HasFP8DstByteSel = 0, bit 
HasBitOp3 = 0> {
   dag ret = getInsVOP3Base.ret;
+HasFP8ByteSel, HasFP8DstByteSel, HasBitOp3>.ret;
 }
 
 class getInsDPPBase  {
+   bit HasByteSel = 0,
+   bit HasBitOp3 = 0> {
   string dst = "$vdst";
 
   string isrc0 = !if(!eq(NumSrcArgs, 1), "$src0", "$src0,");
@@ -2269,7 +2273,8 @@ class getAsmVOP3OpSel  {
@@ -2301,7 +2306,7 @@ class getAsmVOP3Base  {
+   bit HasByteSel = 0, bit HasBitOp3 = 0> {
   string dst = !if(HasDst,
!if(!eq(DstVT.Size, 1),
"$sdst",
@@ -2324,6 +2329,7 @@ class getAsmVOP3Base  {
@@ -2558,6 +2564,7 @@ class VOPProfile  _ArgVT, bit 
_EnableClamp = 0> {
   field bit HasFP8DstByteSel = 0;
   field bit HasFP4DstByteSel = 0;
   field bit HasFP8ByteSel = !or(HasFP8SrcByteSel, HasFP8DstByteSel);
+  field bit HasBitOp3 = 0;
 
   field bit HasDst = !ne(DstVT.Value, untyped.Value);
   field bit HasDst32 = HasDst;
@@ -2628,14 +2635,14 @@ class VOPProfile  _ArgVT, bit 
_EnableClamp = 0> {
   field dag Ins64 = getIns64.ret;
+ HasFP8ByteSel, HasFP8DstByteSel, HasBitOp3>.ret;
   field dag InsVOP3P = getInsVOP3P.ret;
   field dag InsVOP3OpSel = getInsVOP3OpSel.ret;
+HasFP8ByteSel, HasFP8DstByteSel, 
HasBitOp3>.ret;
   field dag InsDPP = !if(HasExtDPP,
  getInsDPP.ret,
@@ -2648,7 +2655,7 @@ class VOPProfile  _ArgVT, bit 
_EnableClamp = 0> {
   defvar InsVOP3DPPBase = getInsVOP3Base.ret;
+  HasFP8ByteSel, HasFP8DstByteSel, HasBitOp3>.ret;
   defvar InsVOP3PDPPBase = getInsVOP3P.ret;
@@ -2677,7 +2684,7 @@ class VOPProfile  _ArgVT, bit 
_EnableClamp = 0> {
   field string AsmDPP8 = getAsmDPP8.ret;
   field string AsmVOP3Base = getAsmVOP3Base.ret;
+   HasSrc2Mods, DstVT, HasFP8ByteSel, HasBitOp3>.ret;
   field string Asm64 = AsmVOP3Base;
   field string AsmVOP3P = getAsmVOP3P.ret;
   field string AsmVOP3OpSel = getAsmVOP3OpSel _ArgVT, bit 
_EnableClamp = 0> {
   HasSrc0FloatMods,
   HasSrc1FloatMods,
   HasSrc2FloatMods,
-  HasFP8ByteSel>.ret;
+  HasFP8ByteSel,
+  HasBitOp3>.ret;
   field string AsmVOP3DPP = getAsmVOP3DPP.ret;
   field string AsmVOP3DPP16 = getAsmVOP3DPP16.ret;
   field string AsmVOP3DPP8 = getAsmVOP3DPP8.ret;
diff --git a/llvm/lib/Target/AMDGPU/VOP3Instructions.td 
b/llvm/lib/Target/AMDGPU/VOP3Instructions.td
index 046cce73ff761..ef88a379f3680 100644
--- a/llvm/lib/Target/AMDGPU/VOP3Instructions.td
+++ b/llvm/lib/Target/AMDGPU/VOP3Instructions.td
@@ -1003,18 +1003,7 @@ class VOP3_BITOP3_Profile : VOP3_Profile
   let HasClamp = 0;
   let HasOMod = 0;
   let HasModifiers = 0;
-
-  let Ins64 = !con(getIns64.ret,
-   (ins bitop3_0:$bitop3));
-
-  let InsVOP3OpSel = !con(getInsVOP3Base.ret,
-  (ins bitop3_0:$bitop3, op_sel0:$op_sel));
-
-  let Asm64 = "$vdst, $src0, $src1, $src2$bitop3";
-  let AsmVOP3OpSel = !subst("$op_sel", "$bitop3$op_sel", getAsmVOP3OpSel<3, 0, 
0, 0, 0, 0>.ret);
+  let HasBitOp3 = 1;
 }
 
 class VOP3_CVT_SCALE_F1632_FP8BF8_Profile : 
VOP3_Profile,

___
llvm-branch-commits mailing

[llvm-branch-commits] [llvm] [AMDGPU] Autogenerate dst bytesel asm. NFCI. (PR #143429)

2025-06-09 Thread Stanislav Mekhanoshin via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [AMDGPU] Autogenerate dst bytesel asm. NFCI. (PR #143429)

2025-06-09 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-amdgpu

Author: Stanislav Mekhanoshin (rampitec)


Changes

Needed for future t16 support.

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


3 Files Affected:

- (modified) llvm/lib/Target/AMDGPU/SIInstrInfo.td (+12-6) 
- (modified) llvm/lib/Target/AMDGPU/VOP3Instructions.td (+2) 
- (modified) llvm/lib/Target/AMDGPU/VOPInstructions.td (+9) 


``diff
diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.td 
b/llvm/lib/Target/AMDGPU/SIInstrInfo.td
index 9c1d82b50c1a5..a78440dc7a1f4 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.td
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.td
@@ -2034,11 +2034,13 @@ class getInsVOP3P  {
+   Operand Src0Mod, Operand Src1Mod, Operand Src2Mod,
+   bit HasFP8ByteSel = 0, bit HasFP8DstByteSel = 0> {
   dag ret = getInsVOP3Base.ret;
+Src0Mod, Src1Mod, Src2Mod, /*HasOpSel=*/1,
+HasFP8ByteSel, HasFP8DstByteSel>.ret;
 }
 
 class getInsDPPBase  {
+   bit Src2HasMods,
+   bit HasByteSel = 0> {
   string dst = "$vdst";
 
   string isrc0 = !if(!eq(NumSrcArgs, 1), "$src0", "$src0,");
@@ -2263,9 +2266,10 @@ class getAsmVOP3OpSel  {
@@ -2630,7 +2634,8 @@ class VOPProfile  _ArgVT, bit 
_EnableClamp = 0> {
Src0PackedMod, Src1PackedMod, 
Src2PackedMod>.ret;
   field dag InsVOP3OpSel = getInsVOP3OpSel.ret;
+Src0Mod, Src1Mod, Src2Mod,
+HasFP8ByteSel, HasFP8DstByteSel>.ret;
   field dag InsDPP = !if(HasExtDPP,
  getInsDPP.ret,
@@ -2680,7 +2685,8 @@ class VOPProfile  _ArgVT, bit 
_EnableClamp = 0> {
   HasOMod,
   HasSrc0FloatMods,
   HasSrc1FloatMods,
-  HasSrc2FloatMods>.ret;
+  HasSrc2FloatMods,
+  HasFP8ByteSel>.ret;
   field string AsmVOP3DPP = getAsmVOP3DPP.ret;
   field string AsmVOP3DPP16 = getAsmVOP3DPP16.ret;
   field string AsmVOP3DPP8 = getAsmVOP3DPP8.ret;
diff --git a/llvm/lib/Target/AMDGPU/VOP3Instructions.td 
b/llvm/lib/Target/AMDGPU/VOP3Instructions.td
index a2672d71cb43c..046cce73ff761 100644
--- a/llvm/lib/Target/AMDGPU/VOP3Instructions.td
+++ b/llvm/lib/Target/AMDGPU/VOP3Instructions.td
@@ -1055,6 +1055,7 @@ class 
VOP3_CVT_SCALE_FP4FP8BF8_F32_TiedInput_Profile : VOP3_Profil
 
 class VOP3_CVT_SCALE_FP4_F32_TiedInput_Profile : 
VOP3_CVT_SCALE_FP4FP8BF8_F32_TiedInput_Profile {
   let HasFP8DstByteSel = 1;
+  let HasFP8ByteSel = 0; // It works as a dst-bytesel, but does not have 
byte_sel operand.
 }
 
 class VOP3_CVT_SCALE_SR_F8BF8_F16BF16F32_TiedInput_Profile : 
VOP3_CVT_SCALE_FP4FP8BF8_F32_TiedInput_Profile {
@@ -1063,6 +1064,7 @@ class 
VOP3_CVT_SCALE_SR_F8BF8_F16BF16F32_TiedInput_Profile : VOP3_
   FP32InputMods:$src2_modifiers, Src2RC64:$src2,
   VGPR_32:$vdst_in, op_sel0:$op_sel);
   let HasFP8DstByteSel = 1;
+  let HasFP8ByteSel = 0; // It works as a dst-bytesel, but does not have 
byte_sel operand.
 }
 
 
diff --git a/llvm/lib/Target/AMDGPU/VOPInstructions.td 
b/llvm/lib/Target/AMDGPU/VOPInstructions.td
index 952ee2fe2c955..4cd845aaa5497 100644
--- a/llvm/lib/Target/AMDGPU/VOPInstructions.td
+++ b/llvm/lib/Target/AMDGPU/VOPInstructions.td
@@ -1478,6 +1478,9 @@ class VOP3_Profile_Base : VO
   let HasOpSel = !if(Features.HasOpSel, 1, P.HasOpSel);
   let IsMAI= !if(Features.IsMAI,1, P.IsMAI);
   let IsPacked = !if(Features.IsPacked, 1, P.IsPacked);
+  let HasFP8SrcByteSel = P.HasFP8SrcByteSel;
+  let HasFP8DstByteSel = P.HasFP8DstByteSel;
+  let HasOMod = P.HasOMod;
 
   let HasModifiers =
   !if (Features.IsMAI, 0,
@@ -1494,6 +1497,9 @@ class VOP3_Profile_True16 :
   let HasOpSel = !if(Features.HasOpSel, 1, P.HasOpSel);
   let IsMAI= !if(Features.IsMAI,1, P.IsMAI);
   let IsPacked = !if(Features.IsPacked, 1, P.IsPacked);
+  let HasFP8SrcByteSel = P.HasFP8SrcByteSel;
+  let HasFP8DstByteSel = P.HasFP8DstByteSel;
+  let HasOMod = P.HasOMod;
 
   let HasModifiers =
   !if (Features.IsMAI, 0,
@@ -1506,6 +1512,9 @@ class VOP3_Profile_Fake16 :
   let HasOpSel = !if(Features.HasOpSel, 1, P.HasOpSel);
   let IsMAI= !if(Features.IsMAI,1, P.IsMAI);
   let IsPacked = !if(Features.IsPacked, 1, P.IsPacked);
+  let HasFP8SrcByteSel = P.HasFP8SrcByteSel;
+  let HasFP8DstByteSel = P.HasFP8DstByteSel;
+  let HasOMod = P.HasOMod;
 
   let HasModifiers =
   !if (Features.IsMAI, 0,

``




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


[llvm-branch-commits] [llvm] [AMDGPU] Autogenerate bitop3 asm and dags. NFCI. (PR #143430)

2025-06-09 Thread Stanislav Mekhanoshin via llvm-branch-commits

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

* **#143430** https://app.graphite.dev/github/pr/llvm/llvm-project/143430?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/143430?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#143429** https://app.graphite.dev/github/pr/llvm/llvm-project/143429?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#143428** https://app.graphite.dev/github/pr/llvm/llvm-project/143428?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/143430
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [AMDGPU] Autogenerate bitop3 asm and dags. NFCI. (PR #143430)

2025-06-09 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-amdgpu

Author: Stanislav Mekhanoshin (rampitec)


Changes



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


2 Files Affected:

- (modified) llvm/lib/Target/AMDGPU/SIInstrInfo.td (+23-15) 
- (modified) llvm/lib/Target/AMDGPU/VOP3Instructions.td (+1-12) 


``diff
diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.td 
b/llvm/lib/Target/AMDGPU/SIInstrInfo.td
index a78440dc7a1f4..2c20475726a48 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.td
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.td
@@ -1973,7 +1973,8 @@ class getIns64  {
+bit HasFP8ByteSel = 0, bit HasFP8DstByteSel = 0,
+bit HasBitOp3 = 0> {
   dag src0 = !if(!ge(NumSrcArgs, 1),
  !if (HasModifiers,
   (ins Src0Mod:$src0_modifiers, Src0RC:$src0),
@@ -1999,21 +2000,23 @@ class getIns64  {
+bit HasFP8ByteSel = 0, bit HasFP8DstByteSel = 0, bit HasBitOp3 
= 0> {
   // getInst64 handles clamp and omod. implicit mutex between vop3p and omod
   dag base = getIns64 .ret;
   dag opsel = (ins op_sel0:$op_sel);
-  dag ret = !con(base, !if(HasOpSel, opsel, (ins)));
+  dag bitop3 = (ins bitop3_0:$bitop3);
+  dag ret = !con(base, !if(HasBitOp3, bitop3, (ins)), !if(HasOpSel, opsel, 
(ins)));
 }
 
 class getInsVOP3P  {
+   bit HasFP8ByteSel = 0, bit HasFP8DstByteSel = 0, bit 
HasBitOp3 = 0> {
   dag ret = getInsVOP3Base.ret;
+HasFP8ByteSel, HasFP8DstByteSel, HasBitOp3>.ret;
 }
 
 class getInsDPPBase  {
+   bit HasByteSel = 0,
+   bit HasBitOp3 = 0> {
   string dst = "$vdst";
 
   string isrc0 = !if(!eq(NumSrcArgs, 1), "$src0", "$src0,");
@@ -2269,7 +2273,8 @@ class getAsmVOP3OpSel  {
@@ -2301,7 +2306,7 @@ class getAsmVOP3Base  {
+   bit HasByteSel = 0, bit HasBitOp3 = 0> {
   string dst = !if(HasDst,
!if(!eq(DstVT.Size, 1),
"$sdst",
@@ -2324,6 +2329,7 @@ class getAsmVOP3Base  {
@@ -2558,6 +2564,7 @@ class VOPProfile  _ArgVT, bit 
_EnableClamp = 0> {
   field bit HasFP8DstByteSel = 0;
   field bit HasFP4DstByteSel = 0;
   field bit HasFP8ByteSel = !or(HasFP8SrcByteSel, HasFP8DstByteSel);
+  field bit HasBitOp3 = 0;
 
   field bit HasDst = !ne(DstVT.Value, untyped.Value);
   field bit HasDst32 = HasDst;
@@ -2628,14 +2635,14 @@ class VOPProfile  _ArgVT, bit 
_EnableClamp = 0> {
   field dag Ins64 = getIns64.ret;
+ HasFP8ByteSel, HasFP8DstByteSel, HasBitOp3>.ret;
   field dag InsVOP3P = getInsVOP3P.ret;
   field dag InsVOP3OpSel = getInsVOP3OpSel.ret;
+HasFP8ByteSel, HasFP8DstByteSel, 
HasBitOp3>.ret;
   field dag InsDPP = !if(HasExtDPP,
  getInsDPP.ret,
@@ -2648,7 +2655,7 @@ class VOPProfile  _ArgVT, bit 
_EnableClamp = 0> {
   defvar InsVOP3DPPBase = getInsVOP3Base.ret;
+  HasFP8ByteSel, HasFP8DstByteSel, HasBitOp3>.ret;
   defvar InsVOP3PDPPBase = getInsVOP3P.ret;
@@ -2677,7 +2684,7 @@ class VOPProfile  _ArgVT, bit 
_EnableClamp = 0> {
   field string AsmDPP8 = getAsmDPP8.ret;
   field string AsmVOP3Base = getAsmVOP3Base.ret;
+   HasSrc2Mods, DstVT, HasFP8ByteSel, HasBitOp3>.ret;
   field string Asm64 = AsmVOP3Base;
   field string AsmVOP3P = getAsmVOP3P.ret;
   field string AsmVOP3OpSel = getAsmVOP3OpSel _ArgVT, bit 
_EnableClamp = 0> {
   HasSrc0FloatMods,
   HasSrc1FloatMods,
   HasSrc2FloatMods,
-  HasFP8ByteSel>.ret;
+  HasFP8ByteSel,
+  HasBitOp3>.ret;
   field string AsmVOP3DPP = getAsmVOP3DPP.ret;
   field string AsmVOP3DPP16 = getAsmVOP3DPP16.ret;
   field string AsmVOP3DPP8 = getAsmVOP3DPP8.ret;
diff --git a/llvm/lib/Target/AMDGPU/VOP3Instructions.td 
b/llvm/lib/Target/AMDGPU/VOP3Instructions.td
index 046cce73ff761..ef88a379f3680 100644
--- a/llvm/lib/Target/AMDGPU/VOP3Instructions.td
+++ b/llvm/lib/Target/AMDGPU/VOP3Instructions.td
@@ -1003,18 +1003,7 @@ class VOP3_BITOP3_Profile : VOP3_Profile
   let HasClamp = 0;
   let HasOMod = 0;
   let HasModifiers = 0;
-
-  let Ins64 = !con(getIns64.ret,
-   (ins bitop3_0:$bitop3));
-
-  let InsVOP3OpSel = !con(getInsVOP3Base.ret,
-  (ins bitop3_0:$bitop3, op_sel0:$op_sel));
-
-  let Asm64 = "$vdst, $src0, $src1, $src2$bitop3";
-  let AsmVOP3OpSel = !subst("$op_sel", "$bitop3$op_sel", getAsmVOP3OpSel<3, 0, 
0, 0, 0, 0>.ret);
+  let HasBitOp3 = 1;
 }
 
 class VOP3_CVT_SCALE_F1632_FP8BF8_Profile : 
VOP3_Profile,

``




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

[llvm-branch-commits] [llvm] [AMDGPU] Autogenerate bitop3 asm and dags. NFCI. (PR #143430)

2025-06-09 Thread Stanislav Mekhanoshin via llvm-branch-commits

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


[llvm-branch-commits] [llvm] RuntimeLibcalls: Cleanup sincos predicate functions (PR #143081)

2025-06-09 Thread Eli Friedman via llvm-branch-commits

https://github.com/efriedma-quic approved this pull request.

LGTM

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


[llvm-branch-commits] [clang-tools-extra] [clang-doc] add namespaces to JSON generator (PR #143209)

2025-06-09 Thread Paul Kirth via llvm-branch-commits

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

LGTM. I left some comments inline, but I'm fine if we plan to address them 
later.

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


[llvm-branch-commits] [clang-tools-extra] [clang-doc] add namespaces to JSON generator (PR #143209)

2025-06-09 Thread Paul Kirth via llvm-branch-commits


@@ -0,0 +1,25 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --output=%t --format=json --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/index.json
+
+static void myFunction() {}
+
+void noExceptFunction() noexcept {}
+
+inline void inlineFunction() {}
+
+extern void externFunction() {}
+
+constexpr void constexprFunction() {}
+
+// CHECK:  "Functions": [
+// CHECK-NEXT:   {
+// CHECK:  "IsStatic": true,

ilovepi wrote:

Don't you need something like CHECK-LABEL to make sure you're matching the 
correct part of the output? If the name is later in the output, maybe we should 
move it to make testing easier? Otherwise, I'd guess we would still need to 
check that we're matching the right property w/ the right entity...

Most of this test is just precommit for the FIXMEs, so it isn't a big deal 
right now, but I can imagine as the test grows, it may become harder to 
maintain.

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


[llvm-branch-commits] [clang-tools-extra] [clang-doc] add namespaces to JSON generator (PR #143209)

2025-06-09 Thread Paul Kirth via llvm-branch-commits

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


[llvm-branch-commits] [clang-tools-extra] [clang-doc] add namespaces to JSON generator (PR #143209)

2025-06-09 Thread Paul Kirth via llvm-branch-commits


@@ -0,0 +1,108 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --output=%t --format=json --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/index.json
+
+class MyClass {};
+
+void myFunction(int Param);
+
+namespace NestedNamespace {
+} // namespace NestedNamespace
+
+// FIXME: Global variables are not mapped or serialized.
+static int Global;
+
+enum Color {
+  RED,
+  GREEN,
+  BLUE = 5
+};
+
+typedef int MyTypedef;
+
+// CHECK:   { 
+// CHECK-NEXT:"Enums": [
+// CHECK-NEXT:  {
+// CHECK-NEXT:"Location": {
+// CHECK-NEXT:  "Filename": "{{.*}}namespace.cpp",
+// CHECK-NEXT:  "LineNumber": 15
+// CHECK-NEXT:},
+// CHECK-NEXT:"Members": [
+// CHECK-NEXT:  {
+// CHECK-NEXT:"Name": "RED",
+// CHECK-NEXT:"Value": "0"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  {
+// CHECK-NEXT:"Name": "GREEN",
+// CHECK-NEXT:"Value": "1"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  {
+// CHECK-NEXT:"Name": "BLUE",
+// CHECK-NEXT:"ValueExpr": "5"
+// CHECK-NEXT:  }
+// CHECK-NEXT:],
+// CHECK-NEXT:"Name": "Color",
+// CHECK-NEXT:"Scoped": false,
+// CHECK-NEXT:"USR": "{{[0-9A-F]*}}"
+// CHECK-NEXT:  }
+// CHECK-NEXT:],
+// CHECK-NEXT:   "Functions": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "IsStatic": false,
+// CHECK-NEXT:   "Name": "myFunction",
+// CHECK-NEXT:   "Params": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "Name": "Param",
+// CHECK-NEXT:   "Type": "int"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "ReturnType": {
+// CHECK-NEXT: "IsBuiltIn": false,
+// CHECK-NEXT: "IsTemplate": false,
+// CHECK-NEXT: "Name": "void",
+// CHECK-NEXT: "QualName": "void",
+// CHECK-NEXT: "USR": ""

ilovepi wrote:

Do builtin types like `void` and `int` get fixed `USR`s? Also, shouldn't 
`IsBuiltIn` be true here? The default value is false, but we should set it in 
Serialize.cpp, right?

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


[llvm-branch-commits] [llvm] [RISCV] Support memcmp expansion for vectors (PR #114517)

2025-06-09 Thread Craig Topper via llvm-branch-commits


@@ -2512,9 +2512,11 @@ bool RISCVTTIImpl::isProfitableToSinkOperands(
 RISCVTTIImpl::TTI::MemCmpExpansionOptions
 RISCVTTIImpl::enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const {
   TTI::MemCmpExpansionOptions Options;
+  // Here we assume that a core that has implemented unaligned vector access
+  // should also have implemented unaligned scalar access.

topperc wrote:

I'm not comfortable with this assumption. Is it even required? Aren't we doing 
byte element loads?

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


[llvm-branch-commits] [llvm] [IR2Vec] Minor vocab changes and exposing weights (PR #143200)

2025-06-09 Thread S. VenkataKeerthy via llvm-branch-commits

https://github.com/svkeerthy updated 
https://github.com/llvm/llvm-project/pull/143200

>From 7f2012cd56db0fc6e1c430a8d5b38d360b33145f Mon Sep 17 00:00:00 2001
From: svkeerthy 
Date: Fri, 6 Jun 2025 20:32:32 +
Subject: [PATCH] Vocab changes1

---
 llvm/include/llvm/Analysis/IR2Vec.h|  10 ++
 llvm/lib/Analysis/IR2Vec.cpp   |  82 +--
 llvm/unittests/Analysis/IR2VecTest.cpp | 137 ++---
 3 files changed, 163 insertions(+), 66 deletions(-)

diff --git a/llvm/include/llvm/Analysis/IR2Vec.h 
b/llvm/include/llvm/Analysis/IR2Vec.h
index 14f28999b174c..3d32942670785 100644
--- a/llvm/include/llvm/Analysis/IR2Vec.h
+++ b/llvm/include/llvm/Analysis/IR2Vec.h
@@ -31,7 +31,9 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/JSON.h"
 #include 
 
 namespace llvm {
@@ -43,6 +45,7 @@ class Function;
 class Type;
 class Value;
 class raw_ostream;
+class LLVMContext;
 
 /// IR2Vec computes two kinds of embeddings: Symbolic and Flow-aware.
 /// Symbolic embeddings capture the "syntactic" and "statistical correlation"
@@ -53,6 +56,11 @@ class raw_ostream;
 enum class IR2VecKind { Symbolic };
 
 namespace ir2vec {
+
+LLVM_ABI extern cl::opt OpcWeight;
+LLVM_ABI extern cl::opt TypeWeight;
+LLVM_ABI extern cl::opt ArgWeight;
+
 /// Embedding is a ADT that wraps std::vector. It provides
 /// additional functionality for arithmetic and comparison operations.
 /// It is meant to be used *like* std::vector but is more restrictive
@@ -224,10 +232,12 @@ class IR2VecVocabResult {
 class IR2VecVocabAnalysis : public AnalysisInfoMixin {
   ir2vec::Vocab Vocabulary;
   Error readVocabulary();
+  void emitError(Error Err, LLVMContext &Ctx);
 
 public:
   static AnalysisKey Key;
   IR2VecVocabAnalysis() = default;
+  explicit IR2VecVocabAnalysis(ir2vec::Vocab &&Vocab);
   using Result = IR2VecVocabResult;
   Result run(Module &M, ModuleAnalysisManager &MAM);
 };
diff --git a/llvm/lib/Analysis/IR2Vec.cpp b/llvm/lib/Analysis/IR2Vec.cpp
index 25ce35d4ace37..2ad65c2f40c33 100644
--- a/llvm/lib/Analysis/IR2Vec.cpp
+++ b/llvm/lib/Analysis/IR2Vec.cpp
@@ -16,13 +16,11 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
-#include "llvm/Support/JSON.h"
 #include "llvm/Support/MemoryBuffer.h"
 
 using namespace llvm;
@@ -33,6 +31,8 @@ using namespace ir2vec;
 STATISTIC(VocabMissCounter,
   "Number of lookups to entites not present in the vocabulary");
 
+namespace llvm {
+namespace ir2vec {
 static cl::OptionCategory IR2VecCategory("IR2Vec Options");
 
 // FIXME: Use a default vocab when not specified
@@ -40,18 +40,20 @@ static cl::opt
 VocabFile("ir2vec-vocab-path", cl::Optional,
   cl::desc("Path to the vocabulary file for IR2Vec"), cl::init(""),
   cl::cat(IR2VecCategory));
-static cl::opt OpcWeight("ir2vec-opc-weight", cl::Optional,
-cl::init(1.0),
-cl::desc("Weight for opcode embeddings"),
-cl::cat(IR2VecCategory));
-static cl::opt TypeWeight("ir2vec-type-weight", cl::Optional,
- cl::init(0.5),
- cl::desc("Weight for type embeddings"),
- cl::cat(IR2VecCategory));
-static cl::opt ArgWeight("ir2vec-arg-weight", cl::Optional,
-cl::init(0.2),
-cl::desc("Weight for argument embeddings"),
-cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt OpcWeight("ir2vec-opc-weight", cl::Optional,
+  cl::init(1.0),
+  cl::desc("Weight for opcode embeddings"),
+  cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt TypeWeight("ir2vec-type-weight", cl::Optional,
+   cl::init(0.5),
+   cl::desc("Weight for type embeddings"),
+   cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt ArgWeight("ir2vec-arg-weight", cl::Optional,
+  cl::init(0.2),
+  cl::desc("Weight for argument embeddings"),
+  cl::cat(IR2VecCategory));
+} // namespace ir2vec
+} // namespace llvm
 
 AnalysisKey IR2VecVocabAnalysis::Key;
 
@@ -251,9 +253,9 @@ bool IR2VecVocabResult::invalidate(
 // by auto-generating a default vocabulary during the build time.
 Error IR2VecVocabAnalysis::readVocabulary() {
   auto BufOrError = MemoryBuffer::getFileOrSTDIN(VocabFile, /*IsText=*/true);
-  if (!BufOrError) {
+  if (!B

[llvm-branch-commits] [llvm] [IR2Vec] Minor vocab changes and exposing weights (PR #143200)

2025-06-09 Thread S. VenkataKeerthy via llvm-branch-commits

https://github.com/svkeerthy updated 
https://github.com/llvm/llvm-project/pull/143200

>From 7f2012cd56db0fc6e1c430a8d5b38d360b33145f Mon Sep 17 00:00:00 2001
From: svkeerthy 
Date: Fri, 6 Jun 2025 20:32:32 +
Subject: [PATCH] Vocab changes1

---
 llvm/include/llvm/Analysis/IR2Vec.h|  10 ++
 llvm/lib/Analysis/IR2Vec.cpp   |  82 +--
 llvm/unittests/Analysis/IR2VecTest.cpp | 137 ++---
 3 files changed, 163 insertions(+), 66 deletions(-)

diff --git a/llvm/include/llvm/Analysis/IR2Vec.h 
b/llvm/include/llvm/Analysis/IR2Vec.h
index 14f28999b174c..3d32942670785 100644
--- a/llvm/include/llvm/Analysis/IR2Vec.h
+++ b/llvm/include/llvm/Analysis/IR2Vec.h
@@ -31,7 +31,9 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/JSON.h"
 #include 
 
 namespace llvm {
@@ -43,6 +45,7 @@ class Function;
 class Type;
 class Value;
 class raw_ostream;
+class LLVMContext;
 
 /// IR2Vec computes two kinds of embeddings: Symbolic and Flow-aware.
 /// Symbolic embeddings capture the "syntactic" and "statistical correlation"
@@ -53,6 +56,11 @@ class raw_ostream;
 enum class IR2VecKind { Symbolic };
 
 namespace ir2vec {
+
+LLVM_ABI extern cl::opt OpcWeight;
+LLVM_ABI extern cl::opt TypeWeight;
+LLVM_ABI extern cl::opt ArgWeight;
+
 /// Embedding is a ADT that wraps std::vector. It provides
 /// additional functionality for arithmetic and comparison operations.
 /// It is meant to be used *like* std::vector but is more restrictive
@@ -224,10 +232,12 @@ class IR2VecVocabResult {
 class IR2VecVocabAnalysis : public AnalysisInfoMixin {
   ir2vec::Vocab Vocabulary;
   Error readVocabulary();
+  void emitError(Error Err, LLVMContext &Ctx);
 
 public:
   static AnalysisKey Key;
   IR2VecVocabAnalysis() = default;
+  explicit IR2VecVocabAnalysis(ir2vec::Vocab &&Vocab);
   using Result = IR2VecVocabResult;
   Result run(Module &M, ModuleAnalysisManager &MAM);
 };
diff --git a/llvm/lib/Analysis/IR2Vec.cpp b/llvm/lib/Analysis/IR2Vec.cpp
index 25ce35d4ace37..2ad65c2f40c33 100644
--- a/llvm/lib/Analysis/IR2Vec.cpp
+++ b/llvm/lib/Analysis/IR2Vec.cpp
@@ -16,13 +16,11 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
-#include "llvm/Support/JSON.h"
 #include "llvm/Support/MemoryBuffer.h"
 
 using namespace llvm;
@@ -33,6 +31,8 @@ using namespace ir2vec;
 STATISTIC(VocabMissCounter,
   "Number of lookups to entites not present in the vocabulary");
 
+namespace llvm {
+namespace ir2vec {
 static cl::OptionCategory IR2VecCategory("IR2Vec Options");
 
 // FIXME: Use a default vocab when not specified
@@ -40,18 +40,20 @@ static cl::opt
 VocabFile("ir2vec-vocab-path", cl::Optional,
   cl::desc("Path to the vocabulary file for IR2Vec"), cl::init(""),
   cl::cat(IR2VecCategory));
-static cl::opt OpcWeight("ir2vec-opc-weight", cl::Optional,
-cl::init(1.0),
-cl::desc("Weight for opcode embeddings"),
-cl::cat(IR2VecCategory));
-static cl::opt TypeWeight("ir2vec-type-weight", cl::Optional,
- cl::init(0.5),
- cl::desc("Weight for type embeddings"),
- cl::cat(IR2VecCategory));
-static cl::opt ArgWeight("ir2vec-arg-weight", cl::Optional,
-cl::init(0.2),
-cl::desc("Weight for argument embeddings"),
-cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt OpcWeight("ir2vec-opc-weight", cl::Optional,
+  cl::init(1.0),
+  cl::desc("Weight for opcode embeddings"),
+  cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt TypeWeight("ir2vec-type-weight", cl::Optional,
+   cl::init(0.5),
+   cl::desc("Weight for type embeddings"),
+   cl::cat(IR2VecCategory));
+LLVM_ABI cl::opt ArgWeight("ir2vec-arg-weight", cl::Optional,
+  cl::init(0.2),
+  cl::desc("Weight for argument embeddings"),
+  cl::cat(IR2VecCategory));
+} // namespace ir2vec
+} // namespace llvm
 
 AnalysisKey IR2VecVocabAnalysis::Key;
 
@@ -251,9 +253,9 @@ bool IR2VecVocabResult::invalidate(
 // by auto-generating a default vocabulary during the build time.
 Error IR2VecVocabAnalysis::readVocabulary() {
   auto BufOrError = MemoryBuffer::getFileOrSTDIN(VocabFile, /*IsText=*/true);
-  if (!BufOrError) {
+  if (!B

[llvm-branch-commits] [llvm] [llvm-debuginfo-analyzer] Add support for LLVM IR format. (PR #135440)

2025-06-09 Thread Stephen Tozer via llvm-branch-commits

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


[llvm-branch-commits] [mlir] [MLIR] Fix incorrect slice contiguity inference in `vector::isContiguousSlice` (PR #142422)

2025-06-09 Thread Momchil Velikov via llvm-branch-commits

https://github.com/momchil-velikov updated 
https://github.com/llvm/llvm-project/pull/142422

>From b950757c234900db941ed950ea3469b520d2e28a Mon Sep 17 00:00:00 2001
From: Momchil Velikov 
Date: Mon, 2 Jun 2025 15:13:13 +
Subject: [PATCH 1/6] [MLIR] Fix incorrect slice contiguity inference in
 `vector::isContiguousSlice`

Previously, slices were sometimes marked as non-contiguous when
they were actually contiguous. This occurred when the vector type had
leading unit dimensions, e.g., `vector<1x1x...x1xd0xd1x...xdn-1xT>``.
In such cases, only the trailing n dimensions of the memref need to be
contiguous, not the entire vector rank.

This affects how `FlattenContiguousRowMajorTransfer{Read,Write}Pattern`
flattens `transfer_read` and `transfer_write`` ops. The pattern used
to collapse a number of dimensions equal the vector rank, which
may be is incorrect when leading dimensions are unit-sized.

This patch fixes the issue by collapsing only as many trailing memref
dimensions as are actually contiguous.
---
 .../mlir/Dialect/Vector/Utils/VectorUtils.h   |  54 -
 .../Transforms/VectorTransferOpTransforms.cpp |   8 +-
 mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp |  25 ++--
 .../Vector/vector-transfer-flatten.mlir   | 108 +-
 4 files changed, 120 insertions(+), 75 deletions(-)

diff --git a/mlir/include/mlir/Dialect/Vector/Utils/VectorUtils.h 
b/mlir/include/mlir/Dialect/Vector/Utils/VectorUtils.h
index 6609b28d77b6c..ed06d7a029494 100644
--- a/mlir/include/mlir/Dialect/Vector/Utils/VectorUtils.h
+++ b/mlir/include/mlir/Dialect/Vector/Utils/VectorUtils.h
@@ -49,35 +49,37 @@ FailureOr> 
isTranspose2DSlice(vector::TransposeOp op);
 
 /// Return true if `vectorType` is a contiguous slice of `memrefType`.
 ///
-/// Only the N = vectorType.getRank() trailing dims of `memrefType` are
-/// checked (the other dims are not relevant). Note that for `vectorType` to be
-/// a contiguous slice of `memrefType`, the trailing dims of the latter have
-/// to be contiguous - this is checked by looking at the corresponding strides.
+/// The leading unit dimensions of the vector type are ignored as they
+/// are not relevant to the result. Let N be the number of the vector
+/// dimensions after ignoring a leading sequence of unit ones.
 ///
-/// There might be some restriction on the leading dim of `VectorType`:
+/// For `vectorType` to be a contiguous slice of `memrefType`
+///   a) the N trailing dimensions of the latter must be contiguous, and
+///   b) the trailing N dimensions of `vectorType` and `memrefType`,
+///  except the first of them, must match.
 ///
-/// Case 1. If all the trailing dims of `vectorType` match the trailing dims
-/// of `memrefType` then the leading dim of `vectorType` can be
-/// arbitrary.
-///
-///Ex. 1.1 contiguous slice, perfect match
-///  vector<4x3x2xi32> from memref<5x4x3x2xi32>
-///Ex. 1.2 contiguous slice, the leading dim does not match (2 != 4)
-///  vector<2x3x2xi32> from memref<5x4x3x2xi32>
-///
-/// Case 2. If an "internal" dim of `vectorType` does not match the
-/// corresponding trailing dim in `memrefType` then the remaining
-/// leading dims of `vectorType` have to be 1 (the first non-matching
-/// dim can be arbitrary).
+/// Examples:
 ///
-///Ex. 2.1 non-contiguous slice, 2 != 3 and the leading dim != <1>
-///  vector<2x2x2xi32> from memref<5x4x3x2xi32>
-///Ex. 2.2  contiguous slice, 2 != 3 and the leading dim == <1>
-///  vector<1x2x2xi32> from memref<5x4x3x2xi32>
-///Ex. 2.3. contiguous slice, 2 != 3 and the leading dims == <1x1>
-///  vector<1x1x2x2xi32> from memref<5x4x3x2xi32>
-///Ex. 2.4. non-contiguous slice, 2 != 3 and the leading dims != <1x1>
-/// vector<2x1x2x2xi32> from memref<5x4x3x2xi32>)
+///   Ex.1 contiguous slice, perfect match
+/// vector<4x3x2xi32> from memref<5x4x3x2xi32>
+///   Ex.2 contiguous slice, the leading dim does not match (2 != 4)
+/// vector<2x3x2xi32> from memref<5x4x3x2xi32>
+///   Ex.3 non-contiguous slice, 2 != 3
+/// vector<2x2x2xi32> from memref<5x4x3x2xi32>
+///   Ex.4 contiguous slice, leading unit dimension of the vector ignored,
+///2 != 3 (allowed)
+/// vector<1x2x2xi32> from memref<5x4x3x2xi32>
+///   Ex.5. contiguous slice, leasing two unit dims of the vector ignored,
+/// 2 != 3 (allowed)
+/// vector<1x1x2x2xi32> from memref<5x4x3x2xi32>
+///   Ex.6. non-contiguous slice, 2 != 3, no leading sequence of unit dims
+/// vector<2x1x2x2xi32> from memref<5x4x3x2xi32>)
+///   Ex.7 contiguous slice, memref needs to be contiguous only on the last
+///dimension
+/// vector<1x1x2xi32> from memref<2x2x2xi32, strided<[8, 4, 1]>>
+///   Ex.8 non-contiguous slice, memref needs to be contiguous one the last
+///two dimensions, and it isn't
+/// vector<1x2x2xi32> from memref<2x2x2xi32, strided<[8, 4, 1]>>
 bool isContiguo

[llvm-branch-commits] [mlir] [MLIR] Fix incorrect slice contiguity inference in `vector::isContiguousSlice` (PR #142422)

2025-06-09 Thread Momchil Velikov via llvm-branch-commits

https://github.com/momchil-velikov updated 
https://github.com/llvm/llvm-project/pull/142422

>From b950757c234900db941ed950ea3469b520d2e28a Mon Sep 17 00:00:00 2001
From: Momchil Velikov 
Date: Mon, 2 Jun 2025 15:13:13 +
Subject: [PATCH 1/6] [MLIR] Fix incorrect slice contiguity inference in
 `vector::isContiguousSlice`

Previously, slices were sometimes marked as non-contiguous when
they were actually contiguous. This occurred when the vector type had
leading unit dimensions, e.g., `vector<1x1x...x1xd0xd1x...xdn-1xT>``.
In such cases, only the trailing n dimensions of the memref need to be
contiguous, not the entire vector rank.

This affects how `FlattenContiguousRowMajorTransfer{Read,Write}Pattern`
flattens `transfer_read` and `transfer_write`` ops. The pattern used
to collapse a number of dimensions equal the vector rank, which
may be is incorrect when leading dimensions are unit-sized.

This patch fixes the issue by collapsing only as many trailing memref
dimensions as are actually contiguous.
---
 .../mlir/Dialect/Vector/Utils/VectorUtils.h   |  54 -
 .../Transforms/VectorTransferOpTransforms.cpp |   8 +-
 mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp |  25 ++--
 .../Vector/vector-transfer-flatten.mlir   | 108 +-
 4 files changed, 120 insertions(+), 75 deletions(-)

diff --git a/mlir/include/mlir/Dialect/Vector/Utils/VectorUtils.h 
b/mlir/include/mlir/Dialect/Vector/Utils/VectorUtils.h
index 6609b28d77b6c..ed06d7a029494 100644
--- a/mlir/include/mlir/Dialect/Vector/Utils/VectorUtils.h
+++ b/mlir/include/mlir/Dialect/Vector/Utils/VectorUtils.h
@@ -49,35 +49,37 @@ FailureOr> 
isTranspose2DSlice(vector::TransposeOp op);
 
 /// Return true if `vectorType` is a contiguous slice of `memrefType`.
 ///
-/// Only the N = vectorType.getRank() trailing dims of `memrefType` are
-/// checked (the other dims are not relevant). Note that for `vectorType` to be
-/// a contiguous slice of `memrefType`, the trailing dims of the latter have
-/// to be contiguous - this is checked by looking at the corresponding strides.
+/// The leading unit dimensions of the vector type are ignored as they
+/// are not relevant to the result. Let N be the number of the vector
+/// dimensions after ignoring a leading sequence of unit ones.
 ///
-/// There might be some restriction on the leading dim of `VectorType`:
+/// For `vectorType` to be a contiguous slice of `memrefType`
+///   a) the N trailing dimensions of the latter must be contiguous, and
+///   b) the trailing N dimensions of `vectorType` and `memrefType`,
+///  except the first of them, must match.
 ///
-/// Case 1. If all the trailing dims of `vectorType` match the trailing dims
-/// of `memrefType` then the leading dim of `vectorType` can be
-/// arbitrary.
-///
-///Ex. 1.1 contiguous slice, perfect match
-///  vector<4x3x2xi32> from memref<5x4x3x2xi32>
-///Ex. 1.2 contiguous slice, the leading dim does not match (2 != 4)
-///  vector<2x3x2xi32> from memref<5x4x3x2xi32>
-///
-/// Case 2. If an "internal" dim of `vectorType` does not match the
-/// corresponding trailing dim in `memrefType` then the remaining
-/// leading dims of `vectorType` have to be 1 (the first non-matching
-/// dim can be arbitrary).
+/// Examples:
 ///
-///Ex. 2.1 non-contiguous slice, 2 != 3 and the leading dim != <1>
-///  vector<2x2x2xi32> from memref<5x4x3x2xi32>
-///Ex. 2.2  contiguous slice, 2 != 3 and the leading dim == <1>
-///  vector<1x2x2xi32> from memref<5x4x3x2xi32>
-///Ex. 2.3. contiguous slice, 2 != 3 and the leading dims == <1x1>
-///  vector<1x1x2x2xi32> from memref<5x4x3x2xi32>
-///Ex. 2.4. non-contiguous slice, 2 != 3 and the leading dims != <1x1>
-/// vector<2x1x2x2xi32> from memref<5x4x3x2xi32>)
+///   Ex.1 contiguous slice, perfect match
+/// vector<4x3x2xi32> from memref<5x4x3x2xi32>
+///   Ex.2 contiguous slice, the leading dim does not match (2 != 4)
+/// vector<2x3x2xi32> from memref<5x4x3x2xi32>
+///   Ex.3 non-contiguous slice, 2 != 3
+/// vector<2x2x2xi32> from memref<5x4x3x2xi32>
+///   Ex.4 contiguous slice, leading unit dimension of the vector ignored,
+///2 != 3 (allowed)
+/// vector<1x2x2xi32> from memref<5x4x3x2xi32>
+///   Ex.5. contiguous slice, leasing two unit dims of the vector ignored,
+/// 2 != 3 (allowed)
+/// vector<1x1x2x2xi32> from memref<5x4x3x2xi32>
+///   Ex.6. non-contiguous slice, 2 != 3, no leading sequence of unit dims
+/// vector<2x1x2x2xi32> from memref<5x4x3x2xi32>)
+///   Ex.7 contiguous slice, memref needs to be contiguous only on the last
+///dimension
+/// vector<1x1x2xi32> from memref<2x2x2xi32, strided<[8, 4, 1]>>
+///   Ex.8 non-contiguous slice, memref needs to be contiguous one the last
+///two dimensions, and it isn't
+/// vector<1x2x2xi32> from memref<2x2x2xi32, strided<[8, 4, 1]>>
 bool isContiguo

[llvm-branch-commits] [mlir] [MLIR] Legalize certain `vector.transfer_read` ops of scalable vectors (PR #143146)

2025-06-09 Thread Momchil Velikov via llvm-branch-commits

https://github.com/momchil-velikov updated 
https://github.com/llvm/llvm-project/pull/143146

>From 6a6d6037b6da51b2da474c99751433542cf35603 Mon Sep 17 00:00:00 2001
From: Momchil Velikov 
Date: Wed, 14 May 2025 09:03:49 +
Subject: [PATCH 1/2] [MLIR] Legalize certain `vector.transfer_read` ops of
 scalable vectors

THis patch add a transform  of `transfer_read` operation to change the
vector type to one that can be mapped to an LLVM type. This is done by
collapsing trailing dimensions so we obtain a vector type with a single
scalable dimension in the rightmost position.
---
 .../Transforms/LegalizeVectorStorage.cpp  | 110 -
 .../ArmSVE/legalize-transfer-read.mlir| 226 ++
 .../transfer-read-scalable-not-rightmost.mlir |  72 ++
 3 files changed, 407 insertions(+), 1 deletion(-)
 create mode 100644 mlir/test/Dialect/ArmSVE/legalize-transfer-read.mlir
 create mode 100644 
mlir/test/Integration/Dialect/Vector/CPU/ArmSVE/transfer-read-scalable-not-rightmost.mlir

diff --git a/mlir/lib/Dialect/ArmSVE/Transforms/LegalizeVectorStorage.cpp 
b/mlir/lib/Dialect/ArmSVE/Transforms/LegalizeVectorStorage.cpp
index d2ac850a5f70b..f16d33c004fec 100644
--- a/mlir/lib/Dialect/ArmSVE/Transforms/LegalizeVectorStorage.cpp
+++ b/mlir/lib/Dialect/ArmSVE/Transforms/LegalizeVectorStorage.cpp
@@ -298,6 +298,113 @@ struct LegalizeSVEMaskLoadConversion : public 
OpRewritePattern {
   }
 };
 
+/// Transforms a `transfer_read` operation so it reads vector of a type that
+/// can be mapped to an LLVM type. This is done by collapsing trailing
+/// dimensions so we obtain a vector type with a single scalable dimension in
+/// the rightmost position.
+///
+/// Example:
+/// ```
+/// %v = vector.transfer_read %M[%i, %j, %c0, %c0], %c0_i8
+///   {in_bounds = [false, true, true, true]}
+///   : memref, vector<2x[4]x2x8xi8>
+/// ```
+/// is rewriten to
+/// ```
+/// %collapse_shape = memref.collapse_shape %M [[0], [1, 2, 3]]
+///   : memref into memref
+/// %0 = vector.transfer_read  %collapse_shape[%i, %j], %c0_i8
+///   {in_bounds = [false, true]}
+///   : memref, vector<2x[64]xi8>
+/// %1 = vector.shape_cast %0 : vector<2x[64]xi8> to vector<2x[4]x2x8xi8>
+/// ```
+struct LegalizeTransferRead : public OpRewritePattern {
+  using OpRewritePattern::OpRewritePattern;
+
+  LogicalResult matchAndRewrite(vector::TransferReadOp readOp,
+PatternRewriter &rewriter) const override {
+
+if (!readOp.getPermutationMap().isMinorIdentity())
+  return rewriter.notifyMatchFailure(readOp, "non-identity permutation");
+
+// We handle transfers of vectors with rank >= 2 and a single scalable
+// dimension.
+VectorType origVT = readOp.getVectorType();
+ArrayRef origScalableDims = origVT.getScalableDims();
+const int64_t origVRank = origVT.getRank();
+if (origVRank < 2 || llvm::count(origScalableDims, true) != 1)
+  return rewriter.notifyMatchFailure(readOp, "wrong dimensions");
+
+// Number of trailing dimensions to collapse, including the scalable
+// dimension.  Nothing to do if the single scalable dimension is already 
the
+// last one.
+const int64_t numCollapseDims = std::distance(
+llvm::find(origScalableDims, true), origScalableDims.end());
+if (numCollapseDims < 2)
+  return rewriter.notifyMatchFailure(readOp,
+ "scalable dimension is trailing");
+
+// We want a simple memref (not a tensor) with contiguous elements for at
+// least all the trailing dimensions up to and including the scalable one.
+auto memTy = dyn_cast(readOp.getBase().getType());
+if (!(memTy && memTy.areTrailingDimsContiguous(numCollapseDims)))
+  return rewriter.notifyMatchFailure(
+  readOp, "non-contiguous memref dimensions to collapse");
+
+// The collapsed dimensions (excluding the scalable one) of the vector and
+// the memref must match and the corresponding indices must be in-bounds 
(it
+// follows these indices would be zero). This guarantees that the operation
+// transfers a contiguous block.
+if (!llvm::equal(memTy.getShape().take_back(numCollapseDims - 1),
+ origVT.getShape().take_back(numCollapseDims - 1)))
+  return rewriter.notifyMatchFailure(
+  readOp, "memref and vector dimensions do not match");
+
+SmallVector origInBounds = readOp.getInBoundsValues();
+if (!llvm::all_of(
+ArrayRef(origInBounds).take_back(numCollapseDims - 1),
+[](bool v) { return v; }))
+  return rewriter.notifyMatchFailure(readOp,
+ "out-if-bounds index to collapse");
+
+// Collapse the trailing dimensions of the memref.
+SmallVector reassoc;
+for (int64_t i = 0; i < memTy.getRank() - numCollapseDims + 1; ++i)
+  reassoc.push_back({i});
+for (int64_t i = memTy.getRank() - numCollapseDims + 1; i < 
memTy.getRank();
+ ++i)
+  reassoc.

[llvm-branch-commits] [mlir] [MLIR] Legalize certain `vector.transfer_read` ops of scalable vectors (PR #143146)

2025-06-09 Thread Momchil Velikov via llvm-branch-commits

https://github.com/momchil-velikov updated 
https://github.com/llvm/llvm-project/pull/143146

>From 6a6d6037b6da51b2da474c99751433542cf35603 Mon Sep 17 00:00:00 2001
From: Momchil Velikov 
Date: Wed, 14 May 2025 09:03:49 +
Subject: [PATCH 1/2] [MLIR] Legalize certain `vector.transfer_read` ops of
 scalable vectors

THis patch add a transform  of `transfer_read` operation to change the
vector type to one that can be mapped to an LLVM type. This is done by
collapsing trailing dimensions so we obtain a vector type with a single
scalable dimension in the rightmost position.
---
 .../Transforms/LegalizeVectorStorage.cpp  | 110 -
 .../ArmSVE/legalize-transfer-read.mlir| 226 ++
 .../transfer-read-scalable-not-rightmost.mlir |  72 ++
 3 files changed, 407 insertions(+), 1 deletion(-)
 create mode 100644 mlir/test/Dialect/ArmSVE/legalize-transfer-read.mlir
 create mode 100644 
mlir/test/Integration/Dialect/Vector/CPU/ArmSVE/transfer-read-scalable-not-rightmost.mlir

diff --git a/mlir/lib/Dialect/ArmSVE/Transforms/LegalizeVectorStorage.cpp 
b/mlir/lib/Dialect/ArmSVE/Transforms/LegalizeVectorStorage.cpp
index d2ac850a5f70b..f16d33c004fec 100644
--- a/mlir/lib/Dialect/ArmSVE/Transforms/LegalizeVectorStorage.cpp
+++ b/mlir/lib/Dialect/ArmSVE/Transforms/LegalizeVectorStorage.cpp
@@ -298,6 +298,113 @@ struct LegalizeSVEMaskLoadConversion : public 
OpRewritePattern {
   }
 };
 
+/// Transforms a `transfer_read` operation so it reads vector of a type that
+/// can be mapped to an LLVM type. This is done by collapsing trailing
+/// dimensions so we obtain a vector type with a single scalable dimension in
+/// the rightmost position.
+///
+/// Example:
+/// ```
+/// %v = vector.transfer_read %M[%i, %j, %c0, %c0], %c0_i8
+///   {in_bounds = [false, true, true, true]}
+///   : memref, vector<2x[4]x2x8xi8>
+/// ```
+/// is rewriten to
+/// ```
+/// %collapse_shape = memref.collapse_shape %M [[0], [1, 2, 3]]
+///   : memref into memref
+/// %0 = vector.transfer_read  %collapse_shape[%i, %j], %c0_i8
+///   {in_bounds = [false, true]}
+///   : memref, vector<2x[64]xi8>
+/// %1 = vector.shape_cast %0 : vector<2x[64]xi8> to vector<2x[4]x2x8xi8>
+/// ```
+struct LegalizeTransferRead : public OpRewritePattern {
+  using OpRewritePattern::OpRewritePattern;
+
+  LogicalResult matchAndRewrite(vector::TransferReadOp readOp,
+PatternRewriter &rewriter) const override {
+
+if (!readOp.getPermutationMap().isMinorIdentity())
+  return rewriter.notifyMatchFailure(readOp, "non-identity permutation");
+
+// We handle transfers of vectors with rank >= 2 and a single scalable
+// dimension.
+VectorType origVT = readOp.getVectorType();
+ArrayRef origScalableDims = origVT.getScalableDims();
+const int64_t origVRank = origVT.getRank();
+if (origVRank < 2 || llvm::count(origScalableDims, true) != 1)
+  return rewriter.notifyMatchFailure(readOp, "wrong dimensions");
+
+// Number of trailing dimensions to collapse, including the scalable
+// dimension.  Nothing to do if the single scalable dimension is already 
the
+// last one.
+const int64_t numCollapseDims = std::distance(
+llvm::find(origScalableDims, true), origScalableDims.end());
+if (numCollapseDims < 2)
+  return rewriter.notifyMatchFailure(readOp,
+ "scalable dimension is trailing");
+
+// We want a simple memref (not a tensor) with contiguous elements for at
+// least all the trailing dimensions up to and including the scalable one.
+auto memTy = dyn_cast(readOp.getBase().getType());
+if (!(memTy && memTy.areTrailingDimsContiguous(numCollapseDims)))
+  return rewriter.notifyMatchFailure(
+  readOp, "non-contiguous memref dimensions to collapse");
+
+// The collapsed dimensions (excluding the scalable one) of the vector and
+// the memref must match and the corresponding indices must be in-bounds 
(it
+// follows these indices would be zero). This guarantees that the operation
+// transfers a contiguous block.
+if (!llvm::equal(memTy.getShape().take_back(numCollapseDims - 1),
+ origVT.getShape().take_back(numCollapseDims - 1)))
+  return rewriter.notifyMatchFailure(
+  readOp, "memref and vector dimensions do not match");
+
+SmallVector origInBounds = readOp.getInBoundsValues();
+if (!llvm::all_of(
+ArrayRef(origInBounds).take_back(numCollapseDims - 1),
+[](bool v) { return v; }))
+  return rewriter.notifyMatchFailure(readOp,
+ "out-if-bounds index to collapse");
+
+// Collapse the trailing dimensions of the memref.
+SmallVector reassoc;
+for (int64_t i = 0; i < memTy.getRank() - numCollapseDims + 1; ++i)
+  reassoc.push_back({i});
+for (int64_t i = memTy.getRank() - numCollapseDims + 1; i < 
memTy.getRank();
+ ++i)
+  reassoc.

[llvm-branch-commits] [flang] [flang][OpenMP] Map basic `local` specifiers to `private` clauses (PR #142735)

2025-06-09 Thread Michael Klemm via llvm-branch-commits

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

LGTM, maybe fix the typo.

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


[llvm-branch-commits] [flang] [flang][OpenMP] Map basic `local` specifiers to `private` clauses (PR #142735)

2025-06-09 Thread Michael Klemm via llvm-branch-commits


@@ -308,10 +310,47 @@ class DoConcurrentConversion
   fir::DoConcurrentLoopOp loop, mlir::IRMapping &mapper,
   const mlir::omp::LoopNestOperands &clauseOps,
   bool isComposite) const {
+mlir::omp::WsloopOperands wsloopClauseOps;
+
+// For `local` (and `local_init`) opernads, emit corresponding `private`

mjklemm wrote:

```suggestion
// For `local` (and `local_init`) operands, emit corresponding `private`
```

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


  1   2   >