Skip to content

Commit 4493f30

Browse files
committed
Add printer pass
1 parent 7e6d9ff commit 4493f30

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

llvm/include/llvm/CodeGen/LiveStacks.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ class LiveStacksAnalysis : public AnalysisInfoMixin<LiveStacksAnalysis> {
125125

126126
LiveStacks run(MachineFunction &MF, MachineFunctionAnalysisManager &);
127127
};
128+
129+
class LiveStacksPrinterPass : public PassInfoMixin<LiveStacksPrinterPass> {
130+
raw_ostream &OS;
131+
132+
public:
133+
LiveStacksPrinterPass(raw_ostream &OS) : OS(OS) {}
134+
PreservedAnalyses run(MachineFunction &MF,
135+
MachineFunctionAnalysisManager &AM);
136+
};
128137
} // end namespace llvm
129138

130139
#endif

llvm/include/llvm/Passes/MachinePassRegistry.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ MACHINE_FUNCTION_PASS("phi-node-elimination", PHIEliminationPass())
151151
MACHINE_FUNCTION_PASS("print", PrintMIRPass())
152152
MACHINE_FUNCTION_PASS("print<livedebugvars>", LiveDebugVariablesPrinterPass(errs()))
153153
MACHINE_FUNCTION_PASS("print<live-intervals>", LiveIntervalsPrinterPass(errs()))
154+
MACHINE_FUNCTION_PASS("print<live-stacks>", LiveStacksPrinterPass(errs()))
154155
MACHINE_FUNCTION_PASS("print<live-vars>", LiveVariablesPrinterPass(errs()))
155156
MACHINE_FUNCTION_PASS("print<machine-block-freq>",
156157
MachineBlockFrequencyPrinterPass(errs()))

llvm/lib/CodeGen/LiveStacks.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "llvm/CodeGen/LiveStacks.h"
1616
#include "llvm/CodeGen/TargetRegisterInfo.h"
1717
#include "llvm/CodeGen/TargetSubtargetInfo.h"
18+
#include "llvm/IR/Function.h"
1819
using namespace llvm;
1920

2021
#define DEBUG_TYPE "livestacks"
@@ -75,6 +76,12 @@ LiveStacks LiveStacksAnalysis::run(MachineFunction &MF,
7576
Impl.init(MF);
7677
return Impl;
7778
}
79+
PreservedAnalyses
80+
LiveStacksPrinterPass::run(MachineFunction &MF,
81+
MachineFunctionAnalysisManager &AM) {
82+
AM.getResult<LiveStacksAnalysis>(MF).print(OS, MF.getFunction().getParent());
83+
return PreservedAnalyses::all();
84+
}
7885

7986
bool LiveStacksWrapperLegacy::runOnMachineFunction(MachineFunction &MF) {
8087
Impl = LiveStacks();

0 commit comments

Comments
 (0)