aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/DependenceAnalysis.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-08-20 20:50:12 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-08-20 20:50:12 +0000
commite6d1592492a3a379186bfb02bd0f4eda0669c0d5 (patch)
tree599ab169a01f1c86eda9adc774edaedde2f2db5b /lib/Analysis/DependenceAnalysis.cpp
parent1a56a5ead7a2e84bee8240f5f6b033b5f1707154 (diff)
Diffstat (limited to 'lib/Analysis/DependenceAnalysis.cpp')
-rw-r--r--lib/Analysis/DependenceAnalysis.cpp51
1 files changed, 36 insertions, 15 deletions
diff --git a/lib/Analysis/DependenceAnalysis.cpp b/lib/Analysis/DependenceAnalysis.cpp
index 3f4dfa52e1da..75f269e84f9d 100644
--- a/lib/Analysis/DependenceAnalysis.cpp
+++ b/lib/Analysis/DependenceAnalysis.cpp
@@ -1,9 +1,8 @@
//===-- DependenceAnalysis.cpp - DA Implementation --------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -110,6 +109,14 @@ STATISTIC(BanerjeeSuccesses, "Banerjee successes");
static cl::opt<bool>
Delinearize("da-delinearize", cl::init(true), cl::Hidden, cl::ZeroOrMore,
cl::desc("Try to delinearize array references."));
+static cl::opt<bool> DisableDelinearizationChecks(
+ "da-disable-delinearization-checks", cl::init(false), cl::Hidden,
+ cl::ZeroOrMore,
+ cl::desc(
+ "Disable checks that try to statically verify validity of "
+ "delinearized subscripts. Enabling this option may result in incorrect "
+ "dependence vectors for languages that allow the subscript of one "
+ "dimension to underflow or overflow into another dimension."));
//===----------------------------------------------------------------------===//
// basics
@@ -3317,19 +3324,20 @@ bool DependenceInfo::tryDelinearize(Instruction *Src, Instruction *Dst,
// and dst.
// FIXME: It may be better to record these sizes and add them as constraints
// to the dependency checks.
- for (int i = 1; i < size; ++i) {
- if (!isKnownNonNegative(SrcSubscripts[i], SrcPtr))
- return false;
+ if (!DisableDelinearizationChecks)
+ for (int i = 1; i < size; ++i) {
+ if (!isKnownNonNegative(SrcSubscripts[i], SrcPtr))
+ return false;
- if (!isKnownLessThan(SrcSubscripts[i], Sizes[i - 1]))
- return false;
+ if (!isKnownLessThan(SrcSubscripts[i], Sizes[i - 1]))
+ return false;
- if (!isKnownNonNegative(DstSubscripts[i], DstPtr))
- return false;
+ if (!isKnownNonNegative(DstSubscripts[i], DstPtr))
+ return false;
- if (!isKnownLessThan(DstSubscripts[i], Sizes[i - 1]))
- return false;
- }
+ if (!isKnownLessThan(DstSubscripts[i], Sizes[i - 1]))
+ return false;
+ }
LLVM_DEBUG({
dbgs() << "\nSrcSubscripts: ";
@@ -3369,6 +3377,19 @@ static void dumpSmallBitVector(SmallBitVector &BV) {
}
#endif
+bool DependenceInfo::invalidate(Function &F, const PreservedAnalyses &PA,
+ FunctionAnalysisManager::Invalidator &Inv) {
+ // Check if the analysis itself has been invalidated.
+ auto PAC = PA.getChecker<DependenceAnalysis>();
+ if (!PAC.preserved() && !PAC.preservedSet<AllAnalysesOn<Function>>())
+ return true;
+
+ // Check transitive dependencies.
+ return Inv.invalidate<AAManager>(F, PA) ||
+ Inv.invalidate<ScalarEvolutionAnalysis>(F, PA) ||
+ Inv.invalidate<LoopAnalysis>(F, PA);
+}
+
// depends -
// Returns NULL if there is no dependence.
// Otherwise, return a Dependence with as many details as possible.
@@ -3510,7 +3531,7 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst,
// to either Separable or Coupled).
//
// Next, we consider 1 and 2. The intersection of the GroupLoops is empty.
- // Next, 1 and 3. The intersectionof their GroupLoops = {2}, not empty,
+ // Next, 1 and 3. The intersection of their GroupLoops = {2}, not empty,
// so Pair[3].Group = {0, 1, 3} and Done = false.
//
// Next, we compare 2 against 3. The intersection of the GroupLoops is empty.