[ARM] Generate 8.1-m CSINC, CSNEG and CSINV instructions.
[llvm-core.git] / lib / Analysis / DominanceFrontier.cpp
blobf9a554acb7ea36818b48f60ecb7b3b764b11423f
1 //===- DominanceFrontier.cpp - Dominance Frontier Calculation -------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Analysis/DominanceFrontier.h"
10 #include "llvm/Analysis/DominanceFrontierImpl.h"
11 #include "llvm/Config/llvm-config.h"
12 #include "llvm/IR/Dominators.h"
13 #include "llvm/IR/Function.h"
14 #include "llvm/IR/PassManager.h"
15 #include "llvm/Pass.h"
16 #include "llvm/Support/Compiler.h"
17 #include "llvm/Support/Debug.h"
18 #include "llvm/Support/raw_ostream.h"
20 using namespace llvm;
22 namespace llvm {
24 template class DominanceFrontierBase<BasicBlock, false>;
25 template class DominanceFrontierBase<BasicBlock, true>;
26 template class ForwardDominanceFrontierBase<BasicBlock>;
28 } // end namespace llvm
30 char DominanceFrontierWrapperPass::ID = 0;
32 INITIALIZE_PASS_BEGIN(DominanceFrontierWrapperPass, "domfrontier",
33 "Dominance Frontier Construction", true, true)
34 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
35 INITIALIZE_PASS_END(DominanceFrontierWrapperPass, "domfrontier",
36 "Dominance Frontier Construction", true, true)
38 DominanceFrontierWrapperPass::DominanceFrontierWrapperPass()
39 : FunctionPass(ID), DF() {
40 initializeDominanceFrontierWrapperPassPass(*PassRegistry::getPassRegistry());
43 void DominanceFrontierWrapperPass::releaseMemory() {
44 DF.releaseMemory();
47 bool DominanceFrontierWrapperPass::runOnFunction(Function &) {
48 releaseMemory();
49 DF.analyze(getAnalysis<DominatorTreeWrapperPass>().getDomTree());
50 return false;
53 void DominanceFrontierWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
54 AU.setPreservesAll();
55 AU.addRequired<DominatorTreeWrapperPass>();
58 void DominanceFrontierWrapperPass::print(raw_ostream &OS, const Module *) const {
59 DF.print(OS);
62 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
63 LLVM_DUMP_METHOD void DominanceFrontierWrapperPass::dump() const {
64 print(dbgs());
66 #endif
68 /// Handle invalidation explicitly.
69 bool DominanceFrontier::invalidate(Function &F, const PreservedAnalyses &PA,
70 FunctionAnalysisManager::Invalidator &) {
71 // Check whether the analysis, all analyses on functions, or the function's
72 // CFG have been preserved.
73 auto PAC = PA.getChecker<DominanceFrontierAnalysis>();
74 return !(PAC.preserved() || PAC.preservedSet<AllAnalysesOn<Function>>() ||
75 PAC.preservedSet<CFGAnalyses>());
78 AnalysisKey DominanceFrontierAnalysis::Key;
80 DominanceFrontier DominanceFrontierAnalysis::run(Function &F,
81 FunctionAnalysisManager &AM) {
82 DominanceFrontier DF;
83 DF.analyze(AM.getResult<DominatorTreeAnalysis>(F));
84 return DF;
87 DominanceFrontierPrinterPass::DominanceFrontierPrinterPass(raw_ostream &OS)
88 : OS(OS) {}
90 PreservedAnalyses
91 DominanceFrontierPrinterPass::run(Function &F, FunctionAnalysisManager &AM) {
92 OS << "DominanceFrontier for function: " << F.getName() << "\n";
93 AM.getResult<DominanceFrontierAnalysis>(F).print(OS);
95 return PreservedAnalyses::all();