]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Analysis/DominanceFrontier.cpp
Update llvm to release_39 branch r278877.
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Analysis / DominanceFrontier.cpp
1 //===- DominanceFrontier.cpp - Dominance Frontier Calculation -------------===//
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/DominanceFrontier.h"
11 #include "llvm/Analysis/DominanceFrontierImpl.h"
12 #include "llvm/IR/PassManager.h"
13
14 using namespace llvm;
15
16 namespace llvm {
17 template class DominanceFrontierBase<BasicBlock>;
18 template class ForwardDominanceFrontierBase<BasicBlock>;
19 }
20
21 char DominanceFrontierWrapperPass::ID = 0;
22
23 INITIALIZE_PASS_BEGIN(DominanceFrontierWrapperPass, "domfrontier",
24                 "Dominance Frontier Construction", true, true)
25 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
26 INITIALIZE_PASS_END(DominanceFrontierWrapperPass, "domfrontier",
27                 "Dominance Frontier Construction", true, true)
28
29  DominanceFrontierWrapperPass::DominanceFrontierWrapperPass()
30     : FunctionPass(ID), DF() {
31   initializeDominanceFrontierWrapperPassPass(*PassRegistry::getPassRegistry());
32 }
33
34 void DominanceFrontierWrapperPass::releaseMemory() {
35   DF.releaseMemory();
36 }
37
38 bool DominanceFrontierWrapperPass::runOnFunction(Function &) {
39   releaseMemory();
40   DF.analyze(getAnalysis<DominatorTreeWrapperPass>().getDomTree());
41   return false;
42 }
43
44 void DominanceFrontierWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
45   AU.setPreservesAll();
46   AU.addRequired<DominatorTreeWrapperPass>();
47 }
48
49 void DominanceFrontierWrapperPass::print(raw_ostream &OS, const Module *) const {
50   DF.print(OS);
51 }
52
53 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
54 LLVM_DUMP_METHOD void DominanceFrontierWrapperPass::dump() const {
55   print(dbgs());
56 }
57 #endif
58
59 char DominanceFrontierAnalysis::PassID;
60
61 DominanceFrontier DominanceFrontierAnalysis::run(Function &F,
62                                                  FunctionAnalysisManager &AM) {
63   DominanceFrontier DF;
64   DF.analyze(AM.getResult<DominatorTreeAnalysis>(F));
65   return DF;
66 }
67
68 DominanceFrontierPrinterPass::DominanceFrontierPrinterPass(raw_ostream &OS)
69   : OS(OS) {}
70
71 PreservedAnalyses
72 DominanceFrontierPrinterPass::run(Function &F, FunctionAnalysisManager &AM) {
73   OS << "DominanceFrontier for function: " << F.getName() << "\n";
74   AM.getResult<DominanceFrontierAnalysis>(F).print(OS);
75
76   return PreservedAnalyses::all();
77 }