Coverage Report

Created: 2017-08-21 19:50

/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.82k
bool ScopPass::runOnRegion(Region *R, RGPassManager &RGM) {
23
5.82k
  S = nullptr;
24
5.82k
25
5.82k
  if (skipRegion(*R))
26
0
    return false;
27
5.82k
28
5.82k
  
if (5.82k
(S = getAnalysis<ScopInfoRegionPass>().getScop())5.82k
)
29
1.50k
    return runOnScop(*S);
30
5.82k
31
4.31k
  return false;
32
5.82k
}
33
34
1.55k
void ScopPass::print(raw_ostream &OS, const Module *M) const {
35
1.55k
  if (S)
36
410
    printScop(OS, *S);
37
1.55k
}
38
39
616
void ScopPass::getAnalysisUsage(AnalysisUsage &AU) const {
40
616
  AU.addRequired<ScopInfoRegionPass>();
41
616
  AU.setPreservesAll();
42
616
}
43
44
namespace polly {
45
template class OwningInnerAnalysisManagerProxy<ScopAnalysisManager, Function>;
46
}
47
48
namespace llvm {
49
50
template class PassManager<Scop, ScopAnalysisManager,
51
                           ScopStandardAnalysisResults &, SPMUpdater &>;
52
template class InnerAnalysisManagerProxy<ScopAnalysisManager, Function>;
53
template class OuterAnalysisManagerProxy<FunctionAnalysisManager, Scop,
54
                                         ScopStandardAnalysisResults &>;
55
56
template <>
57
PreservedAnalyses
58
PassManager<Scop, ScopAnalysisManager, ScopStandardAnalysisResults &,
59
            SPMUpdater &>::run(Scop &S, ScopAnalysisManager &AM,
60
0
                               ScopStandardAnalysisResults &AR, SPMUpdater &U) {
61
0
  auto PA = PreservedAnalyses::all();
62
0
  for (auto &Pass : Passes) {
63
0
    auto PassPA = Pass->run(S, AM, AR, U);
64
0
65
0
    AM.invalidate(S, PassPA);
66
0
    PA.intersect(std::move(PassPA));
67
0
  }
68
0
69
0
  // All analyses for 'this' Scop have been invalidated above.
70
0
  // If ScopPasses affect break other scops they have to propagate this
71
0
  // information through the updater
72
0
  PA.preserveSet<AllAnalysesOn<Scop>>();
73
0
  return PA;
74
0
}
75
76
bool ScopAnalysisManagerFunctionProxy::Result::invalidate(
77
    Function &F, const PreservedAnalyses &PA,
78
0
    FunctionAnalysisManager::Invalidator &Inv) {
79
0
80
0
  // First, check whether our ScopInfo is about to be invalidated
81
0
  auto PAC = PA.getChecker<ScopAnalysisManagerFunctionProxy>();
82
0
  if (
!(PAC.preserved() || 0
PAC.preservedSet<AllAnalysesOn<Function>>()0
) ||
83
0
      Inv.invalidate<ScopInfoAnalysis>(F, PA) ||
84
0
      Inv.invalidate<ScalarEvolutionAnalysis>(F, PA) ||
85
0
      Inv.invalidate<LoopAnalysis>(F, PA) ||
86
0
      
Inv.invalidate<DominatorTreeAnalysis>(F, PA)0
)
{0
87
0
88
0
    // As everything depends on ScopInfo, we must drop all existing results
89
0
    for (auto &S : *SI)
90
0
      
if (auto *0
scop0
= S.second.get())
91
0
        
if (0
InnerAM0
)
92
0
          InnerAM->clear(*scop);
93
0
94
0
    InnerAM = nullptr;
95
0
    return true; // Invalidate the proxy result as well.
96
0
  }
97
0
98
0
  bool allPreserved = PA.allAnalysesInSetPreserved<AllAnalysesOn<Scop>>();
99
0
100
0
  // Invalidate all non-preserved analyses
101
0
  // Even if all analyses were preserved, we still need to run deferred
102
0
  // invalidation
103
0
  for (auto &S : *SI) {
104
0
    Optional<PreservedAnalyses> InnerPA;
105
0
    auto *scop = S.second.get();
106
0
    if (!scop)
107
0
      continue;
108
0
109
0
    
if (auto *0
OuterProxy0
=
110
0
            InnerAM->getCachedResult<FunctionAnalysisManagerScopProxy>(*scop)) {
111
0
      for (const auto &InvPair : OuterProxy->getOuterInvalidations()) {
112
0
        auto *OuterAnalysisID = InvPair.first;
113
0
        const auto &InnerAnalysisIDs = InvPair.second;
114
0
115
0
        if (
Inv.invalidate(OuterAnalysisID, F, PA)0
)
{0
116
0
          if (!InnerPA)
117
0
            InnerPA = PA;
118
0
          for (auto *InnerAnalysisID : InnerAnalysisIDs)
119
0
            InnerPA->abandon(InnerAnalysisID);
120
0
        }
121
0
      }
122
0
123
0
      if (
InnerPA0
)
{0
124
0
        InnerAM->invalidate(*scop, *InnerPA);
125
0
        continue;
126
0
      }
127
0
    }
128
0
129
0
    
if (0
!allPreserved0
)
130
0
      InnerAM->invalidate(*scop, PA);
131
0
  }
132
0
133
0
  return false; // This proxy is still valid
134
0
}
135
136
template <>
137
ScopAnalysisManagerFunctionProxy::Result
138
ScopAnalysisManagerFunctionProxy::run(Function &F,
139
0
                                      FunctionAnalysisManager &FAM) {
140
0
  return Result(*InnerAM, FAM.getResult<ScopInfoAnalysis>(F));
141
0
}
142
} // namespace llvm
143
144
namespace polly {
145
template <>
146
OwningScopAnalysisManagerFunctionProxy::Result
147
OwningScopAnalysisManagerFunctionProxy::run(Function &F,
148
0
                                            FunctionAnalysisManager &FAM) {
149
0
  return Result(InnerAM, FAM.getResult<ScopInfoAnalysis>(F));
150
0
}
151
} // namespace polly