Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 1 | //===----- ScopDetection.cpp - Detect Scops --------------------*- 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 | // Detect the maximal Scops of a function. |
| 11 | // |
| 12 | // A static control part (Scop) is a subgraph of the control flow graph (CFG) |
| 13 | // that only has statically known control flow and can therefore be described |
| 14 | // within the polyhedral model. |
| 15 | // |
| 16 | // Every Scop fullfills these restrictions: |
| 17 | // |
| 18 | // * It is a single entry single exit region |
| 19 | // |
| 20 | // * Only affine linear bounds in the loops |
| 21 | // |
| 22 | // Every natural loop in a Scop must have a number of loop iterations that can |
| 23 | // be described as an affine linear function in surrounding loop iterators or |
| 24 | // parameters. (A parameter is a scalar that does not change its value during |
| 25 | // execution of the Scop). |
| 26 | // |
| 27 | // * Only comparisons of affine linear expressions in conditions |
| 28 | // |
| 29 | // * All loops and conditions perfectly nested |
| 30 | // |
| 31 | // The control flow needs to be structured such that it could be written using |
| 32 | // just 'for' and 'if' statements, without the need for any 'goto', 'break' or |
| 33 | // 'continue'. |
| 34 | // |
| 35 | // * Side effect free functions call |
| 36 | // |
| 37 | // Only function calls and intrinsics that do not have side effects are allowed |
| 38 | // (readnone). |
| 39 | // |
| 40 | // The Scop detection finds the largest Scops by checking if the largest |
| 41 | // region is a Scop. If this is not the case, its canonical subregions are |
| 42 | // checked until a region is a Scop. It is now tried to extend this Scop by |
| 43 | // creating a larger non canonical region. |
| 44 | // |
| 45 | //===----------------------------------------------------------------------===// |
| 46 | |
Tobias Grosser | ecfe21b | 2013-03-20 18:03:18 +0000 | [diff] [blame] | 47 | #include "polly/CodeGen/BlockGenerators.h" |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 48 | #include "polly/LinkAllPasses.h" |
Tobias Grosser | 637bd63 | 2013-05-07 07:31:10 +0000 | [diff] [blame] | 49 | #include "polly/Options.h" |
Tobias Grosser | ecfe21b | 2013-03-20 18:03:18 +0000 | [diff] [blame] | 50 | #include "polly/ScopDetection.h" |
Tobias Grosser | 120db6b | 2011-11-07 12:58:54 +0000 | [diff] [blame] | 51 | #include "polly/Support/SCEVValidator.h" |
Tobias Grosser | 8362818 | 2013-05-07 08:11:54 +0000 | [diff] [blame] | 52 | #include "polly/Support/ScopHelper.h" |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 53 | #include "llvm/ADT/Statistic.h" |
| 54 | #include "llvm/Analysis/AliasAnalysis.h" |
Tobias Grosser | 6e9f25a | 2011-11-09 22:35:00 +0000 | [diff] [blame] | 55 | #include "llvm/Analysis/LoopInfo.h" |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 56 | #include "llvm/Analysis/RegionIterator.h" |
Tobias Grosser | 6e9f25a | 2011-11-09 22:35:00 +0000 | [diff] [blame] | 57 | #include "llvm/Analysis/ScalarEvolution.h" |
Tobias Grosser | b8710b5 | 2011-11-10 12:44:50 +0000 | [diff] [blame] | 58 | #include "llvm/Analysis/ScalarEvolutionExpressions.h" |
Chandler Carruth | 6b96c24 | 2014-03-06 00:47:27 +0000 | [diff] [blame] | 59 | #include "llvm/IR/DebugInfo.h" |
Tobias Grosser | 8519f89 | 2013-12-18 10:49:53 +0000 | [diff] [blame] | 60 | #include "llvm/IR/DiagnosticInfo.h" |
| 61 | #include "llvm/IR/DiagnosticPrinter.h" |
Chandler Carruth | 6b96c24 | 2014-03-06 00:47:27 +0000 | [diff] [blame] | 62 | #include "llvm/IR/LLVMContext.h" |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 63 | |
| 64 | #define DEBUG_TYPE "polly-detect" |
| 65 | #include "llvm/Support/Debug.h" |
| 66 | |
Tobias Grosser | 60b54f1 | 2011-11-08 15:41:28 +0000 | [diff] [blame] | 67 | #include <set> |
| 68 | |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 69 | using namespace llvm; |
| 70 | using namespace polly; |
| 71 | |
Sebastian Pop | 8fe6d11 | 2013-05-30 17:47:32 +0000 | [diff] [blame] | 72 | static cl::opt<bool> |
| 73 | DetectScopsWithoutLoops("polly-detect-scops-in-functions-without-loops", |
| 74 | cl::desc("Detect scops in functions without loops"), |
| 75 | cl::Hidden, cl::init(false), cl::cat(PollyCategory)); |
| 76 | |
Sebastian Pop | 2c9ec2e | 2013-06-03 16:35:37 +0000 | [diff] [blame] | 77 | static cl::opt<bool> |
| 78 | DetectRegionsWithoutLoops("polly-detect-scops-in-regions-without-loops", |
| 79 | cl::desc("Detect scops in regions without loops"), |
| 80 | cl::Hidden, cl::init(false), cl::cat(PollyCategory)); |
| 81 | |
Tobias Grosser | 2ff8723 | 2011-10-23 11:17:06 +0000 | [diff] [blame] | 82 | static cl::opt<std::string> |
Tobias Grosser | 637bd63 | 2013-05-07 07:31:10 +0000 | [diff] [blame] | 83 | OnlyFunction("polly-only-func", cl::desc("Only run on a single function"), |
| 84 | cl::value_desc("function-name"), cl::ValueRequired, cl::init(""), |
| 85 | cl::cat(PollyCategory)); |
Tobias Grosser | 2ff8723 | 2011-10-23 11:17:06 +0000 | [diff] [blame] | 86 | |
Tobias Grosser | 4449e52 | 2014-01-27 14:24:53 +0000 | [diff] [blame] | 87 | static cl::opt<std::string> |
| 88 | OnlyRegion("polly-only-region", |
| 89 | cl::desc("Only run on certain regions (The provided identifier must " |
| 90 | "appear in the name of the region's entry block"), |
| 91 | cl::value_desc("identifier"), cl::ValueRequired, cl::init(""), |
| 92 | cl::cat(PollyCategory)); |
| 93 | |
Tobias Grosser | 60cd932 | 2011-11-10 12:47:26 +0000 | [diff] [blame] | 94 | static cl::opt<bool> |
| 95 | IgnoreAliasing("polly-ignore-aliasing", |
| 96 | cl::desc("Ignore possible aliasing of the array bases"), |
Tobias Grosser | 637bd63 | 2013-05-07 07:31:10 +0000 | [diff] [blame] | 97 | cl::Hidden, cl::init(false), cl::cat(PollyCategory)); |
Tobias Grosser | 2ff8723 | 2011-10-23 11:17:06 +0000 | [diff] [blame] | 98 | |
Tobias Grosser | 637bd63 | 2013-05-07 07:31:10 +0000 | [diff] [blame] | 99 | static cl::opt<bool> |
| 100 | ReportLevel("polly-report", |
| 101 | cl::desc("Print information about the activities of Polly"), |
| 102 | cl::init(false), cl::cat(PollyCategory)); |
Tobias Grosser | 531891e | 2012-11-01 16:45:20 +0000 | [diff] [blame] | 103 | |
| 104 | static cl::opt<bool> |
Tobias Grosser | a187964 | 2011-12-20 10:43:14 +0000 | [diff] [blame] | 105 | AllowNonAffine("polly-allow-nonaffine", |
| 106 | cl::desc("Allow non affine access functions in arrays"), |
Tobias Grosser | 637bd63 | 2013-05-07 07:31:10 +0000 | [diff] [blame] | 107 | cl::Hidden, cl::init(false), cl::cat(PollyCategory)); |
Tobias Grosser | a187964 | 2011-12-20 10:43:14 +0000 | [diff] [blame] | 108 | |
Tobias Grosser | c7d3fc5 | 2013-07-25 03:02:29 +0000 | [diff] [blame] | 109 | static cl::opt<bool, true> |
| 110 | TrackFailures("polly-detect-track-failures", |
| 111 | cl::desc("Track failure strings in detecting scop regions"), |
| 112 | cl::location(PollyTrackFailures), cl::Hidden, cl::init(false), |
| 113 | cl::cat(PollyCategory)); |
| 114 | |
Tobias Grosser | a168993 | 2014-02-18 18:49:49 +0000 | [diff] [blame] | 115 | static cl::opt<bool> |
| 116 | VerifyScops("polly-detect-verify", |
| 117 | cl::desc("Verify the detected SCoPs after each transformation"), |
| 118 | cl::Hidden, cl::init(false), cl::cat(PollyCategory)); |
| 119 | |
Tobias Grosser | c7d3fc5 | 2013-07-25 03:02:29 +0000 | [diff] [blame] | 120 | bool polly::PollyTrackFailures = false; |
| 121 | |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 122 | //===----------------------------------------------------------------------===// |
| 123 | // Statistics. |
| 124 | |
| 125 | STATISTIC(ValidRegion, "Number of regions that a valid part of Scop"); |
| 126 | |
Tobias Grosser | 74394f0 | 2013-01-14 22:40:23 +0000 | [diff] [blame] | 127 | #define BADSCOP_STAT(NAME, DESC) \ |
| 128 | STATISTIC(Bad##NAME##ForScop, "Number of bad regions for Scop: " DESC) |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 129 | |
Tobias Grosser | 74394f0 | 2013-01-14 22:40:23 +0000 | [diff] [blame] | 130 | #define INVALID(NAME, MESSAGE) \ |
| 131 | do { \ |
Tobias Grosser | c7d3fc5 | 2013-07-25 03:02:29 +0000 | [diff] [blame] | 132 | if (PollyTrackFailures) { \ |
| 133 | std::string Buf; \ |
| 134 | raw_string_ostream fmt(Buf); \ |
| 135 | fmt << MESSAGE; \ |
| 136 | fmt.flush(); \ |
| 137 | LastFailure = Buf; \ |
| 138 | } \ |
Tobias Grosser | 74394f0 | 2013-01-14 22:40:23 +0000 | [diff] [blame] | 139 | DEBUG(dbgs() << MESSAGE); \ |
| 140 | DEBUG(dbgs() << "\n"); \ |
Tobias Grosser | 1c84d80 | 2013-11-16 01:07:06 +0000 | [diff] [blame] | 141 | assert(!Context.Verifying && #NAME); \ |
Tobias Grosser | 74394f0 | 2013-01-14 22:40:23 +0000 | [diff] [blame] | 142 | if (!Context.Verifying) \ |
| 143 | ++Bad##NAME##ForScop; \ |
Tobias Grosser | 84b81de | 2013-03-19 21:44:07 +0000 | [diff] [blame] | 144 | } while (0) |
Tobias Grosser | fff5adc | 2011-11-10 13:21:43 +0000 | [diff] [blame] | 145 | |
Tobias Grosser | 74394f0 | 2013-01-14 22:40:23 +0000 | [diff] [blame] | 146 | #define INVALID_NOVERIFY(NAME, MESSAGE) \ |
| 147 | do { \ |
Tobias Grosser | c7d3fc5 | 2013-07-25 03:02:29 +0000 | [diff] [blame] | 148 | if (PollyTrackFailures) { \ |
| 149 | std::string Buf; \ |
| 150 | raw_string_ostream fmt(Buf); \ |
| 151 | fmt << MESSAGE; \ |
| 152 | fmt.flush(); \ |
| 153 | LastFailure = Buf; \ |
| 154 | } \ |
Tobias Grosser | 74394f0 | 2013-01-14 22:40:23 +0000 | [diff] [blame] | 155 | DEBUG(dbgs() << MESSAGE); \ |
| 156 | DEBUG(dbgs() << "\n"); \ |
| 157 | /* DISABLED: assert(!Context.Verifying && #NAME); */ \ |
| 158 | if (!Context.Verifying) \ |
| 159 | ++Bad##NAME##ForScop; \ |
Tobias Grosser | 84b81de | 2013-03-19 21:44:07 +0000 | [diff] [blame] | 160 | } while (0) |
Tobias Grosser | c4a0bd1 | 2011-10-08 00:30:48 +0000 | [diff] [blame] | 161 | |
Tobias Grosser | 74394f0 | 2013-01-14 22:40:23 +0000 | [diff] [blame] | 162 | BADSCOP_STAT(CFG, "CFG too complex"); |
| 163 | BADSCOP_STAT(IndVar, "Non canonical induction variable in loop"); |
Sebastian Pop | 9d63234 | 2013-06-11 22:20:40 +0000 | [diff] [blame] | 164 | BADSCOP_STAT(IndEdge, "Found invalid region entering edges"); |
Tobias Grosser | 74394f0 | 2013-01-14 22:40:23 +0000 | [diff] [blame] | 165 | BADSCOP_STAT(LoopBound, "Loop bounds can not be computed"); |
| 166 | BADSCOP_STAT(FuncCall, "Function call with side effects appeared"); |
| 167 | BADSCOP_STAT(AffFunc, "Expression not affine"); |
Tobias Grosser | 74394f0 | 2013-01-14 22:40:23 +0000 | [diff] [blame] | 168 | BADSCOP_STAT(Alias, "Found base address alias"); |
Tobias Grosser | 8edce4e | 2013-04-16 08:04:42 +0000 | [diff] [blame] | 169 | BADSCOP_STAT(SimpleLoop, "Loop not in -loop-simplify form"); |
Tobias Grosser | 74394f0 | 2013-01-14 22:40:23 +0000 | [diff] [blame] | 170 | BADSCOP_STAT(Other, "Others"); |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 171 | |
Tobias Grosser | 8519f89 | 2013-12-18 10:49:53 +0000 | [diff] [blame] | 172 | class DiagnosticScopFound : public DiagnosticInfo { |
| 173 | private: |
| 174 | static int PluginDiagnosticKind; |
| 175 | |
| 176 | Function &F; |
| 177 | std::string FileName; |
| 178 | unsigned EntryLine, ExitLine; |
| 179 | |
| 180 | public: |
Tobias Grosser | 1b12f46 | 2013-12-18 11:14:36 +0000 | [diff] [blame] | 181 | DiagnosticScopFound(Function &F, std::string FileName, unsigned EntryLine, |
| 182 | unsigned ExitLine) |
Tobias Grosser | 8519f89 | 2013-12-18 10:49:53 +0000 | [diff] [blame] | 183 | : DiagnosticInfo(PluginDiagnosticKind, DS_Note), F(F), FileName(FileName), |
Tobias Grosser | 1b12f46 | 2013-12-18 11:14:36 +0000 | [diff] [blame] | 184 | EntryLine(EntryLine), ExitLine(ExitLine) {} |
Tobias Grosser | 8519f89 | 2013-12-18 10:49:53 +0000 | [diff] [blame] | 185 | |
| 186 | virtual void print(DiagnosticPrinter &DP) const; |
| 187 | |
| 188 | static bool classof(const DiagnosticInfo *DI) { |
| 189 | return DI->getKind() == PluginDiagnosticKind; |
| 190 | } |
| 191 | }; |
| 192 | |
| 193 | int DiagnosticScopFound::PluginDiagnosticKind = 10; |
| 194 | |
Tobias Grosser | 8519f89 | 2013-12-18 10:49:53 +0000 | [diff] [blame] | 195 | void DiagnosticScopFound::print(DiagnosticPrinter &DP) const { |
| 196 | |
Tobias Grosser | 1b12f46 | 2013-12-18 11:14:36 +0000 | [diff] [blame] | 197 | DP << "Polly detected an optimizable loop region (scop) in function '" << F |
| 198 | << "'\n"; |
Tobias Grosser | 8519f89 | 2013-12-18 10:49:53 +0000 | [diff] [blame] | 199 | |
| 200 | if (FileName.empty()) { |
| 201 | DP << "Scop location is unknown. Compile with debug info " |
| 202 | "(-g) to get more precise information. "; |
Tobias Grosser | 1b12f46 | 2013-12-18 11:14:36 +0000 | [diff] [blame] | 203 | return; |
Tobias Grosser | 8519f89 | 2013-12-18 10:49:53 +0000 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | DP << FileName << ":" << EntryLine << ": Start of scop\n"; |
| 207 | DP << FileName << ":" << ExitLine << ": End of scop"; |
| 208 | } |
| 209 | |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 210 | //===----------------------------------------------------------------------===// |
| 211 | // ScopDetection. |
Tobias Grosser | a168993 | 2014-02-18 18:49:49 +0000 | [diff] [blame] | 212 | bool ScopDetection::isMaxRegionInScop(const Region &R, bool Verify) const { |
| 213 | if (!ValidRegions.count(&R)) |
| 214 | return false; |
| 215 | |
| 216 | if (Verify) |
| 217 | return isValidRegion(const_cast<Region &>(R)); |
| 218 | |
| 219 | return true; |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 220 | } |
| 221 | |
Tobias Grosser | 4f129a6 | 2011-10-08 00:30:55 +0000 | [diff] [blame] | 222 | std::string ScopDetection::regionIsInvalidBecause(const Region *R) const { |
| 223 | if (!InvalidRegions.count(R)) |
| 224 | return ""; |
| 225 | |
| 226 | return InvalidRegions.find(R)->second; |
| 227 | } |
| 228 | |
Tobias Grosser | e602a07 | 2013-05-07 07:30:56 +0000 | [diff] [blame] | 229 | bool ScopDetection::isValidCFG(BasicBlock &BB, |
| 230 | DetectionContext &Context) const { |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 231 | Region &RefRegion = Context.CurRegion; |
| 232 | TerminatorInst *TI = BB.getTerminator(); |
| 233 | |
| 234 | // Return instructions are only valid if the region is the top level region. |
| 235 | if (isa<ReturnInst>(TI) && !RefRegion.getExit() && TI->getNumOperands() == 0) |
| 236 | return true; |
| 237 | |
| 238 | BranchInst *Br = dyn_cast<BranchInst>(TI); |
| 239 | |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 240 | if (!Br) { |
Tobias Grosser | 29ee0b1 | 2011-11-17 14:52:36 +0000 | [diff] [blame] | 241 | INVALID(CFG, "Non branch instruction terminates BB: " + BB.getName()); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 242 | return false; |
| 243 | } |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 244 | |
Tobias Grosser | 74394f0 | 2013-01-14 22:40:23 +0000 | [diff] [blame] | 245 | if (Br->isUnconditional()) |
| 246 | return true; |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 247 | |
| 248 | Value *Condition = Br->getCondition(); |
| 249 | |
| 250 | // UndefValue is not allowed as condition. |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 251 | if (isa<UndefValue>(Condition)) { |
Tobias Grosser | 1bb59b0 | 2012-12-29 23:47:38 +0000 | [diff] [blame] | 252 | INVALID(AffFunc, "Condition based on 'undef' value in BB: " + BB.getName()); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 253 | return false; |
| 254 | } |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 255 | |
| 256 | // Only Constant and ICmpInst are allowed as condition. |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 257 | if (!(isa<Constant>(Condition) || isa<ICmpInst>(Condition))) { |
Tobias Grosser | 4d96c8d | 2013-03-23 01:05:07 +0000 | [diff] [blame] | 258 | INVALID(AffFunc, "Condition in BB '" + BB.getName() + |
Tobias Grosser | d7e5864 | 2013-04-10 06:55:45 +0000 | [diff] [blame] | 259 | "' neither constant nor an icmp instruction"); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 260 | return false; |
| 261 | } |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 262 | |
| 263 | // Allow perfectly nested conditions. |
| 264 | assert(Br->getNumSuccessors() == 2 && "Unexpected number of successors"); |
| 265 | |
| 266 | if (ICmpInst *ICmp = dyn_cast<ICmpInst>(Condition)) { |
| 267 | // Unsigned comparisons are not allowed. They trigger overflow problems |
| 268 | // in the code generation. |
| 269 | // |
| 270 | // TODO: This is not sufficient and just hides bugs. However it does pretty |
| 271 | // well. |
Tobias Grosser | 1bb59b0 | 2012-12-29 23:47:38 +0000 | [diff] [blame] | 272 | if (ICmp->isUnsigned()) |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 273 | return false; |
| 274 | |
| 275 | // Are both operands of the ICmp affine? |
Tobias Grosser | 74394f0 | 2013-01-14 22:40:23 +0000 | [diff] [blame] | 276 | if (isa<UndefValue>(ICmp->getOperand(0)) || |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 277 | isa<UndefValue>(ICmp->getOperand(1))) { |
Tobias Grosser | 29ee0b1 | 2011-11-17 14:52:36 +0000 | [diff] [blame] | 278 | INVALID(AffFunc, "undef operand in branch at BB: " + BB.getName()); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 279 | return false; |
| 280 | } |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 281 | |
Sebastian Pop | 9f57c5b | 2013-04-10 04:05:18 +0000 | [diff] [blame] | 282 | Loop *L = LI->getLoopFor(ICmp->getParent()); |
| 283 | const SCEV *LHS = SE->getSCEVAtScope(ICmp->getOperand(0), L); |
| 284 | const SCEV *RHS = SE->getSCEVAtScope(ICmp->getOperand(1), L); |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 285 | |
Tobias Grosser | a66fa6c | 2011-11-10 12:45:11 +0000 | [diff] [blame] | 286 | if (!isAffineExpr(&Context.CurRegion, LHS, *SE) || |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 287 | !isAffineExpr(&Context.CurRegion, RHS, *SE)) { |
Tobias Grosser | 983e785 | 2013-07-28 09:05:20 +0000 | [diff] [blame] | 288 | INVALID(AffFunc, "Non affine branch in BB '" << BB.getName() |
| 289 | << "' with LHS: " << *LHS |
| 290 | << " and RHS: " << *RHS); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 291 | return false; |
| 292 | } |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | // Allow loop exit conditions. |
| 296 | Loop *L = LI->getLoopFor(&BB); |
| 297 | if (L && L->getExitingBlock() == &BB) |
| 298 | return true; |
| 299 | |
| 300 | // Allow perfectly nested conditions. |
| 301 | Region *R = RI->getRegionFor(&BB); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 302 | if (R->getEntry() != &BB) { |
Tobias Grosser | 29ee0b1 | 2011-11-17 14:52:36 +0000 | [diff] [blame] | 303 | INVALID(CFG, "Not well structured condition at BB: " + BB.getName()); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 304 | return false; |
| 305 | } |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 306 | |
| 307 | return true; |
| 308 | } |
| 309 | |
| 310 | bool ScopDetection::isValidCallInst(CallInst &CI) { |
| 311 | if (CI.mayHaveSideEffects() || CI.doesNotReturn()) |
| 312 | return false; |
| 313 | |
| 314 | if (CI.doesNotAccessMemory()) |
| 315 | return true; |
| 316 | |
| 317 | Function *CalledFunction = CI.getCalledFunction(); |
| 318 | |
| 319 | // Indirect calls are not supported. |
| 320 | if (CalledFunction == 0) |
| 321 | return false; |
| 322 | |
| 323 | // TODO: Intrinsics. |
| 324 | return false; |
| 325 | } |
| 326 | |
Tobias Grosser | c7d3fc5 | 2013-07-25 03:02:29 +0000 | [diff] [blame] | 327 | std::string ScopDetection::formatInvalidAlias(AliasSet &AS) const { |
| 328 | std::string Message; |
| 329 | raw_string_ostream OS(Message); |
| 330 | |
| 331 | OS << "Possible aliasing: "; |
| 332 | |
| 333 | std::vector<Value *> Pointers; |
| 334 | |
Tobias Grosser | b5846f9 | 2014-03-02 17:05:27 +0000 | [diff] [blame] | 335 | for (const auto &I : AS) |
Tobias Grosser | 00dc309 | 2014-03-02 12:02:46 +0000 | [diff] [blame] | 336 | Pointers.push_back(I.getValue()); |
Tobias Grosser | c7d3fc5 | 2013-07-25 03:02:29 +0000 | [diff] [blame] | 337 | |
| 338 | std::sort(Pointers.begin(), Pointers.end()); |
| 339 | |
| 340 | for (std::vector<Value *>::iterator PI = Pointers.begin(), |
| 341 | PE = Pointers.end(); |
| 342 | ;) { |
| 343 | Value *V = *PI; |
| 344 | |
| 345 | if (V->getName().size() == 0) |
| 346 | OS << "\"" << *V << "\""; |
| 347 | else |
| 348 | OS << "\"" << V->getName() << "\""; |
| 349 | |
| 350 | ++PI; |
| 351 | |
| 352 | if (PI != PE) |
| 353 | OS << ", "; |
| 354 | else |
| 355 | break; |
| 356 | } |
| 357 | |
| 358 | return OS.str(); |
| 359 | } |
| 360 | |
Tobias Grosser | 458fb78 | 2014-01-28 12:58:58 +0000 | [diff] [blame] | 361 | bool ScopDetection::isInvariant(const Value &Val, const Region &Reg) const { |
| 362 | // A reference to function argument or constant value is invariant. |
| 363 | if (isa<Argument>(Val) || isa<Constant>(Val)) |
| 364 | return true; |
| 365 | |
| 366 | const Instruction *I = dyn_cast<Instruction>(&Val); |
| 367 | if (!I) |
| 368 | return false; |
| 369 | |
| 370 | if (!Reg.contains(I)) |
| 371 | return true; |
| 372 | |
| 373 | if (I->mayHaveSideEffects()) |
| 374 | return false; |
| 375 | |
| 376 | // When Val is a Phi node, it is likely not invariant. We do not check whether |
| 377 | // Phi nodes are actually invariant, we assume that Phi nodes are usually not |
| 378 | // invariant. Recursively checking the operators of Phi nodes would lead to |
| 379 | // infinite recursion. |
| 380 | if (isa<PHINode>(*I)) |
| 381 | return false; |
| 382 | |
Tobias Grosser | 1d19190 | 2014-03-03 13:13:55 +0000 | [diff] [blame] | 383 | for (const auto &Operand : I->operands()) |
| 384 | if (!isInvariant(*Operand, Reg)) |
Tobias Grosser | 458fb78 | 2014-01-28 12:58:58 +0000 | [diff] [blame] | 385 | return false; |
Tobias Grosser | 458fb78 | 2014-01-28 12:58:58 +0000 | [diff] [blame] | 386 | |
| 387 | // When the instruction is a load instruction, check that no write to memory |
| 388 | // in the region aliases with the load. |
| 389 | if (const LoadInst *LI = dyn_cast<LoadInst>(I)) { |
| 390 | AliasAnalysis::Location Loc = AA->getLocation(LI); |
| 391 | const Region::const_block_iterator BE = Reg.block_end(); |
| 392 | // Check if any basic block in the region can modify the location pointed to |
| 393 | // by 'Loc'. If so, 'Val' is (likely) not invariant in the region. |
Tobias Grosser | 1d19190 | 2014-03-03 13:13:55 +0000 | [diff] [blame] | 394 | for (const auto &BB : Reg.blocks()) |
| 395 | if (AA->canBasicBlockModify(*BB, Loc)) |
Tobias Grosser | 458fb78 | 2014-01-28 12:58:58 +0000 | [diff] [blame] | 396 | return false; |
Tobias Grosser | 458fb78 | 2014-01-28 12:58:58 +0000 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | return true; |
| 400 | } |
| 401 | |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 402 | bool ScopDetection::isValidMemoryAccess(Instruction &Inst, |
| 403 | DetectionContext &Context) const { |
Tobias Grosser | e5e171e | 2011-11-10 12:45:03 +0000 | [diff] [blame] | 404 | Value *Ptr = getPointerOperand(Inst); |
Sebastian Pop | 9f57c5b | 2013-04-10 04:05:18 +0000 | [diff] [blame] | 405 | Loop *L = LI->getLoopFor(Inst.getParent()); |
| 406 | const SCEV *AccessFunction = SE->getSCEVAtScope(Ptr, L); |
Tobias Grosser | b8710b5 | 2011-11-10 12:44:50 +0000 | [diff] [blame] | 407 | const SCEVUnknown *BasePointer; |
Tobias Grosser | e5e171e | 2011-11-10 12:45:03 +0000 | [diff] [blame] | 408 | Value *BaseValue; |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 409 | |
Tobias Grosser | b8710b5 | 2011-11-10 12:44:50 +0000 | [diff] [blame] | 410 | BasePointer = dyn_cast<SCEVUnknown>(SE->getPointerBase(AccessFunction)); |
| 411 | |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 412 | if (!BasePointer) { |
Tobias Grosser | b8710b5 | 2011-11-10 12:44:50 +0000 | [diff] [blame] | 413 | INVALID(AffFunc, "No base pointer"); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 414 | return false; |
| 415 | } |
Tobias Grosser | b8710b5 | 2011-11-10 12:44:50 +0000 | [diff] [blame] | 416 | |
| 417 | BaseValue = BasePointer->getValue(); |
| 418 | |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 419 | if (isa<UndefValue>(BaseValue)) { |
Tobias Grosser | b8710b5 | 2011-11-10 12:44:50 +0000 | [diff] [blame] | 420 | INVALID(AffFunc, "Undefined base pointer"); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 421 | return false; |
| 422 | } |
Tobias Grosser | b8710b5 | 2011-11-10 12:44:50 +0000 | [diff] [blame] | 423 | |
Tobias Grosser | 458fb78 | 2014-01-28 12:58:58 +0000 | [diff] [blame] | 424 | // Check that the base address of the access is invariant in the current |
| 425 | // region. |
| 426 | if (!isInvariant(*BaseValue, Context.CurRegion)) { |
Tobias Grosser | ab2227a | 2014-01-28 13:43:24 +0000 | [diff] [blame] | 427 | // Verification of this property is difficult as the independent blocks |
| 428 | // pass may introduce aliasing that we did not have when running the |
| 429 | // scop detection. |
| 430 | INVALID_NOVERIFY( |
| 431 | AffFunc, "Base address not invariant in current region:" << *BaseValue); |
Tobias Grosser | 458fb78 | 2014-01-28 12:58:58 +0000 | [diff] [blame] | 432 | return false; |
| 433 | } |
| 434 | |
Tobias Grosser | b8710b5 | 2011-11-10 12:44:50 +0000 | [diff] [blame] | 435 | AccessFunction = SE->getMinusSCEV(AccessFunction, BasePointer); |
| 436 | |
Tobias Grosser | 58032cb | 2013-06-23 01:29:29 +0000 | [diff] [blame] | 437 | if (!AllowNonAffine && |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 438 | !isAffineExpr(&Context.CurRegion, AccessFunction, *SE, BaseValue)) { |
Tobias Grosser | eeb776a | 2012-09-08 14:00:37 +0000 | [diff] [blame] | 439 | INVALID(AffFunc, "Non affine access function: " << *AccessFunction); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 440 | return false; |
| 441 | } |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 442 | |
| 443 | // FIXME: Alias Analysis thinks IntToPtrInst aliases with alloca instructions |
| 444 | // created by IndependentBlocks Pass. |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 445 | if (isa<IntToPtrInst>(BaseValue)) { |
Tobias Grosser | e5e171e | 2011-11-10 12:45:03 +0000 | [diff] [blame] | 446 | INVALID(Other, "Find bad intToptr prt: " << *BaseValue); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 447 | return false; |
| 448 | } |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 449 | |
Sebastian Pop | 8c2d753 | 2013-07-03 22:50:36 +0000 | [diff] [blame] | 450 | if (IgnoreAliasing) |
| 451 | return true; |
Tobias Grosser | fff5adc | 2011-11-10 13:21:43 +0000 | [diff] [blame] | 452 | |
Sebastian Pop | 8c2d753 | 2013-07-03 22:50:36 +0000 | [diff] [blame] | 453 | // Check if the base pointer of the memory access does alias with |
| 454 | // any other pointer. This cannot be handled at the moment. |
Tobias Grosser | 298a764 | 2013-07-14 18:09:43 +0000 | [diff] [blame] | 455 | AliasSet &AS = |
| 456 | Context.AST.getAliasSetForPointer(BaseValue, AliasAnalysis::UnknownSize, |
| 457 | Inst.getMetadata(LLVMContext::MD_tbaa)); |
Tobias Grosser | 428b3e4 | 2013-02-04 15:46:25 +0000 | [diff] [blame] | 458 | |
Sebastian Pop | 8c2d753 | 2013-07-03 22:50:36 +0000 | [diff] [blame] | 459 | // INVALID triggers an assertion in verifying mode, if it detects that a |
| 460 | // SCoP was detected by SCoP detection and that this SCoP was invalidated by |
| 461 | // a pass that stated it would preserve the SCoPs. We disable this check as |
| 462 | // the independent blocks pass may create memory references which seem to |
| 463 | // alias, if -basicaa is not available. They actually do not, but as we can |
| 464 | // not proof this without -basicaa we would fail. We disable this check to |
| 465 | // not cause irrelevant verification failures. |
| 466 | if (!AS.isMustAlias()) { |
Tobias Grosser | c7d3fc5 | 2013-07-25 03:02:29 +0000 | [diff] [blame] | 467 | INVALID_NOVERIFY(Alias, formatInvalidAlias(AS)); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 468 | return false; |
Tobias Grosser | 428b3e4 | 2013-02-04 15:46:25 +0000 | [diff] [blame] | 469 | } |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 470 | |
| 471 | return true; |
| 472 | } |
| 473 | |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 474 | bool ScopDetection::isValidInstruction(Instruction &Inst, |
| 475 | DetectionContext &Context) const { |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 476 | if (PHINode *PN = dyn_cast<PHINode>(&Inst)) |
Tobias Grosser | ecfe21b | 2013-03-20 18:03:18 +0000 | [diff] [blame] | 477 | if (!canSynthesize(PN, LI, SE, &Context.CurRegion)) { |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 478 | if (SCEVCodegen) { |
Tobias Grosser | ecfe21b | 2013-03-20 18:03:18 +0000 | [diff] [blame] | 479 | INVALID(IndVar, |
| 480 | "SCEV of PHI node refers to SSA names in region: " << Inst); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 481 | return false; |
| 482 | |
| 483 | } else { |
Tobias Grosser | ecfe21b | 2013-03-20 18:03:18 +0000 | [diff] [blame] | 484 | INVALID(IndVar, "Non canonical PHI node: " << Inst); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 485 | return false; |
| 486 | } |
Tobias Grosser | ecfe21b | 2013-03-20 18:03:18 +0000 | [diff] [blame] | 487 | } |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 488 | |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 489 | // We only check the call instruction but not invoke instruction. |
| 490 | if (CallInst *CI = dyn_cast<CallInst>(&Inst)) { |
| 491 | if (isValidCallInst(*CI)) |
| 492 | return true; |
| 493 | |
Tobias Grosser | b43ba82 | 2011-10-08 00:49:30 +0000 | [diff] [blame] | 494 | INVALID(FuncCall, "Call instruction: " << Inst); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 495 | return false; |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 496 | } |
| 497 | |
| 498 | if (!Inst.mayWriteToMemory() && !Inst.mayReadFromMemory()) { |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 499 | if (!isa<AllocaInst>(Inst)) |
| 500 | return true; |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 501 | |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 502 | INVALID(Other, "Alloca instruction: " << Inst); |
| 503 | return false; |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | // Check the access function. |
| 507 | if (isa<LoadInst>(Inst) || isa<StoreInst>(Inst)) |
| 508 | return isValidMemoryAccess(Inst, Context); |
| 509 | |
| 510 | // We do not know this instruction, therefore we assume it is invalid. |
Tobias Grosser | c4a0bd1 | 2011-10-08 00:30:48 +0000 | [diff] [blame] | 511 | INVALID(Other, "Unknown instruction: " << Inst); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 512 | return false; |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 513 | } |
| 514 | |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 515 | bool ScopDetection::isValidLoop(Loop *L, DetectionContext &Context) const { |
Tobias Grosser | 826b2af | 2013-03-21 16:14:50 +0000 | [diff] [blame] | 516 | if (!SCEVCodegen) { |
| 517 | // If code generation is not in scev based mode, we need to ensure that |
| 518 | // each loop has a canonical induction variable. |
| 519 | PHINode *IndVar = L->getCanonicalInductionVariable(); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 520 | if (!IndVar) { |
Tobias Grosser | 826b2af | 2013-03-21 16:14:50 +0000 | [diff] [blame] | 521 | INVALID(IndVar, |
| 522 | "No canonical IV at loop header: " << L->getHeader()->getName()); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 523 | return false; |
| 524 | } |
Tobias Grosser | 826b2af | 2013-03-21 16:14:50 +0000 | [diff] [blame] | 525 | } |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 526 | |
| 527 | // Is the loop count affine? |
| 528 | const SCEV *LoopCount = SE->getBackedgeTakenCount(L); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 529 | if (!isAffineExpr(&Context.CurRegion, LoopCount, *SE)) { |
Tobias Grosser | 58032cb | 2013-06-23 01:29:29 +0000 | [diff] [blame] | 530 | INVALID(LoopBound, "Non affine loop bound '" << *LoopCount << "' in loop: " |
| 531 | << L->getHeader()->getName()); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 532 | return false; |
| 533 | } |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 534 | |
| 535 | return true; |
| 536 | } |
| 537 | |
| 538 | Region *ScopDetection::expandRegion(Region &R) { |
Hongbin Zheng | ed986ab | 2012-04-07 15:14:28 +0000 | [diff] [blame] | 539 | // Initial no valid region was found (greater than R) |
| 540 | Region *LastValidRegion = NULL; |
Tobias Grosser | 1bb59b0 | 2012-12-29 23:47:38 +0000 | [diff] [blame] | 541 | Region *ExpandedRegion = R.getExpandedRegion(); |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 542 | |
| 543 | DEBUG(dbgs() << "\tExpanding " << R.getNameStr() << "\n"); |
| 544 | |
Hongbin Zheng | ed986ab | 2012-04-07 15:14:28 +0000 | [diff] [blame] | 545 | while (ExpandedRegion) { |
| 546 | DetectionContext Context(*ExpandedRegion, *AA, false /* verifying */); |
| 547 | DEBUG(dbgs() << "\t\tTrying " << ExpandedRegion->getNameStr() << "\n"); |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 548 | |
Hongbin Zheng | ed986ab | 2012-04-07 15:14:28 +0000 | [diff] [blame] | 549 | // Check the exit first (cheap) |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 550 | if (isValidExit(Context)) { |
Hongbin Zheng | ed986ab | 2012-04-07 15:14:28 +0000 | [diff] [blame] | 551 | // If the exit is valid check all blocks |
| 552 | // - if true, a valid region was found => store it + keep expanding |
| 553 | // - if false, .tbd. => stop (should this really end the loop?) |
| 554 | if (!allBlocksValid(Context)) |
| 555 | break; |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 556 | |
Hongbin Zheng | ed986ab | 2012-04-07 15:14:28 +0000 | [diff] [blame] | 557 | // Delete unnecessary regions (allocated by getExpandedRegion) |
| 558 | if (LastValidRegion) |
| 559 | delete LastValidRegion; |
| 560 | |
Tobias Grosser | d7e5864 | 2013-04-10 06:55:45 +0000 | [diff] [blame] | 561 | // Store this region, because it is the greatest valid (encountered so |
| 562 | // far). |
Hongbin Zheng | ed986ab | 2012-04-07 15:14:28 +0000 | [diff] [blame] | 563 | LastValidRegion = ExpandedRegion; |
| 564 | |
| 565 | // Create and test the next greater region (if any) |
| 566 | ExpandedRegion = ExpandedRegion->getExpandedRegion(); |
| 567 | |
| 568 | } else { |
| 569 | // Create and test the next greater region (if any) |
| 570 | Region *TmpRegion = ExpandedRegion->getExpandedRegion(); |
| 571 | |
| 572 | // Delete unnecessary regions (allocated by getExpandedRegion) |
| 573 | delete ExpandedRegion; |
| 574 | |
| 575 | ExpandedRegion = TmpRegion; |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 576 | } |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 577 | } |
| 578 | |
Tobias Grosser | 378a9f2 | 2013-11-16 19:34:11 +0000 | [diff] [blame] | 579 | DEBUG({ |
| 580 | if (LastValidRegion) |
| 581 | dbgs() << "\tto " << LastValidRegion->getNameStr() << "\n"; |
| 582 | else |
| 583 | dbgs() << "\tExpanding " << R.getNameStr() << " failed\n"; |
| 584 | }); |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 585 | |
Hongbin Zheng | ed986ab | 2012-04-07 15:14:28 +0000 | [diff] [blame] | 586 | return LastValidRegion; |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 587 | } |
Sebastian Pop | 2c9ec2e | 2013-06-03 16:35:37 +0000 | [diff] [blame] | 588 | static bool regionWithoutLoops(Region &R, LoopInfo *LI) { |
Tobias Grosser | 1d19190 | 2014-03-03 13:13:55 +0000 | [diff] [blame] | 589 | for (const auto &BB : R.blocks()) |
| 590 | if (R.contains(LI->getLoopFor(BB))) |
Sebastian Pop | 2c9ec2e | 2013-06-03 16:35:37 +0000 | [diff] [blame] | 591 | return false; |
| 592 | |
| 593 | return true; |
| 594 | } |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 595 | |
Tobias Grosser | 28a70c5 | 2014-01-29 19:05:30 +0000 | [diff] [blame] | 596 | // Remove all direct and indirect children of region R from the region set Regs, |
| 597 | // but do not recurse further if the first child has been found. |
| 598 | // |
| 599 | // Return the number of regions erased from Regs. |
| 600 | static unsigned eraseAllChildren(std::set<const Region *> &Regs, |
| 601 | const Region *R) { |
| 602 | unsigned Count = 0; |
Tobias Grosser | b5846f9 | 2014-03-02 17:05:27 +0000 | [diff] [blame] | 603 | for (const auto &SubRegion : *R) { |
Tobias Grosser | 00dc309 | 2014-03-02 12:02:46 +0000 | [diff] [blame] | 604 | if (Regs.find(SubRegion) != Regs.end()) { |
Tobias Grosser | 28a70c5 | 2014-01-29 19:05:30 +0000 | [diff] [blame] | 605 | ++Count; |
Tobias Grosser | 00dc309 | 2014-03-02 12:02:46 +0000 | [diff] [blame] | 606 | Regs.erase(SubRegion); |
Tobias Grosser | 28a70c5 | 2014-01-29 19:05:30 +0000 | [diff] [blame] | 607 | } else { |
Tobias Grosser | 00dc309 | 2014-03-02 12:02:46 +0000 | [diff] [blame] | 608 | Count += eraseAllChildren(Regs, SubRegion); |
Tobias Grosser | 28a70c5 | 2014-01-29 19:05:30 +0000 | [diff] [blame] | 609 | } |
| 610 | } |
| 611 | return Count; |
| 612 | } |
| 613 | |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 614 | void ScopDetection::findScops(Region &R) { |
Sebastian Pop | 2c9ec2e | 2013-06-03 16:35:37 +0000 | [diff] [blame] | 615 | |
| 616 | if (!DetectRegionsWithoutLoops && regionWithoutLoops(R, LI)) |
| 617 | return; |
| 618 | |
Tobias Grosser | 4eb7381 | 2011-11-10 12:45:15 +0000 | [diff] [blame] | 619 | LastFailure = ""; |
| 620 | |
Tobias Grosser | 9b1100b | 2014-02-18 18:49:46 +0000 | [diff] [blame] | 621 | if (isValidRegion(R)) { |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 622 | ++ValidRegion; |
| 623 | ValidRegions.insert(&R); |
| 624 | return; |
| 625 | } |
| 626 | |
Tobias Grosser | 4f129a6 | 2011-10-08 00:30:55 +0000 | [diff] [blame] | 627 | InvalidRegions[&R] = LastFailure; |
| 628 | |
Tobias Grosser | b5846f9 | 2014-03-02 17:05:27 +0000 | [diff] [blame] | 629 | for (const auto &SubRegion : R) |
Tobias Grosser | 00dc309 | 2014-03-02 12:02:46 +0000 | [diff] [blame] | 630 | findScops(*SubRegion); |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 631 | |
| 632 | // Try to expand regions. |
| 633 | // |
| 634 | // As the region tree normally only contains canonical regions, non canonical |
| 635 | // regions that form a Scop are not found. Therefore, those non canonical |
| 636 | // regions are checked by expanding the canonical ones. |
| 637 | |
Tobias Grosser | 0d1eee3 | 2013-02-05 11:56:05 +0000 | [diff] [blame] | 638 | std::vector<Region *> ToExpand; |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 639 | |
Tobias Grosser | b5846f9 | 2014-03-02 17:05:27 +0000 | [diff] [blame] | 640 | for (const auto &SubRegion : R) |
Tobias Grosser | 00dc309 | 2014-03-02 12:02:46 +0000 | [diff] [blame] | 641 | ToExpand.push_back(SubRegion); |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 642 | |
Tobias Grosser | b5846f9 | 2014-03-02 17:05:27 +0000 | [diff] [blame] | 643 | for (const auto &CurrentRegion : ToExpand) { |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 644 | // Skip invalid regions. Regions may become invalid, if they are element of |
| 645 | // an already expanded region. |
| 646 | if (ValidRegions.find(CurrentRegion) == ValidRegions.end()) |
| 647 | continue; |
| 648 | |
| 649 | Region *ExpandedR = expandRegion(*CurrentRegion); |
| 650 | |
| 651 | if (!ExpandedR) |
| 652 | continue; |
| 653 | |
| 654 | R.addSubRegion(ExpandedR, true); |
| 655 | ValidRegions.insert(ExpandedR); |
| 656 | ValidRegions.erase(CurrentRegion); |
| 657 | |
Tobias Grosser | 28a70c5 | 2014-01-29 19:05:30 +0000 | [diff] [blame] | 658 | // Erase all (direct and indirect) children of ExpandedR from the valid |
| 659 | // regions and update the number of valid regions. |
| 660 | ValidRegion -= eraseAllChildren(ValidRegions, ExpandedR); |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 661 | } |
| 662 | } |
| 663 | |
| 664 | bool ScopDetection::allBlocksValid(DetectionContext &Context) const { |
| 665 | Region &R = Context.CurRegion; |
| 666 | |
Tobias Grosser | 1d19190 | 2014-03-03 13:13:55 +0000 | [diff] [blame] | 667 | for (const auto &BB : R.blocks()) { |
| 668 | Loop *L = LI->getLoopFor(BB); |
| 669 | if (L && L->getHeader() == BB && !isValidLoop(L, Context)) |
Sebastian Pop | b88ea5e | 2013-06-11 22:20:32 +0000 | [diff] [blame] | 670 | return false; |
| 671 | } |
| 672 | |
Tobias Grosser | 1d19190 | 2014-03-03 13:13:55 +0000 | [diff] [blame] | 673 | for (const auto &BB : R.blocks()) |
| 674 | if (!isValidCFG(*BB, Context)) |
Sebastian Pop | 9e3d2dd | 2013-06-11 22:20:27 +0000 | [diff] [blame] | 675 | return false; |
| 676 | |
Tobias Grosser | 1d19190 | 2014-03-03 13:13:55 +0000 | [diff] [blame] | 677 | for (const auto &BB : R.blocks()) |
| 678 | for (BasicBlock::iterator I = BB->begin(), E = --BB->end(); I != E; ++I) |
Sebastian Pop | 8ca899c | 2013-06-14 20:20:43 +0000 | [diff] [blame] | 679 | if (!isValidInstruction(*I, Context)) |
| 680 | return false; |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 681 | |
| 682 | return true; |
| 683 | } |
| 684 | |
| 685 | bool ScopDetection::isValidExit(DetectionContext &Context) const { |
| 686 | Region &R = Context.CurRegion; |
| 687 | |
| 688 | // PHI nodes are not allowed in the exit basic block. |
| 689 | if (BasicBlock *Exit = R.getExit()) { |
| 690 | BasicBlock::iterator I = Exit->begin(); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 691 | if (I != Exit->end() && isa<PHINode>(*I)) { |
Tobias Grosser | c4a0bd1 | 2011-10-08 00:30:48 +0000 | [diff] [blame] | 692 | INVALID(Other, "PHI node in exit BB"); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 693 | return false; |
| 694 | } |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 695 | } |
| 696 | |
| 697 | return true; |
| 698 | } |
| 699 | |
Tobias Grosser | 9b1100b | 2014-02-18 18:49:46 +0000 | [diff] [blame] | 700 | bool ScopDetection::isValidRegion(Region &R) const { |
| 701 | DetectionContext Context(R, *AA, false /*verifying*/); |
| 702 | return isValidRegion(Context); |
| 703 | } |
| 704 | |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 705 | bool ScopDetection::isValidRegion(DetectionContext &Context) const { |
| 706 | Region &R = Context.CurRegion; |
| 707 | |
| 708 | DEBUG(dbgs() << "Checking region: " << R.getNameStr() << "\n\t"); |
| 709 | |
Tobias Grosser | aeabcf2 | 2013-04-02 06:41:48 +0000 | [diff] [blame] | 710 | if (R.isTopLevelRegion()) { |
Tobias Grosser | 4d96c8d | 2013-03-23 01:05:07 +0000 | [diff] [blame] | 711 | DEBUG(dbgs() << "Top level region is invalid"; dbgs() << "\n"); |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 712 | return false; |
| 713 | } |
| 714 | |
Tobias Grosser | 4449e52 | 2014-01-27 14:24:53 +0000 | [diff] [blame] | 715 | if (!R.getEntry()->getName().count(OnlyRegion)) { |
| 716 | DEBUG({ |
| 717 | dbgs() << "Region entry does not match -polly-region-only"; |
| 718 | dbgs() << "\n"; |
| 719 | }); |
| 720 | return false; |
| 721 | } |
| 722 | |
Tobias Grosser | e602a07 | 2013-05-07 07:30:56 +0000 | [diff] [blame] | 723 | if (!R.getEnteringBlock()) { |
Sebastian Pop | 9d63234 | 2013-06-11 22:20:40 +0000 | [diff] [blame] | 724 | BasicBlock *entry = R.getEntry(); |
| 725 | Loop *L = LI->getLoopFor(entry); |
| 726 | |
| 727 | if (L) { |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 728 | if (!L->isLoopSimplifyForm()) { |
Sebastian Pop | 9d63234 | 2013-06-11 22:20:40 +0000 | [diff] [blame] | 729 | INVALID(SimpleLoop, "Loop not in simplify form is invalid!"); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 730 | return false; |
| 731 | } |
Sebastian Pop | 9d63234 | 2013-06-11 22:20:40 +0000 | [diff] [blame] | 732 | |
| 733 | for (pred_iterator PI = pred_begin(entry), PE = pred_end(entry); PI != PE; |
| 734 | ++PI) { |
| 735 | // Region entering edges come from the same loop but outside the region |
| 736 | // are not allowed. |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 737 | if (L->contains(*PI) && !R.contains(*PI)) { |
Sebastian Pop | 9d63234 | 2013-06-11 22:20:40 +0000 | [diff] [blame] | 738 | INVALID(IndEdge, "Region has invalid entering edges!"); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 739 | return false; |
| 740 | } |
Sebastian Pop | 9d63234 | 2013-06-11 22:20:40 +0000 | [diff] [blame] | 741 | } |
| 742 | } |
Tobias Grosser | 8edce4e | 2013-04-16 08:04:42 +0000 | [diff] [blame] | 743 | } |
| 744 | |
Tobias Grosser | d654c25 | 2012-04-10 18:12:19 +0000 | [diff] [blame] | 745 | // SCoP cannot contain the entry block of the function, because we need |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 746 | // to insert alloca instruction there when translate scalar to array. |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 747 | if (R.getEntry() == &(R.getEntry()->getParent()->getEntryBlock())) { |
Tobias Grosser | c4a0bd1 | 2011-10-08 00:30:48 +0000 | [diff] [blame] | 748 | INVALID(Other, "Region containing entry block of function is invalid!"); |
Tobias Grosser | 5b1a7f2 | 2013-07-22 03:50:33 +0000 | [diff] [blame] | 749 | return false; |
| 750 | } |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 751 | |
Hongbin Zheng | 94868e6 | 2012-04-07 12:29:17 +0000 | [diff] [blame] | 752 | if (!isValidExit(Context)) |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 753 | return false; |
| 754 | |
Hongbin Zheng | 94868e6 | 2012-04-07 12:29:17 +0000 | [diff] [blame] | 755 | if (!allBlocksValid(Context)) |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 756 | return false; |
| 757 | |
| 758 | DEBUG(dbgs() << "OK\n"); |
| 759 | return true; |
| 760 | } |
| 761 | |
| 762 | bool ScopDetection::isValidFunction(llvm::Function &F) { |
Hongbin Zheng | 94c5df1 | 2011-05-06 02:38:20 +0000 | [diff] [blame] | 763 | return !InvalidFunctions.count(&F); |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 764 | } |
| 765 | |
Tobias Grosser | 531891e | 2012-11-01 16:45:20 +0000 | [diff] [blame] | 766 | void ScopDetection::getDebugLocation(const Region *R, unsigned &LineBegin, |
| 767 | unsigned &LineEnd, std::string &FileName) { |
| 768 | LineBegin = -1; |
| 769 | LineEnd = 0; |
| 770 | |
Tobias Grosser | 1d19190 | 2014-03-03 13:13:55 +0000 | [diff] [blame] | 771 | for (const auto &BB : R->blocks()) |
| 772 | for (BasicBlock::iterator BI = BB->begin(), BE = BB->end(); BI != BE; |
Tobias Grosser | 531891e | 2012-11-01 16:45:20 +0000 | [diff] [blame] | 773 | ++BI) { |
| 774 | DebugLoc DL = BI->getDebugLoc(); |
| 775 | if (DL.isUnknown()) |
| 776 | continue; |
| 777 | |
| 778 | DIScope Scope(DL.getScope(BI->getContext())); |
| 779 | |
| 780 | if (FileName.empty()) |
| 781 | FileName = Scope.getFilename(); |
| 782 | |
| 783 | unsigned NewLine = DL.getLine(); |
| 784 | |
| 785 | LineBegin = std::min(LineBegin, NewLine); |
| 786 | LineEnd = std::max(LineEnd, NewLine); |
Tobias Grosser | 1bb59b0 | 2012-12-29 23:47:38 +0000 | [diff] [blame] | 787 | } |
Tobias Grosser | 531891e | 2012-11-01 16:45:20 +0000 | [diff] [blame] | 788 | } |
| 789 | |
Tobias Grosser | b2863ca | 2013-03-04 19:49:51 +0000 | [diff] [blame] | 790 | void ScopDetection::printLocations(llvm::Function &F) { |
Tobias Grosser | b5846f9 | 2014-03-02 17:05:27 +0000 | [diff] [blame] | 791 | for (const auto &R : *this) { |
Tobias Grosser | 531891e | 2012-11-01 16:45:20 +0000 | [diff] [blame] | 792 | unsigned LineEntry, LineExit; |
| 793 | std::string FileName; |
| 794 | |
Tobias Grosser | 00dc309 | 2014-03-02 12:02:46 +0000 | [diff] [blame] | 795 | getDebugLocation(R, LineEntry, LineExit, FileName); |
Tobias Grosser | 8519f89 | 2013-12-18 10:49:53 +0000 | [diff] [blame] | 796 | DiagnosticScopFound Diagnostic(F, FileName, LineEntry, LineExit); |
| 797 | F.getContext().diagnose(Diagnostic); |
Tobias Grosser | 531891e | 2012-11-01 16:45:20 +0000 | [diff] [blame] | 798 | } |
| 799 | } |
| 800 | |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 801 | bool ScopDetection::runOnFunction(llvm::Function &F) { |
Sebastian Pop | 8fe6d11 | 2013-05-30 17:47:32 +0000 | [diff] [blame] | 802 | LI = &getAnalysis<LoopInfo>(); |
Tobias Grosser | 9a26f29 | 2014-01-02 22:28:53 +0000 | [diff] [blame] | 803 | RI = &getAnalysis<RegionInfo>(); |
Sebastian Pop | 8fe6d11 | 2013-05-30 17:47:32 +0000 | [diff] [blame] | 804 | if (!DetectScopsWithoutLoops && LI->empty()) |
| 805 | return false; |
| 806 | |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 807 | AA = &getAnalysis<AliasAnalysis>(); |
| 808 | SE = &getAnalysis<ScalarEvolution>(); |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 809 | Region *TopRegion = RI->getTopLevelRegion(); |
| 810 | |
Tobias Grosser | 2ff8723 | 2011-10-23 11:17:06 +0000 | [diff] [blame] | 811 | releaseMemory(); |
| 812 | |
Tobias Grosser | 29ee0b1 | 2011-11-17 14:52:36 +0000 | [diff] [blame] | 813 | if (OnlyFunction != "" && F.getName() != OnlyFunction) |
Tobias Grosser | 2ff8723 | 2011-10-23 11:17:06 +0000 | [diff] [blame] | 814 | return false; |
| 815 | |
Tobias Grosser | 1bb59b0 | 2012-12-29 23:47:38 +0000 | [diff] [blame] | 816 | if (!isValidFunction(F)) |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 817 | return false; |
| 818 | |
| 819 | findScops(*TopRegion); |
Tobias Grosser | 531891e | 2012-11-01 16:45:20 +0000 | [diff] [blame] | 820 | |
| 821 | if (ReportLevel >= 1) |
Tobias Grosser | b2863ca | 2013-03-04 19:49:51 +0000 | [diff] [blame] | 822 | printLocations(F); |
Tobias Grosser | 531891e | 2012-11-01 16:45:20 +0000 | [diff] [blame] | 823 | |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 824 | return false; |
| 825 | } |
| 826 | |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 827 | void polly::ScopDetection::verifyRegion(const Region &R) const { |
| 828 | assert(isMaxRegionInScop(R) && "Expect R is a valid region."); |
Tobias Grosser | 0d1eee3 | 2013-02-05 11:56:05 +0000 | [diff] [blame] | 829 | DetectionContext Context(const_cast<Region &>(R), *AA, true /*verifying*/); |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 830 | isValidRegion(Context); |
| 831 | } |
| 832 | |
| 833 | void polly::ScopDetection::verifyAnalysis() const { |
Tobias Grosser | a168993 | 2014-02-18 18:49:49 +0000 | [diff] [blame] | 834 | if (!VerifyScops) |
| 835 | return; |
| 836 | |
Tobias Grosser | b5846f9 | 2014-03-02 17:05:27 +0000 | [diff] [blame] | 837 | for (const auto &R : ValidRegions) |
Tobias Grosser | 00dc309 | 2014-03-02 12:02:46 +0000 | [diff] [blame] | 838 | verifyRegion(*R); |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 839 | } |
| 840 | |
| 841 | void ScopDetection::getAnalysisUsage(AnalysisUsage &AU) const { |
Tobias Grosser | 42aff30 | 2014-01-13 22:29:56 +0000 | [diff] [blame] | 842 | AU.addRequired<DominatorTreeWrapperPass>(); |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 843 | AU.addRequired<PostDominatorTree>(); |
| 844 | AU.addRequired<LoopInfo>(); |
| 845 | AU.addRequired<ScalarEvolution>(); |
| 846 | // We also need AA and RegionInfo when we are verifying analysis. |
| 847 | AU.addRequiredTransitive<AliasAnalysis>(); |
| 848 | AU.addRequiredTransitive<RegionInfo>(); |
| 849 | AU.setPreservesAll(); |
| 850 | } |
| 851 | |
Tobias Grosser | 4d96c8d | 2013-03-23 01:05:07 +0000 | [diff] [blame] | 852 | void ScopDetection::print(raw_ostream &OS, const Module *) const { |
Tobias Grosser | b5846f9 | 2014-03-02 17:05:27 +0000 | [diff] [blame] | 853 | for (const auto &R : ValidRegions) |
Tobias Grosser | 00dc309 | 2014-03-02 12:02:46 +0000 | [diff] [blame] | 854 | OS << "Valid Region for Scop: " << R->getNameStr() << '\n'; |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 855 | |
| 856 | OS << "\n"; |
| 857 | } |
| 858 | |
| 859 | void ScopDetection::releaseMemory() { |
| 860 | ValidRegions.clear(); |
Tobias Grosser | 4f129a6 | 2011-10-08 00:30:55 +0000 | [diff] [blame] | 861 | InvalidRegions.clear(); |
Hongbin Zheng | 94c5df1 | 2011-05-06 02:38:20 +0000 | [diff] [blame] | 862 | // Do not clear the invalid function set. |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 863 | } |
| 864 | |
| 865 | char ScopDetection::ID = 0; |
| 866 | |
Tobias Grosser | 4d96c8d | 2013-03-23 01:05:07 +0000 | [diff] [blame] | 867 | Pass *polly::createScopDetectionPass() { return new ScopDetection(); } |
| 868 | |
Tobias Grosser | 73600b8 | 2011-10-08 00:30:40 +0000 | [diff] [blame] | 869 | INITIALIZE_PASS_BEGIN(ScopDetection, "polly-detect", |
| 870 | "Polly - Detect static control parts (SCoPs)", false, |
Tobias Grosser | 4d96c8d | 2013-03-23 01:05:07 +0000 | [diff] [blame] | 871 | false); |
| 872 | INITIALIZE_AG_DEPENDENCY(AliasAnalysis); |
Tobias Grosser | 42aff30 | 2014-01-13 22:29:56 +0000 | [diff] [blame] | 873 | INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass); |
Tobias Grosser | 4d96c8d | 2013-03-23 01:05:07 +0000 | [diff] [blame] | 874 | INITIALIZE_PASS_DEPENDENCY(LoopInfo); |
| 875 | INITIALIZE_PASS_DEPENDENCY(PostDominatorTree); |
| 876 | INITIALIZE_PASS_DEPENDENCY(RegionInfo); |
| 877 | INITIALIZE_PASS_DEPENDENCY(ScalarEvolution); |
Tobias Grosser | 73600b8 | 2011-10-08 00:30:40 +0000 | [diff] [blame] | 878 | INITIALIZE_PASS_END(ScopDetection, "polly-detect", |
| 879 | "Polly - Detect static control parts (SCoPs)", false, false) |