Mercurial > hg > CbC > CbC_llvm
comparison lib/Analysis/LoopPass.cpp @ 77:54457678186b LLVM3.6
LLVM 3.6
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 08 Sep 2014 22:06:00 +0900 |
parents | 95c75e76d11b |
children | 60c9769439b8 |
comparison
equal
deleted
inserted
replaced
34:e874dbf0ad9d | 77:54457678186b |
---|---|
12 // responsible for managing LoopPasses. | 12 // responsible for managing LoopPasses. |
13 // | 13 // |
14 //===----------------------------------------------------------------------===// | 14 //===----------------------------------------------------------------------===// |
15 | 15 |
16 #include "llvm/Analysis/LoopPass.h" | 16 #include "llvm/Analysis/LoopPass.h" |
17 #include "llvm/Assembly/PrintModulePass.h" | 17 #include "llvm/IR/IRPrintingPasses.h" |
18 #include "llvm/IR/LLVMContext.h" | |
18 #include "llvm/Support/Debug.h" | 19 #include "llvm/Support/Debug.h" |
19 #include "llvm/Support/Timer.h" | 20 #include "llvm/Support/Timer.h" |
20 using namespace llvm; | 21 using namespace llvm; |
22 | |
23 #define DEBUG_TYPE "loop-pass-manager" | |
21 | 24 |
22 namespace { | 25 namespace { |
23 | 26 |
24 /// PrintLoopPass - Print a Function corresponding to a Loop. | 27 /// PrintLoopPass - Print a Function corresponding to a Loop. |
25 /// | 28 /// |
31 public: | 34 public: |
32 static char ID; | 35 static char ID; |
33 PrintLoopPass(const std::string &B, raw_ostream &o) | 36 PrintLoopPass(const std::string &B, raw_ostream &o) |
34 : LoopPass(ID), Banner(B), Out(o) {} | 37 : LoopPass(ID), Banner(B), Out(o) {} |
35 | 38 |
36 virtual void getAnalysisUsage(AnalysisUsage &AU) const { | 39 void getAnalysisUsage(AnalysisUsage &AU) const override { |
37 AU.setPreservesAll(); | 40 AU.setPreservesAll(); |
38 } | 41 } |
39 | 42 |
40 bool runOnLoop(Loop *L, LPPassManager &) { | 43 bool runOnLoop(Loop *L, LPPassManager &) override { |
41 Out << Banner; | 44 Out << Banner; |
42 for (Loop::block_iterator b = L->block_begin(), be = L->block_end(); | 45 for (Loop::block_iterator b = L->block_begin(), be = L->block_end(); |
43 b != be; | 46 b != be; |
44 ++b) { | 47 ++b) { |
45 (*b)->print(Out); | 48 if (*b) |
49 (*b)->print(Out); | |
50 else | |
51 Out << "Printing <null> block"; | |
46 } | 52 } |
47 return false; | 53 return false; |
48 } | 54 } |
49 }; | 55 }; |
50 | 56 |
59 | 65 |
60 LPPassManager::LPPassManager() | 66 LPPassManager::LPPassManager() |
61 : FunctionPass(ID), PMDataManager() { | 67 : FunctionPass(ID), PMDataManager() { |
62 skipThisLoop = false; | 68 skipThisLoop = false; |
63 redoThisLoop = false; | 69 redoThisLoop = false; |
64 LI = NULL; | 70 LI = nullptr; |
65 CurrentLoop = NULL; | 71 CurrentLoop = nullptr; |
66 } | 72 } |
67 | 73 |
68 /// Delete loop from the loop queue and loop hierarchy (LoopInfo). | 74 /// Delete loop from the loop queue and loop hierarchy (LoopInfo). |
69 void LPPassManager::deleteLoopFromQueue(Loop *L) { | 75 void LPPassManager::deleteLoopFromQueue(Loop *L) { |
70 | 76 |
249 CurrentLoop->verifyLoop(); | 255 CurrentLoop->verifyLoop(); |
250 } | 256 } |
251 | 257 |
252 // Then call the regular verifyAnalysis functions. | 258 // Then call the regular verifyAnalysis functions. |
253 verifyPreservedAnalysis(P); | 259 verifyPreservedAnalysis(P); |
260 | |
261 F.getContext().yield(); | |
254 } | 262 } |
255 | 263 |
256 removeNotPreservedAnalysis(P); | 264 removeNotPreservedAnalysis(P); |
257 recordAvailableAnalysis(P); | 265 recordAvailableAnalysis(P); |
258 removeDeadPasses(P, | 266 removeDeadPasses(P, |
363 PMS.push(LPPM); | 371 PMS.push(LPPM); |
364 } | 372 } |
365 | 373 |
366 LPPM->add(this); | 374 LPPM->add(this); |
367 } | 375 } |
376 | |
377 // Containing function has Attribute::OptimizeNone and transformation | |
378 // passes should skip it. | |
379 bool LoopPass::skipOptnoneFunction(const Loop *L) const { | |
380 const Function *F = L->getHeader()->getParent(); | |
381 if (F && F->hasFnAttribute(Attribute::OptimizeNone)) { | |
382 // FIXME: Report this to dbgs() only once per function. | |
383 DEBUG(dbgs() << "Skipping pass '" << getPassName() | |
384 << "' in function " << F->getName() << "\n"); | |
385 // FIXME: Delete loop from pass manager's queue? | |
386 return true; | |
387 } | |
388 return false; | |
389 } |