[llvm] Adding Matching and Inference Functionality to Propeller-PR4: Implement matching and inference and create clusters (PR #167622)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 24 00:06:20 PST 2025
================
@@ -0,0 +1,62 @@
+//===- llvm/CodeGen/BasicBlockMatchingAndInference.h ------------*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// Infer weights for all basic blocks using matching and inference.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CODEGEN_BASIC_BLOCK_AND_INFERENCE_H
+#define LLVM_CODEGEN_BASIC_BLOCK_AND_INFERENCE_H
+
+#include "llvm/CodeGen/BasicBlockSectionsProfileReader.h"
+#include "llvm/CodeGen/MachineFunctionPass.h"
+#include "llvm/Transforms/Utils/SampleProfileInference.h"
+
+namespace llvm {
+
+class BasicBlockMatchingAndInference : public MachineFunctionPass {
+private:
+ using Edge = std::pair<const MachineBasicBlock *, const MachineBasicBlock *>;
----------------
wdx727 wrote:
Since `Edge` is used as the key for `DenseMap`, using a struct would require implementing additional required methods, which would increase code complexity. Moreover, per the existing codebase, `Edge` is typically represented via a `pair` (e.g., in `SampleProfileInference.h`, `SampleProfileLoaderBaseImpl.h`, and `BranchProbabilityInfo.h)`. Therefore, we intend to use a `pair`. Is this acceptable?
https://github.com/llvm/llvm-project/pull/167622
More information about the llvm-commits
mailing list