diff options
Diffstat (limited to 'polly/lib/Analysis/ScopDetection.cpp')
| -rw-r--r-- | polly/lib/Analysis/ScopDetection.cpp | 66 |
1 files changed, 37 insertions, 29 deletions
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp index 548b8747c20..024f87e6aa6 100644 --- a/polly/lib/Analysis/ScopDetection.cpp +++ b/polly/lib/Analysis/ScopDetection.cpp @@ -132,6 +132,12 @@ static cl::opt<bool> cl::Hidden, cl::init(false), cl::ZeroOrMore, cl::cat(PollyCategory)); +static cl::opt<bool> + AllowModrefCall("polly-allow-modref-calls", + cl::desc("Allow functions with known modref behavior"), + cl::Hidden, cl::init(false), cl::ZeroOrMore, + cl::cat(PollyCategory)); + static cl::opt<bool> AllowNonAffineSubRegions( "polly-allow-nonaffine-branches", cl::desc("Allow non affine conditions for branches"), cl::Hidden, @@ -470,39 +476,41 @@ bool ScopDetection::isValidCallInst(CallInst &CI, if (CalledFunction == 0) return false; - switch (AA->getModRefBehavior(CalledFunction)) { - case llvm::FMRB_UnknownModRefBehavior: - return false; - case llvm::FMRB_DoesNotAccessMemory: - case llvm::FMRB_OnlyReadsMemory: - // Implicitly disable delinearization since we have an unknown - // accesses with an unknown access function. - Context.HasUnknownAccess = true; - Context.AST.add(&CI); - return true; - case llvm::FMRB_OnlyReadsArgumentPointees: - case llvm::FMRB_OnlyAccessesArgumentPointees: - for (const auto &Arg : CI.arg_operands()) { - if (!Arg->getType()->isPointerTy()) - continue; - - // Bail if a pointer argument has a base address not known to - // ScalarEvolution. Note that a zero pointer is acceptable. - auto *ArgSCEV = SE->getSCEVAtScope(Arg, LI->getLoopFor(CI.getParent())); - if (ArgSCEV->isZero()) - continue; - - auto *BP = dyn_cast<SCEVUnknown>(SE->getPointerBase(ArgSCEV)); - if (!BP) - return false; - + if (AllowModrefCall) { + switch (AA->getModRefBehavior(CalledFunction)) { + case llvm::FMRB_UnknownModRefBehavior: + return false; + case llvm::FMRB_DoesNotAccessMemory: + case llvm::FMRB_OnlyReadsMemory: // Implicitly disable delinearization since we have an unknown // accesses with an unknown access function. Context.HasUnknownAccess = true; - } + Context.AST.add(&CI); + return true; + case llvm::FMRB_OnlyReadsArgumentPointees: + case llvm::FMRB_OnlyAccessesArgumentPointees: + for (const auto &Arg : CI.arg_operands()) { + if (!Arg->getType()->isPointerTy()) + continue; + + // Bail if a pointer argument has a base address not known to + // ScalarEvolution. Note that a zero pointer is acceptable. + auto *ArgSCEV = SE->getSCEVAtScope(Arg, LI->getLoopFor(CI.getParent())); + if (ArgSCEV->isZero()) + continue; + + auto *BP = dyn_cast<SCEVUnknown>(SE->getPointerBase(ArgSCEV)); + if (!BP) + return false; - Context.AST.add(&CI); - return true; + // Implicitly disable delinearization since we have an unknown + // accesses with an unknown access function. + Context.HasUnknownAccess = true; + } + + Context.AST.add(&CI); + return true; + } } return false; |

