[lld] [llvm] [llvm][lld] Respect temporal profile weights in balanced partitioning (PR #213837)

Karim Alweheshy via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 5 15:45:54 PDT 2026


================
@@ -60,10 +61,41 @@ class BPFunctionNode {
 public:
   using IDT = uint64_t;
   using UtilityNodeT = uint32_t;
+  using UtilityNodeWeightT = uint64_t;
+
+  struct WeightedUtilityNode {
+    UtilityNodeT Id;
+    UtilityNodeWeightT Weight;
+
+    WeightedUtilityNode(UtilityNodeT Id, UtilityNodeWeightT Weight)
+        : Id(Id), Weight(Weight) {}
+
+    bool operator==(const WeightedUtilityNode &Other) const {
+      return Id == Other.Id && Weight == Other.Weight;
+    }
+  };
 
   /// \param UtilityNodes the set of utility nodes (must be unique'd)
-  BPFunctionNode(IDT Id, ArrayRef<UtilityNodeT> UtilityNodes)
-      : Id(Id), UtilityNodes(UtilityNodes) {}
+  BPFunctionNode(IDT Id, ArrayRef<UtilityNodeT> UtilityNodes) : Id(Id) {
+    for (UtilityNodeT UtilityNode : UtilityNodes)
+      this->UtilityNodes.emplace_back(UtilityNode, 1);
+  }
+
+  /// Create a node with weighted utility nodes (which must be unique'd). All
+  /// occurrences of a utility node must have the same weight. A utility's cost
+  /// is multiplied by its weight without materializing duplicate utility
+  /// nodes. Zero-weight utility nodes are ignored.
+  static BPFunctionNode
+  createWithWeightedUtilities(IDT Id,
+                              ArrayRef<WeightedUtilityNode> UtilityNodes) {
----------------
karim-alweheshy wrote:

Superseded by the sparse side-map design in 3f0762d23292; BPFunctionNode keeps its original constructor and compact utility storage.

https://github.com/llvm/llvm-project/pull/213837


More information about the llvm-commits mailing list