From 284b0324e217e38c3992536545f3e72f425a1daa Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Thu, 7 Jul 2016 01:01:53 +0000 Subject: [PATCH] [PM] Avoid getResult on a higher level in LoopAccessAnalysis Note that require and require aren't needed because they come in implicitly via the loop pass manager. llvm-svn: 274712 --- llvm/lib/Analysis/LoopAccessAnalysis.cpp | 22 +++++++++++++------ .../backward-dep-different-types.ll | 2 +- .../forward-loop-carried.ll | 2 +- .../forward-loop-independent.ll | 2 +- .../independent-interleaved.ll | 2 +- .../memcheck-for-loop-invariant.ll | 2 +- .../multiple-strides-rt-memory-checks.ll | 2 +- .../non-wrapping-pointer.ll | 2 +- .../Analysis/LoopAccessAnalysis/nullptr.ll | 2 +- .../LoopAccessAnalysis/number-of-memchecks.ll | 2 +- .../pointer-with-unknown-bounds.ll | 2 +- .../resort-to-memchecks-only.ll | 2 +- .../reverse-memcheck-bounds.ll | 2 +- .../LoopAccessAnalysis/safe-no-checks.ll | 2 +- .../safe-with-dep-distance.ll | 2 +- .../store-to-invariant-check2.ll | 2 +- .../store-to-invariant-check3.ll | 2 +- .../stride-access-dependence.ll | 2 +- .../underlying-objects-1.ll | 2 +- .../underlying-objects-2.ll | 2 +- .../unsafe-and-rt-checks.ll | 2 +- .../wrapping-pointer-versioning.ll | 2 +- 22 files changed, 36 insertions(+), 28 deletions(-) diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp index 92d642fd11dd..ead137b94355 100644 --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -2027,15 +2027,23 @@ INITIALIZE_PASS_END(LoopAccessAnalysis, LAA_NAME, laa_name, false, true) char LoopAccessInfoAnalysis::PassID; LoopAccessInfo LoopAccessInfoAnalysis::run(Loop &L, AnalysisManager &AM) { - // FIXME: ugly const cast - AnalysisManager &FAM = const_cast( - AM.getResult(L).getManager()); + const AnalysisManager &FAM = + AM.getResult(L).getManager(); Function &F = *L.getHeader()->getParent(); - auto *SE = &FAM.getResult(F); + auto *SE = FAM.getCachedResult(F); auto *TLI = FAM.getCachedResult(F); - auto *AA = &FAM.getResult(F); - auto *DT = &FAM.getResult(F); - auto *LI = &FAM.getResult(F); + auto *AA = FAM.getCachedResult(F); + auto *DT = FAM.getCachedResult(F); + auto *LI = FAM.getCachedResult(F); + if (!SE) + report_fatal_error( + "ScalarEvolution must have been cached at a higher level"); + if (!AA) + report_fatal_error("AliasAnalysis must have been cached at a higher level"); + if (!DT) + report_fatal_error("DominatorTree must have been cached at a higher level"); + if (!LI) + report_fatal_error("LoopInfo must have been cached at a higher level"); const DataLayout &DL = F.getParent()->getDataLayout(); return LoopAccessInfo(&L, SE, DL, TLI, AA, DT, LI); } diff --git a/llvm/test/Analysis/LoopAccessAnalysis/backward-dep-different-types.ll b/llvm/test/Analysis/LoopAccessAnalysis/backward-dep-different-types.ll index 96335caa6373..d8040a31a8dc 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/backward-dep-different-types.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/backward-dep-different-types.ll @@ -1,5 +1,5 @@ ; RUN: opt -loop-accesses -analyze < %s | FileCheck %s -; RUN: opt -passes='loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s +; RUN: opt -passes='require,require,loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s ; In this loop just because we access A through different types (int, float) ; we still have a dependence cycle: diff --git a/llvm/test/Analysis/LoopAccessAnalysis/forward-loop-carried.ll b/llvm/test/Analysis/LoopAccessAnalysis/forward-loop-carried.ll index 6e3110091f2e..7d3ac09dbb9c 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/forward-loop-carried.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/forward-loop-carried.ll @@ -1,5 +1,5 @@ ; RUN: opt -loop-accesses -analyze < %s | FileCheck %s -; RUN: opt -passes='loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s +; RUN: opt -passes='require,require,loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s ; for (unsigned i = 0; i < 100; i++) { ; A[i+8] = B[i] + 2; diff --git a/llvm/test/Analysis/LoopAccessAnalysis/forward-loop-independent.ll b/llvm/test/Analysis/LoopAccessAnalysis/forward-loop-independent.ll index a74627e79513..41e2a2904fb2 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/forward-loop-independent.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/forward-loop-independent.ll @@ -1,5 +1,5 @@ ; RUN: opt -loop-accesses -analyze < %s | FileCheck %s -; RUN: opt -passes='loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s +; RUN: opt -passes='require,require,loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s ; Check that loop-indepedent forward dependences are discovered properly. ; diff --git a/llvm/test/Analysis/LoopAccessAnalysis/independent-interleaved.ll b/llvm/test/Analysis/LoopAccessAnalysis/independent-interleaved.ll index e09429afe5d5..fe56ea9ab593 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/independent-interleaved.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/independent-interleaved.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -store-to-load-forwarding-conflict-detection=false -loop-accesses -analyze | FileCheck %s -; RUN: opt -passes='loop(print-access-info)' -store-to-load-forwarding-conflict-detection=false -disable-output < %s 2>&1 | FileCheck %s +; RUN: opt -passes='require,require,loop(print-access-info)' -store-to-load-forwarding-conflict-detection=false -disable-output < %s 2>&1 | FileCheck %s ; This test checks that we prove the strided accesses to be independent before ; concluding that there is a forward dependence. diff --git a/llvm/test/Analysis/LoopAccessAnalysis/memcheck-for-loop-invariant.ll b/llvm/test/Analysis/LoopAccessAnalysis/memcheck-for-loop-invariant.ll index a74b23a41671..f06bb00ec64a 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/memcheck-for-loop-invariant.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/memcheck-for-loop-invariant.ll @@ -1,5 +1,5 @@ ; RUN: opt -loop-accesses -analyze < %s | FileCheck %s -; RUN: opt -passes='loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s +; RUN: opt -passes='require,require,loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s ; Handle memchecks involving loop-invariant addresses: ; diff --git a/llvm/test/Analysis/LoopAccessAnalysis/multiple-strides-rt-memory-checks.ll b/llvm/test/Analysis/LoopAccessAnalysis/multiple-strides-rt-memory-checks.ll index c7bdf169019a..87a6c18ab303 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/multiple-strides-rt-memory-checks.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/multiple-strides-rt-memory-checks.ll @@ -1,5 +1,5 @@ ; RUN: opt -loop-accesses -analyze -S < %s | FileCheck %s -; RUN: opt -passes='loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s +; RUN: opt -passes='require,require,loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s ; This is the test case from PR26314. ; When we were retrying dependence checking with memchecks only, diff --git a/llvm/test/Analysis/LoopAccessAnalysis/non-wrapping-pointer.ll b/llvm/test/Analysis/LoopAccessAnalysis/non-wrapping-pointer.ll index e995cb63fc0f..94080f05bde2 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/non-wrapping-pointer.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/non-wrapping-pointer.ll @@ -1,5 +1,5 @@ ; RUN: opt -basicaa -loop-accesses -analyze < %s | FileCheck %s -; RUN: opt -passes='require,loop(print-access-info)' -aa-pipeline='basic-aa' -disable-output < %s 2>&1 | FileCheck %s +; RUN: opt -passes='require,require,require,loop(print-access-info)' -aa-pipeline='basic-aa' -disable-output < %s 2>&1 | FileCheck %s ; For this loop: ; for (int i = 0; i < n; i++) diff --git a/llvm/test/Analysis/LoopAccessAnalysis/nullptr.ll b/llvm/test/Analysis/LoopAccessAnalysis/nullptr.ll index 83466ce889bd..476cf3208c84 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/nullptr.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/nullptr.ll @@ -1,5 +1,5 @@ ; RUN: opt -loop-accesses -analyze %s | FileCheck %s -; RUN: opt -passes='loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s +; RUN: opt -passes='require,require,loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s ; Test that the loop accesses are proven safe in this case. ; The analyzer uses to be confused by the "diamond" because GetUnderlyingObjects diff --git a/llvm/test/Analysis/LoopAccessAnalysis/number-of-memchecks.ll b/llvm/test/Analysis/LoopAccessAnalysis/number-of-memchecks.ll index cbd8a3e5844c..a9626f4dc710 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/number-of-memchecks.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/number-of-memchecks.ll @@ -1,5 +1,5 @@ ; RUN: opt -loop-accesses -analyze < %s | FileCheck %s -; RUN: opt -passes='loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s +; RUN: opt -passes='require,require,loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128" target triple = "aarch64--linux-gnueabi" diff --git a/llvm/test/Analysis/LoopAccessAnalysis/pointer-with-unknown-bounds.ll b/llvm/test/Analysis/LoopAccessAnalysis/pointer-with-unknown-bounds.ll index ae52a55ffadc..a10b851bcd1a 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/pointer-with-unknown-bounds.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/pointer-with-unknown-bounds.ll @@ -1,5 +1,5 @@ ; RUN: opt -loop-accesses -analyze < %s | FileCheck %s -; RUN: opt -passes='loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s +; RUN: opt -passes='require,require,loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" diff --git a/llvm/test/Analysis/LoopAccessAnalysis/resort-to-memchecks-only.ll b/llvm/test/Analysis/LoopAccessAnalysis/resort-to-memchecks-only.ll index de8b50e90f56..921fd4d06314 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/resort-to-memchecks-only.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/resort-to-memchecks-only.ll @@ -1,5 +1,5 @@ ; RUN: opt -loop-accesses -analyze < %s | FileCheck %s -; RUN: opt -passes='loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s +; RUN: opt -passes='require,require,loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s ; We give up analyzing the dependences in this loop due to non-constant ; distance between A[i+offset] and A[i] and add memchecks to prove diff --git a/llvm/test/Analysis/LoopAccessAnalysis/reverse-memcheck-bounds.ll b/llvm/test/Analysis/LoopAccessAnalysis/reverse-memcheck-bounds.ll index 556eaddd3eae..607e007f7a2d 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/reverse-memcheck-bounds.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/reverse-memcheck-bounds.ll @@ -1,5 +1,5 @@ ; RUN: opt -loop-accesses -analyze < %s | FileCheck %s -; RUN: opt -passes='loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s +; RUN: opt -passes='require,require,loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s ; The runtime memory check code and the access grouping ; algorithm both assume that the start and end values diff --git a/llvm/test/Analysis/LoopAccessAnalysis/safe-no-checks.ll b/llvm/test/Analysis/LoopAccessAnalysis/safe-no-checks.ll index 8ef5b05fb501..801899400995 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/safe-no-checks.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/safe-no-checks.ll @@ -1,5 +1,5 @@ ; RUN: opt -basicaa -loop-accesses -analyze < %s | FileCheck %s -; RUN: opt -passes='require,loop(print-access-info)' -aa-pipeline='basic-aa' -disable-output < %s 2>&1 | FileCheck %s +; RUN: opt -passes='require,require,require,loop(print-access-info)' -aa-pipeline='basic-aa' -disable-output < %s 2>&1 | FileCheck %s ; If the arrays don't alias this loop is safe with no memchecks: ; for (i = 0; i < n; i++) diff --git a/llvm/test/Analysis/LoopAccessAnalysis/safe-with-dep-distance.ll b/llvm/test/Analysis/LoopAccessAnalysis/safe-with-dep-distance.ll index 2025fad00a99..910d49edbb18 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/safe-with-dep-distance.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/safe-with-dep-distance.ll @@ -1,5 +1,5 @@ ; RUN: opt -loop-accesses -analyze < %s | FileCheck %s -; RUN: opt -passes='loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s +; RUN: opt -passes='require,require,loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s ; Analyze this loop: ; for (i = 0; i < n; i++) diff --git a/llvm/test/Analysis/LoopAccessAnalysis/store-to-invariant-check2.ll b/llvm/test/Analysis/LoopAccessAnalysis/store-to-invariant-check2.ll index 29fcea3903d1..711c14ef7728 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/store-to-invariant-check2.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/store-to-invariant-check2.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -loop-accesses -analyze | FileCheck %s -; RUN: opt -passes='loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s +; RUN: opt -passes='require,require,loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s ; Test to confirm LAA will not find store to invariant address. ; Inner loop has no store to invariant address. diff --git a/llvm/test/Analysis/LoopAccessAnalysis/store-to-invariant-check3.ll b/llvm/test/Analysis/LoopAccessAnalysis/store-to-invariant-check3.ll index f28921896590..85fea798071f 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/store-to-invariant-check3.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/store-to-invariant-check3.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -loop-accesses -analyze | FileCheck %s -; RUN: opt -passes='loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s +; RUN: opt -passes='require,require,loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s ; Test to confirm LAA will find store to invariant address. ; Inner loop has a store to invariant address. diff --git a/llvm/test/Analysis/LoopAccessAnalysis/stride-access-dependence.ll b/llvm/test/Analysis/LoopAccessAnalysis/stride-access-dependence.ll index 8e6a9e27d7e7..4fe6f9f704f7 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/stride-access-dependence.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/stride-access-dependence.ll @@ -1,5 +1,5 @@ ; RUN: opt -loop-accesses -analyze < %s | FileCheck %s -; RUN: opt -passes='loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s +; RUN: opt -passes='require,require,loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128" diff --git a/llvm/test/Analysis/LoopAccessAnalysis/underlying-objects-1.ll b/llvm/test/Analysis/LoopAccessAnalysis/underlying-objects-1.ll index cf4418061a98..705453b65cc5 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/underlying-objects-1.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/underlying-objects-1.ll @@ -1,5 +1,5 @@ ; RUN: opt -basicaa -loop-accesses -analyze < %s | FileCheck %s -; RUN: opt -passes='loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s +; RUN: opt -passes='require,require,loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s ; In: ; diff --git a/llvm/test/Analysis/LoopAccessAnalysis/underlying-objects-2.ll b/llvm/test/Analysis/LoopAccessAnalysis/underlying-objects-2.ll index e140b254a321..f9d88e891be9 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/underlying-objects-2.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/underlying-objects-2.ll @@ -1,5 +1,5 @@ ; RUN: opt -basicaa -loop-accesses -analyze < %s | FileCheck %s -; RUN: opt -passes='loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s +; RUN: opt -passes='require,require,loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s ; This loop: ; diff --git a/llvm/test/Analysis/LoopAccessAnalysis/unsafe-and-rt-checks.ll b/llvm/test/Analysis/LoopAccessAnalysis/unsafe-and-rt-checks.ll index 49e2ed43c8c8..7fbed6fcc15c 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/unsafe-and-rt-checks.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/unsafe-and-rt-checks.ll @@ -1,5 +1,5 @@ ; RUN: opt -loop-accesses -analyze < %s | FileCheck %s -; RUN: opt -passes='loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s +; RUN: opt -passes='require,require,loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s ; Analyze this loop: ; for (i = 0; i < n; i++) diff --git a/llvm/test/Analysis/LoopAccessAnalysis/wrapping-pointer-versioning.ll b/llvm/test/Analysis/LoopAccessAnalysis/wrapping-pointer-versioning.ll index beb94cfe9eab..75a71b444283 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/wrapping-pointer-versioning.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/wrapping-pointer-versioning.ll @@ -1,5 +1,5 @@ ; RUN: opt -basicaa -loop-accesses -analyze < %s | FileCheck %s -check-prefix=LAA -; RUN: opt -passes='require,loop(print-access-info)' -aa-pipeline='basic-aa' -disable-output < %s 2>&1 | FileCheck %s --check-prefix=LAA +; RUN: opt -passes='require,require,require,loop(print-access-info)' -aa-pipeline='basic-aa' -disable-output < %s 2>&1 | FileCheck %s --check-prefix=LAA ; RUN: opt -loop-versioning -S < %s | FileCheck %s -check-prefix=LV target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"