LLVM: lib/CodeGen/EdgeBundles.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
22
23using namespace llvm;
24
27 cl::desc("Pop up a window to show edge bundle graphs"));
28
30
32 "Bundle Machine CFG Edges",
33 true, true)
34
36
38 AU.setPreservesAll();
40}
41
43
49
50bool EdgeBundlesWrapperLegacy::runOnMachineFunction(MachineFunction &MF) {
52 return false;
53}
54
55EdgeBundles::EdgeBundles(MachineFunction &MF) : MF(&MF) { init(); }
56
57void EdgeBundles::init() {
58 EC.clear();
59 EC.grow(2 * MF->getNumBlockIDs());
60
61 for (const auto &MBB : *MF) {
63
64 for (const MachineBasicBlock *Succ : MBB.successors())
65 EC.join(OutE, 2 * Succ->getNumber());
66 }
67 EC.compress();
70
71
72 Blocks.clear();
74
75 for (unsigned i = 0, e = MF->getNumBlockIDs(); i != e; ++i) {
76 unsigned b0 = getBundle(i, false);
78 Blocks[b0].push_back(i);
79 if (b1 != b0)
80 Blocks[b1].push_back(i);
81 }
82}
83
84
85template <>
87 bool ShortNames, const Twine &Title) {
89
90 O << "digraph {\n";
91 for (const auto &MBB : *MF) {
96 << "\"\n"
98 << '\n';
102 }
103 O << "}\n";
104 return O;
105}
106
107
111
113 MachineFunctionAnalysisManager::Invalidator &Inv) {
114
116 return !PAC.preserved() && !PAC.preservedSet<CFGAnalyses>() &&
118}
static cl::opt< bool > ViewEdgeBundles("view-edge-bundles", cl::Hidden, cl::desc("Pop up a window to show edge bundle graphs"))
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This templated class represents "all analyses that operate over " (e....
Represent the analysis usage information of a pass.
Represents analyses that only rely on functions' control flow.
EdgeBundles run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Definition EdgeBundles.cpp:44
bool invalidate(MachineFunction &MF, const PreservedAnalyses &PA, MachineFunctionAnalysisManager::Invalidator &Inv)
Definition EdgeBundles.cpp:112
unsigned getBundle(unsigned N, bool Out) const
getBundle - Return the ingoing (Out = false) or outgoing (Out = true) bundle number for basic block N
unsigned getNumBundles() const
getNumBundles - Return the total number of bundles in the CFG.
void view() const
view - Visualize the annotated bipartite CFG with Graphviz.
Definition EdgeBundles.cpp:108
friend class EdgeBundlesAnalysis
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
iterator_range< succ_iterator > successors()
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
A set of analyses that are preserved following a run of a transformation pass.
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
This class implements an extremely fast bulk output stream that can only output to a stream.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & WriteGraph(raw_ostream &O, const GraphType &G, bool ShortNames=false, const Twine &Title="")
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI char & EdgeBundlesWrapperLegacyID
EdgeBundles analysis - Bundle machine CFG edges.
void ViewGraph(const GraphType &G, const Twine &Name, bool ShortNames=false, const Twine &Title="", GraphProgram::Name Program=GraphProgram::DOT)
ViewGraph - Emit a dot graph, run 'dot', run gv on the postscript file, then cleanup.
LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
A special type used by analysis passes to provide an address that identifies that particular analysis...