blob: 90e7fd00dbae017cb6a9df4102ab90461a5a3035 [file] [log] [blame]
Cameron Zwarich6b0c4c92011-01-18 06:06:27 +00001//===- 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"
Matt Arsenault4181ea32014-07-12 21:59:52 +000011#include "llvm/Analysis/DominanceFrontierImpl.h"
12
Cameron Zwarich6b0c4c92011-01-18 06:06:27 +000013using namespace llvm;
14
Matt Arsenault4181ea32014-07-12 21:59:52 +000015namespace llvm {
16template class DominanceFrontierBase<BasicBlock>;
17template class ForwardDominanceFrontierBase<BasicBlock>;
18}
19
Cameron Zwarich6b0c4c92011-01-18 06:06:27 +000020char DominanceFrontier::ID = 0;
Matt Arsenault4181ea32014-07-12 21:59:52 +000021
Cameron Zwarich6b0c4c92011-01-18 06:06:27 +000022INITIALIZE_PASS_BEGIN(DominanceFrontier, "domfrontier",
23 "Dominance Frontier Construction", true, true)
Chandler Carruth73523022014-01-13 13:07:17 +000024INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
Cameron Zwarich6b0c4c92011-01-18 06:06:27 +000025INITIALIZE_PASS_END(DominanceFrontier, "domfrontier",
26 "Dominance Frontier Construction", true, true)
27
Matt Arsenault4181ea32014-07-12 21:59:52 +000028DominanceFrontier::DominanceFrontier()
29 : FunctionPass(ID),
30 Base() {
31 initializeDominanceFrontierPass(*PassRegistry::getPassRegistry());
Cameron Zwarich6b0c4c92011-01-18 06:06:27 +000032}
33
Matt Arsenault4181ea32014-07-12 21:59:52 +000034void DominanceFrontier::releaseMemory() {
35 Base.releaseMemory();
Cameron Zwarich6b0c4c92011-01-18 06:06:27 +000036}
37
Matt Arsenault4181ea32014-07-12 21:59:52 +000038bool DominanceFrontier::runOnFunction(Function &) {
39 releaseMemory();
40 Base.analyze(getAnalysis<DominatorTreeWrapperPass>().getDomTree());
41 return false;
42}
43
44void DominanceFrontier::getAnalysisUsage(AnalysisUsage &AU) const {
45 AU.setPreservesAll();
46 AU.addRequired<DominatorTreeWrapperPass>();
47}
48
49void DominanceFrontier::print(raw_ostream &OS, const Module *) const {
50 Base.print(OS);
Cameron Zwarich6b0c4c92011-01-18 06:06:27 +000051}
52
Manman Ren49d684e2012-09-12 05:06:18 +000053#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
Yaron Kereneb2a2542016-01-29 20:50:44 +000054LLVM_DUMP_METHOD void DominanceFrontier::dump() const {
Cameron Zwarich6b0c4c92011-01-18 06:06:27 +000055 print(dbgs());
56}
Manman Renc3366cc2012-09-06 19:55:56 +000057#endif