diff options
| author | Johannes Doerfert <doerfert@cs.uni-saarland.de> | 2016-02-25 14:08:48 +0000 |
|---|---|---|
| committer | Johannes Doerfert <doerfert@cs.uni-saarland.de> | 2016-02-25 14:08:48 +0000 |
| commit | a79209804751d13f591de68ec7052a8297fc5421 (patch) | |
| tree | a675a5b421b86ec88fe50a6907884cd42056e7b5 /polly/lib/Analysis/ScopDetection.cpp | |
| parent | f33c125dd253981c6ff2bb9505e1d98682c3e846 (diff) | |
| download | bcm5719-llvm-a79209804751d13f591de68ec7052a8297fc5421.tar.gz bcm5719-llvm-a79209804751d13f591de68ec7052a8297fc5421.zip | |
Support calls with known ModRef function behaviour
Check the ModRefBehaviour of functions in order to decide whether or
not a call instruction might be acceptable.
Differential Revision: http://reviews.llvm.org/D5227
llvm-svn: 261866
Diffstat (limited to 'polly/lib/Analysis/ScopDetection.cpp')
| -rw-r--r-- | polly/lib/Analysis/ScopDetection.cpp | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp index 6d16b9fc8ce..a8833f193e9 100644 --- a/polly/lib/Analysis/ScopDetection.cpp +++ b/polly/lib/Analysis/ScopDetection.cpp @@ -451,7 +451,8 @@ bool ScopDetection::isValidCallInst(CallInst &CI, return true; if (auto *II = dyn_cast<IntrinsicInst>(&CI)) - return isValidIntrinsicInst(*II, Context); + if (isValidIntrinsicInst(*II, Context)) + return true; Function *CalledFunction = CI.getCalledFunction(); @@ -459,6 +460,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; + + // 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; } @@ -784,6 +820,11 @@ bool ScopDetection::hasBaseAffineAccesses( } bool ScopDetection::hasAffineMemoryAccesses(DetectionContext &Context) const { + // TODO: If we have an unknown access and other non-affine accesses we do + // not try to delinearize them for now. + if (Context.HasUnknownAccess && !Context.NonAffineAccesses.empty()) + return AllowNonAffine; + for (const SCEVUnknown *BasePointer : Context.NonAffineAccesses) if (!hasBaseAffineAccesses(Context, BasePointer)) { if (KeepGoing) |

