Justin Bogner | eecc3c8 | 2016-02-25 07:23:08 +0000 | [diff] [blame] | 1 | //===- 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 Bogner | e839c3e | 2016-05-03 21:35:08 +0000 | [diff] [blame] | 11 | #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 Bogner | eecc3c8 | 2016-02-25 07:23:08 +0000 | [diff] [blame] | 17 | |
| 18 | using namespace llvm; |
| 19 | |
Chandler Carruth | 6b98164 | 2016-12-10 06:34:44 +0000 | [diff] [blame] | 20 | // Explicit template instantiations and specialization defininitions for core |
| 21 | // template typedefs. |
Chandler Carruth | 2a54094 | 2016-02-27 10:38:10 +0000 | [diff] [blame] | 22 | namespace llvm { |
Chandler Carruth | afcec4c | 2016-02-27 10:45:35 +0000 | [diff] [blame] | 23 | template class PassManager<Loop>; |
| 24 | template class AnalysisManager<Loop>; |
Chandler Carruth | 2a54094 | 2016-02-27 10:38:10 +0000 | [diff] [blame] | 25 | template class InnerAnalysisManagerProxy<LoopAnalysisManager, Function>; |
| 26 | template class OuterAnalysisManagerProxy<FunctionAnalysisManager, Loop>; |
Chandler Carruth | 6b98164 | 2016-12-10 06:34:44 +0000 | [diff] [blame] | 27 | |
| 28 | template <> |
| 29 | bool 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 Carruth | ba90ae9 | 2016-12-27 08:40:39 +0000 | [diff] [blame] | 36 | auto PAC = PA.getChecker<LoopAnalysisManagerFunctionProxy>(); |
| 37 | if (!PAC.preserved() && !PAC.preservedSet<AllAnalysesOn<Loop>>()) |
Chandler Carruth | 6b98164 | 2016-12-10 06:34:44 +0000 | [diff] [blame] | 38 | 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 Bogner | eecc3c8 | 2016-02-25 07:23:08 +0000 | [diff] [blame] | 45 | } |
Justin Bogner | e839c3e | 2016-05-03 21:35:08 +0000 | [diff] [blame] | 46 | |
| 47 | PreservedAnalyses 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 Carruth | e3f5064 | 2016-12-22 06:59:15 +0000 | [diff] [blame] | 54 | PA.preserve<AAManager>(); |
Justin Bogner | e839c3e | 2016-05-03 21:35:08 +0000 | [diff] [blame] | 55 | PA.preserve<BasicAA>(); |
| 56 | PA.preserve<GlobalsAA>(); |
| 57 | PA.preserve<SCEVAA>(); |
| 58 | return PA; |
| 59 | } |