LLVM  9.0.0svn
PostDominators.cpp
Go to the documentation of this file.
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.
10 //
11 //===----------------------------------------------------------------------===//
12 
14 #include "llvm/IR/Function.h"
15 #include "llvm/IR/PassManager.h"
16 #include "llvm/Pass.h"
18 
19 using namespace llvm;
20 
21 #define DEBUG_TYPE "postdomtree"
22 
23 #ifdef EXPENSIVE_CHECKS
24 static constexpr bool ExpensiveChecksEnabled = true;
25 #else
26 static constexpr bool ExpensiveChecksEnabled = false;
27 #endif
28 
29 //===----------------------------------------------------------------------===//
30 // PostDominatorTree Implementation
31 //===----------------------------------------------------------------------===//
32 
34 
36  "Post-Dominator Tree Construction", true, true)
37 
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>());
45 }
46 
48  DT.recalculate(F);
49  return false;
50 }
51 
53  if (VerifyDomInfo)
55  else if (ExpensiveChecksEnabled)
57 }
58 
60  DT.print(OS);
61 }
62 
64  return new PostDominatorTreeWrapperPass();
65 }
66 
67 AnalysisKey PostDominatorTreeAnalysis::Key;
68 
71  PostDominatorTree PDT(F);
72  return PDT;
73 }
74 
76  : OS(OS) {}
77 
80  OS << "PostDominatorTree for function: " << F.getName() << "\n";
82 
83  return PreservedAnalyses::all();
84 }
PostDominatorTree run(Function &F, FunctionAnalysisManager &)
Run the analysis pass over a function and produce a post dominator tree.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:769
This class represents lattice values for constants.
Definition: AllocatorList.h:23
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
void recalculate(ParentType &Func)
recalculate - compute a dominator tree for the given function
PostDominatorTreePrinterPass(raw_ostream &OS)
void verifyAnalysis() const override
verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis infor...
F(f)
bool verify(VerificationLevel VL=VerificationLevel::Full) const
verify - checks if the tree is correct.
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:153
void print(raw_ostream &OS, const Module *) const override
print - Print out the internal state of the pass.
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:284
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
bool VerifyDomInfo
Enables verification of dominator trees.
Definition: Dominators.cpp:31
INITIALIZE_PASS(PostDominatorTreeWrapperPass, "postdomtree", "Post-Dominator Tree Construction", true, true) bool PostDominatorTree
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass...
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:159
void print(raw_ostream &O) const
print - Convert to human readable form
Analysis pass which computes a PostDominatorTree.
static constexpr bool ExpensiveChecksEnabled
PostDominatorTree Class - Concrete subclass of DominatorTree that is used to compute the post-dominat...
Represents analyses that only rely on functions&#39; control flow.
Definition: PassManager.h:114
StringRef getName() const
Return a constant reference to the value&#39;s name.
Definition: Value.cpp:214
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This templated class represents "all analyses that operate over <a particular IR unit>" (e...
Definition: PassManager.h:91
FunctionPass * createPostDomTree()
aarch64 promote const
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
A container for analyses that lazily runs them and caches their results.
This header defines various interfaces for pass management in LLVM.
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:70