1515#include " llvm/CodeGen/LiveStacks.h"
1616#include " llvm/CodeGen/TargetRegisterInfo.h"
1717#include " llvm/CodeGen/TargetSubtargetInfo.h"
18+ #include " llvm/IR/Function.h"
1819using namespace llvm ;
1920
2021#define DEBUG_TYPE " livestacks"
2122
22- char LiveStacks ::ID = 0 ;
23- INITIALIZE_PASS_BEGIN (LiveStacks , DEBUG_TYPE,
24- " Live Stack Slot Analysis" , false , false )
23+ char LiveStacksWrapperLegacy ::ID = 0 ;
24+ INITIALIZE_PASS_BEGIN (LiveStacksWrapperLegacy , DEBUG_TYPE,
25+ " Live Stack Slot Analysis" , false , false )
2526INITIALIZE_PASS_DEPENDENCY(SlotIndexesWrapperPass)
26- INITIALIZE_PASS_END(LiveStacks , DEBUG_TYPE,
27- " Live Stack Slot Analysis" , false , false )
27+ INITIALIZE_PASS_END(LiveStacksWrapperLegacy , DEBUG_TYPE,
28+ " Live Stack Slot Analysis" , false , false )
2829
29- char &llvm::LiveStacksID = LiveStacks ::ID;
30+ char &llvm::LiveStacksID = LiveStacksWrapperLegacy ::ID;
3031
31- void LiveStacks ::getAnalysisUsage (AnalysisUsage &AU) const {
32+ void LiveStacksWrapperLegacy ::getAnalysisUsage (AnalysisUsage &AU) const {
3233 AU.setPreservesAll ();
3334 AU.addPreserved <SlotIndexesWrapperPass>();
3435 AU.addRequiredTransitive <SlotIndexesWrapperPass>();
@@ -42,11 +43,10 @@ void LiveStacks::releaseMemory() {
4243 S2RCMap.clear ();
4344}
4445
45- bool LiveStacks::runOnMachineFunction (MachineFunction &MF) {
46+ void LiveStacks::init (MachineFunction &MF) {
4647 TRI = MF.getSubtarget ().getRegisterInfo ();
4748 // FIXME: No analysis is being done right now. We are relying on the
4849 // register allocators to provide the information.
49- return false ;
5050}
5151
5252LiveInterval &
@@ -68,6 +68,33 @@ LiveStacks::getOrCreateInterval(int Slot, const TargetRegisterClass *RC) {
6868 return I->second ;
6969}
7070
71+ AnalysisKey LiveStacksAnalysis::Key;
72+
73+ LiveStacks LiveStacksAnalysis::run (MachineFunction &MF,
74+ MachineFunctionAnalysisManager &) {
75+ LiveStacks Impl;
76+ Impl.init (MF);
77+ return Impl;
78+ }
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+ }
85+
86+ bool LiveStacksWrapperLegacy::runOnMachineFunction (MachineFunction &MF) {
87+ Impl = LiveStacks ();
88+ Impl.init (MF);
89+ return false ;
90+ }
91+
92+ void LiveStacksWrapperLegacy::releaseMemory () { Impl = LiveStacks (); }
93+
94+ void LiveStacksWrapperLegacy::print (raw_ostream &OS, const Module *) const {
95+ Impl.print (OS);
96+ }
97+
7198// / print - Implement the dump method.
7299void LiveStacks::print (raw_ostream &OS, const Module*) const {
73100
0 commit comments