68#define PASS_KEY "x86-lvi-load"
69#define DEBUG_TYPE PASS_KEY
71STATISTIC(NumFences,
"Number of LFENCEs inserted for LVI mitigation");
72STATISTIC(NumFunctionsConsidered,
"Number of functions analyzed");
73STATISTIC(NumFunctionsMitigated,
"Number of functions for which mitigations "
75STATISTIC(NumGadgets,
"Number of LVI gadgets detected during analysis");
83 cl::desc(
"Don't treat conditional branches as disclosure gadgets. This "
84 "may improve performance, at the cost of security."),
90 "For each function, emit a dot graph depicting potential LVI gadgets"),
95 cl::desc(
"For each function, emit a dot graph depicting potential LVI "
96 "gadgets, and do not insert any fences"),
101 cl::desc(
"For each function, emit a dot graph to stdout depicting "
102 "potential LVI gadgets, used for testing purposes only"),
106typedef int (*
OptimizeCutT)(
unsigned int *Nodes,
unsigned int NodesSize,
107 unsigned int *Edges,
int *EdgeValues,
108 int *CutEdges ,
unsigned int EdgesSize);
114 static constexpr int GadgetEdgeSentinel = -1;
115 static constexpr MachineInstr *
const ArgNodeSentinel =
nullptr;
118 using Node =
typename GraphT::Node;
119 using Edge =
typename GraphT::Edge;
121 MachineGadgetGraph(std::unique_ptr<
Node[]> Nodes,
122 std::unique_ptr<Edge[]> Edges, size_type NodesSize,
123 size_type EdgesSize,
int NumFences = 0,
int NumGadgets = 0)
124 : GraphT(std::move(Nodes), std::move(Edges), NodesSize, EdgesSize),
125 NumFences(NumFences), NumGadgets(NumGadgets) {}
126 static inline bool isCFGEdge(
const Edge &
E) {
127 return E.getValue() != GadgetEdgeSentinel;
129 static inline bool isGadgetEdge(
const Edge &
E) {
130 return E.getValue() == GadgetEdgeSentinel;
141 return "X86 Load Value Injection (LVI) Load Hardening";
150 using Edge = MachineGadgetGraph::Edge;
151 using Node = MachineGadgetGraph::Node;
152 using EdgeSet = MachineGadgetGraph::EdgeSet;
153 using NodeSet = MachineGadgetGraph::NodeSet;
159 std::unique_ptr<MachineGadgetGraph>
164 std::unique_ptr<MachineGadgetGraph> Graph)
const;
166 std::unique_ptr<MachineGadgetGraph> Graph)
const;
167 int elimMitigatedEdgesAndNodes(MachineGadgetGraph &
G,
170 std::unique_ptr<MachineGadgetGraph>
171 trimMitigatedEdges(std::unique_ptr<MachineGadgetGraph> Graph)
const;
173 EdgeSet &CutEdges )
const;
177 return MI && (
MI->getOpcode() == X86::LFENCE ||
178 (STI->useLVIControlFlowIntegrity() &&
MI->isCall()));
202 if (
Node->getValue() == MachineGadgetGraph::ArgNodeSentinel)
207 OS << *
Node->getValue();
213 if (
MI == MachineGadgetGraph::ArgNodeSentinel)
214 return "color = blue";
215 if (
MI->getOpcode() == X86::LFENCE)
216 return "color = green";
222 int EdgeVal = (*E.getCurrent()).getValue();
223 return EdgeVal >= 0 ?
"label = " + std::to_string(EdgeVal)
224 :
"color = red, style = \"dashed\"";
230constexpr MachineInstr *MachineGadgetGraph::ArgNodeSentinel;
231constexpr int MachineGadgetGraph::GadgetEdgeSentinel;
233char X86LoadValueInjectionLoadHardeningPass::ID = 0;
235void X86LoadValueInjectionLoadHardeningPass::getAnalysisUsage(
245 MachineGadgetGraph *
G) {
247 "Speculative gadgets for \"" + MF.
getName() +
"\" function");
250bool X86LoadValueInjectionLoadHardeningPass::runOnMachineFunction(
251 MachineFunction &MF) {
255 if (!STI->useLVILoadHardening())
264 if (!
F.hasOptNone() && skipFunction(
F))
267 ++NumFunctionsConsidered;
271 const auto &MLI = getAnalysis<MachineLoopInfoWrapperPass>().getLI();
272 const auto &MDT = getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
273 const auto &MDF = getAnalysis<MachineDominanceFrontier>();
274 std::unique_ptr<MachineGadgetGraph> Graph = getGadgetGraph(MF, MLI, MDT, MDF);
276 if (Graph ==
nullptr)
286 std::error_code FileError;
287 std::string FileName =
"lvi.";
290 raw_fd_ostream FileOut(FileName, FileError);
292 errs() << FileError.message();
303 std::string ErrorMsg;
306 if (!ErrorMsg.empty())
313 FencesInserted = hardenLoadsWithPlugin(MF, std::move(Graph));
315 FencesInserted = hardenLoadsWithHeuristic(MF, std::move(Graph));
318 if (FencesInserted > 0)
319 ++NumFunctionsMitigated;
320 NumFences += FencesInserted;
321 return (FencesInserted > 0);
324std::unique_ptr<MachineGadgetGraph>
325X86LoadValueInjectionLoadHardeningPass::getGadgetGraph(
326 MachineFunction &MF,
const MachineLoopInfo &MLI,
327 const MachineDominatorTree &MDT,
328 const MachineDominanceFrontier &MDF)
const {
332 DataFlowGraph DFG{MF, *
TII, *
TRI, MDT, MDF};
337 GraphBuilder Builder;
338 using GraphIter =
typename GraphBuilder::BuilderNodeRef;
339 DenseMap<MachineInstr *, GraphIter> NodeMap;
340 int FenceCount = 0, GadgetCount = 0;
341 auto MaybeAddNode = [&NodeMap, &Builder](MachineInstr *
MI) {
344 auto I = Builder.addVertex(
MI);
346 return std::pair<GraphIter, bool>{
I,
true};
348 return std::pair<GraphIter, bool>{
Ref->getSecond(),
false};
355 DenseMap<NodeId, std::vector<NodeId>> Transmitters;
359 auto AnalyzeDef = [&](NodeAddr<DefNode *> SourceDef) {
360 SmallSet<NodeId, 8> UsesVisited, DefsVisited;
361 std::function<void(NodeAddr<DefNode *>)> AnalyzeDefUseChain =
362 [&](NodeAddr<DefNode *>
Def) {
369 for (
auto UseID :
L.getAllReachedUses(DefReg, Def)) {
370 auto Use = DFG.addr<UseNode *>(UseID);
373 for (
const auto&
I :
L.getRealUses(
Phi.
Id)) {
374 if (DFG.getPRI().alias(RegisterRef(
I.first), DefReg)) {
375 for (
const auto &UA :
I.second)
376 Uses.emplace(UA.first);
387 for (
auto UseID :
Uses) {
388 if (!UsesVisited.
insert(UseID).second)
391 auto Use = DFG.addr<UseNode *>(UseID);
405 if (instrUsesRegToAccessMemory(
UseMI, UseMO.
getReg()) ||
417 for (
const auto &ChildDef :
418 Owner.Addr->members_if(DataFlowGraph::IsDef, DFG)) {
419 if (!DefsVisited.
insert(ChildDef.Id).second)
423 if (
Def.
Id == ChildDef.Id)
426 AnalyzeDefUseChain(ChildDef);
429 for (
auto TransmitterId : Transmitters[ChildDef.Id])
430 Transmitters[
Def.
Id].push_back(TransmitterId);
436 auto &DefTransmitters = Transmitters[
Def.
Id];
441 DefTransmitters.end());
445 AnalyzeDefUseChain(SourceDef);
446 auto &SourceDefTransmitters = Transmitters[SourceDef.Id];
447 if (SourceDefTransmitters.empty())
450 MachineInstr *
Source = SourceDef.Addr->getFlags() & NodeAttrs::PhiRef
451 ? MachineGadgetGraph::ArgNodeSentinel
453 auto GadgetSource = MaybeAddNode(Source);
455 for (
auto TransmitterId : SourceDefTransmitters) {
456 MachineInstr *
Sink = DFG.addr<StmtNode *>(TransmitterId).Addr->getCode();
457 auto GadgetSink = MaybeAddNode(Sink);
459 Builder.addEdge(MachineGadgetGraph::GadgetEdgeSentinel,
460 GadgetSource.first, GadgetSink.first);
465 LLVM_DEBUG(
dbgs() <<
"Analyzing def-use chains to find gadgets\n");
467 NodeAddr<BlockNode *> EntryBlock = DFG.getFunc().Addr->getEntryBlock(DFG);
468 for (NodeAddr<PhiNode *> ArgPhi :
469 EntryBlock.Addr->members_if(DataFlowGraph::IsPhi, DFG)) {
470 NodeList Defs = ArgPhi.Addr->members_if(DataFlowGraph::IsDef, DFG);
474 for (NodeAddr<BlockNode *> BA : DFG.getFunc().Addr->members(DFG)) {
475 for (NodeAddr<StmtNode *> SA :
476 BA.Addr->members_if(DataFlowGraph::IsCode<NodeAttrs::Stmt>, DFG)) {
477 MachineInstr *
MI = SA.Addr->getCode();
481 }
else if (
MI->mayLoad()) {
482 NodeList Defs = SA.Addr->members_if(DataFlowGraph::IsDef, DFG);
489 if (GadgetCount == 0)
491 NumGadgets += GadgetCount;
494 SmallPtrSet<MachineBasicBlock *, 8> BlocksVisited;
495 std::function<void(MachineBasicBlock *, GraphIter,
unsigned)> TraverseCFG =
496 [&](MachineBasicBlock *
MBB, GraphIter GI,
unsigned ParentDepth) {
501 auto BeginBB = MaybeAddNode(&*NI);
502 Builder.addEdge(ParentDepth, GI, BeginBB.first);
508 while (++NI !=
MBB->
end()) {
510 if (
Ref != NodeMap.
end()) {
511 Builder.addEdge(LoopDepth, GI,
Ref->getSecond());
512 GI =
Ref->getSecond();
519 auto EndBB = MaybeAddNode(&*
T);
521 Builder.addEdge(LoopDepth, GI, EndBB.first);
526 TraverseCFG(Succ, GI, LoopDepth);
530 GraphIter ArgNode = MaybeAddNode(MachineGadgetGraph::ArgNodeSentinel).first;
531 TraverseCFG(&MF.
front(), ArgNode, 0);
532 std::unique_ptr<MachineGadgetGraph>
G{Builder.get(FenceCount, GadgetCount)};
538int X86LoadValueInjectionLoadHardeningPass::elimMitigatedEdgesAndNodes(
539 MachineGadgetGraph &
G, EdgeSet &ElimEdges ,
540 NodeSet &ElimNodes )
const {
541 if (
G.NumFences > 0) {
544 for (
const Edge &
E :
G.edges()) {
545 const Node *Dest =
E.getDest();
546 if (isFence(Dest->getValue())) {
549 for (
const Edge &DE : Dest->edges())
550 ElimEdges.insert(DE);
556 int RemainingGadgets = 0;
557 NodeSet ReachableNodes{
G};
558 for (
const Node &RootN :
G.nodes()) {
559 if (
llvm::none_of(RootN.edges(), MachineGadgetGraph::isGadgetEdge))
563 ReachableNodes.
clear();
564 std::function<void(
const Node *,
bool)> FindReachableNodes =
565 [&](
const Node *
N,
bool FirstNode) {
568 for (
const Edge &
E :
N->edges()) {
569 const Node *Dest =
E.getDest();
570 if (MachineGadgetGraph::isCFGEdge(
E) && !ElimEdges.contains(
E) &&
571 !ReachableNodes.contains(*Dest))
572 FindReachableNodes(Dest,
false);
575 FindReachableNodes(&RootN,
true);
578 for (
const Edge &
E : RootN.edges()) {
579 if (MachineGadgetGraph::isGadgetEdge(
E)) {
580 if (ReachableNodes.contains(*
E.getDest())) {
589 return RemainingGadgets;
592std::unique_ptr<MachineGadgetGraph>
593X86LoadValueInjectionLoadHardeningPass::trimMitigatedEdges(
594 std::unique_ptr<MachineGadgetGraph> Graph)
const {
595 NodeSet ElimNodes{*Graph};
596 EdgeSet ElimEdges{*Graph};
597 int RemainingGadgets =
598 elimMitigatedEdgesAndNodes(*Graph, ElimEdges, ElimNodes);
599 if (ElimEdges.empty() && ElimNodes.
empty()) {
600 Graph->NumFences = 0;
601 Graph->NumGadgets = RemainingGadgets;
603 Graph = GraphBuilder::trim(*Graph, ElimNodes, ElimEdges, 0 ,
609int X86LoadValueInjectionLoadHardeningPass::hardenLoadsWithPlugin(
610 MachineFunction &MF, std::unique_ptr<MachineGadgetGraph> Graph)
const {
611 int FencesInserted = 0;
615 Graph = trimMitigatedEdges(std::move(Graph));
617 if (Graph->NumGadgets == 0)
621 EdgeSet CutEdges{*Graph};
622 auto Nodes = std::make_unique<unsigned int[]>(Graph->nodes_size() +
624 auto Edges = std::make_unique<unsigned int[]>(Graph->edges_size());
625 auto EdgeCuts = std::make_unique<int[]>(Graph->edges_size());
626 auto EdgeValues = std::make_unique<int[]>(Graph->edges_size());
627 for (
const Node &
N : Graph->nodes()) {
628 Nodes[Graph->getNodeIndex(
N)] = Graph->getEdgeIndex(*
N.edges_begin());
630 Nodes[Graph->nodes_size()] = Graph->edges_size();
631 for (
const Edge &
E : Graph->edges()) {
632 Edges[Graph->getEdgeIndex(
E)] = Graph->getNodeIndex(*
E.getDest());
633 EdgeValues[Graph->getEdgeIndex(
E)] =
E.getValue();
635 OptimizeCut(Nodes.get(), Graph->nodes_size(), Edges.get(), EdgeValues.get(),
636 EdgeCuts.get(), Graph->edges_size());
637 for (
int I = 0;
I < Graph->edges_size(); ++
I)
644 FencesInserted += insertFences(MF, *Graph, CutEdges);
646 LLVM_DEBUG(
dbgs() <<
"Inserted " << FencesInserted <<
" fences\n");
648 Graph = GraphBuilder::trim(*Graph, NodeSet{*Graph}, CutEdges);
651 return FencesInserted;
654int X86LoadValueInjectionLoadHardeningPass::hardenLoadsWithHeuristic(
655 MachineFunction &MF, std::unique_ptr<MachineGadgetGraph> Graph)
const {
658 if (Graph->NumFences > 0) {
660 Graph = trimMitigatedEdges(std::move(Graph));
664 if (Graph->NumGadgets == 0)
668 EdgeSet CutEdges{*Graph};
671 DenseMap<const Node *, SmallVector<const Edge *, 2>> IngressEdgeMap;
672 for (
const Edge &
E : Graph->edges())
673 if (MachineGadgetGraph::isCFGEdge(
E))
674 IngressEdgeMap[
E.getDest()].push_back(&
E);
684 for (
const Node &
N : Graph->nodes()) {
685 for (
const Edge &
E :
N.edges()) {
686 if (!MachineGadgetGraph::isGadgetEdge(
E))
691 for (
const Edge &EgressEdge :
N.edges())
692 if (MachineGadgetGraph::isCFGEdge(EgressEdge))
695 int EgressCutCost = 0, IngressCutCost = 0;
696 for (
const Edge *EgressEdge : EgressEdges)
697 if (!CutEdges.contains(*EgressEdge))
698 EgressCutCost += EgressEdge->getValue();
699 for (
const Edge *IngressEdge : IngressEdges)
700 if (!CutEdges.contains(*IngressEdge))
701 IngressCutCost += IngressEdge->getValue();
704 IngressCutCost < EgressCutCost ? IngressEdges : EgressEdges;
705 for (
const Edge *
E : EdgesToCut)
713 int FencesInserted = insertFences(MF, *Graph, CutEdges);
715 LLVM_DEBUG(
dbgs() <<
"Inserted " << FencesInserted <<
" fences\n");
717 return FencesInserted;
720int X86LoadValueInjectionLoadHardeningPass::insertFences(
721 MachineFunction &MF, MachineGadgetGraph &
G,
722 EdgeSet &CutEdges )
const {
723 int FencesInserted = 0;
724 for (
const Node &
N :
G.nodes()) {
725 for (
const Edge &
E :
N.edges()) {
726 if (CutEdges.contains(
E)) {
727 MachineInstr *
MI =
N.getValue(), *Prev;
728 MachineBasicBlock *
MBB;
730 if (
MI == MachineGadgetGraph::ArgNodeSentinel) {
735 }
else if (
MI->isBranch()) {
736 MBB =
MI->getParent();
738 Prev =
MI->getPrevNode();
741 for (
const Edge &
E :
N.edges()) {
742 if (MachineGadgetGraph::isCFGEdge(
E))
746 MBB =
MI->getParent();
747 InsertionPt =
MI->getNextNode() ?
MI->getNextNode() :
MBB->
end();
748 Prev = InsertionPt ==
MBB->
end()
750 : InsertionPt->getPrevNode();
753 if ((InsertionPt ==
MBB->
end() || !isFence(&*InsertionPt)) &&
754 (!Prev || !isFence(Prev))) {
761 return FencesInserted;
764bool X86LoadValueInjectionLoadHardeningPass::instrUsesRegToAccessMemory(
766 if (!
MI.mayLoadOrStore() ||
MI.getOpcode() == X86::MFENCE ||
767 MI.getOpcode() == X86::SFENCE ||
MI.getOpcode() == X86::LFENCE)
771 if (MemRefBeginIdx < 0) {
772 LLVM_DEBUG(
dbgs() <<
"Warning: unable to obtain memory operand for loading "
778 const MachineOperand &BaseMO =
780 const MachineOperand &IndexMO =
788bool X86LoadValueInjectionLoadHardeningPass::instrUsesRegToBranch(
790 if (!
MI.isConditionalBranch())
792 for (
const MachineOperand &Use :
MI.uses())
799 "X86 LVI load hardening",
false,
false)
807 return new X86LoadValueInjectionLoadHardeningPass();
MachineInstrBuilder & UseMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseMap class.
const HexagonInstrInfo * TII
Description: ImmutableGraph is a fast DAG implementation that cannot be modified, except by creating ...
Register const TargetRegisterInfo * TRI
Promote Memory to Register
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Remove Loads Into Fake Uses
std::pair< BasicBlock *, BasicBlock * > Edge
This file defines the SmallSet class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
int(* OptimizeCutT)(unsigned int *Nodes, unsigned int NodesSize, unsigned int *Edges, int *EdgeValues, int *CutEdges, unsigned int EdgesSize)
static cl::opt< bool > EmitDot(PASS_KEY "-dot", cl::desc("For each function, emit a dot graph depicting potential LVI gadgets"), cl::init(false), cl::Hidden)
static cl::opt< std::string > OptimizePluginPath(PASS_KEY "-opt-plugin", cl::desc("Specify a plugin to optimize LFENCE insertion"), cl::Hidden)
static void writeGadgetGraph(raw_ostream &OS, MachineFunction &MF, MachineGadgetGraph *G)
static cl::opt< bool > EmitDotVerify(PASS_KEY "-dot-verify", cl::desc("For each function, emit a dot graph to stdout depicting " "potential LVI gadgets, used for testing purposes only"), cl::init(false), cl::Hidden)
static llvm::sys::DynamicLibrary OptimizeDL
static OptimizeCutT OptimizeCut
static cl::opt< bool > EmitDotOnly(PASS_KEY "-dot-only", cl::desc("For each function, emit a dot graph depicting potential LVI " "gadgets, and do not insert any fences"), cl::init(false), cl::Hidden)
static cl::opt< bool > NoConditionalBranches(PASS_KEY "-no-cbranch", cl::desc("Don't treat conditional branches as disclosure gadgets. This " "may improve performance, at the cost of security."), cl::init(false), cl::Hidden)
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
iterator find(const_arg_type_t< KeyT > Val)
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
FunctionPass class - This class is used to implement most global optimizations.
unsigned getLoopDepth(const BlockT *BB) const
Return the loop nesting level of the specified block.
LLVM_ABI iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
iterator_range< succ_iterator > successors()
MachineInstrBundleIterator< MachineInstr > iterator
Analysis pass which computes a MachineDominatorTree.
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
const MachineBasicBlock & front() const
Representation of each machine instruction.
const MachineBasicBlock * getParent() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
Register getReg() const
getReg - Returns the register number.
A NodeSet contains a set of SUnit DAG nodes with additional information that assigns a priority to th...
virtual void print(raw_ostream &OS, const Module *M) const
print - Print out the internal state of the pass.
Wrapper class representing virtual and physical registers.
constexpr bool isValid() const
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
void push_back(const T &Elt)
StringRef - Represent a constant reference to a string, i.e.
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
const X86InstrInfo * getInstrInfo() const override
const X86RegisterInfo * getRegisterInfo() const override
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an std::string.
std::string & str()
Returns the string's reference.
This class provides a portable interface to dynamic libraries which also might be known as shared lib...
static LLVM_ABI DynamicLibrary getPermanentLibrary(const char *filename, std::string *errMsg=nullptr)
This function permanently loads the dynamic library at the given path using the library load operatio...
LLVM_ABI void * getAddressOfSymbol(const char *symbolName)
Searches through the library for the symbol symbolName.
bool isValid() const
Returns true if the object refers to a valid library.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
int getFirstAddrOperandIdx(const MachineInstr &MI)
Return the index of the instruction's first address operand, if it has a memory reference,...
initializer< Ty > init(const Ty &Val)
NodeAddr< DefNode * > Def
NodeAddr< PhiNode * > Phi
NodeAddr< UseNode * > Use
std::set< NodeId > NodeSet
SmallVector< Node, 4 > NodeList
This is an optimization pass for GlobalISel generic memory operations.
UnaryFunction for_each(R &&Range, UnaryFunction F)
Provide wrappers to std::for_each which take ranges instead of having to pass begin/end explicitly.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
FunctionPass * createX86LoadValueInjectionLoadHardeningPass()
LLVM_ABI raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
raw_ostream & WriteGraph(raw_ostream &O, const GraphType &G, bool ShortNames=false, const Twine &Title="")
auto unique(Range &&R, Predicate P)
void sort(IteratorTy Start, IteratorTy End)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
@ Ref
The access may reference the value stored in memory.
typename Traits::NodeRef NodeRef
static std::string getNodeAttributes(NodeRef Node, GraphType *)
typename Traits::ChildIteratorType ChildIteratorType
std::string getNodeLabel(NodeRef Node, GraphType *)
static std::string getEdgeAttributes(NodeRef, ChildIteratorType E, GraphType *)
MachineGadgetGraph GraphType
typename Traits::EdgeRef EdgeRef
typename Traits::ChildEdgeIteratorType ChildEdgeIteratorType
llvm::GraphTraits< GraphType * > Traits
DOTGraphTraits(bool IsSimple=false)
DefaultDOTGraphTraits(bool simple=false)
typename GraphType::UnknownGraphTypeError NodeRef
uint16_t getAttrs() const
uint16_t getFlags() const
RegisterRef getRegRef(const DataFlowGraph &G) const
Node getOwner(const DataFlowGraph &G)