1 //===- PruneUnprofitable.cpp ------------------------------------*- C++ -*-===// 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 // 10 // Mark a SCoP as unfeasible if not deemed profitable to optimize. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #include "polly/PruneUnprofitable.h" 15 #include "polly/ScopInfo.h" 16 #include "polly/ScopPass.h" 17 #define DEBUG_TYPE "polly-prune-unprofitable" 18 19 using namespace polly; 20 using namespace llvm; 21 22 namespace { 23 24 STATISTIC(ScopsProcessed, 25 "Number of SCoPs considered for unprofitability pruning"); 26 STATISTIC(ScopsPruned, "Number of pruned SCoPs because it they cannot be " 27 "optimized in a significant way"); 28 29 class PruneUnprofitable : public ScopPass { 30 private: 31 PruneUnprofitable(const PruneUnprofitable &) = delete; 32 const PruneUnprofitable &operator=(const PruneUnprofitable &) = delete; 33 34 public: 35 static char ID; 36 explicit PruneUnprofitable() : ScopPass(ID) {} 37 38 virtual void getAnalysisUsage(AnalysisUsage &AU) const override { 39 AU.addRequired<ScopInfoRegionPass>(); 40 AU.setPreservesAll(); 41 } 42 43 virtual bool runOnScop(Scop &S) override { 44 if (PollyProcessUnprofitable) { 45 DEBUG(dbgs() << "NOTE: -polly-process-unprofitable active, won't prune " 46 "anything\n"); 47 return false; 48 } 49 50 ScopsProcessed++; 51 52 if (!S.isProfitable(true)) { 53 DEBUG(dbgs() << "SCoP pruned because it probably cannot be optimized in " 54 "a significant way\n"); 55 ScopsPruned++; 56 S.invalidate(PROFITABLE, DebugLoc()); 57 } 58 59 return false; 60 } 61 }; 62 63 char PruneUnprofitable::ID; 64 } // anonymous namespace 65 66 Pass *polly::createPruneUnprofitablePass() { return new PruneUnprofitable(); } 67 68 INITIALIZE_PASS_BEGIN(PruneUnprofitable, "polly-prune-unprofitable", 69 "Polly - Prune unprofitable SCoPs", false, false) 70 INITIALIZE_PASS_END(PruneUnprofitable, "polly-prune-unprofitable", 71 "Polly - Prune unprofitable SCoPs", false, false) 72