Skip to content

[CodeGen][NewPM] Port machine-block-freq to new pass manager #98317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 12, 2024

Conversation

paperchalice
Copy link
Contributor

  • Add MachineBlockFrequencyAnalysis.
  • Add MachineBlockFrequencyPrinterPass.
  • Use MachineBlockFrequencyInfoWrapperPass in legacy pass manager.
  • LazyMachineBlockFrequencyInfo::print is empty, drop it due to new pass manager migration.

@llvmbot
Copy link
Member

llvmbot commented Jul 10, 2024

@llvm/pr-subscribers-llvm-globalisel
@llvm/pr-subscribers-pgo
@llvm/pr-subscribers-backend-x86
@llvm/pr-subscribers-backend-webassembly
@llvm/pr-subscribers-backend-powerpc

@llvm/pr-subscribers-llvm-regalloc

Author: None (paperchalice)

Changes
  • Add MachineBlockFrequencyAnalysis.
  • Add MachineBlockFrequencyPrinterPass.
  • Use MachineBlockFrequencyInfoWrapperPass in legacy pass manager.
  • LazyMachineBlockFrequencyInfo::print is empty, drop it due to new pass manager migration.

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

35 Files Affected:

  • (modified) llvm/include/llvm/CodeGen/LazyMachineBlockFrequencyInfo.h (-1)
  • (modified) llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h (+54-9)
  • (modified) llvm/include/llvm/InitializePasses.h (+1-1)
  • (modified) llvm/include/llvm/Passes/MachinePassRegistry.def (+3-1)
  • (modified) llvm/lib/CodeGen/BranchFolding.cpp (+2-2)
  • (modified) llvm/lib/CodeGen/CodeGen.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp (+15-14)
  • (modified) llvm/lib/CodeGen/IfConversion.cpp (+3-2)
  • (modified) llvm/lib/CodeGen/InlineSpiller.cpp (+4-2)
  • (modified) llvm/lib/CodeGen/LazyMachineBlockFrequencyInfo.cpp (+5-9)
  • (modified) llvm/lib/CodeGen/MIRSampleProfile.cpp (+3-3)
  • (modified) llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp (+9-6)
  • (modified) llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp (+51-11)
  • (modified) llvm/lib/CodeGen/MachineBlockPlacement.cpp (+6-6)
  • (modified) llvm/lib/CodeGen/MachineCSE.cpp (+3-3)
  • (modified) llvm/lib/CodeGen/MachineFunctionSplitter.cpp (+2-2)
  • (modified) llvm/lib/CodeGen/MachineLICM.cpp (+4-4)
  • (modified) llvm/lib/CodeGen/MachineSink.cpp (+4-2)
  • (modified) llvm/lib/CodeGen/RegAllocBasic.cpp (+5-5)
  • (modified) llvm/lib/CodeGen/RegAllocGreedy.cpp (+3-3)
  • (modified) llvm/lib/CodeGen/RegAllocPBQP.cpp (+3-3)
  • (modified) llvm/lib/CodeGen/ShrinkWrap.cpp (+3-3)
  • (modified) llvm/lib/CodeGen/SpillPlacement.cpp (+2-2)
  • (modified) llvm/lib/CodeGen/StackSlotColoring.cpp (+3-3)
  • (modified) llvm/lib/Passes/PassBuilder.cpp (+1)
  • (modified) llvm/lib/Target/Hexagon/HexagonLoopAlign.cpp (+2-2)
  • (modified) llvm/lib/Target/PowerPC/PPCMIPeephole.cpp (+4-4)
  • (modified) llvm/lib/Target/WebAssembly/WebAssemblyArgumentMove.cpp (+1-1)
  • (modified) llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp (+1-1)
  • (modified) llvm/lib/Target/WebAssembly/WebAssemblyMemIntrinsicResults.cpp (+2-2)
  • (modified) llvm/lib/Target/WebAssembly/WebAssemblyOptimizeLiveIntervals.cpp (+1-1)
  • (modified) llvm/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp (+3-3)
  • (modified) llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp (+1-1)
  • (modified) llvm/lib/Target/WebAssembly/WebAssemblySetP2AlignOperands.cpp (+1-1)
  • (added) llvm/test/CodeGen/X86/machine-block-freq.ll (+44)
diff --git a/llvm/include/llvm/CodeGen/LazyMachineBlockFrequencyInfo.h b/llvm/include/llvm/CodeGen/LazyMachineBlockFrequencyInfo.h
index e5794966ce630..f7e5b0e4f9d2b 100644
--- a/llvm/include/llvm/CodeGen/LazyMachineBlockFrequencyInfo.h
+++ b/llvm/include/llvm/CodeGen/LazyMachineBlockFrequencyInfo.h
@@ -69,7 +69,6 @@ class LazyMachineBlockFrequencyInfoPass : public MachineFunctionPass {
 
   bool runOnMachineFunction(MachineFunction &F) override;
   void releaseMemory() override;
-  void print(raw_ostream &OS, const Module *M) const override;
 };
 }
 #endif
diff --git a/llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h b/llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h
index 3a85bb4ac9f7d..546a5be317667 100644
--- a/llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h
@@ -14,6 +14,7 @@
 #define LLVM_CODEGEN_MACHINEBLOCKFREQUENCYINFO_H
 
 #include "llvm/CodeGen/MachineFunctionPass.h"
+#include "llvm/CodeGen/MachinePassManager.h"
 #include "llvm/Support/BlockFrequency.h"
 #include <cstdint>
 #include <memory>
@@ -30,29 +31,30 @@ class raw_ostream;
 
 /// MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation
 /// to estimate machine basic block frequencies.
