Safe Haskell | None |
---|
LLVM.Analysis.CFG
Contents
Description
This module defines control flow graphs over the LLVM IR.
- data CFG = CFG {
- cfgGraph :: CFGType
- cfgEntryValue :: Instruction
- cfgEntryNode :: NodeType
- cfgExitValue :: Instruction
- cfgExitNode :: NodeType
- cfgFunction :: Function
- data RCFG = RCFG {
- rcfgGraph :: CFGType
- rcfgEntryValue :: Instruction
- rcfgEntryNode :: NodeType
- rcfgExitValue :: Instruction
- rcfgExitNode :: NodeType
- rcfgFunction :: Function
- data CFGEdge
- = UnconditionalEdge
- | DefaultEdge
- | TrueEdge Value
- | FalseEdge Value
- | EqualityEdge Value Value
- | IndirectEdge Value
- | NormalEdge Instruction
- | UnwindEdge Instruction
- type CFGType = DenseDigraph Instruction CFGEdge
- class HasCFG a where
- mkCFG :: Function -> CFG
- reverseCFG :: CFG -> RCFG
- basicBlockPredecessors :: CFG -> BasicBlock -> [BasicBlock]
- basicBlockSuccessors :: CFG -> BasicBlock -> [BasicBlock]
- basicBlockPredecessorEdges :: CFG -> BasicBlock -> [CFGEdge]
- basicBlockSuccessorEdges :: CFG -> BasicBlock -> [CFGEdge]
- basicBlockLabeledPredecessors :: CFG -> BasicBlock -> [(BasicBlock, CFGEdge)]
- basicBlockLabeledSuccessors :: CFG -> BasicBlock -> [(BasicBlock, CFGEdge)]
- instructionReachable :: CFG -> Instruction -> Bool
- cfgGraphvizRepr :: CFG -> DotGraph NodeType
Types
The control flow graph representation
Constructors
CFG | |
Fields
|
Instances
HasFunction CFG | |
FuncLike CFG | |
HasCFG CFG | |
HasPostdomTree CFG | |
HasDomTree CFG |
The control flow graph with the edges reversed
Constructors
RCFG | |
Fields
|
Instances
HasFunction RCFG | |
HasPostdomTree RCFG |
The types of edges that appear in the CFG
Constructors
UnconditionalEdge | An unconditional jump from somewhere |
DefaultEdge | A default jump due to a case statement |
TrueEdge Value | True edge successor for the comparison contained in the value. This value was the argument to the branch instruction. |
FalseEdge Value | False edge successor for the comparison contained in the value. This value was the argument to a branch instruction. |
EqualityEdge Value Value | A case equality edge (the case value v1 was equal to val v2) |
IndirectEdge Value | Jump from the given indirect branch value |
NormalEdge Instruction | The normal return from an invoke |
UnwindEdge Instruction | Exceptional return from an invoke |
Types that have control flow graphs.
Constructors
mkCFG :: Function -> CFGSource
Build a control flow graph for the given function. Each instruction in the function body is a node in the graph. Branching instructions induce edges. This form of the CFG is fine-grained in that each instruction has its own CFG node.
The other function, mkCompactCFG
, has a basic-block-granularity
CFG that can be easier to visualize.
reverseCFG :: CFG -> RCFGSource
Accessors
basicBlockPredecessors :: CFG -> BasicBlock -> [BasicBlock]Source
Get all of the predecessor blocks for basic block bb
basicBlockPredecessors cfg bb
basicBlockSuccessors :: CFG -> BasicBlock -> [BasicBlock]Source
Get all of the successor blocks for basic block bb
basicBlockSuccessors cfg bb
basicBlockPredecessorEdges :: CFG -> BasicBlock -> [CFGEdge]Source
basicBlockSuccessorEdges :: CFG -> BasicBlock -> [CFGEdge]Source
basicBlockLabeledPredecessors :: CFG -> BasicBlock -> [(BasicBlock, CFGEdge)]Source
basicBlockLabeledSuccessors :: CFG -> BasicBlock -> [(BasicBlock, CFGEdge)]Source
instructionReachable :: CFG -> Instruction -> BoolSource
An instruction is reachable if its basic block has predecessors *OR* (if there are no predecessors) it is the first basic block.
Visualization
cfgGraphvizRepr :: CFG -> DotGraph NodeTypeSource