Coverage Report

Created: 2017-06-23 12:40

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/polly/lib/Analysis/ScopPass.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- ScopPass.cpp - The base class of Passes that operate on Polly IR ---===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This file contains the definitions of the ScopPass members.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#include "polly/ScopPass.h"
15
#include "polly/ScopInfo.h"
16
17
#include "llvm/Analysis/AssumptionCache.h"
18
19
using namespace llvm;
20
using namespace polly;
21
22
5.46k
bool ScopPass::runOnRegion(Region *R, RGPassManager &RGM) {
23
5.46k
  S = nullptr;
24
5.46k
25
5.46k
  if (skipRegion(*R))
26
0
    return false;
27
5.46k
28
5.46k
  
if (5.46k
(S = getAnalysis<ScopInfoRegionPass>().getScop())5.46k
)
29
1.40k
    return runOnScop(*S);
30
5.46k
31
4.05k
  return false;
32
5.46k
}
33
34
1.28k
void ScopPass::print(raw_ostream &OS, const Module *M) const {
35
1.28k
  if (S)
36
333
    printScop(OS, *S);
37
1.28k
}
38
39
581
void ScopPass::getAnalysisUsage(AnalysisUsage &AU) const {
40
581
  AU.addRequired<ScopInfoRegionPass>();
41
581
  AU.setPreservesAll();
42
581
}
43
44
namespace llvm {
45
46
template class PassManager<Scop, ScopAnalysisManager,
47
                           ScopStandardAnalysisResults &, SPMUpdater &>;
48
template class InnerAnalysisManagerProxy<ScopAnalysisManager, Function>;
49
template class OuterAnalysisManagerProxy<FunctionAnalysisManager, Scop,
50
                                         ScopStandardAnalysisResults &>;
51
52
template <>
53
PreservedAnalyses
54
PassManager<Scop, ScopAnalysisManager, ScopStandardAnalysisResults &,
55
            SPMUpdater &>::run(Scop &S, ScopAnalysisManager &AM,
56
0
                               ScopStandardAnalysisResults &AR, SPMUpdater &U) {
57
0
  auto PA = PreservedAnalyses::all();
58
0
  for (auto &Pass : Passes) {
59
0
    auto PassPA = Pass->run(S, AM, AR, U);
60
0
61
0
    AM.invalidate(S, PassPA);
62
0
    PA.intersect(std::move(PassPA));
63
0
  }
64
0
65
0
  // All analyses for 'this' Scop have been invalidated above.
66
0
  // If ScopPasses affect break other scops they have to propagate this
67
0
  // information through the updater
68
0
  PA.preserveSet<AllAnalysesOn<Scop>>();
69
0
  return PA;
70
0
}
71
72
bool ScopAnalysisManagerFunctionProxy::Result::invalidate(
73
    Function &F, const PreservedAnalyses &PA,
74
0
    FunctionAnalysisManager::Invalidator &Inv) {
75
0
76
0
  // First, check whether our ScopInfo is about to be invalidated
77
0
  auto PAC = PA.getChecker<ScopAnalysisManagerFunctionProxy>();
78
0
  if (
!(PAC.preserved() || 0
PAC.preservedSet<AllAnalysesOn<Function>>()0
||
79
0
        Inv.invalidate<ScopAnalysis>(F, PA) ||
80
0
        Inv.invalidate<ScalarEvolutionAnalysis>(F, PA) ||
81
0
        Inv.invalidate<LoopAnalysis>(F, PA) ||
82
0
        Inv.invalidate<AAManager>(F, PA) ||
83
0
        Inv.invalidate<DominatorTreeAnalysis>(F, PA) ||
84
0
        
Inv.invalidate<AssumptionAnalysis>(F, PA)0
))
{0
85
0
86
0
    // As everything depends on ScopInfo, we must drop all existing results
87
0
    for (auto &S : *SI)
88
0
      
if (auto *0
scop0
= S.second.get())
89
0
        
if (0
InnerAM0
)
90
0
          InnerAM->clear(*scop);
91
0
92
0
    InnerAM = nullptr;
93
0
    return true; // Invalidate the proxy result as well.
94
0
  }
95
0
96
0
  bool allPreserved = PA.allAnalysesInSetPreserved<AllAnalysesOn<Scop>>();
97
0
98
0
  // Invalidate all non-preserved analyses
99
0
  // Even if all analyses were preserved, we still need to run deferred
100
0
  // invalidation
101
0
  for (auto &S : *SI) {
102
0
    Optional<PreservedAnalyses> InnerPA;
103
0
    auto *scop = S.second.get();
104
0
    if (!scop)
105
0
      continue;
106
0
107
0
    
if (auto *0
OuterProxy0
=
108
0
            InnerAM->getCachedResult<FunctionAnalysisManagerScopProxy>(*scop)) {
109
0
      for (const auto &InvPair : OuterProxy->getOuterInvalidations()) {
110
0
        auto *OuterAnalysisID = InvPair.first;
111
0
        const auto &InnerAnalysisIDs = InvPair.second;
112
0
113
0
        if (
Inv.invalidate(OuterAnalysisID, F, PA)0
)
{0
114
0
          if (!InnerPA)
115
0
            InnerPA = PA;
116
0
          for (auto *InnerAnalysisID : InnerAnalysisIDs)
117
0
            InnerPA->abandon(InnerAnalysisID);
118
0
        }
119
0
      }
120
0
121
0
      if (
InnerPA0
)
{0
122
0
        InnerAM->invalidate(*scop, *InnerPA);
123
0
        continue;
124
0
      }
125
0
    }
126
0
127
0
    
if (0
!allPreserved0
)
128
0
      InnerAM->invalidate(*scop, PA);
129
0
  }
130
0
131
0
  return false; // This proxy is still valid
132
0
}
133
134
template <>
135
ScopAnalysisManagerFunctionProxy::Result
136
ScopAnalysisManagerFunctionProxy::run(Function &F,
137
0
                                      FunctionAnalysisManager &FAM) {
138
0
  return Result(*InnerAM, FAM.getResult<ScopInfoAnalysis>(F));
139
0
}
140
} // namespace llvm