18 #ifndef LLVM_ANALYSIS_CFGPRINTER_H 19 #define LLVM_ANALYSIS_CFGPRINTER_H 59 return "CFG for '" + F->
getName().
str() +
"' function";
76 enum { MaxColumns = 80 };
86 std::string OutStr = OS.
str();
87 if (OutStr[0] ==
'\n') OutStr.erase(OutStr.begin());
91 unsigned LastSpace = 0;
92 for (
unsigned i = 0; i != OutStr.length(); ++i) {
93 if (OutStr[i] ==
'\n') {
95 OutStr.insert(OutStr.begin()+i+1,
'l');
98 }
else if (OutStr[i] ==
';') {
99 unsigned Idx = OutStr.find(
'\n', i+1);
100 OutStr.erase(OutStr.begin()+i, OutStr.begin()+Idx);
102 }
else if (ColNum == MaxColumns) {
106 OutStr.insert(LastSpace,
"\\l...");
107 ColNum = i - LastSpace;
113 if (OutStr[i] ==
' ')
122 return getSimpleNodeLabel(Node, Graph);
124 return getCompleteNodeLabel(Node, Graph);
131 if (BI->isConditional())
138 if (SuccNo == 0)
return "def";
143 OS << Case.getCaseValue()->getValue();
161 if (MDName->
getString() !=
"branch_weights")
168 mdconst::dyn_extract<ConstantInt>(WeightsNode->
getOperand(OpNo));
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
This class represents lattice values for constants.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
DOTGraphTraits(bool isSimple=false)
static std::string getGraphName(const Function *F)
FunctionPass * createCFGPrinterLegacyPassPass()
int getSuccessorIndex() const
This is used to interface between code that wants to operate on terminator instructions directly...
std::string getEdgeAttributes(const BasicBlock *Node, succ_const_iterator I, const Function *F)
Display the raw branch weights from PGO.
const MDOperand & getOperand(unsigned I) const
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
static std::string getCompleteNodeLabel(const BasicBlock *Node, const Function *)
std::string getNodeLabel(const BasicBlock *Node, const Function *Graph)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Interval::succ_iterator succ_begin(Interval *I)
succ_begin/succ_end - define methods so that Intervals may be used just like BasicBlocks can with the...
static CaseIteratorImpl fromSuccessorIndex(SwitchInstT *SI, unsigned SuccessorIndex)
Initializes case iterator for given SwitchInst and for given successor index.
static bool isSimple(Instruction *I)
A CRTP mix-in to automatically provide informational APIs needed for passes.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
unsigned getNumSuccessors() const
Return the number of successors that this instruction has.
StringRef getString() const
FunctionPass * createCFGOnlyPrinterLegacyPassPass()
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
A set of analyses that are preserved following a run of a transformation pass.
LLVM Basic Block Representation.
Conditional or Unconditional Branch instruction.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
FunctionPass class - This class is used to implement most global optimizations.
void printAsOperand(raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
Print the name of this Value out to the specified raw_ostream.
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to 'dot...
static std::string getSimpleNodeLabel(const BasicBlock *Node, const Function *)
This is the shared class of boolean and integer constants.
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
StringRef getName() const
Return a constant reference to the value's name.
A raw_ostream that writes to an std::string.
DefaultDOTGraphTraits - This class provides the default implementations of all of the DOTGraphTraits ...
A container for analyses that lazily runs them and caches their results.
This header defines various interfaces for pass management in LLVM.
unsigned getNumOperands() const
Return number of MDNode operands.
static std::string getEdgeSourceLabel(const BasicBlock *Node, succ_const_iterator I)