[ARM] Generate 8.1-m CSINC, CSNEG and CSINV instructions.
[llvm-core.git] / lib / Analysis / PostDominators.cpp
blob4afe22bd5342afe1da2253f8d84b313bff487f02
1 //===- PostDominators.cpp - Post-Dominator 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 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the post-dominator construction algorithms.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/Analysis/PostDominators.h"
14 #include "llvm/IR/Function.h"
15 #include "llvm/IR/PassManager.h"
16 #include "llvm/Pass.h"
17 #include "llvm/Support/raw_ostream.h"
19 using namespace llvm;
21 #define DEBUG_TYPE "postdomtree"
23 #ifdef EXPENSIVE_CHECKS
24 static constexpr bool ExpensiveChecksEnabled = true;
25 #else
26 static constexpr bool ExpensiveChecksEnabled = false;
27 #endif
29 //===----------------------------------------------------------------------===//
30 // PostDominatorTree Implementation
31 //===----------------------------------------------------------------------===//
33 char PostDominatorTreeWrapperPass::ID = 0;
35 INITIALIZE_PASS(PostDominatorTreeWrapperPass, "postdomtree",
36 "Post-Dominator Tree Construction", true, true)
38 bool PostDominatorTree::invalidate(Function &F, const PreservedAnalyses &PA,
39 FunctionAnalysisManager::Invalidator &) {
40 // Check whether the analysis, all analyses on functions, or the function's
41 // CFG have been preserved.
42 auto PAC = PA.getChecker<PostDominatorTreeAnalysis>();
43 return !(PAC.preserved() || PAC.preservedSet<AllAnalysesOn<Function>>() ||
44 PAC.preservedSet<CFGAnalyses>());
47 bool PostDominatorTreeWrapperPass::runOnFunction(Function &F) {
48 DT.recalculate(F);
49 return false;
52 void PostDominatorTreeWrapperPass::verifyAnalysis() const {
53 if (VerifyDomInfo)
54 assert(DT.verify(PostDominatorTree::VerificationLevel::Full));
55 else if (ExpensiveChecksEnabled)
56 assert(DT.verify(PostDominatorTree::VerificationLevel::Basic));
59 void PostDominatorTreeWrapperPass::print(raw_ostream &OS, const Module *) const {
60 DT.print(OS);
63 FunctionPass* llvm::createPostDomTree() {
64 return new PostDominatorTreeWrapperPass();
67 AnalysisKey PostDominatorTreeAnalysis::Key;
69 PostDominatorTree PostDominatorTreeAnalysis::run(Function &F,
70 FunctionAnalysisManager &) {
71 PostDominatorTree PDT(F);
72 return PDT;
75 PostDominatorTreePrinterPass::PostDominatorTreePrinterPass(raw_ostream &OS)
76 : OS(OS) {}
78 PreservedAnalyses
79 PostDominatorTreePrinterPass::run(Function &F, FunctionAnalysisManager &AM) {
80 OS << "PostDominatorTree for function: " << F.getName() << "\n";
81 AM.getResult<PostDominatorTreeAnalysis>(F).print(OS);
83 return PreservedAnalyses::all();