LLVM  3.7.0
MachineRegionInfo.cpp
Go to the documentation of this file.
1 
3 #include "llvm/ADT/Statistic.h"
6 
7 #define DEBUG_TYPE "region"
8 
9 using namespace llvm;
10 
11 STATISTIC(numMachineRegions, "The # of machine regions");
12 STATISTIC(numMachineSimpleRegions, "The # of simple machine regions");
13 
14 namespace llvm {
18 }
19 
20 //===----------------------------------------------------------------------===//
21 // MachineRegion implementation
22 //
23 
26  MachineDominatorTree *DT, MachineRegion *Parent) :
27  RegionBase<RegionTraits<MachineFunction>>(Entry, Exit, RI, DT, Parent) {
28 
29 }
30 
32 
33 //===----------------------------------------------------------------------===//
34 // MachineRegionInfo implementation
35 //
36 
39 
40 }
41 
43 
44 }
45 
47  ++numMachineRegions;
48 
49  // TODO: Slow. Should only be enabled if -stats is used.
50  if (R->isSimple())
51  ++numMachineSimpleRegions;
52 }
53 
58  DT = DT_;
59  PDT = PDT_;
60  DF = DF_;
61 
63 
64  TopLevelRegion = new MachineRegion(Entry, nullptr, this, DT, nullptr);
65  updateStatistics(TopLevelRegion);
66  calculate(F);
67 }
68 
69 //===----------------------------------------------------------------------===//
70 // MachineRegionInfoPass implementation
71 //
72 
75 }
76 
78 
79 }
80 
82  releaseMemory();
83 
84  auto DT = &getAnalysis<MachineDominatorTree>();
85  auto PDT = &getAnalysis<MachinePostDominatorTree>();
86  auto DF = &getAnalysis<MachineDominanceFrontier>();
87 
88  RI.recalculate(F, DT, PDT, DF);
89  return false;
90 }
91 
93  RI.releaseMemory();
94 }
95 
97  // Only do verification when user wants to, otherwise this expensive check
98  // will be invoked by PMDataManager::verifyPreservedAnalysis when
99  // a regionpass (marked PreservedAll) finish.
101  RI.verifyAnalysis();
102 }
103 
105  AU.setPreservesAll();
109 }
110 
112  RI.print(OS);
113 }
114 
115 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
117  RI.dump();
118 }
119 #endif
120 
122 
124  "Detect single entry single exit regions", true, true)
129  "Detect single entry single exit regions", true, true)
130 
131 // Create methods available outside of this file, to use them
132 // "include/llvm/LinkAllPasses.h". Otherwise the pass would be deleted by
133 // the link time optimization.
134 
135 namespace llvm {
137  return new MachineRegionInfoPass();
138  }
139 }
140 
FunctionPass * createMachineRegionInfoPass()
MachineRegion(MachineBasicBlock *Entry, MachineBasicBlock *Exit, MachineRegionInfo *RI, MachineDominatorTree *DT, MachineRegion *Parent=nullptr)
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
STATISTIC(NumFunctions,"Total number of functions")
bool isSimple() const
Is this a simple region?
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:114
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: GraphTraits.h:27
void initializeMachineRegionInfoPassPass(PassRegistry &)
F(f)
Analysis that detects all canonical Regions.
Definition: RegionInfo.h:75
Detect single entry single exit true
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition: PassSupport.h:70
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
bool runOnMachineFunction(MachineFunction &F) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
A RegionNode represents a subregion or a BasicBlock that is part of a Region.
Definition: RegionInfo.h:110
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:75
void print(raw_ostream &OS) const
void verifyAnalysis() const
void updateStatistics(MachineRegion *R) final
Represent the analysis usage information of a pass.
void print(raw_ostream &OS, const Module *) const override
print - Print out the internal state of the pass.
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:294
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
INITIALIZE_PASS_BEGIN(MachineRegionInfoPass,"regions","Detect single entry single exit regions", true, true) INITIALIZE_PASS_END(MachineRegionInfoPass
PostDominatorTree Class - Concrete subclass of DominatorTree that is used to compute the post-dominat...
A single entry single exit Region.
Definition: RegionInfo.h:71
void setPreservesAll()
Set by analyses that do not transform their input at all.
PostDominatorTree Class - Concrete subclass of DominatorTree that is used to compute the post-dominat...
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
void recalculate(MachineFunction &F, MachineDominatorTree *DT, MachinePostDominatorTree *PDT, MachineDominanceFrontier *DF)
void verifyAnalysis() const override
verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis infor...
AnalysisUsage & addRequiredTransitive()
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
Legacy analysis pass which computes a DominatorTree.
Definition: Dominators.h:203
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...