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));
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
DOTGraphTraits(bool isSimple=false)
static std::string getGraphName(const Function *F)
FunctionPass * createCFGPrinterLegacyPassPass()
unsigned getNumOperands() const
Return number of MDNode operands.
unsigned getNumSuccessors() const
Return the number of successors that this terminator has.
std::string getEdgeAttributes(const BasicBlock *Node, succ_const_iterator I, const Function *F)
Display the raw branch weights from PGO.
static std::string getCompleteNodeLabel(const BasicBlock *Node, const Function *)
StringRef getName() const
Return a constant reference to the value's name.
std::string str() const
Return the twine contents as a std::string.
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...
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
static CaseIteratorImpl fromSuccessorIndex(SwitchInstT *SI, unsigned SuccessorIndex)
Initializes case iterator for given SwitchInst and for given TerminatorInst's successor index...
static bool isSimple(Instruction *I)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
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.
A CRTP mix-in to automatically provide informational APIs needed for passes.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
FunctionPass * createCFGOnlyPrinterLegacyPassPass()
Subclasses of this class are all able to terminate a basic block.
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...
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
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...
StringRef getString() const
const MDOperand & getOperand(unsigned I) const
static std::string getSimpleNodeLabel(const BasicBlock *Node, const Function *)
This is the shared class of boolean and integer constants.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
A raw_ostream that writes to an std::string.
unsigned getSuccessorIndex() const
This is used to interface between code that wants to operate on terminator instructions directly...
DefaultDOTGraphTraits - This class provides the default implementations of all of the DOTGraphTraits ...
A container for analyses that lazily runs them and caches their results.
const TerminatorInst * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
This header defines various interfaces for pass management in LLVM.
static std::string getEdgeSourceLabel(const BasicBlock *Node, succ_const_iterator I)