[llvm-branch-commits] [flang] [flang][OpenMP] Emit requirements in module files (PR #163449)

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

https://github.com/kparzysz updated 
https://github.com/llvm/llvm-project/pull/163449

>From 2fb2af4b9bd9dd75f093da820addac484a0e70e1 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Tue, 14 Oct 2025 14:47:42 -0500
Subject: [PATCH 1/2] [flang][OpenMP] Emit requirements in module files

For each program unit, collect the set of requirements from REQUIRES
directives in the source, and modules used by the program unit, and
add them to the details of the program unit symbol.

The requirements in the symbol details as now stored as clauses. Since
requirements need to be emitted in the module files as OpenMP directives,
this makes the clause emission straightforward via getOpenMPClauseName.

Each program unit, including modules, the corresponding symbol will have
the transitive closure of the requirements for everything contained or
used in that program unit.
---
 flang/include/flang/Semantics/symbol.h|  22 +--
 flang/lib/Lower/OpenMP/OpenMP.cpp |  15 +-
 flang/lib/Semantics/mod-file.cpp  |  37 
 flang/lib/Semantics/resolve-directives.cpp| 161 ++
 flang/lib/Semantics/resolve-directives.h  |   2 -
 flang/lib/Semantics/resolve-names.cpp |   3 -
 .../Semantics/OpenMP/requires-modfile.f90 |  39 +
 flang/test/Semantics/OpenMP/requires09.f90|   6 +-
 8 files changed, 147 insertions(+), 138 deletions(-)
 create mode 100644 flang/test/Semantics/OpenMP/requires-modfile.f90

diff --git a/flang/include/flang/Semantics/symbol.h 
b/flang/include/flang/Semantics/symbol.h
index 77f567e69ce55..14da5b443633f 100644
--- a/flang/include/flang/Semantics/symbol.h
+++ b/flang/include/flang/Semantics/symbol.h
@@ -16,6 +16,7 @@
 #include "flang/Semantics/module-dependences.h"
 #include "flang/Support/Fortran.h"
 #include "llvm/ADT/DenseMapInfo.h"
+#include "llvm/Frontend/OpenMP/OMP.h"
 
 #include 
 #include 
@@ -50,32 +51,31 @@ using MutableSymbolVector = std::vector;
 
 // Mixin for details with OpenMP declarative constructs.
 class WithOmpDeclarative {
-  using OmpAtomicOrderType = common::OmpMemoryOrderType;
-
 public:
-  ENUM_CLASS(RequiresFlag, ReverseOffload, UnifiedAddress, UnifiedSharedMemory,
-  DynamicAllocators);
-  using RequiresFlags = common::EnumSet;
+  // The set of requirements for any program unit include requirements
+  // from any module used in the program unit.
+  using RequiresClauses =
+  common::EnumSet;
 
   bool has_ompRequires() const { return ompRequires_.has_value(); }
-  const RequiresFlags *ompRequires() const {
+  const RequiresClauses *ompRequires() const {
 return ompRequires_ ? &*ompRequires_ : nullptr;
   }
-  void set_ompRequires(RequiresFlags flags) { ompRequires_ = flags; }
+  void set_ompRequires(RequiresClauses clauses) { ompRequires_ = clauses; }
 
   bool has_ompAtomicDefaultMemOrder() const {
 return ompAtomicDefaultMemOrder_.has_value();
   }
-  const OmpAtomicOrderType *ompAtomicDefaultMemOrder() const {
+  const common::OmpMemoryOrderType *ompAtomicDefaultMemOrder() const {
 return ompAtomicDefaultMemOrder_ ? &*ompAtomicDefaultMemOrder_ : nullptr;
   }
-  void set_ompAtomicDefaultMemOrder(OmpAtomicOrderType flags) {
+  void set_ompAtomicDefaultMemOrder(common::OmpMemoryOrderType flags) {
 ompAtomicDefaultMemOrder_ = flags;
   }
 
 private:
-  std::optional ompRequires_;
-  std::optional ompAtomicDefaultMemOrder_;
+  std::optional ompRequires_;
+  std::optional ompAtomicDefaultMemOrder_;
 };
 
 // A module or submodule.
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp 
b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 444f27471020b..f86ee01355104 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -4208,18 +4208,17 @@ bool 
Fortran::lower::markOpenMPDeferredDeclareTargetFunctions(
 void Fortran::lower::genOpenMPRequires(mlir::Operation *mod,
const semantics::Symbol *symbol) {
   using MlirRequires = mlir::omp::ClauseRequires;
-  using SemaRequires = semantics::WithOmpDeclarative::RequiresFlag;
 
   if (auto offloadMod =
   llvm::dyn_cast(mod)) {
-semantics::WithOmpDeclarative::RequiresFlags semaFlags;
+semantics::WithOmpDeclarative::RequiresClauses reqs;
 if (symbol) {
   common::visit(
   [&](const auto &details) {
 if constexpr (std::is_base_of_v>) {
   if (details.has_ompRequires())
-semaFlags = *details.ompRequires();
+reqs = *details.ompRequires();
 }
   },
   symbol->details());
@@ -4228,14 +4227,14 @@ void Fortran::lower::genOpenMPRequires(mlir::Operation 
*mod,
 // Use pre-populated omp.requires module attribute if it was set, so that
 // the "-fopenmp-force-usm" compiler option is honored.
 MlirRequires mlirFlags = offloadMod.getRequires();
-if (semaFlags.test(SemaRequires::ReverseOffload))
+if (reqs.test(llvm::omp::Clause::OMPC_dynamic_allocators))
+  mlirFlags = 

[llvm-branch-commits] [llvm] [CI] Make CI Jobs Upload Failures to Premerge Advisor (PR #163276)

2025-10-14 Thread Aiden Grossman via llvm-branch-commits

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

>From 736fbda8f9e2e81f5db83ceccaa79feb13bdb9ea Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Mon, 13 Oct 2025 22:37:09 +
Subject: [PATCH] fix

Created using spr 1.3.7
---
 .ci/premerge_advisor_upload.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/.ci/premerge_advisor_upload.py b/.ci/premerge_advisor_upload.py
index 27e45bdd7f589..fb2bc251044b3 100644
--- a/.ci/premerge_advisor_upload.py
+++ b/.ci/premerge_advisor_upload.py
@@ -45,4 +45,3 @@ def main(commit_sha, workflow_run_number, build_log_files):
 args = parser.parse_args()
 
 main(args.commit_sha, args.workflow_run_number, args.build_log_files)
-main()

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


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

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

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

>From f70bce342fd8246298802c35d06373ba23cc9ee2 Mon Sep 17 00:00:00 2001
From: svkeerthy 
Date: Mon, 6 Oct 2025 21:15:14 +
Subject: [PATCH] MIR2Vec embedding

---
 llvm/include/llvm/CodeGen/MIR2Vec.h   | 108 ++
 llvm/include/llvm/CodeGen/Passes.h|   4 +
 llvm/include/llvm/InitializePasses.h  |   1 +
 llvm/lib/CodeGen/CodeGen.cpp  |   1 +
 llvm/lib/CodeGen/MIR2Vec.cpp  | 195 ++-
 .../Inputs/mir2vec_dummy_3D_vocab.json|  22 ++
 llvm/test/CodeGen/MIR2Vec/if-else.mir | 144 
 .../MIR2Vec/mir2vec-basic-symbolic.mir|  76 
 llvm/tools/llc/llc.cpp|  15 +
 llvm/unittests/CodeGen/MIR2VecTest.cpp| 324 --
 10 files changed, 863 insertions(+), 27 deletions(-)
 create mode 100644 llvm/test/CodeGen/MIR2Vec/Inputs/mir2vec_dummy_3D_vocab.json
 create mode 100644 llvm/test/CodeGen/MIR2Vec/if-else.mir
 create mode 100644 llvm/test/CodeGen/MIR2Vec/mir2vec-basic-symbolic.mir

diff --git a/llvm/include/llvm/CodeGen/MIR2Vec.h 
b/llvm/include/llvm/CodeGen/MIR2Vec.h
index ea68b4594a2ad..ebafe4ccddff3 100644
--- a/llvm/include/llvm/CodeGen/MIR2Vec.h
+++ b/llvm/include/llvm/CodeGen/MIR2Vec.h
@@ -51,11 +51,21 @@ class LLVMContext;
 class MIR2VecVocabLegacyAnalysis;
 class TargetInstrInfo;
 
+enum class MIR2VecKind { Symbolic };
+
 namespace mir2vec {
+
+// Forward declarations
+class MIREmbedder;
+class SymbolicMIREmbedder;
+
 extern llvm::cl::OptionCategory MIR2VecCategory;
 extern cl::opt OpcWeight;
 
 using Embedding = ir2vec::Embedding;
+using MachineInstEmbeddingsMap = DenseMap;
+using MachineBlockEmbeddingsMap =
+DenseMap;
 
 /// Class for storing and accessing the MIR2Vec vocabulary.
 /// The MIRVocabulary class manages seed embeddings for LLVM Machine IR
@@ -132,6 +142,79 @@ class MIRVocabulary {
 assert(isValid() && "Invalid vocabulary");
 return Storage.size();
   }
+
+  /// Create a dummy vocabulary for testing purposes.
+  static MIRVocabulary createDummyVocabForTest(const TargetInstrInfo &TII,
+   unsigned Dim = 1);
+};
+
+/// Base class for MIR embedders
+class MIREmbedder {
+protected:
+  const MachineFunction &MF;
+  const MIRVocabulary &Vocab;
+
+  /// Dimension of the embeddings; Captured from the vocabulary
+  const unsigned Dimension;
+
+  /// Weight for opcode embeddings
+  const float OpcWeight;
+
+  // Utility maps - these are used to store the vector representations of
+  // instructions, basic blocks and functions.
+  mutable Embedding MFuncVector;
+  mutable MachineBlockEmbeddingsMap MBBVecMap;
+  mutable MachineInstEmbeddingsMap MInstVecMap;
+
+  MIREmbedder(const MachineFunction &MF, const MIRVocabulary &Vocab);
+
+  /// Function to compute embeddings. It generates embeddings for all
+  /// the instructions and basic blocks in the function F.
+  void computeEmbeddings() const;
+
+  /// Function to compute the embedding for a given basic block.
+  /// Specific to the kind of embeddings being computed.
+  virtual void computeEmbeddings(const MachineBasicBlock &MBB) const = 0;
+
+public:
+  virtual ~MIREmbedder() = default;
+
+  /// Factory method to create an Embedder object of the specified kind
+  /// Returns nullptr if the requested kind is not supported.
+  static std::unique_ptr create(MIR2VecKind Mode,
+ const MachineFunction &MF,
+ const MIRVocabulary &Vocab);
+
+  /// Returns a map containing machine instructions and the corresponding
+  /// embeddings for the machine function MF if it has been computed. If not, 
it
+  /// computes the embeddings for MF and returns the map.
+  const MachineInstEmbeddingsMap &getMInstVecMap() const;
+
+  /// Returns a map containing machine basic block and the corresponding
+  /// embeddings for the machine function MF if it has been computed. If not, 
it
+  /// computes the embeddings for MF and returns the map.
+  const MachineBlockEmbeddingsMap &getMBBVecMap() const;
+
+  /// Returns the embedding for a given machine basic block in the machine
+  /// function MF if it has been computed. If not, it computes the embedding 
for
+  /// MBB and returns it.
+  const Embedding &getMBBVector(const MachineBasicBlock &MBB) const;
+
+  /// Computes and returns the embedding for the current machine function.
+  const Embedding &getMFunctionVector() const;
+};
+
+/// Class for computing Symbolic embeddings
+/// Symbolic embeddings are constructed based on the entity-level
+/// representations obtained from the MIR Vocabulary.
+class SymbolicMIREmbedder : public MIREmbedder {
+private:
+  void computeEmbeddings(const MachineBasicBlock &MBB) const override;
+
+public:
+  SymbolicMIREmbedder(const MachineFunction &F, const MIRVocabulary &Vocab);
+  static std::unique_ptr
+  create(const MachineFun

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

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


@@ -58,11 +58,18 @@ class StaticDataProfileInfo {
   LLVM_ABI StaticDataHotness getSectionHotnessUsingProfileCount(
   const Constant *C, const ProfileSummaryInfo *PSI, uint64_t Count) const;
 
+  /// Return the hotness based on section prefix \p SectionPrefix.
+  LLVM_ABI StaticDataHotness
+  getSectionHotnessUsingDAP(std::optional SectionPrefix) const;

mingmingl-llvm wrote:

done by extending 'DAP' to `DataAccessProfile` or `DataAccessProf`. I'll think 
about where to mention 'DAP' to LLVM docs so the abbreviation name are widely 
known (like PGO/LTO, etc).

I'll revise the test name 
`llvm/test/CodeGen/X86/global-variable-partition-with-dap.ll` in a follow-up 
patch.

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


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

2025-10-14 Thread Snehasish Kumar via llvm-branch-commits


@@ -46,6 +50,12 @@ bool IsAnnotationOK(const GlobalVariable &GV) {
 } // namespace memprof
 } // namespace llvm
 
+#ifndef NDEBUG
+static StringRef debugPrintSectionPrefix(StringRef Prefix) {

snehasish wrote:

This is only used within one function, so maybe move it closer to where it's 
used and make it a function object?

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


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

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

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


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

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

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


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

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

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


[llvm-branch-commits] [clang] [clang][Driver] Support Outline Flags on RISC-V and X86 (PR #163494)

2025-10-14 Thread Sam Elliott via llvm-branch-commits

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

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


[llvm-branch-commits] [clang] [llvm] [HLSL] GetDimensions methods for buffer resources (PR #161929)

2025-10-14 Thread Farzon Lotfi via llvm-branch-commits

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


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