-class MachineBlockFrequencyInfo : public MachineFunctionPass {
+class MachineBlockFrequencyInfo {
   using ImplType = BlockFrequencyInfoImpl<MachineBasicBlock>;
   std::unique_ptr<ImplType> MBFI;
 
 public:
-  static char ID;
-
-  MachineBlockFrequencyInfo();
+  MachineBlockFrequencyInfo(); // Legacy pass manager only.
   explicit MachineBlockFrequencyInfo(MachineFunction &F,
                                      MachineBranchProbabilityInfo &MBPI,
                                      MachineLoopInfo &MLI);
-  ~MachineBlockFrequencyInfo() override;
-
-  void getAnalysisUsage(AnalysisUsage &AU) const override;
+  MachineBlockFrequencyInfo(MachineBlockFrequencyInfo &&);
+  ~MachineBlockFrequencyInfo();
 
-  bool runOnMachineFunction(MachineFunction &F) override;
+  /// Handle invalidation explicitly.
+  bool invalidate(MachineFunction &F, const PreservedAnalyses &PA,
+                  MachineFunctionAnalysisManager::Invalidator &);
 
   /// calculate - compute block frequency info for the given function.
   void calculate(const MachineFunction &F,
                  const MachineBranchProbabilityInfo &MBPI,
                  const MachineLoopInfo &MLI);
 
-  void releaseMemory() override;
+  void print(raw_ostream &OS);
+
+  void releaseMemory();
 
   /// getblockFreq - Return block frequency. Return 0 if we don't have the
   /// information. Please note that initial frequency is equal to 1024. It means
@@ -107,6 +109,49 @@ Printable printBlockFreq(const MachineBlockFrequencyInfo &MBFI,
 Printable printBlockFreq(const MachineBlockFrequencyInfo &MBFI,
                          const MachineBasicBlock &MBB);
 
+class MachineBlockFrequencyAnalysis
+    : public AnalysisInfoMixin<MachineBlockFrequencyAnalysis> {
+  friend AnalysisInfoMixin<MachineBlockFrequencyAnalysis>;
+  static AnalysisKey Key;
+
+public:
+  using Result = MachineBlockFrequencyInfo;
+
+  Result run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM);
+};
+
+/// Printer pass for the \c MachineBlockFrequencyInfo results.
+class MachineBlockFrequencyPrinterPass
+    : public PassInfoMixin<MachineBlockFrequencyPrinterPass> {
+  raw_ostream &OS;
+
+public:
+  explicit MachineBlockFrequencyPrinterPass(raw_ostream &OS) : OS(OS) {}
+
+  PreservedAnalyses run(MachineFunction &MF,
+                        MachineFunctionAnalysisManager &MFAM);
+
+  static bool isRequired() { return true; }
+};
+
+class MachineBlockFrequencyInfoWrapperPass : public MachineFunctionPass {
+  MachineBlockFrequencyInfo MBFI;
+
+public:
+  static char ID;
+
+  MachineBlockFrequencyInfoWrapperPass();
+
+  void getAnalysisUsage(AnalysisUsage &AU) const override;
+
+  bool runOnMachineFunction(MachineFunction &F) override;
+
+  void releaseMemory() override { MBFI.releaseMemory(); }
+
+  MachineBlockFrequencyInfo &getMBFI() { return MBFI; }
+
+  const MachineBlockFrequencyInfo &getMBFI() const { return MBFI; }
+};
 } // end namespace llvm
 
 #endif // LLVM_CODEGEN_MACHINEBLOCKFREQUENCYINFO_H
diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h
index a2dfc17ac46fd..8979fcd95aa9a 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -179,7 +179,7 @@ void initializeMIRAddFSDiscriminatorsPass(PassRegistry &);
 void initializeMIRCanonicalizerPass(PassRegistry &);
 void initializeMIRNamerPass(PassRegistry &);
 void initializeMIRPrintingPassPass(PassRegistry&);
-void initializeMachineBlockFrequencyInfoPass(PassRegistry&);
+void initializeMachineBlockFrequencyInfoWrapperPassPass(PassRegistry &);
 void initializeMachineBlockPlacementPass(PassRegistry&);
 void initializeMachineBlockPlacementStatsPass(PassRegistry&);
 void initializeMachineBranchProbabilityInfoWrapperPassPass(PassRegistry &);
diff --git a/llvm/include/llvm/Passes/MachinePassRegistry.def b/llvm/include/llvm/Passes/MachinePassRegistry.def
index e8d3810670ef9..d5cd8d4a132fc 100644
--- a/llvm/include/llvm/Passes/MachinePassRegistry.def
+++ b/llvm/include/llvm/Passes/MachinePassRegistry.def
@@ -96,6 +96,7 @@ LOOP_PASS("loop-reduce", LoopStrengthReducePass())
 // preferably fix the scavenger to not depend on them).
 MACHINE_FUNCTION_ANALYSIS("live-intervals", LiveIntervalsAnalysis())
 MACHINE_FUNCTION_ANALYSIS("live-vars", LiveVariablesAnalysis())
+MACHINE_FUNCTION_ANALYSIS("machine-block-freq", MachineBlockFrequencyAnalysis())
 MACHINE_FUNCTION_ANALYSIS("machine-branch-prob",
                           MachineBranchProbabilityAnalysis())
 MACHINE_FUNCTION_ANALYSIS("machine-dom-tree", MachineDominatorTreeAnalysis())
@@ -108,7 +109,6 @@ MACHINE_FUNCTION_ANALYSIS("slot-indexes", SlotIndexesAnalysis())
 // MACHINE_FUNCTION_ANALYSIS("edge-bundles", EdgeBundlesAnalysis())
 // MACHINE_FUNCTION_ANALYSIS("lazy-machine-bfi",
 // LazyMachineBlockFrequencyInfoAnalysis())
-// MACHINE_FUNCTION_ANALYSIS("machine-bfi", MachineBlockFrequencyInfoAnalysis())
 // MACHINE_FUNCTION_ANALYSIS("machine-loops", MachineLoopInfoAnalysis())
 // MACHINE_FUNCTION_ANALYSIS("machine-dom-frontier",
 // MachineDominanceFrontierAnalysis())
@@ -135,6 +135,8 @@ MACHINE_FUNCTION_PASS("no-op-machine-function", NoOpMachineFunctionPass())
 MACHINE_FUNCTION_PASS("print", PrintMIRPass())
 MACHINE_FUNCTION_PASS("print<live-intervals>", LiveIntervalsPrinterPass(dbgs()))
 MACHINE_FUNCTION_PASS("print<live-vars>", LiveVariablesPrinterPass(dbgs()))
+MACHINE_FUNCTION_PASS("print<machine-block-freq>",
+                      MachineBlockFrequencyPrinterPass(dbgs()))
 MACHINE_FUNCTION_PASS("print<machine-branch-prob>",
                       MachineBranchProbabilityPrinterPass(dbgs()))
 MACHINE_FUNCTION_PASS("print<machine-dom-tree>",
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp
index afe797014095d..c0fc7a2b35ea3 100644
--- a/llvm/lib/CodeGen/BranchFolding.cpp
+++ b/llvm/lib/CodeGen/BranchFolding.cpp
@@ -98,7 +98,7 @@ namespace {
     bool runOnMachineFunction(MachineFunction &MF) override;
 
     void getAnalysisUsage(AnalysisUsage &AU) const override {
-      AU.addRequired<MachineBlockFrequencyInfo>();
+      AU.addRequired<MachineBlockFrequencyInfoWrapperPass>();
       AU.addRequired<MachineBranchProbabilityInfoWrapperPass>();
       AU.addRequired<ProfileSummaryInfoWrapperPass>();
       AU.addRequired<TargetPassConfig>();
@@ -130,7 +130,7 @@ bool BranchFolderPass::runOnMachineFunction(MachineFunction &MF) {
   bool EnableTailMerge = !MF.getTarget().requiresStructuredCFG() &&
                          PassConfig->getEnableTailMerge();
   MBFIWrapper MBBFreqInfo(
-      getAnalysis<MachineBlockFrequencyInfo>());
+      getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI());
   BranchFolder Folder(
       EnableTailMerge, /*CommonHoist=*/true, MBBFreqInfo,
       getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI(),
diff --git a/llvm/lib/CodeGen/CodeGen.cpp b/llvm/lib/CodeGen/CodeGen.cpp
index a30eaae90a5fd..ccd8f76fb4f63 100644
--- a/llvm/lib/CodeGen/CodeGen.cpp
+++ b/llvm/lib/CodeGen/CodeGen.cpp
@@ -71,7 +71,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) {
   initializeMIRCanonicalizerPass(Registry);
   initializeMIRNamerPass(Registry);
   initializeMIRProfileLoaderPassPass(Registry);
-  initializeMachineBlockFrequencyInfoPass(Registry);
+  initializeMachineBlockFrequencyInfoWrapperPassPass(Registry);
   initializeMachineBlockPlacementPass(Registry);
   initializeMachineBlockPlacementStatsPass(Registry);
   initializeMachineCFGPrinterPass(Registry);
diff --git a/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp b/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp
index e067bd8961a23..e386647daa653 100644
--- a/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp
@@ -62,7 +62,7 @@ char RegBankSelect::ID = 0;
 INITIALIZE_PASS_BEGIN(RegBankSelect, DEBUG_TYPE,
                       "Assign register bank of generic virtual registers",
                       false, false);
-INITIALIZE_PASS_DEPENDENCY(MachineBlockFrequencyInfo)
+INITIALIZE_PASS_DEPENDENCY(MachineBlockFrequencyInfoWrapperPass)
 INITIALIZE_PASS_DEPENDENCY(MachineBranchProbabilityInfoWrapperPass)
 INITIALIZE_PASS_DEPENDENCY(TargetPassConfig)
 INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,
@@ -85,7 +85,7 @@ void RegBankSelect::init(MachineFunction &MF) {
   TRI = MF.getSubtarget().getRegisterInfo();
   TPC = &getAnalysis<TargetPassConfig>();
   if (OptMode != Mode::Fast) {
-    MBFI = &getAnalysis<MachineBlockFrequencyInfo>();
+    MBFI = &getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI();
     MBPI = &getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI();
   } else {
     MBFI = nullptr;
@@ -99,7 +99,7 @@ void RegBankSelect::getAnalysisUsage(AnalysisUsage &AU) const {
   if (OptMode != Mode::Fast) {
     // We could preserve the information from these two analysis but
     // the APIs do not allow to do so yet.
-    AU.addRequired<MachineBlockFrequencyInfo>();
+    AU.addRequired<MachineBlockFrequencyInfoWrapperPass>();
     AU.addRequired<MachineBranchProbabilityInfoWrapperPass>();
   }
   AU.addRequired<TargetPassConfig>();
@@ -919,19 +919,19 @@ bool RegBankSelect::InstrInsertPoint::isSplit() const {
 uint64_t RegBankSelect::InstrInsertPoint::frequency(const Pass &P) const {
   // Even if we need to split, because we insert between terminators,
   // this split has actually the same frequency as the instruction.
-  const MachineBlockFrequencyInfo *MBFI =
-      P.getAnalysisIfAvailable<MachineBlockFrequencyInfo>();
-  if (!MBFI)
+  const auto *MBFIWrapper =
+      P.getAnalysisIfAvailable<MachineBlockFrequencyInfoWrapperPass>();
+  if (!MBFIWrapper)
     return 1;
-  return MBFI->getBlockFreq(Instr.getParent()).getFrequency();
+  return MBFIWrapper->getMBFI().getBlockFreq(Instr.getParent()).getFrequency();
 }
 
 uint64_t RegBankSelect::MBBInsertPoint::frequency(const Pass &P) const {
-  const MachineBlockFrequencyInfo *MBFI =
-      P.getAnalysisIfAvailable<MachineBlockFrequencyInfo>();
-  if (!MBFI)
+  const auto *MBFIWrapper =
+      P.getAnalysisIfAvailable<MachineBlockFrequencyInfoWrapperPass>();
+  if (!MBFIWrapper)
     return 1;
-  return MBFI->getBlockFreq(&MBB).getFrequency();
+  return MBFIWrapper->getMBFI().getBlockFreq(&MBB).getFrequency();
 }
 
 void RegBankSelect::EdgeInsertPoint::materialize() {
@@ -948,10 +948,11 @@ void RegBankSelect::EdgeInsertPoint::materialize() {
 }
 
 uint64_t RegBankSelect::EdgeInsertPoint::frequency(const Pass &P) const {
-  const MachineBlockFrequencyInfo *MBFI =
-      P.getAnalysisIfAvailable<MachineBlockFrequencyInfo>();
-  if (!MBFI)
+  const auto *MBFIWrapper =
+      P.getAnalysisIfAvailable<MachineBlockFrequencyInfoWrapperPass>();
+  if (!MBFIWrapper)
     return 1;
+  const auto *MBFI = &MBFIWrapper->getMBFI();
   if (WasMaterialized)
     return MBFI->getBlockFreq(DstOrSplit).getFrequency();
 
diff --git a/llvm/lib/CodeGen/IfConversion.cpp b/llvm/lib/CodeGen/IfConversion.cpp
index 02cb95c5d7664..f3789569b78fb 100644
--- a/llvm/lib/CodeGen/IfConversion.cpp
+++ b/llvm/lib/CodeGen/IfConversion.cpp
@@ -209,7 +209,7 @@ namespace {
     }
 
     void getAnalysisUsage(AnalysisUsage &AU) const override {
-      AU.addRequired<MachineBlockFrequencyInfo>();
+      AU.addRequired<MachineBlockFrequencyInfoWrapperPass>();
       AU.addRequired<MachineBranchProbabilityInfoWrapperPass>();
       AU.addRequired<ProfileSummaryInfoWrapperPass>();
       MachineFunctionPass::getAnalysisUsage(AU);
@@ -444,7 +444,8 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
   TLI = ST.getTargetLowering();
   TII = ST.getInstrInfo();
   TRI = ST.getRegisterInfo();
-  MBFIWrapper MBFI(getAnalysis<MachineBlockFrequencyInfo>());
+  MBFIWrapper MBFI(
+      getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI());
   MBPI = &getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI();
   ProfileSummaryInfo *PSI =
       &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
diff --git a/llvm/lib/CodeGen/InlineSpiller.cpp b/llvm/lib/CodeGen/InlineSpiller.cpp
index 6abbf8b6d7e0a..81ae805d64e1e 100644
--- a/llvm/lib/CodeGen/InlineSpiller.cpp
+++ b/llvm/lib/CodeGen/InlineSpiller.cpp
@@ -136,7 +136,8 @@ class HoistSpillHelper : private LiveRangeEdit::Delegate {
         MDT(pass.getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree()),
         VRM(vrm), MRI(mf.getRegInfo()), TII(*mf.getSubtarget().getInstrInfo()),
         TRI(*mf.getSubtarget().getRegisterInfo()),
-        MBFI(pass.getAnalysis<MachineBlockFrequencyInfo>()),
+        MBFI(
+            pass.getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI()),
         IPA(LIS, mf.getNumBlockIDs()) {}
 
   void addToMergeableSpills(MachineInstr &Spill, int StackSlot,
@@ -193,7 +194,8 @@ class InlineSpiller : public Spiller {
         MDT(Pass.getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree()),
         VRM(VRM), MRI(MF.getRegInfo()), TII(*MF.getSubtarget().getInstrInfo()),
         TRI(*MF.getSubtarget().getRegisterInfo()),
-        MBFI(Pass.getAnalysis<MachineBlockFrequencyInfo>()),
+        MBFI(
+            Pass.getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI()),
         HSpiller(Pass, MF, VRM), VRAI(VRAI) {}
 
   void spill(LiveRangeEdit &) override;
diff --git a/llvm/lib/CodeGen/LazyMachineBlockFrequencyInfo.cpp b/llvm/lib/CodeGen/LazyMachineBlockFrequencyInfo.cpp
index 0cf01edbff6c8..ff6b42238bb21 100644
--- a/llvm/lib/CodeGen/LazyMachineBlockFrequencyInfo.cpp
+++ b/llvm/lib/CodeGen/LazyMachineBlockFrequencyInfo.cpp
@@ -36,11 +36,6 @@ LazyMachineBlockFrequencyInfoPass::LazyMachineBlockFrequencyInfoPass()
       *PassRegistry::getPassRegistry());
 }
 
-void LazyMachineBlockFrequencyInfoPass::print(raw_ostream &OS,
-                                              const Module *M) const {
-  getBFI().print(OS, M);
-}
-
 void LazyMachineBlockFrequencyInfoPass::getAnalysisUsage(
     AnalysisUsage &AU) const {
   AU.addRequired<MachineBranchProbabilityInfoWrapperPass>();
@@ -56,10 +51,11 @@ void LazyMachineBlockFrequencyInfoPass::releaseMemory() {
 
 MachineBlockFrequencyInfo &
 LazyMachineBlockFrequencyInfoPass::calculateIfNotAvailable() const {
-  auto *MBFI = getAnalysisIfAvailable<MachineBlockFrequencyInfo>();
-  if (MBFI) {
-    LLVM_DEBUG(dbgs() << "MachineBlockFrequencyInfo is available\n");
-    return *MBFI;
+  auto *MBFIWrapper =
+      getAnalysisIfAvailable<MachineBlockFrequencyInfoWrapperPass>();
+  if (MBFIWrapper) {
+    LLVM_DEBUG(dbgs() << "MachineBlockFrequencyInfoWrapperPass is available\n");
+    return MBFIWrapper->getMBFI();
   }
 
   auto &MBPI = getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI();
diff --git a/llvm/lib/CodeGen/MIRSampleProfile.cpp b/llvm/lib/CodeGen/MIRSampleProfile.cpp
index b77d8aabe029a..ce82f280c1c53 100644
--- a/llvm/lib/CodeGen/MIRSampleProfile.cpp
+++ b/llvm/lib/CodeGen/MIRSampleProfile.cpp
@@ -69,7 +69,7 @@ char MIRProfileLoaderPass::ID = 0;
 INITIALIZE_PASS_BEGIN(MIRProfileLoaderPass, DEBUG_TYPE,
                       "Load MIR Sample Profile",
                       /* cfg = */ false, /* is_analysis = */ false)
-INITIALIZE_PASS_DEPENDENCY(MachineBlockFrequencyInfo)
+INITIALIZE_PASS_DEPENDENCY(MachineBlockFrequencyInfoWrapperPass)
 INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass)
 INITIALIZE_PASS_DEPENDENCY(MachinePostDominatorTreeWrapperPass)
 INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass)
@@ -363,7 +363,7 @@ bool MIRProfileLoaderPass::runOnMachineFunction(MachineFunction &MF) {
 
   LLVM_DEBUG(dbgs() << "MIRProfileLoader pass working on Func: "
                     << MF.getFunction().getName() << "\n");
-  MBFI = &getAnalysis<MachineBlockFrequencyInfo>();
+  MBFI = &getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI();
   MIRSampleLoader->setInitVals(
       &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree(),
       &getAnalysis<MachinePostDominatorTreeWrapperPass>().getPostDomTree(),
@@ -401,7 +401,7 @@ bool MIRProfileLoaderPass::doInitialization(Module &M) {
 
 void MIRProfileLoaderPass::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.setPreservesAll();
-  AU.addRequired<MachineBlockFrequencyInfo>();
+  AU.addRequired<MachineBlockFrequencyInfoWrapperPass>();
   AU.addRequired<MachineDominatorTreeWrapperPass>();
   AU.addRequired<MachinePostDominatorTreeWrapperPass>();
   AU.addRequiredTransitive<MachineLoopInfoWrapperPass>();
diff --git a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp
index 7f90457d720b4..4f0fab8e58bf8 100644
--- a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp
+++ b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp
@@ -110,7 +110,7 @@ class RegAllocScoring : public MachineFunctionPass {
     AU.setPreservesAll();
     AU.addRequired<RegAllocEvictionAdvisorAnalysis>();
     AU.addRequired<RegAllocPriorityAdvisorAnalysis>();
-    AU.addRequired<MachineBlockFrequencyInfo>();
+    AU.addRequired<MachineBlockFrequencyInfoWrapperPass>();
     MachineFunctionPass::getAnalysisUsage(AU);
   }
 
@@ -388,7 +388,7 @@ class ReleaseModeEvictionAdvisorAnalysis final
   std::vector<TensorSpec> InputFeatures;
 
   void getAnalysisUsage(AnalysisUsage &AU) const override {
-    AU.addRequired<MachineBlockFrequencyInfo>();
+    AU.addRequired<MachineBlockFrequencyInfoWrapperPass>();
     AU.addRequired<MachineLoopInfoWrapperPass>();
     RegAllocEvictionAdvisorAnalysis::getAnalysisUsage(AU);
   }
@@ -406,7 +406,8 @@ class ReleaseModeEvictionAdvisorAnalysis final
             InteractiveChannelBaseName + ".in");
     }
     return std::make_unique<MLEvictAdvisor>(
-        MF, RA, Runner.get(), getAnalysis<MachineBlockFrequencyInfo>(),
+        MF, RA, Runner.get(),
+        getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI(),
         getAnalysis<MachineLoopInfoWrapperPass>().getLI());
   }
   std::unique_ptr<MLModelRunner> Runner;
@@ -495,7 +496,7 @@ class DevelopmentModeEvictionAdvisorAnalysis final
   std::vector<TensorSpec> TrainingInputFeatures;
 
   void getAnalysisUsage(AnalysisUsage &AU) const override {
-    AU.addRequired<MachineBlockFrequencyInfo>();
+    AU.addRequired<MachineBlockFrequencyInfoWrapperPass>();
     AU.addRequired<MachineLoopInfoWrapperPass>();
     RegAllocEvictionAdvisorAnalysis::getAnalysisUsage(AU);
   }
@@ -544,7 +545,8 @@ class DevelopmentModeEvictionAdvisorAnalysis final
     if (Log)
       Log->switchContext(MF.getName());
     return std::make_unique<DevelopmentModeEvictAdvisor>(
-        MF, RA, Runner.get(), getAnalysis<MachineBlockFrequencyInfo>(),
+        MF, RA, Runner.get(),
+        getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI(),
         getAnalysis<MachineLoopInfoWrapperPass>().getLI(), Log.get());
   }
 
@@ -1139,7 +1141,8 @@ bool RegAllocScoring::runOnMachineFunction(MachineFunction &MF) {
   auto GetReward = [&]() {
     if (!CachedReward)
       CachedReward = static_cast<float>(
-          calculateRegAllocScore(MF, getAnalysis<MachineBlockFrequencyInfo>())
+          calculateRegAllocScore(
+              MF, getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI())
               .getScore());
     return *CachedReward;
   };
diff --git a/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp b/llvm/...
[truncated]

@llvmbot
Copy link
Member

llvmbot commented Jul 10, 2024

@llvm/pr-subscribers-mlgo

Author: None (paperchalice)

Changes
  • Add MachineBlockFrequencyAnalysis.
  • Add MachineBlockFrequencyPrinterPass.
  • Use MachineBlockFrequencyInfoWrapperPass in legacy pass manager.
  • LazyMachineBlockFrequencyInfo::print is empty, drop it due to new pass manager migration.

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

35 Files Affected:

  • (modified) llvm/include/llvm/CodeGen/LazyMachineBlockFrequencyInfo.h (-1)
  • (modified) llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h (+54-9)
  • (modified) llvm/include/llvm/InitializePasses.h (+1-1)
  • (modified) llvm/include/llvm/Passes/MachinePassRegistry.def (+3-1)
  • (modified) llvm/lib/CodeGen/BranchFolding.cpp (+2-2)
  • (modified) llvm/lib/CodeGen/CodeGen.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp (+15-14)
  • (modified) llvm/lib/CodeGen/IfConversion.cpp (+3-2)
  • (modified) llvm/lib/CodeGen/InlineSpiller.cpp (+4-2)
  • (modified) llvm/lib/CodeGen/LazyMachineBlockFrequencyInfo.cpp (+5-9)
  • (modified) llvm/lib/CodeGen/MIRSampleProfile.cpp (+3-3)
  • (modified) llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp (+9-6)
  • (modified) llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp (+51-11)
  • (modified) llvm/lib/CodeGen/MachineBlockPlacement.cpp (+6-6)
  • (modified) llvm/lib/CodeGen/MachineCSE.cpp (+3-3)
  • (modified) llvm/lib/CodeGen/MachineFunctionSplitter.cpp (+2-2)
  • (modified) llvm/lib/CodeGen/MachineLICM.cpp (+4-4)
  • (modified) llvm/lib/CodeGen/MachineSink.cpp (+4-2)
  • (modified) llvm/lib/CodeGen/RegAllocBasic.cpp (+5-5)
  • (modified) llvm/lib/CodeGen/RegAllocGreedy.cpp (+3-3)
  • (modified) llvm/lib/CodeGen/RegAllocPBQP.cpp (+3-3)
  • (modified) llvm/lib/CodeGen/ShrinkWrap.cpp (+3-3)
  • (modified) llvm/lib/CodeGen/SpillPlacement.cpp (+2-2)
  • (modified) llvm/lib/CodeGen/StackSlotColoring.cpp (+3-3)
  • (modified) llvm/lib/Passes/PassBuilder.cpp (+1)
  • (modified) llvm/lib/Target/Hexagon/HexagonLoopAlign.cpp (+2-2)
  • (modified) llvm/lib/Target/PowerPC/PPCMIPeephole.cpp (+4-4)
  • (modified) llvm/lib/Target/WebAssembly/WebAssemblyArgumentMove.cpp (+1-1)
  • (modified) llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp (+1-1)
  • (modified) llvm/lib/Target/WebAssembly/WebAssemblyMemIntrinsicResults.cpp (+2-2)
  • (modified) llvm/lib/Target/WebAssembly/WebAssemblyOptimizeLiveIntervals.cpp (+1-1)
  • (modified) llvm/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp (+3-3)
  • (modified) llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp (+1-1)
  • (modified) llvm/lib/Target/WebAssembly/WebAssemblySetP2AlignOperands.cpp (+1-1)
  • (added) llvm/test/CodeGen/X86/machine-block-freq.ll (+44)
diff --git a/llvm/include/llvm/CodeGen/LazyMachineBlockFrequencyInfo.h b/llvm/include/llvm/CodeGen/LazyMachineBlockFrequencyInfo.h
index e5794966ce630..f7e5b0e4f9d2b 100644
--- a/llvm/include/llvm/CodeGen/LazyMachineBlockFrequencyInfo.h
+++ b/llvm/include/llvm/CodeGen/LazyMachineBlockFrequencyInfo.h
@@ -69,7 +69,6 @@ class LazyMachineBlockFrequencyInfoPass : public MachineFunctionPass {
 
   bool runOnMachineFunction(MachineFunction &F) override;
   void releaseMemory() override;
-  void print(raw_ostream &OS, const Module *M) const override;
 };
 }
 #endif
diff --git a/llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h b/llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h
index 3a85bb4ac9f7d..546a5be317667 100644
--- a/llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h
@@ -14,6 +14,7 @@
 #define LLVM_CODEGEN_MACHINEBLOCKFREQUENCYINFO_H
 
 #include "llvm/CodeGen/MachineFunctionPass.h"
+#include "llvm/CodeGen/MachinePassManager.h"
 #include "llvm/Support/BlockFrequency.h"
 #include <cstdint>
 #include <memory>
@@ -30,29 +31,30 @@ class raw_ostream;
 
 /// MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation
 /// to estimate machine basic block frequencies.
-class MachineBlockFrequencyInfo : public MachineFunctionPass {
+class MachineBlockFrequencyInfo {
   using ImplType = BlockFrequencyInfoImpl<MachineBasicBlock>;
   std::unique_ptr<ImplType> MBFI;
 
 public:
-  static char ID;
-
-  MachineBlockFrequencyInfo();
+  MachineBlockFrequencyInfo(); // Legacy pass manager only.
   explicit MachineBlockFrequencyInfo(MachineFunction &F,
                                      MachineBranchProbabilityInfo &MBPI,
                                      MachineLoopInfo &MLI);
-  ~MachineBlockFrequencyInfo() override;
-
-  void getAnalysisUsage(AnalysisUsage &AU) const override;
+  MachineBlockFrequencyInfo(MachineBlockFrequencyInfo &&);
+  ~MachineBlockFrequencyInfo();
 
-  bool runOnMachineFunction(MachineFunction &F) override;
+  /// Handle invalidation explicitly.
+  bool invalidate(MachineFunction &F, const PreservedAnalyses &PA,
+                  MachineFunctionAnalysisManager::Invalidator &);
 
   /// calculate - compute block frequency info for the given function.
   void calculate(const MachineFunction &F,
                  const MachineBranchProbabilityInfo &MBPI,
                  const MachineLoopInfo &MLI);
 
-  void releaseMemory() override;
+  void print(raw_ostream &OS);
+
+  void releaseMemory();
 
   /// getblockFreq - Return block frequency. Return 0 if we don't have the
   /// information. Please note that initial frequency is equal to 1024. It means
@@ -107,6 +109,49 @@ Printable printBlockFreq(const MachineBlockFrequencyInfo &MBFI,
 Printable printBlockFreq(const MachineBlockFrequencyInfo &MBFI,
                          const MachineBasicBlock &MBB);
 
+class MachineBlockFrequencyAnalysis
+    : public AnalysisInfoMixin<MachineBlockFrequencyAnalysis> {
+  friend AnalysisInfoMixin<MachineBlockFrequencyAnalysis>;
+  static AnalysisKey Key;
+
+public:
+  using Result = MachineBlockFrequencyInfo;
+
+  Result run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM);
+};
+
+/// Printer pass for the \c MachineBlockFrequencyInfo results.
+class MachineBlockFrequencyPrinterPass
+    : public PassInfoMixin<MachineBlockFrequencyPrinterPass> {
+  raw_ostream &OS;
+
+public:
+  explicit MachineBlockFrequencyPrinterPass(raw_ostream &OS) : OS(OS) {}
+
+  PreservedAnalyses run(MachineFunction &MF,
+                        MachineFunctionAnalysisManager &MFAM);
+
+  static bool isRequired() { return true; }
+};
+
+class MachineBlockFrequencyInfoWrapperPass : public MachineFunctionPass {
+  MachineBlockFrequencyInfo MBFI;
+
+public:
+  static char ID;
+
+  MachineBlockFrequencyInfoWrapperPass();
+
+  void getAnalysisUsage(AnalysisUsage &AU) const override;
+
+  bool runOnMachineFunction(MachineFunction &F) override;
+
+  void releaseMemory() override { MBFI.releaseMemory(); }
+
+  MachineBlockFrequencyInfo &getMBFI() { return MBFI; }
+
+  const MachineBlockFrequencyInfo &getMBFI() const { return MBFI; }
+};
 } // end namespace llvm
 
 #endif // LLVM_CODEGEN_MACHINEBLOCKFREQUENCYINFO_H
diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h
index a2dfc17ac46fd..8979fcd95aa9a 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -179,7 +179,7 @@ void initializeMIRAddFSDiscriminatorsPass(PassRegistry &);
 void initializeMIRCanonicalizerPass(PassRegistry &);
 void initializeMIRNamerPass(PassRegistry &);
 void initializeMIRPrintingPassPass(PassRegistry&);
-void initializeMachineBlockFrequencyInfoPass(PassRegistry&);
+void initializeMachineBlockFrequencyInfoWrapperPassPass(PassRegistry &);
 void initializeMachineBlockPlacementPass(PassRegistry&);
 void initializeMachineBlockPlacementStatsPass(PassRegistry&);
 void initializeMachineBranchProbabilityInfoWrapperPassPass(PassRegistry &);
diff --git a/llvm/include/llvm/Passes/MachinePassRegistry.def b/llvm/include/llvm/Passes/MachinePassRegistry.def
index e8d3810670ef9..d5cd8d4a132fc 100644
--- a/llvm/include/llvm/Passes/MachinePassRegistry.def
+++ b/llvm/include/llvm/Passes/MachinePassRegistry.def
@@ -96,6 +96,7 @@ LOOP_PASS("loop-reduce", LoopStrengthReducePass())
 // preferably fix the scavenger to not depend on them).
 MACHINE_FUNCTION_ANALYSIS("live-intervals", LiveIntervalsAnalysis())
 MACHINE_FUNCTION_ANALYSIS("live-vars", LiveVariablesAnalysis())
+MACHINE_FUNCTION_ANALYSIS("machine-block-freq", MachineBlockFrequencyAnalysis())
 MACHINE_FUNCTION_ANALYSIS("machine-branch-prob",
                           MachineBranchProbabilityAnalysis())
 MACHINE_FUNCTION_ANALYSIS("machine-dom-tree", MachineDominatorTreeAnalysis())
@@ -108,7 +109,6 @@ MACHINE_FUNCTION_ANALYSIS("slot-indexes", SlotIndexesAnalysis())
 // MACHINE_FUNCTION_ANALYSIS("edge-bundles", EdgeBundlesAnalysis())
 // MACHINE_FUNCTION_ANALYSIS("lazy-machine-bfi",
 // LazyMachineBlockFrequencyInfoAnalysis())
-// MACHINE_FUNCTION_ANALYSIS("machine-bfi", MachineBlockFrequencyInfoAnalysis())
 // MACHINE_FUNCTION_ANALYSIS("machine-loops", MachineLoopInfoAnalysis())
 // MACHINE_FUNCTION_ANALYSIS("machine-dom-frontier",
 // MachineDominanceFrontierAnalysis())
@@ -135,6 +135,8 @@ MACHINE_FUNCTION_PASS("no-op-machine-function", NoOpMachineFunctionPass())
 MACHINE_FUNCTION_PASS("print", PrintMIRPass())
 MACHINE_FUNCTION_PASS("print<live-intervals>", LiveIntervalsPrinterPass(dbgs()))
 MACHINE_FUNCTION_PASS("print<live-vars>", LiveVariablesPrinterPass(dbgs()))
+MACHINE_FUNCTION_PASS("print<machine-block-freq>",
+                      MachineBlockFrequencyPrinterPass(dbgs()))
 MACHINE_FUNCTION_PASS("print<machine-branch-prob>",
                       MachineBranchProbabilityPrinterPass(dbgs()))
 MACHINE_FUNCTION_PASS("print<machine-dom-tree>",
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp
index afe797014095d..c0fc7a2b35ea3 100644
--- a/llvm/lib/CodeGen/BranchFolding.cpp
+++ b/llvm/lib/CodeGen/BranchFolding.cpp
@@ -98,7 +98,7 @@ namespace {
     bool runOnMachineFunction(MachineFunction &MF) override;
 
     void getAnalysisUsage(AnalysisUsage &AU) const override {
-      AU.addRequired<MachineBlockFrequencyInfo>();
+      AU.addRequired<MachineBlockFrequencyInfoWrapperPass>();
       AU.addRequired<MachineBranchProbabilityInfoWrapperPass>();
       AU.addRequired<ProfileSummaryInfoWrapperPass>();
       AU.addRequired<TargetPassConfig>();
@@ -130,7 +130,7 @@ bool BranchFolderPass::runOnMachineFunction(MachineFunction &MF) {
   bool EnableTailMerge = !MF.getTarget().requiresStructuredCFG() &&
                          PassConfig->getEnableTailMerge();
   MBFIWrapper MBBFreqInfo(
-      getAnalysis<MachineBlockFrequencyInfo>());
+      getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI());
   BranchFolder Folder(
       EnableTailMerge, /*CommonHoist=*/true, MBBFreqInfo,
       getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI(),
diff --git a/llvm/lib/CodeGen/CodeGen.cpp b/llvm/lib/CodeGen/CodeGen.cpp
index a30eaae90a5fd..ccd8f76fb4f63 100644
--- a/llvm/lib/CodeGen/CodeGen.cpp
+++ b/llvm/lib/CodeGen/CodeGen.cpp
@@ -71,7 +71,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) {
   initializeMIRCanonicalizerPass(Registry);
   initializeMIRNamerPass(Registry);
   initializeMIRProfileLoaderPassPass(Registry);
-  initializeMachineBlockFrequencyInfoPass(Registry);
+  initializeMachineBlockFrequencyInfoWrapperPassPass(Registry);
   initializeMachineBlockPlacementPass(Registry);
   initializeMachineBlockPlacementStatsPass(Registry);
   initializeMachineCFGPrinterPass(Registry);
diff --git a/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp b/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp
index e067bd8961a23..e386647daa653 100644
--- a/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp
@@ -62,7 +62,7 @@ char RegBankSelect::ID = 0;
 INITIALIZE_PASS_BEGIN(RegBankSelect, DEBUG_TYPE,
                       "Assign register bank of generic virtual registers",
                       false, false);
-INITIALIZE_PASS_DEPENDENCY(MachineBlockFrequencyInfo)
+INITIALIZE_PASS_DEPENDENCY(MachineBlockFrequencyInfoWrapperPass)
 INITIALIZE_PASS_DEPENDENCY(MachineBranchProbabilityInfoWrapperPass)
 INITIALIZE_PASS_DEPENDENCY(TargetPassConfig)
 INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,
@@ -85,7 +85,7 @@ void RegBankSelect::init(MachineFunction &MF) {
   TRI = MF.getSubtarget().getRegisterInfo();
   TPC = &getAnalysis<TargetPassConfig>();
   if (OptMode != Mode::Fast) {
-    MBFI = &getAnalysis<MachineBlockFrequencyInfo>();
+    MBFI = &getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI();
     MBPI = &getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI();
   } else {
     MBFI = nullptr;
@@ -99,7 +99,7 @@ void RegBankSelect::getAnalysisUsage(AnalysisUsage &AU) const {
   if (OptMode != Mode::Fast) {
     // We could preserve the information from these two analysis but
     // the APIs do not allow to do so yet.
-    AU.addRequired<MachineBlockFrequencyInfo>();
+    AU.addRequired<MachineBlockFrequencyInfoWrapperPass>();
     AU.addRequired<MachineBranchProbabilityInfoWrapperPass>();
   }
   AU.addRequired<TargetPassConfig>();
@@ -919,19 +919,19 @@ bool RegBankSelect::InstrInsertPoint::isSplit() const {
 uint64_t RegBankSelect::InstrInsertPoint::frequency(const Pass &P) const {
   // Even if we need to split, because we insert between terminators,
   // this split has actually the same frequency as the instruction.
-  const MachineBlockFrequencyInfo *MBFI =
-      P.getAnalysisIfAvailable<MachineBlockFrequencyInfo>();
-  if (!MBFI)
+  const auto *MBFIWrapper =
+      P.getAnalysisIfAvailable<MachineBlockFrequencyInfoWrapperPass>();
+  if (!MBFIWrapper)
     return 1;
-  return MBFI->getBlockFreq(Instr.getParent()).getFrequency();
+  return MBFIWrapper->getMBFI().getBlockFreq(Instr.getParent()).getFrequency();
 }
 
 uint64_t RegBankSelect::MBBInsertPoint::frequency(const Pass &P) const {
-  const MachineBlockFrequencyInfo *MBFI =
-      P.getAnalysisIfAvailable<MachineBlockFrequencyInfo>();
-  if (!MBFI)
+  const auto *MBFIWrapper =
+      P.getAnalysisIfAvailable<MachineBlockFrequencyInfoWrapperPass>();
+  if (!MBFIWrapper)
     return 1;
-  return MBFI->getBlockFreq(&MBB).getFrequency();
+  return MBFIWrapper->getMBFI().getBlockFreq(&MBB).getFrequency();
 }
 
 void RegBankSelect::EdgeInsertPoint::materialize() {
@@ -948,10 +948,11 @@ void RegBankSelect::EdgeInsertPoint::materialize() {
 }
 
 uint64_t RegBankSelect::EdgeInsertPoint::frequency(const Pass &P) const {
-  const MachineBlockFrequencyInfo *MBFI =
-      P.getAnalysisIfAvailable<MachineBlockFrequencyInfo>();
-  if (!MBFI)
+  const auto *MBFIWrapper =
+      P.getAnalysisIfAvailable<MachineBlockFrequencyInfoWrapperPass>();
+  if (!MBFIWrapper)
     return 1;
+  const auto *MBFI = &MBFIWrapper->getMBFI();
   if (WasMaterialized)
     return MBFI->getBlockFreq(DstOrSplit).getFrequency();
 
diff --git a/llvm/lib/CodeGen/IfConversion.cpp b/llvm/lib/CodeGen/IfConversion.cpp
index 02cb95c5d7664..f3789569b78fb 100644
--- a/llvm/lib/CodeGen/IfConversion.cpp
+++ b/llvm/lib/CodeGen/IfConversion.cpp
@@ -209,7 +209,7 @@ namespace {
     }
 
     void getAnalysisUsage(AnalysisUsage &AU) const override {
-      AU.addRequired<MachineBlockFrequencyInfo>();
+      AU.addRequired<MachineBlockFrequencyInfoWrapperPass>();
       AU.addRequired<MachineBranchProbabilityInfoWrapperPass>();
       AU.addRequired<ProfileSummaryInfoWrapperPass>();
       MachineFunctionPass::getAnalysisUsage(AU);
@@ -444,7 +444,8 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
   TLI = ST.getTargetLowering();
   TII = ST.getInstrInfo();
   TRI = ST.getRegisterInfo();
-  MBFIWrapper MBFI(getAnalysis<MachineBlockFrequencyInfo>());
+  MBFIWrapper MBFI(
+      getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI());
   MBPI = &getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI();
   ProfileSummaryInfo *PSI =
       &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
diff --git a/llvm/lib/CodeGen/InlineSpiller.cpp b/llvm/lib/CodeGen/InlineSpiller.cpp
index 6abbf8b6d7e0a..81ae805d64e1e 100644
--- a/llvm/lib/CodeGen/InlineSpiller.cpp
+++ b/llvm/lib/CodeGen/InlineSpiller.cpp
@@ -136,7 +136,8 @@ class HoistSpillHelper : private LiveRangeEdit::Delegate {
         MDT(pass.getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree()),
         VRM(vrm), MRI(mf.getRegInfo()), TII(*mf.getSubtarget().getInstrInfo()),
         TRI(*mf.getSubtarget().getRegisterInfo()),
-        MBFI(pass.getAnalysis<MachineBlockFrequencyInfo>()),
+        MBFI(
+            pass.getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI()),
         IPA(LIS, mf.getNumBlockIDs()) {}
 
   void addToMergeableSpills(MachineInstr &Spill, int StackSlot,
@@ -193,7 +194,8 @@ class InlineSpiller : public Spiller {
         MDT(Pass.getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree()),
         VRM(VRM), MRI(MF.getRegInfo()), TII(*MF.getSubtarget().getInstrInfo()),
         TRI(*MF.getSubtarget().getRegisterInfo()),
-        MBFI(Pass.getAnalysis<MachineBlockFrequencyInfo>()),
+        MBFI(
+            Pass.getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI()),
         HSpiller(Pass, MF, VRM), VRAI(VRAI) {}
 
   void spill(LiveRangeEdit &) override;
diff --git a/llvm/lib/CodeGen/LazyMachineBlockFrequencyInfo.cpp b/llvm/lib/CodeGen/LazyMachineBlockFrequencyInfo.cpp
index 0cf01edbff6c8..ff6b42238bb21 100644
--- a/llvm/lib/CodeGen/LazyMachineBlockFrequencyInfo.cpp
+++ b/llvm/lib/CodeGen/LazyMachineBlockFrequencyInfo.cpp
@@ -36,11 +36,6 @@ LazyMachineBlockFrequencyInfoPass::LazyMachineBlockFrequencyInfoPass()
       *PassRegistry::getPassRegistry());
 }
 
-void LazyMachineBlockFrequencyInfoPass::print(raw_ostream &OS,
-                                              const Module *M) const {
-  getBFI().print(OS, M);
-}
-
 void LazyMachineBlockFrequencyInfoPass::getAnalysisUsage(
     AnalysisUsage &AU) const {
   AU.addRequired<MachineBranchProbabilityInfoWrapperPass>();
@@ -56,10 +51,11 @@ void LazyMachineBlockFrequencyInfoPass::releaseMemory() {
 
 MachineBlockFrequencyInfo &
 LazyMachineBlockFrequencyInfoPass::calculateIfNotAvailable() const {
-  auto *MBFI = getAnalysisIfAvailable<MachineBlockFrequencyInfo>();
-  if (MBFI) {
-    LLVM_DEBUG(dbgs() << "MachineBlockFrequencyInfo is available\n");
-    return *MBFI;
+  auto *MBFIWrapper =
+      getAnalysisIfAvailable<MachineBlockFrequencyInfoWrapperPass>();
+  if (MBFIWrapper) {
+    LLVM_DEBUG(dbgs() << "MachineBlockFrequencyInfoWrapperPass is available\n");
+    return MBFIWrapper->getMBFI();
   }
 
   auto &MBPI = getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI();
diff --git a/llvm/lib/CodeGen/MIRSampleProfile.cpp b/llvm/lib/CodeGen/MIRSampleProfile.cpp
index b77d8aabe029a..ce82f280c1c53 100644
--- a/llvm/lib/CodeGen/MIRSampleProfile.cpp
+++ b/llvm/lib/CodeGen/MIRSampleProfile.cpp
@@ -69,7 +69,7 @@ char MIRProfileLoaderPass::ID = 0;
 INITIALIZE_PASS_BEGIN(MIRProfileLoaderPass, DEBUG_TYPE,
                       "Load MIR Sample Profile",
                       /* cfg = */ false, /* is_analysis = */ false)
-INITIALIZE_PASS_DEPENDENCY(MachineBlockFrequencyInfo)
+INITIALIZE_PASS_DEPENDENCY(MachineBlockFrequencyInfoWrapperPass)
 INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass)
 INITIALIZE_PASS_DEPENDENCY(MachinePostDominatorTreeWrapperPass)
 INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass)
@@ -363,7 +363,7 @@ bool MIRProfileLoaderPass::runOnMachineFunction(MachineFunction &MF) {
 
   LLVM_DEBUG(dbgs() << "MIRProfileLoader pass working on Func: "
                     << MF.getFunction().getName() << "\n");
-  MBFI = &getAnalysis<MachineBlockFrequencyInfo>();
+  MBFI = &getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI();
   MIRSampleLoader->setInitVals(
       &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree(),
       &getAnalysis<MachinePostDominatorTreeWrapperPass>().getPostDomTree(),
@@ -401,7 +401,7 @@ bool MIRProfileLoaderPass::doInitialization(Module &M) {
 
 void MIRProfileLoaderPass::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.setPreservesAll();
-  AU.addRequired<MachineBlockFrequencyInfo>();
+  AU.addRequired<MachineBlockFrequencyInfoWrapperPass>();
   AU.addRequired<MachineDominatorTreeWrapperPass>();
   AU.addRequired<MachinePostDominatorTreeWrapperPass>();
   AU.addRequiredTransitive<MachineLoopInfoWrapperPass>();
diff --git a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp
index 7f90457d720b4..4f0fab8e58bf8 100644
--- a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp
+++ b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp
@@ -110,7 +110,7 @@ class RegAllocScoring : public MachineFunctionPass {
     AU.setPreservesAll();
     AU.addRequired<RegAllocEvictionAdvisorAnalysis>();
     AU.addRequired<RegAllocPriorityAdvisorAnalysis>();
-    AU.addRequired<MachineBlockFrequencyInfo>();
+    AU.addRequired<MachineBlockFrequencyInfoWrapperPass>();
     MachineFunctionPass::getAnalysisUsage(AU);
   }
 
@@ -388,7 +388,7 @@ class ReleaseModeEvictionAdvisorAnalysis final
   std::vector<TensorSpec> InputFeatures;
 
   void getAnalysisUsage(AnalysisUsage &AU) const override {
-    AU.addRequired<MachineBlockFrequencyInfo>();
+    AU.addRequired<MachineBlockFrequencyInfoWrapperPass>();
     AU.addRequired<MachineLoopInfoWrapperPass>();
     RegAllocEvictionAdvisorAnalysis::getAnalysisUsage(AU);
   }
@@ -406,7 +406,8 @@ class ReleaseModeEvictionAdvisorAnalysis final
             InteractiveChannelBaseName + ".in");
     }
     return std::make_unique<MLEvictAdvisor>(
-        MF, RA, Runner.get(), getAnalysis<MachineBlockFrequencyInfo>(),
+        MF, RA, Runner.get(),
+        getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI(),
         getAnalysis<MachineLoopInfoWrapperPass>().getLI());
   }
   std::unique_ptr<MLModelRunner> Runner;
@@ -495,7 +496,7 @@ class DevelopmentModeEvictionAdvisorAnalysis final
   std::vector<TensorSpec> TrainingInputFeatures;
 
   void getAnalysisUsage(AnalysisUsage &AU) const override {
-    AU.addRequired<MachineBlockFrequencyInfo>();
+    AU.addRequired<MachineBlockFrequencyInfoWrapperPass>();
     AU.addRequired<MachineLoopInfoWrapperPass>();
     RegAllocEvictionAdvisorAnalysis::getAnalysisUsage(AU);
   }
@@ -544,7 +545,8 @@ class DevelopmentModeEvictionAdvisorAnalysis final
     if (Log)
       Log->switchContext(MF.getName());
     return std::make_unique<DevelopmentModeEvictAdvisor>(
-        MF, RA, Runner.get(), getAnalysis<MachineBlockFrequencyInfo>(),
+        MF, RA, Runner.get(),
+        getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI(),
         getAnalysis<MachineLoopInfoWrapperPass>().getLI(), Log.get());
   }
 
@@ -1139,7 +1141,8 @@ bool RegAllocScoring::runOnMachineFunction(MachineFunction &MF) {
   auto GetReward = [&]() {
     if (!CachedReward)
       CachedReward = static_cast<float>(
-          calculateRegAllocScore(MF, getAnalysis<MachineBlockFrequencyInfo>())
+          calculateRegAllocScore(
+              MF, getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI())
               .getScore());
     return *CachedReward;
   };
diff --git a/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp b/llvm/...
[truncated]


; Function Attrs: noinline nounwind optnone ssp uwtable
define i32 @foo(i32 noundef %0) #0 {
%2 = alloca i32, align 4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use named values in tests

@@ -0,0 +1,44 @@
; RUN: llc -mtriple=x86_64-linux-gnu -stop-after=x86-isel %s -o - | llc --passes='print<machine-block-freq>' -x mir -o - 2>&1 | FileCheck %s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use -filetype=null if you are just discarding the output.

Is there much point to starting with IR if you're just codegening it to get the MIR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convert to MIR test for now. Because ideally these test should stay in test/CodeGen/Generic, but I couldn't find a good way to write a generic test, llc may crash with its output on some targets.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no such thing as a generic codegen test. Don't put anything in there, we should move just about everything in there out that's there now

- Add `MachineBlockFrequencyAnalysis`.
- Add `MachineBlockFrequencyPrinterPass`.
- Use `MachineBlockFrequencyInfoWrapperPass` in legacy pass manager.
@paperchalice paperchalice merged commit 0998999 into llvm:main Jul 12, 2024
7 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 12, 2024

LLVM Buildbot has detected a new failure on builder llvm-nvptx64-nvidia-ubuntu running on as-builder-7 while building llvm at step 6 "test-build-unified-tree-check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/160/builds/1577

Here is the relevant piece of the build log for the reference:

Step 6 (test-build-unified-tree-check-llvm) failure: test (failure)
******************** TEST 'LLVM :: CodeGen/X86/machine-block-freq.mir' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/build/bin/llc --passes='print<machine-block-freq>' -filetype=null 2>&1 /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir | /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
+ /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/build/bin/llc '--passes=print<machine-block-freq>' -filetype=null /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
+ /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:32:10: error: CHECK: expected string not found in input
# CHECK: block-frequency-info: is_odd
         ^
<stdin>:1:1: note: scanning from here
error: /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi'
^
<stdin>:1:121: note: possible intended match here
error: /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi'
                                                                                                                        ^

Input file: <stdin>
Check file: /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: error: /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi' 
check:32'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:32'1                                                                                                                             ?                                                 possible intended match
            2:  liveins: $edi 
check:32'0     ~~~~~~~~~~~~~~~
            3:  ^ 
check:32'0     ~~~
            4:  
check:32'0     ~
>>>>>>

--

********************


paperchalice added a commit to paperchalice/llvm-project that referenced this pull request Jul 12, 2024
paperchalice added a commit that referenced this pull request Jul 12, 2024
Missing `-mtriple` in test, causes failure on some none x86 default
targets.
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 12, 2024

LLVM Buildbot has detected a new failure on builder llvm-nvptx-nvidia-ubuntu running on as-builder-7 while building llvm at step 6 "test-build-unified-tree-check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/180/builds/1576

Here is the relevant piece of the build log for the reference:

Step 6 (test-build-unified-tree-check-llvm) failure: test (failure)
******************** TEST 'LLVM :: CodeGen/X86/machine-block-freq.mir' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/build/bin/llc --passes='print<machine-block-freq>' -filetype=null 2>&1 /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir | /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
+ /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/build/bin/llc '--passes=print<machine-block-freq>' -filetype=null /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
+ /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:32:10: error: CHECK: expected string not found in input
# CHECK: block-frequency-info: is_odd
         ^
<stdin>:1:1: note: scanning from here
error: /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi'
^
<stdin>:1:119: note: possible intended match here
error: /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi'
                                                                                                                      ^

Input file: <stdin>
Check file: /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: error: /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi' 
check:32'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:32'1                                                                                                                           ?                                                 possible intended match
            2:  liveins: $edi 
check:32'0     ~~~~~~~~~~~~~~~
            3:  ^ 
check:32'0     ~~~
            4:  
check:32'0     ~
>>>>>>

--

********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 12, 2024

LLVM Buildbot has detected a new failure on builder clang-hip-vega20 running on hip-vega20-0 while building llvm at step 3 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/123/builds/1690

Here is the relevant piece of the build log for the reference:

Step 3 (annotate) failure: '../llvm-zorg/zorg/buildbot/builders/annotated/hip-build.sh --jobs=' (failure)
...
[36/38] : && /buildbot/hip-vega20-0/clang-hip-vega20/llvm/bin/clang++ -O3 -DNDEBUG  External/HIP/CMakeFiles/InOneWeekend-hip-6.0.2.dir/workload/ray-tracing/InOneWeekend/main.cc.o -o External/HIP/InOneWeekend-hip-6.0.2  --rocm-path=/buildbot/Externals/hip/rocm-6.0.2 --hip-link -rtlib=compiler-rt -unwindlib=libgcc -frtlib-add-rpath && cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP && /usr/local/bin/cmake -E create_symlink /buildbot/llvm-test-suite/External/HIP/InOneWeekend.reference_output /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/InOneWeekend.reference_output-hip-6.0.2
[37/38] /buildbot/hip-vega20-0/clang-hip-vega20/llvm/bin/clang++ -DNDEBUG  -O3 -DNDEBUG   -w -Werror=date-time --rocm-path=/buildbot/Externals/hip/rocm-6.0.2 --offload-arch=gfx908 --offload-arch=gfx90a --offload-arch=gfx1030 --offload-arch=gfx1100 -xhip -mfma -MD -MT External/HIP/CMakeFiles/TheNextWeek-hip-6.0.2.dir/workload/ray-tracing/TheNextWeek/main.cc.o -MF External/HIP/CMakeFiles/TheNextWeek-hip-6.0.2.dir/workload/ray-tracing/TheNextWeek/main.cc.o.d -o External/HIP/CMakeFiles/TheNextWeek-hip-6.0.2.dir/workload/ray-tracing/TheNextWeek/main.cc.o -c /buildbot/llvm-test-suite/External/HIP/workload/ray-tracing/TheNextWeek/main.cc
[38/38] : && /buildbot/hip-vega20-0/clang-hip-vega20/llvm/bin/clang++ -O3 -DNDEBUG  External/HIP/CMakeFiles/TheNextWeek-hip-6.0.2.dir/workload/ray-tracing/TheNextWeek/main.cc.o -o External/HIP/TheNextWeek-hip-6.0.2  --rocm-path=/buildbot/Externals/hip/rocm-6.0.2 --hip-link -rtlib=compiler-rt -unwindlib=libgcc -frtlib-add-rpath && cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP && /usr/local/bin/cmake -E create_symlink /buildbot/llvm-test-suite/External/HIP/TheNextWeek.reference_output /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/TheNextWeek.reference_output-hip-6.0.2
+ build_step 'Testing HIP test-suite'
+ echo '@@@BUILD_STEP Testing HIP test-suite@@@'
+ ninja -v check-hip-simple
@@@BUILD_STEP Testing HIP test-suite@@@
[0/1] cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP && /buildbot/hip-vega20-0/clang-hip-vega20/llvm/bin/llvm-lit -sv empty-hip-6.0.2.test with-fopenmp-hip-6.0.2.test saxpy-hip-6.0.2.test InOneWeekend-hip-6.0.2.test TheNextWeek-hip-6.0.2.test blender.test
-- Testing: 6 tests, 6 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 
FAIL: test-suite :: External/HIP/InOneWeekend-hip-6.0.2.test (4 of 6)
******************** TEST 'test-suite :: External/HIP/InOneWeekend-hip-6.0.2.test' FAILED ********************

/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/tools/timeit-target --timeout 7200 --limit-core 0 --limit-cpu 7200 --limit-file-size 209715200 --limit-rss-size 838860800 --append-exitstatus --redirect-output /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/Output/InOneWeekend-hip-6.0.2.test.out --redirect-input /dev/null --summary /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/Output/InOneWeekend-hip-6.0.2.test.time /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/InOneWeekend-hip-6.0.2
cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP ; /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/tools/fpcmp-target /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/Output/InOneWeekend-hip-6.0.2.test.out InOneWeekend.reference_output-hip-6.0.2

+ cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP
+ /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/tools/fpcmp-target /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/Output/InOneWeekend-hip-6.0.2.test.out InOneWeekend.reference_output-hip-6.0.2
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/tools/fpcmp-target: Comparison failed, textual difference between 'M' and 'i'

********************
/usr/bin/strip: /bin/bash.stripped: Bad file descriptor
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
********************
Failed Tests (1):
  test-suite :: External/HIP/InOneWeekend-hip-6.0.2.test


Testing Time: 386.66s

Total Discovered Tests: 6
  Passed: 5 (83.33%)
  Failed: 1 (16.67%)
FAILED: External/HIP/CMakeFiles/check-hip-simple-hip-6.0.2 
cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP && /buildbot/hip-vega20-0/clang-hip-vega20/llvm/bin/llvm-lit -sv empty-hip-6.0.2.test with-fopenmp-hip-6.0.2.test saxpy-hip-6.0.2.test InOneWeekend-hip-6.0.2.test TheNextWeek-hip-6.0.2.test blender.test
ninja: build stopped: subcommand failed.
Step 12 (Testing HIP test-suite) failure: Testing HIP test-suite (failure)
@@@BUILD_STEP Testing HIP test-suite@@@
[0/1] cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP && /buildbot/hip-vega20-0/clang-hip-vega20/llvm/bin/llvm-lit -sv empty-hip-6.0.2.test with-fopenmp-hip-6.0.2.test saxpy-hip-6.0.2.test InOneWeekend-hip-6.0.2.test TheNextWeek-hip-6.0.2.test blender.test
-- Testing: 6 tests, 6 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 
FAIL: test-suite :: External/HIP/InOneWeekend-hip-6.0.2.test (4 of 6)
******************** TEST 'test-suite :: External/HIP/InOneWeekend-hip-6.0.2.test' FAILED ********************

/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/tools/timeit-target --timeout 7200 --limit-core 0 --limit-cpu 7200 --limit-file-size 209715200 --limit-rss-size 838860800 --append-exitstatus --redirect-output /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/Output/InOneWeekend-hip-6.0.2.test.out --redirect-input /dev/null --summary /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/Output/InOneWeekend-hip-6.0.2.test.time /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/InOneWeekend-hip-6.0.2
cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP ; /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/tools/fpcmp-target /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/Output/InOneWeekend-hip-6.0.2.test.out InOneWeekend.reference_output-hip-6.0.2

+ cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP
+ /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/tools/fpcmp-target /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/Output/InOneWeekend-hip-6.0.2.test.out InOneWeekend.reference_output-hip-6.0.2
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/tools/fpcmp-target: Comparison failed, textual difference between 'M' and 'i'

********************
/usr/bin/strip: /bin/bash.stripped: Bad file descriptor
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
********************
Failed Tests (1):
  test-suite :: External/HIP/InOneWeekend-hip-6.0.2.test


Testing Time: 386.66s

Total Discovered Tests: 6
  Passed: 5 (83.33%)
  Failed: 1 (16.67%)
FAILED: External/HIP/CMakeFiles/check-hip-simple-hip-6.0.2 
cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP && /buildbot/hip-vega20-0/clang-hip-vega20/llvm/bin/llvm-lit -sv empty-hip-6.0.2.test with-fopenmp-hip-6.0.2.test saxpy-hip-6.0.2.test InOneWeekend-hip-6.0.2.test TheNextWeek-hip-6.0.2.test blender.test
ninja: build stopped: subcommand failed.
program finished with exit code 1
elapsedTime=639.206763

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 12, 2024

LLVM Buildbot has detected a new failure on builder sanitizer-aarch64-linux-bootstrap-ubsan running on sanitizer-buildbot10 while building llvm at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/85/builds/519

Here is the relevant piece of the build log for the reference:

Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using lld-link: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/lld-link
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using ld64.lld: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld64.lld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using wasm-ld: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/wasm-ld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using ld.lld: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld.lld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using lld-link: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/lld-link
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using ld64.lld: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld64.lld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using wasm-ld: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/wasm-ld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 81060 tests, 48 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.
FAIL: LLVM :: CodeGen/X86/machine-block-freq.mir (45737 of 81060)
******************** TEST 'LLVM :: CodeGen/X86/machine-block-freq.mir' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/llc --passes='print<machine-block-freq>' -filetype=null 2>&1 /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir | /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
+ /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
+ /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/llc '--passes=print<machine-block-freq>' -filetype=null /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:32:10: error: CHECK: expected string not found in input
# CHECK: block-frequency-info: is_odd
         ^
<stdin>:1:1: note: scanning from here
error: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi'
^
<stdin>:1:100: note: possible intended match here
error: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi'
                                                                                                   ^

Input file: <stdin>
Check file: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: error: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi' 
check:32'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:32'1                                                                                                        ?                                                 possible intended match
            2:  liveins: $edi 
check:32'0     ~~~~~~~~~~~~~~~
            3:  ^ 
check:32'0     ~~~
            4:  
check:32'0     ~
>>>>>>

--

Step 10 (stage2/ubsan check) failure: stage2/ubsan check (failure)
...
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using lld-link: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/lld-link
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using ld64.lld: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld64.lld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using wasm-ld: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/wasm-ld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using ld.lld: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld.lld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using lld-link: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/lld-link
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using ld64.lld: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld64.lld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using wasm-ld: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/wasm-ld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 81060 tests, 48 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.
FAIL: LLVM :: CodeGen/X86/machine-block-freq.mir (45737 of 81060)
******************** TEST 'LLVM :: CodeGen/X86/machine-block-freq.mir' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/llc --passes='print<machine-block-freq>' -filetype=null 2>&1 /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir | /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
+ /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
+ /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/llc '--passes=print<machine-block-freq>' -filetype=null /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:32:10: error: CHECK: expected string not found in input
# CHECK: block-frequency-info: is_odd
         ^
<stdin>:1:1: note: scanning from here
error: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi'
^
<stdin>:1:100: note: possible intended match here
error: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi'
                                                                                                   ^

Input file: <stdin>
Check file: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: error: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi' 
check:32'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:32'1                                                                                                        ?                                                 possible intended match
            2:  liveins: $edi 
check:32'0     ~~~~~~~~~~~~~~~
            3:  ^ 
check:32'0     ~~~
            4:  
check:32'0     ~
>>>>>>

--

Step 13 (stage3/ubsan check) failure: stage3/ubsan check (failure)
...
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using lld-link: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build2_ubsan/bin/lld-link
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using ld64.lld: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build2_ubsan/bin/ld64.lld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using wasm-ld: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build2_ubsan/bin/wasm-ld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using ld.lld: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build2_ubsan/bin/ld.lld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using lld-link: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build2_ubsan/bin/lld-link
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using ld64.lld: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build2_ubsan/bin/ld64.lld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using wasm-ld: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build2_ubsan/bin/wasm-ld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 78429 tests, 48 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50..
FAIL: LLVM :: CodeGen/X86/machine-block-freq.mir (45737 of 78429)
******************** TEST 'LLVM :: CodeGen/X86/machine-block-freq.mir' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build2_ubsan/bin/llc --passes='print<machine-block-freq>' -filetype=null 2>&1 /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir | /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build2_ubsan/bin/FileCheck /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
+ /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build2_ubsan/bin/FileCheck /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
+ /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm_build2_ubsan/bin/llc '--passes=print<machine-block-freq>' -filetype=null /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:32:10: error: CHECK: expected string not found in input
# CHECK: block-frequency-info: is_odd
         ^
<stdin>:1:1: note: scanning from here
error: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi'
^
<stdin>:1:100: note: possible intended match here
error: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi'
                                                                                                   ^

Input file: <stdin>
Check file: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: error: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi' 
check:32'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:32'1                                                                                                        ?                                                 possible intended match
            2:  liveins: $edi 
check:32'0     ~~~~~~~~~~~~~~~
            3:  ^ 
check:32'0     ~~~
            4:  
check:32'0     ~
>>>>>>

--


@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 12, 2024

LLVM Buildbot has detected a new failure on builder sanitizer-aarch64-linux-bootstrap-msan running on sanitizer-buildbot9 while building llvm at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/94/builds/384

Here is the relevant piece of the build log for the reference:

Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using lld-link: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using ld64.lld: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using wasm-ld: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using ld.lld: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld.lld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using lld-link: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using ld64.lld: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using wasm-ld: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 81058 tests, 48 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.
FAIL: LLVM :: CodeGen/X86/machine-block-freq.mir (45732 of 81058)
******************** TEST 'LLVM :: CodeGen/X86/machine-block-freq.mir' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/llc --passes='print<machine-block-freq>' -filetype=null 2>&1 /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir | /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
+ /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/llc '--passes=print<machine-block-freq>' -filetype=null /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
+ /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:32:10: error: CHECK: expected string not found in input
# CHECK: block-frequency-info: is_odd
         ^
<stdin>:1:1: note: scanning from here
error: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi'
^
<stdin>:1:99: note: possible intended match here
error: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi'
                                                                                                  ^

Input file: <stdin>
Check file: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: error: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi' 
check:32'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:32'1                                                                                                       ?                                                 possible intended match
            2:  liveins: $edi 
check:32'0     ~~~~~~~~~~~~~~~
            3:  ^ 
check:32'0     ~~~
            4:  
check:32'0     ~
>>>>>>

--

Step 10 (stage2/msan check) failure: stage2/msan check (failure)
...
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using lld-link: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using ld64.lld: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using wasm-ld: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using ld.lld: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld.lld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using lld-link: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using ld64.lld: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using wasm-ld: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 81058 tests, 48 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.
FAIL: LLVM :: CodeGen/X86/machine-block-freq.mir (45732 of 81058)
******************** TEST 'LLVM :: CodeGen/X86/machine-block-freq.mir' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/llc --passes='print<machine-block-freq>' -filetype=null 2>&1 /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir | /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
+ /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/llc '--passes=print<machine-block-freq>' -filetype=null /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
+ /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:32:10: error: CHECK: expected string not found in input
# CHECK: block-frequency-info: is_odd
         ^
<stdin>:1:1: note: scanning from here
error: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi'
^
<stdin>:1:99: note: possible intended match here
error: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi'
                                                                                                  ^

Input file: <stdin>
Check file: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: error: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi' 
check:32'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:32'1                                                                                                       ?                                                 possible intended match
            2:  liveins: $edi 
check:32'0     ~~~~~~~~~~~~~~~
            3:  ^ 
check:32'0     ~~~
            4:  
check:32'0     ~
>>>>>>

--

Step 13 (stage3/msan check) failure: stage3/msan check (failure)
...
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using lld-link: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/bin/lld-link
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using ld64.lld: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/bin/ld64.lld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using wasm-ld: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/bin/wasm-ld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using ld.lld: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/bin/ld.lld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using lld-link: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/bin/lld-link
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using ld64.lld: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/bin/ld64.lld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using wasm-ld: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/bin/wasm-ld
llvm-lit: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 78429 tests, 48 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50..
FAIL: LLVM :: CodeGen/X86/machine-block-freq.mir (45733 of 78429)
******************** TEST 'LLVM :: CodeGen/X86/machine-block-freq.mir' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/bin/llc --passes='print<machine-block-freq>' -filetype=null 2>&1 /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir | /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/bin/FileCheck /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
+ /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/bin/llc '--passes=print<machine-block-freq>' -filetype=null /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
+ /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/bin/FileCheck /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:32:10: error: CHECK: expected string not found in input
# CHECK: block-frequency-info: is_odd
         ^
<stdin>:1:1: note: scanning from here
error: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi'
^
<stdin>:1:99: note: possible intended match here
error: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi'
                                                                                                  ^

Input file: <stdin>
Check file: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: error: /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/test/CodeGen/X86/machine-block-freq.mir:9:14: unknown register name 'edi' 
check:32'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:32'1                                                                                                       ?                                                 possible intended match
            2:  liveins: $edi 
check:32'0     ~~~~~~~~~~~~~~~
            3:  ^ 
check:32'0     ~~~
            4:  
check:32'0     ~
>>>>>>

--


aaryanshukla pushed a commit to aaryanshukla/llvm-project that referenced this pull request Jul 14, 2024
…98317)

- Add `MachineBlockFrequencyAnalysis`.
- Add `MachineBlockFrequencyPrinterPass`.
- Use `MachineBlockFrequencyInfoWrapperPass` in legacy pass manager.
- `LazyMachineBlockFrequencyInfo::print` is empty, drop it due to new
pass manager migration.
aaryanshukla pushed a commit to aaryanshukla/llvm-project that referenced this pull request Jul 14, 2024
Missing `-mtriple` in test, causes failure on some none x86 default
targets.
@paperchalice paperchalice deleted the mbfreq branch July 15, 2024 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants