We do not support alias checks for base pointers defined inside the SCoP
The run-time alias check places code that involves the base pointer at the
beginning of the SCoP. This breaks if the base pointer is defined inside the
SCoP. Hence, we can only create a run-time alias check if we are sure the base
pointer is not an instruction defined inside the scop. If it is we refuse to
handle the SCoP.
This commit should unbreak most of our current LNT failures.
Differential Revision: http://reviews.llvm.org/D5483
llvm-svn: 218412
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index 11edd13..e8226c8 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -532,7 +532,7 @@
if (IntToPtrInst *Inst = dyn_cast<IntToPtrInst>(BaseValue))
return invalid<ReportIntToPtr>(Context, /*Assert=*/true, Inst);
- if (PollyUseRuntimeAliasChecks || IgnoreAliasing)
+ if (IgnoreAliasing)
return true;
// Check if the base pointer of the memory access does alias with
@@ -548,8 +548,26 @@
// alias, if -basicaa is not available. They actually do not, but as we can
// not proof this without -basicaa we would fail. We disable this check to
// not cause irrelevant verification failures.
- if (!AS.isMustAlias())
+ if (!AS.isMustAlias()) {
+ if (PollyUseRuntimeAliasChecks) {
+ bool CanBuildRunTimeCheck = true;
+ // The run-time alias check places code that involves the base pointer at
+ // the beginning of the SCoP. This breaks if the base pointer is defined
+ // inside the scop. Hence, we can only create a run-time check if we are
+ // sure the base pointer is not an instruction defined inside the scop.
+ for (const auto &Ptr : AS) {
+ Instruction *Inst = dyn_cast<Instruction>(Ptr.getValue());
+ if (Inst && Context.CurRegion.contains(Inst)) {
+ CanBuildRunTimeCheck = false;
+ break;
+ }
+ }
+
+ if (CanBuildRunTimeCheck)
+ return true;
+ }
return invalid<ReportAlias>(Context, /*Assert=*/false, &Inst, AS);
+ }
return true;
}