LLVM  6.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/Pass.h"
15 #include "llvm/Support/Compiler.h"
16 #include "llvm/Support/Debug.h"
17 
18 #define DEBUG_TYPE "machine-region-info"
19 
20 using namespace llvm;
21 
22 STATISTIC(numMachineRegions, "The # of machine regions");
23 STATISTIC(numMachineSimpleRegions, "The # of simple machine regions");
24 
25 namespace llvm {
26 
30 
31 } // end namespace llvm
32 
33 //===----------------------------------------------------------------------===//
34 // MachineRegion implementation
35 
38  MachineDominatorTree *DT, MachineRegion *Parent) :
39  RegionBase<RegionTraits<MachineFunction>>(Entry, Exit, RI, DT, Parent) {}
40 
42 
43 //===----------------------------------------------------------------------===//
44 // MachineRegionInfo implementation
45 
47 
49 
51  ++numMachineRegions;
52 
53  // TODO: Slow. Should only be enabled if -stats is used.
54  if (R->isSimple())
55  ++numMachineSimpleRegions;
56 }
57 
62  DT = DT_;
63  PDT = PDT_;
64  DF = DF_;
65 
67 
68  TopLevelRegion = new MachineRegion(Entry, nullptr, this, DT, nullptr);
69  updateStatistics(TopLevelRegion);
70  calculate(F);
71 }
72 
73 //===----------------------------------------------------------------------===//
74 // MachineRegionInfoPass implementation
75 //
76 
79 }
80 
82 
84  releaseMemory();
85 
86  auto DT = &getAnalysis<MachineDominatorTree>();
87  auto PDT = &getAnalysis<MachinePostDominatorTree>();
88  auto DF = &getAnalysis<MachineDominanceFrontier>();
89 
90  RI.recalculate(F, DT, PDT, DF);
91 
92  DEBUG(RI.dump());
93 
94  return false;
95 }
96 
98  RI.releaseMemory();
99 }
100 
102  // Only do verification when user wants to, otherwise this expensive check
103  // will be invoked by PMDataManager::verifyPreservedAnalysis when
104  // a regionpass (marked PreservedAll) finish.
106  RI.verifyAnalysis();
107 }
108 
110  AU.setPreservesAll();
115 }
116 
118  RI.print(OS);
119 }
120 
121 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
123  RI.dump();
124 }
125 #endif
126 
129 
131  "Detect single entry single exit regions", true, true)
136  "Detect single entry single exit regions", true, true)
137 
138 // Create methods available outside of this file, to use them
139 // "include/llvm/LinkAllPasses.h". Otherwise the pass would be deleted by
140 // the link time optimization.
141 
142 namespace llvm {
143 
145  return new MachineRegionInfoPass();
146 }
147 
148 } // 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
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
Definition: Compiler.h:449
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:63
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:69
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:118
void verifyAnalysis() const
#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:67
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:44
#define DEBUG(X)
Definition: Debug.h:118
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...