LLVM: lib/Analysis/RegionPass.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
24
25using namespace llvm;
26
27#define DEBUG_TYPE "regionpassmgr"
28
29
30
31
32
34
36 RI = nullptr;
37 CurrentRegion = nullptr;
38}
39
40
42 RQ.push_back(&R);
43 for (const auto &E : R)
45}
46
47
50 Info.setPreservesAll();
51}
52
53
54
58
59
61
63
64 if (RQ.empty())
65 return false;
66
67
68 for (Region *R : RQ) {
71 Changed |= RP->doInitialization(R, *this);
72 }
73 }
74
75
76 while (!RQ.empty()) {
77
78 CurrentRegion = RQ.back();
79
80
83
86 CurrentRegion->getNameStr());
88 }
89
91
92 bool LocalChanged = false;
93 {
95
97#ifdef EXPENSIVE_CHECKS
98 uint64_t RefHash = P->structuralHash(F);
99#endif
100 LocalChanged = P->runOnRegion(CurrentRegion, *this);
101
102#ifdef EXPENSIVE_CHECKS
103 if (!LocalChanged && (RefHash != P->structuralHash(F))) {
104 llvm::errs() << "Pass modifies its input and doesn't report it: "
105 << P->getPassName() << "\n";
106 llvm_unreachable("Pass modifies its input and doesn't report it");
107 }
108#endif
109
111 }
112
114 if (LocalChanged)
116 CurrentRegion->getNameStr());
118 }
119
120
121
122
123
124
125 {
127 CurrentRegion->verifyRegion();
128 }
129
130
132
133 if (LocalChanged)
138 ? ""
139 : CurrentRegion->getNameStr(),
141 }
142
143
144 RQ.pop_back();
145
146
147 RI->clearNodeCache();
148 }
149
150
153 Changed |= P->doFinalization();
154 }
155
156
157 LLVM_DEBUG(dbgs() << "\nRegion tree of function " << F.getName()
158 << " after all region Pass:\n";
159 RI->dump(); dbgs() << "\n";);
160
162}
163
164
169 P->dumpPassStructure(Offset + 1);
171 }
172}
173
174namespace {
175
176
177class PrintRegionPass : public RegionPass {
178private:
179 std::string Banner;
180 raw_ostream &Out;
181
182public:
183 static char ID;
184 PrintRegionPass(const std::string &B, raw_ostream &o)
186
187 void getAnalysisUsage(AnalysisUsage &AU) const override {
189 }
190
191 bool runOnRegion(Region *R, RGPassManager &RGM) override {
193 return false;
194 Out << Banner;
195 for (const auto *BB : R->blocks()) {
196 if (BB)
197 BB->print(Out);
198 else
199 Out << "Printing Block";
200 }
201
202 return false;
203 }
204
205 StringRef getPassName() const override { return "Print Region IR"; }
206};
207
208char PrintRegionPass::ID = 0;
209}
210
211
212
213
214
215
216
217
218
219
221
222
223 while (!PMS.empty() &&
225 PMS.pop();
226
227
228
229
230
233 PMS.pop();
234}
235
236
239
240 while (!PMS.empty() &&
242 PMS.pop();
243
245
246
249 else {
250
251 assert (!PMS.empty() && "Unable to create Region Pass Manager");
253
254
257
258
261
262
263
265
266
267 PMS.push(RGPM);
268 }
269
270 RGPM->add(this);
271}
272
273
275 const std::string &Banner) const {
276 return new PrintRegionPass(Banner, O);
277}
278
280 return "region";
281}
282
284 Function &F = *R.getEntry()->getParent();
285 const OptPassGate &Gate = F.getContext().getOptPassGate();
288 return true;
289
290 if (F.hasOptNone()) {
291
292 if (R.getEntry() == &F.getEntryBlock())
294 << "' on function " << F.getName() << "\n");
295 return true;
296 }
297 return false;
298}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static std::string getDescription(const Loop &L)
This file declares the interface for bisecting optimizations.
This header defines classes/functions to handle pass execution timing information with interfaces for...
static void addRegionIntoQueue(Region &R, std::deque< Region * > &RQ)
Definition RegionPass.cpp:41
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
Extensions to this class implement mechanisms to disable passes and individual optimizations at compi...
virtual bool isEnabled() const
isEnabled() should return true before calling shouldRunPass().
virtual bool shouldRunPass(StringRef PassName, StringRef IRDescription) const
IRDescription is a textual description of the IR unit the pass is running over.
PMDataManager provides the common place to manage the analysis data used by pass managers.
void removeDeadPasses(Pass *P, StringRef Msg, enum PassDebuggingString)
Remove dead passes used by P.
void dumpLastUses(Pass *P, unsigned Offset) const
void recordAvailableAnalysis(Pass *P)
Augment AvailableAnalysis by adding analysis made available by pass P.
bool isPassDebuggingExecutionsOrMore() const
isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions or higher is specified.
PMTopLevelManager * getTopLevelManager()
void dumpRequiredSet(const Pass *P) const
void initializeAnalysisImpl(Pass *P)
All Required analyses should be available to the pass as it runs!
void verifyPreservedAnalysis(Pass *P)
verifyPreservedAnalysis – Verify analysis presreved by pass P.
bool preserveHigherLevelAnalysis(Pass *P)
unsigned getNumContainedPasses() const
virtual PassManagerType getPassManagerType() const
void add(Pass *P, bool ProcessAnalysis=true)
Add pass P into the PassVector.
void populateInheritedAnalysis(PMStack &PMS)
void dumpPreservedSet(const Pass *P) const
void removeNotPreservedAnalysis(Pass *P)
Remove Analysis that is not preserved by the pass.
void dumpPassInfo(Pass *P, enum PassDebuggingString S1, enum PassDebuggingString S2, StringRef Msg)
PMStack - This class implements a stack data structure of PMDataManager pointers.
PMDataManager * top() const
LLVM_ABI void push(PMDataManager *PM)
PMTopLevelManager manages LastUser info and collects common APIs used by top level pass managers.
void addIndirectPassManager(PMDataManager *Manager)
void schedulePass(Pass *P)
Schedule pass P for execution.
PassManagerPrettyStackEntry - This is used to print informative information about what pass is runnin...
Pass interface - Implemented by all 'passes'.
Pass(PassKind K, char &pid)
AnalysisType & getAnalysis() const
getAnalysis() - This function is used by subclasses to get to the analysis information ...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
The pass manager to schedule RegionPasses.
void dumpPassStructure(unsigned Offset) override
Print passes managed by this manager.
Definition RegionPass.cpp:165
Pass * getContainedPass(unsigned N)
Get passes contained by this manager.
void getAnalysisUsage(AnalysisUsage &Info) const override
Pass Manager itself does not invalidate any analysis info.
Definition RegionPass.cpp:48
RGPassManager()
Definition RegionPass.cpp:35
bool runOnFunction(Function &F) override
Execute all of the passes scheduled for execution.
Definition RegionPass.cpp:55
A pass that runs on each Region in a function.
void preparePassManager(PMStack &PMS) override
Check if available pass managers are suitable for this pass or not.
Definition RegionPass.cpp:220
bool skipRegion(Region &R) const
Optional passes call this function to check whether the pass should be skipped.
Definition RegionPass.cpp:283
void assignPassManager(PMStack &PMS, PassManagerType PMT=PMT_RegionPassManager) override
Assign pass manager to manage this pass.
Definition RegionPass.cpp:237
Pass * createPrinterPass(raw_ostream &O, const std::string &Banner) const override
Get a pass to print the LLVM IR in the region.
Definition RegionPass.cpp:274
The TimeRegion class is used as a helper class to call the startTimer() and stopTimer() methods of th...
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
PassManagerType
Different types of internal pass managers.
@ PMT_RegionPassManager
RGPassManager.
LLVM_ABI Timer * getPassTimer(Pass *)
Request the timer for this legacy-pass-manager's pass instance.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isFunctionInPrintList(StringRef FunctionName)
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.