blob: 044e5d55dafd06c4833ab25ca51e5c2de62183e3 [file] [log] [blame]
Justin Bognereecc3c82016-02-25 07:23:08 +00001//===- LoopPassManager.cpp - Loop pass management -------------------------===//
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#include "llvm/Analysis/LoopPassManager.h"
Justin Bognere839c3e2016-05-03 21:35:08 +000011#include "llvm/Analysis/BasicAliasAnalysis.h"
12#include "llvm/Analysis/GlobalsModRef.h"
13#include "llvm/Analysis/LoopInfo.h"
14#include "llvm/Analysis/ScalarEvolution.h"
15#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
16#include "llvm/IR/Dominators.h"
Justin Bognereecc3c82016-02-25 07:23:08 +000017
18using namespace llvm;
19
Chandler Carruth6b981642016-12-10 06:34:44 +000020// Explicit template instantiations and specialization defininitions for core
21// template typedefs.
Chandler Carruth2a540942016-02-27 10:38:10 +000022namespace llvm {
Chandler Carruthafcec4c2016-02-27 10:45:35 +000023template class PassManager<Loop>;
24template class AnalysisManager<Loop>;
Chandler Carruth2a540942016-02-27 10:38:10 +000025template class InnerAnalysisManagerProxy<LoopAnalysisManager, Function>;
26template class OuterAnalysisManagerProxy<FunctionAnalysisManager, Loop>;
Chandler Carruth6b981642016-12-10 06:34:44 +000027
28template <>
29bool LoopAnalysisManagerFunctionProxy::Result::invalidate(
30 Function &F, const PreservedAnalyses &PA,
31 FunctionAnalysisManager::Invalidator &Inv) {
32 // If this proxy isn't marked as preserved, the set of Function objects in
33 // the module may have changed. We therefore can't call
34 // InnerAM->invalidate(), because any pointers to Functions it has may be
35 // stale.
Chandler Carruthba90ae92016-12-27 08:40:39 +000036 auto PAC = PA.getChecker<LoopAnalysisManagerFunctionProxy>();
37 if (!PAC.preserved() && !PAC.preservedSet<AllAnalysesOn<Loop>>())
Chandler Carruth6b981642016-12-10 06:34:44 +000038 InnerAM->clear();
39
40 // FIXME: Proper suppor for invalidation isn't yet implemented for the LPM.
41
42 // Return false to indicate that this result is still a valid proxy.
43 return false;
44}
Justin Bognereecc3c82016-02-25 07:23:08 +000045}
Justin Bognere839c3e2016-05-03 21:35:08 +000046
47PreservedAnalyses llvm::getLoopPassPreservedAnalyses() {
48 PreservedAnalyses PA;
49 PA.preserve<DominatorTreeAnalysis>();
50 PA.preserve<LoopAnalysis>();
51 PA.preserve<ScalarEvolutionAnalysis>();
52 // TODO: What we really want to do here is preserve an AA category, but that
53 // concept doesn't exist yet.
Chandler Carruthe3f50642016-12-22 06:59:15 +000054 PA.preserve<AAManager>();
Justin Bognere839c3e2016-05-03 21:35:08 +000055 PA.preserve<BasicAA>();
56 PA.preserve<GlobalsAA>();
57 PA.preserve<SCEVAA>();
58 return PA;
59}