19 #ifndef LLVM_ANALYSIS_CFGPRINTER_H 20 #define LLVM_ANALYSIS_CFGPRINTER_H 60 return "CFG for '" + F->
getName().
str() +
"' function";
77 enum { MaxColumns = 80 };
87 std::string OutStr = OS.
str();
88 if (OutStr[0] ==
'\n') OutStr.erase(OutStr.begin());
92 unsigned LastSpace = 0;
93 for (
unsigned i = 0; i != OutStr.length(); ++i) {
94 if (OutStr[i] ==
'\n') {
96 OutStr.insert(OutStr.begin()+i+1,
'l');
99 }
else if (OutStr[i] ==
';') {
100 unsigned Idx = OutStr.find(
'\n', i+1);
101 OutStr.erase(OutStr.begin()+i, OutStr.begin()+Idx);
103 }
else if (ColNum == MaxColumns) {
107 OutStr.insert(LastSpace,
"\\l...");
108 ColNum = i - LastSpace;
114 if (OutStr[i] ==
' ')
123 return getSimpleNodeLabel(Node, Graph);
125 return getCompleteNodeLabel(Node, Graph);
132 if (BI->isConditional())
139 if (SuccNo == 0)
return "def";
144 OS << Case.getCaseValue()->getValue();
162 if (MDName->
getString() !=
"branch_weights")
169 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...
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.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
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)