LLVM  8.0.0svn
MachineRegionInfo.cpp
Go to the documentation of this file.
1 //===- lib/Codegen/MachineRegionInfo.cpp ----------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
11 #include "llvm/ADT/Statistic.h"
14 #include "llvm/Config/llvm-config.h"
15 #include "llvm/Pass.h"
16 #include "llvm/Support/Compiler.h"
17 #include "llvm/Support/Debug.h"
18 
19 #define DEBUG_TYPE "machine-region-info"
20 
21 using namespace llvm;
22 
23 STATISTIC(numMachineRegions, "The # of machine regions");
24 STATISTIC(numMachineSimpleRegions, "The # of simple machine regions");
25 
26 namespace llvm {
27 
31 
32 } // end namespace llvm
33 
34 //===----------------------------------------------------------------------===//
35 // MachineRegion implementation
36 
39  MachineDominatorTree *DT, MachineRegion *Parent) :
40  RegionBase<RegionTraits<MachineFunction>>(Entry, Exit, RI, DT, Parent) {}
41 
43 
44 //===----------------------------------------------------------------------===//
45 // MachineRegionInfo implementation
46 
48 
50 
52  ++numMachineRegions;
53 
54  // TODO: Slow. Should only be enabled if -stats is used.
55  if (R->isSimple())
56  ++numMachineSimpleRegions;
57 }
58 
63  DT = DT_;
64  PDT = PDT_;
65  DF = DF_;
66 
68 
69  TopLevelRegion = new MachineRegion(Entry, nullptr, this, DT, nullptr);
70  updateStatistics(TopLevelRegion);
71  calculate(F);
72 }
73 
74 //===----------------------------------------------------------------------===//
75 // MachineRegionInfoPass implementation
76 //
77 
80 }
81 
83 
85  releaseMemory();
86 
87  auto DT = &getAnalysis<MachineDominatorTree>();
88  auto PDT = &getAnalysis<MachinePostDominatorTree>();
89  auto DF = &getAnalysis<MachineDominanceFrontier>();
90 
91  RI.recalculate(F, DT, PDT, DF);
92 
93  LLVM_DEBUG(RI.dump());
94 
95  return false;
96 }
97 
99  RI.releaseMemory();
100 }
101 
103  // Only do verification when user wants to, otherwise this expensive check
104  // will be invoked by PMDataManager::verifyPreservedAnalysis when
105  // a regionpass (marked PreservedAll) finish.
107  RI.verifyAnalysis();
108 }
109 
111  AU.setPreservesAll();
116 }
117 
119  RI.print(OS);
120 }
121 
122 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
124  RI.dump();
125 }
126 #endif
127 
130 
132  "Detect single entry single exit regions", true, true)
137  "Detect single entry single exit regions", true, true)
138 
139 // Create methods available outside of this file, to use them
140 // "include/llvm/LinkAllPasses.h". Otherwise the pass would be deleted by
141 // the link time optimization.
142 
143 namespace llvm {
144 
146  return new MachineRegionInfoPass();
147 }
148 
149 } // end namespace llvm
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...
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:64
void print(raw_ostream &OS) const
void initializeMachineRegionInfoPassPass(PassRegistry &)
STATISTIC(NumFunctions, "Total number of functions")
F(f)
INITIALIZE_PASS_BEGIN(MachineRegionInfoPass, DEBUG_TYPE, "Detect single entry single exit regions", true, true) INITIALIZE_PASS_END(MachineRegionInfoPass
Analysis that detects all canonical Regions.
Definition: RegionInfo.h:70
Detect single entry single exit true
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition: PassSupport.h:51
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
char & MachineRegionInfoPassID
MachineRegionInfo - This pass computes SESE regions for machine functions.
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:119
void verifyAnalysis() const
#define LLVM_DUMP_METHOD
Definition: Compiler.h:74
#define DEBUG_TYPE
void updateStatistics(MachineRegion *R) final
Detect single entry single exit regions
bool isSimple() const
Is this a simple region?
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
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:285
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
PostDominatorTree Class - Concrete subclass of DominatorTree that is used to compute the post-dominat...
~MachineRegionInfo() override
A single entry single exit Region.
Definition: RegionInfo.h:68
void setPreservesAll()
Set by analyses that do not transform their input at all.
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...
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
print Instructions which execute on loop entry
#define LLVM_DEBUG(X)
Definition: Debug.h:123
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...