retdec
|
A converter of the LLVM function structure. More...
#include <structure_converter.h>
Public Member Functions | |
StructureConverter (llvm::Pass *basePass, ShPtr< LLVMValueConverter > conv, ShPtr< Module > module) | |
Constructs a new structure converter. More... | |
ShPtr< Statement > | convertFuncBody (llvm::Function &func) |
Converts body of the given LLVM function func into a sequence of statements in BIR which include conditional statements and loops. More... | |
Private Types | |
enum class | DFSNodeState { Opened , Closed } |
Information about state of node during DFS traversal. More... | |
using | SwitchClause = std::pair< ExprVector, ShPtr< CFGNode > > |
using | BBSet = std::unordered_set< llvm::BasicBlock * > |
using | CFGNodeQueue = std::queue< ShPtr< CFGNode > > |
using | CFGNodeStack = std::stack< ShPtr< CFGNode > > |
using | CFGNodeVector = std::vector< ShPtr< CFGNode > > |
using | LoopSet = std::unordered_set< llvm::Loop * > |
using | SwitchClauseVector = std::vector< ShPtr< SwitchClause > > |
using | MapBBToBBSet = std::unordered_map< llvm::BasicBlock *, BBSet > |
using | MapBBToCFGNode = std::unordered_map< llvm::BasicBlock *, ShPtr< CFGNode > > |
using | MapCFGNodeToSwitchClause = std::unordered_map< ShPtr< CFGNode >, ShPtr< SwitchClause > > |
using | MapCFGNodeToDFSNodeState = std::unordered_map< ShPtr< CFGNode >, DFSNodeState > |
using | MapLoopToCFGNode = std::unordered_map< llvm::Loop *, ShPtr< CFGNode > > |
using | MapStmtToTargetNode = std::unordered_map< ShPtr< Statement >, ShPtr< CFGNode > > |
using | MapTargetToGoto = std::unordered_map< ShPtr< CFGNode >, std::vector< ShPtr< GotoStmt > >> |
using | MapStmtToClones = std::unordered_map< ShPtr< Statement >, std::vector< ShPtr< Statement > >> |
Private Member Functions | |
Construction and traversal through control-flow graph | |
ShPtr< CFGNode > | createCFG (llvm::BasicBlock &root) |
Creates control-flow graph of the function from the given root basic block root. More... | |
void | detectBackEdges (ShPtr< CFGNode > cfg) const |
Traverses the given control-flow graph cfg and detects all back edges. More... | |
bool | reduceCFG (ShPtr< CFGNode > cfg) |
Traverses the given control-flow graph cfg and tries to reduce some nodes to control-flow statements. More... | |
bool | inspectCFGNode (ShPtr< CFGNode > node) |
Inspects the given CFG node node and tries to reduce this and neighboring nodes to any control-flow statement. More... | |
ShPtr< CFGNode > | popFromQueue (CFGNodeQueue &queue) const |
Pop and return node from the given queue queue. More... | |
void | addUnvisitedSuccessorsToQueue (const ShPtr< CFGNode > &node, CFGNodeQueue &toBeVisited, CFGNode::CFGNodeSet &visited) const |
Adds all unvisited successors of the given node node to the queue toBeVisited and also to the set of visited nodes visited. More... | |
void | addUnvisitedSuccessorsToQueueInLoop (const ShPtr< CFGNode > &node, CFGNodeQueue &toBeVisited, CFGNode::CFGNodeSet &visited, llvm::Loop *loop) const |
Adds all unvisited successors inside loop loop of the given node node to the queue toBeVisited and also to the set of visited nodes visited. More... | |
bool | BFSTraverse (ShPtr< CFGNode > cfg, std::function< bool(ShPtr< CFGNode >)> inspectFunc) const |
Traverses the given control-flow graph cfg using breadth-first search and inspect every node by function inspectFunc. More... | |
bool | BFSTraverseLoop (ShPtr< CFGNode > cfg, std::function< bool(ShPtr< CFGNode >)> inspectFunc) const |
Traverses the given control-flow graph cfg of a loop using breadth-first search and inspect every node by function inspectFunc. More... | |
ShPtr< CFGNode > | BFSFindFirst (ShPtr< CFGNode > cfg, std::function< bool(ShPtr< CFGNode >)> pred) const |
Traverses the given control-flow graph cfg using breadth-first search and returns first node which satisfies the predicate pred. More... | |
bool | existsPathWithoutLoopsBetween (const ShPtr< CFGNode > &node1, const ShPtr< CFGNode > &node2) const |
Determines whether exists direct path (without loops) between two given nodes node1 and node2. More... | |
Detection of constructions | |
bool | isSequence (const ShPtr< CFGNode > &node) const |
Determines whether the given node node can be reduced with following node as a sequence. More... | |
bool | isSequenceWithTerminatingBranchToClone (const ShPtr< CFGNode > &node) const |
Determines whether the given node node can be reduced with following node as a sequence, where is cloned the terminating successor. More... | |
bool | isIfElseStatement (const ShPtr< CFGNode > &node) const |
Determines whether the given the given node node is an if statement with else clause. More... | |
bool | isIfStatement (const ShPtr< CFGNode > &node, std::size_t succ) const |
Determines whether the given node node is an if statement without else clause and if body is in the successor on index succ. More... | |
bool | isIfStatementWithTerminatingBranch (const ShPtr< CFGNode > &node, std::size_t succ) const |
Determines whether the given node node is an if statement and successor on the index succ is terminated (e.g. by return). More... | |
bool | isIfStatementWithTerminatingBranchToClone (const ShPtr< CFGNode > &node, std::size_t succ) const |
Determines whether the given node node is an if statement and successor on the index succ is terminated (e.g. by return). More... | |
bool | isIfStatementWithBreakInLoop (const ShPtr< CFGNode > &node, std::size_t succ) const |
Determines whether the given node node is an if statement without else clause and in its successor on the index succ schould be break. More... | |
bool | isIfStatementWithBreakByGotoInLoop (const ShPtr< CFGNode > &node, std::size_t succ) const |
Determines whether the given node node is an if statement without else clause and in its successor on the index succ is outside loop. More... | |
bool | isIfElseStatementWithContinue (const ShPtr< CFGNode > &node, std::size_t succ) const |
Determines whether the given node node is an if statement without else clause and in its successor on the index succ schould be continue. More... | |
bool | isContinueStatement (const ShPtr< CFGNode > &node) const |
Determines whether the given node node is terminated by continue statement. More... | |
bool | isForLoop (const ShPtr< CFGNode > &node) const |
Determines whether the given node node is a reducible for loop. More... | |
bool | isWhileTrueLoop (const ShPtr< CFGNode > &node) const |
Determines whether the given node node is a while(true) loop. More... | |
bool | isNestedWhileTrueLoopWithContinueInHeader (const ShPtr< CFGNode > &node, std::size_t succ) const |
Determines whether the given node node is a while(true) statement, when on the index succ is the body of the loop and on the other index is continue statement to the parent loop. More... | |
bool | isSwitchStatement (const ShPtr< CFGNode > &node) const |
Determines whether the given node node is a switch statement. More... | |
bool | canBeCloned (const ShPtr< CFGNode > &node) const |
Determines whether the given node node can be cloned. More... | |
Reduction of nodes | |
void | reduceToSequence (ShPtr< CFGNode > node) |
Reduces node node and its only successor into a single node which contains merged bodies of both nodes. More... | |
void | reduceToSequenceClone (ShPtr< CFGNode > node) |
Reduces node node and its only successor into a single node which contains merged bodies of both nodes, where is cloned the terminating successor. More... | |
void | reduceToIfElseStatement (ShPtr< CFGNode > node) |
Reduces node node and both its successors into a single node with if statement with else clause. More... | |
void | reduceToIfStatement (ShPtr< CFGNode > node, std::size_t succ) |
Reduces node node and its successor on index succ into a single node with if statement without else clause. More... | |
void | reduceToIfStatementClone (ShPtr< CFGNode > node, std::size_t succ) |
Reduces node node and its successor on index succ into a single node with if statement without else clause. The body of the node on index succ is cloned. More... | |
void | reduceToIfElseStatementWithBreakInLoop (ShPtr< CFGNode > node, std::size_t succ) |
Reduces node node and its successor on index succ into a single node with if statement with break statement inside. More... | |
void | reduceToIfElseStatementWithBreakByGotoInLoop (ShPtr< CFGNode > node, std::size_t succ) |
Reduces node node and its successor on index succ into a single node with if statement with goto statement inside. More... | |
void | reduceToIfElseStatementWithContinue (ShPtr< CFGNode > node, std::size_t succ) |
Reduces node node and its successor on index succ into a single node with if statement with continue statement inside. More... | |
void | reduceToContinueStatement (ShPtr< CFGNode > node) |
Reduces node node into a node which is terminated by switch statement. More... | |
void | reduceToForLoop (ShPtr< CFGNode > node) |
Reduces node node into a node with for loop. More... | |
void | reduceToWhileTrueLoop (ShPtr< CFGNode > node) |
Reduces node node into a node with while(true) loop. More... | |
void | reduceToNestedWhileTrueLoopWithContinueInHeader (ShPtr< CFGNode > node, std::size_t succ) |
Reduces the given node node is into a while(true) statement, when on the index succ is the body of the loop and on the other index is continue statement to the parent loop. More... | |
void | structureByGotos (ShPtr< CFGNode > cfg) |
Completely structures given CFG cfg using goto statements. More... | |
Condition refinement | |
ShPtr< Statement > | getIfClauseBody (const ShPtr< CFGNode > &node, const ShPtr< CFGNode > &clause, const ShPtr< CFGNode > &ifSuccessor) |
Creates a new body of the given if clause clause. More... | |
ShPtr< Statement > | getIfClauseBodyClone (const ShPtr< CFGNode > &node, const ShPtr< CFGNode > &clause, const ShPtr< CFGNode > &ifSuccessor) |
Creates a new body of the given if clause clause. The body of the clause is cloned. More... | |
ShPtr< IfStmt > | getIfStmt (const ShPtr< Expression > &cond, const ShPtr< Statement > &trueBody, const ShPtr< Statement > &falseBody=nullptr) const |
Returns new if statement with the given condition cond and true body trueBody and false body (else clause) falseBody. More... | |
Loop refinement | |
ShPtr< CFGNode > | getLoopSuccessor (const ShPtr< CFGNode > &loopNode) const |
Returns successor of the given loop node loopNode. More... | |
void | completelyReduceLoop (ShPtr< CFGNode > loopNode) |
Completely reduces the given loop node loopNode. More... | |
Switch refinement | |
void | reduceSwitchStatement (ShPtr< CFGNode > node) |
Reduces node node into a node with the switch statement. More... | |
ShPtr< CFGNode > | getSwitchSuccessor (const ShPtr< CFGNode > &switchNode) const |
Returns successor of the given switch node switchNode. More... | |
bool | isNodeAfterAllSwitchClauses (const ShPtr< CFGNode > &node, const ShPtr< CFGNode > &switchNode) const |
Determines whether the given node node is after all clauses of the given switch switchNode. More... | |
bool | isNodeAfterSwitchClause (const ShPtr< CFGNode > &node, const ShPtr< CFGNode > &clauseNode) const |
Determines whether the given node node is after the given switch clause clauseNode. More... | |
bool | hasDefaultClause (const ShPtr< CFGNode > &switchNode, const ShPtr< CFGNode > &switchSuccessor) const |
Determines whether the given switch node switchNode has a default clause. More... | |
bool | isReducibleClause (const ShPtr< CFGNode > &clauseNode, const ShPtr< CFGNode > &switchNode, const ShPtr< CFGNode > &switchSuccessor, bool hasDefault=true) const |
Determines whether the given switch clause clauseNode is a clause ready to be reduced. More... | |
bool | hasOnlySwitchOrClausesInPreds (const ShPtr< CFGNode > &clauseNode, const ShPtr< CFGNode > &switchNode, bool hasDefault) const |
Determines whether the given switch clause clauseNode has only switch node or other clauses in predecessors. More... | |
bool | fallsThroughToAnotherCase (const ShPtr< CFGNode > &clauseNode, const ShPtr< CFGNode > &switchNode, bool hasDefault) const |
Determines whether the given switch clause clauseNode falls through to the another case clause or to the default clause. More... | |
ShPtr< SwitchStmt > | getSwitchStmt (const ShPtr< CFGNode > &switchNode, const ShPtr< CFGNode > &switchSuccessor, bool hasDefault) |
Returns new switch statement which is created from the given switch node switchNode. More... | |
SwitchClauseVector | getSwitchClauses (const ShPtr< CFGNode > &switchNode, bool hasDefault) const |
Returns a vector of clauses of the given switch node switchNode. More... | |
SwitchClauseVector | sortSwitchClauses (const SwitchClauseVector &clauses, const ShPtr< CFGNode > &switchSuccessor) const |
Returns sorted vector of switch clauses clauses. More... | |
ShPtr< SwitchClause > | findFirstClauseWithSinglePred (const SwitchClauseVector &clauses) const |
Returns first switch clause from the vector of clauses clauses which has only single predecessor. More... | |
ShPtr< Statement > | getClauseBody (const ShPtr< CFGNode > &clauseNode, const ShPtr< CFGNode > &switchNode, const ShPtr< CFGNode > &switchSuccessor, const CFGNode::CFGNodeSet &generated) |
Returns new case clause of the switch statement which is created from the given switch node clauseNode. More... | |
bool | isClauseTerminatedByBreak (const ShPtr< CFGNode > &clauseNode, const ShPtr< CFGNode > &switchSuccessor) const |
Determines whether the given switch clause clauseNode is terminated by a break statement. More... | |
void | addClausesWithTheSameCond (ShPtr< SwitchStmt > switchStmt, const ExprVector &conds, const ShPtr< Statement > &clauseBody) const |
Adds case clauses with different conditions, but with the same clause body to the given switch statement switchStmt. More... | |
void | removeReducedSuccsOfSwitch (const ShPtr< CFGNode > &switchNode, bool hasDefault) const |
Removes reduced successors of the given switch node switchNode. More... | |
Successor getters | |
ShPtr< Statement > | getSuccessorsBody (const ShPtr< CFGNode > &node, const ShPtr< CFGNode > &succ) |
Creates a new body of the given node node successor succ. More... | |
ShPtr< Statement > | getSuccessorsBodyClone (const ShPtr< CFGNode > &node, const ShPtr< CFGNode > &succ) |
Creates a new body of the given node node successor succ. The body of the successor is cloned. More... | |
ShPtr< Statement > | getGotoForSuccessor (const ShPtr< CFGNode > &node, const ShPtr< CFGNode > &target) |
Creates a goto statement which jumps from the given node node to the given target node target. More... | |
ShPtr< Statement > | getAssignsToPHINodes (const ShPtr< CFGNode > &from, const ShPtr< CFGNode > &to) |
Returns assignments to the PHI nodes from the given node from and to the given node to. More... | |
ShPtr< Statement > | getPHICopiesForSuccessor (llvm::BasicBlock *currBB, llvm::BasicBlock *succ) |
Returns PHI copies for the given basic block currBB and its successor succ. More... | |
Work with LLVM analyses | |
void | initialiazeLLVMAnalyses (llvm::Function &func) |
Initializes required LLVM analyses for converted function func. More... | |
llvm::Loop * | getLoopFor (const ShPtr< CFGNode > &node) const |
Returns the innermost loop for the given node node. If node is not inside loop, returns nulptr. More... | |
bool | isLoopHeader (const ShPtr< CFGNode > &node) const |
Determines whether the given node node is a loop header. More... | |
bool | isLoopHeader (const ShPtr< CFGNode > &node, llvm::Loop *loop) const |
Determines whether the given node node is a header of the given loop loop. More... | |
bool | isNodeOutsideLoop (const ShPtr< CFGNode > &node, llvm::Loop *loop) const |
Determines whether the given node node is outside of the given loop loop. More... | |
bool | isInParentLoopOf (const ShPtr< CFGNode > &node, llvm::Loop *loop) const |
Determines whether the given node node is in the parent loop of the given loop loop. More... | |
unsigned | getTripCount (llvm::Loop *loop) const |
Returns number of iterations for the given for loop loop. If loop is not a for loop, it returns zero. More... | |
bool | canBeForLoop (llvm::Loop *loop) const |
Determines whether the given loop loop can be a for loop. More... | |
Postprocessing methods | |
ShPtr< Statement > | replaceBreakOrContinueOutsideLoop (ShPtr< Statement > statement, SwitchParent sp) |
Replaces break/continue statements that are outside of loop with goto statements. More... | |
void | replaceGoto (CFGNodeVector &targets) |
Replaces goto with code if there is only one reference to it. More... | |
void | correctUndefinedLabels () |
If goto target label is not used in code, it is replaced with its clone (that is used) More... | |
std::vector< ShPtr< Statement > > | findContinueOrBreakStatements (ShPtr< Statement > parent, SwitchParent sp) |
Finds break and continue statements in cloned statements. More... | |
unsigned | getStatementCount (ShPtr< Statement > statement) |
Returns number of statements in parent statement (body of if/while etc.) More... | |
void | insertClonedLoopTargets (ShPtr< Statement > origParent, ShPtr< Statement > newParent) |
Inserts cloned break/continue stmts in case they need replacing. More... | |
void | fixClonedGotos (ShPtr< Statement > statement) |
Helper methods | |
void | addGotoTargetIfNotExists (const ShPtr< CFGNode > &node) |
Adds node node to the vector of the goto targets if it isn't already there. More... | |
void | addBranchMetadataToEndOfBodyIfNeeded (ShPtr< Statement > &body, const ShPtr< CFGNode > &clause, const ShPtr< CFGNode > &ifSuccessor) const |
Adds metadata of the form "branch -> xxx" to the body of the given if statement (if needed). More... | |
std::string | getLabel (const ShPtr< CFGNode > &node) const |
Returns a label of the given node node. More... | |
void | cleanUp () |
Cleans up the helper containers. More... | |
![]() | |
NonCopyable (const NonCopyable &)=delete | |
NonCopyable & | operator= (const NonCopyable &)=delete |
NonCopyable ()=default | |
~NonCopyable ()=default | |
A converter of the LLVM function structure.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
strongprivate |
retdec::llvmir2hll::StructureConverter::StructureConverter | ( | llvm::Pass * | basePass, |
ShPtr< LLVMValueConverter > | conv, | ||
ShPtr< Module > | module | ||
) |
Constructs a new structure converter.
[in] | basePass | Pass that have instantiated the converter. |
[in] | conv | A converter from LLVM values to values in BIR. |
[in] | module | A module this converter works on. Needed only for debugging purposes. |
|
private |
Adds metadata of the form "branch -> xxx" to the body of the given if statement (if needed).
|
private |
Adds case
clauses with different conditions, but with the same clause body to the given switch statement switchStmt.
[out] | switchStmt | Given switch statement. |
[in] | conds | Given vector of conditions with the same clause body. |
[in] | clauseBody | Given clause clauseBody. |
|
private |
Adds node node to the vector of the goto targets if it isn't already there.
|
private |
Adds all unvisited successors of the given node node to the queue toBeVisited and also to the set of visited nodes visited.
|
private |
Adds all unvisited successors inside loop loop of the given node node to the queue toBeVisited and also to the set of visited nodes visited.
|
private |
Traverses the given control-flow graph cfg using breadth-first search and returns first node which satisfies the predicate pred.
|
private |
Traverses the given control-flow graph cfg using breadth-first search and inspect every node by function inspectFunc.
true
if inspection of any node return true
.
|
private |
Traverses the given control-flow graph cfg of a loop using breadth-first search and inspect every node by function inspectFunc.
true
if inspection of any node return true
.
|
private |
Determines whether the given node node can be cloned.
|
private |
Determines whether the given loop loop can be a for
loop.
Loop can be a for
loop when it has the induction variable and non-zero number of iterations.
|
private |
Cleans up the helper containers.
|
private |
Completely reduces the given loop node loopNode.
If loop cannot be reduced normally, it will be reduced by goto
statements.
Converts body of the given LLVM function func into a sequence of statements in BIR which include conditional statements and loops.
|
private |
If goto target label is not used in code, it is replaced with its clone (that is used)
|
private |
Creates control-flow graph of the function from the given root basic block root.
Traverses the given control-flow graph cfg and detects all back edges.
|
private |
Determines whether exists direct path (without loops) between two given nodes node1 and node2.
|
private |
Determines whether the given switch clause clauseNode falls through to the another case clause or to the default clause.
[in] | clauseNode | Given switch clause node. |
[in] | switchNode | Given switch node. |
[in] | hasDefault | Has switch default clause? |
|
private |
Finds break and continue statements in cloned statements.
|
private |
Returns first switch clause from the vector of clauses clauses which has only single predecessor.
Add goto statements created by cloning to targetReferences
container.
|
private |
Returns assignments to the PHI nodes from the given node from and to the given node to.
|
private |
Returns new case
clause of the switch
statement which is created from the given switch node clauseNode.
[in] | clauseNode | Given switch clause node. |
[in] | switchNode | Given switch node. |
[in] | switchSuccessor | Successor of the switch. |
[in] | generated | Already generated switch clauses. |
|
private |
Creates a goto
statement which jumps from the given node node to the given target node target.
|
private |
Creates a new body of the given if clause clause.
[in] | node | Given if statement node. |
[in] | clause | Given if clause node. |
[in] | ifSuccessor | Successor of the if statement. |
|
private |
Creates a new body of the given if clause clause. The body of the clause is cloned.
[in] | node | Given if statement node. |
[in] | clause | Given if clause node. |
[in] | ifSuccessor | Successor of the if statement. |
|
private |
Returns new if
statement with the given condition cond and true body trueBody
and false body (else clause) falseBody.
If the given trueBody contains only empty statements, the condition will be negated to produce non-empty body of the if
statement.
If the given falseBody ir nullptr
or contains only empty statements, the else clause will be omitted.
If both trueBody and falseBody contain only empty statements, nullptr
will be returned.
|
private |
Returns a label of the given node node.
|
private |
Returns the innermost loop for the given node node. If node is not inside loop, returns nulptr.
|
private |
Returns successor of the given loop node loopNode.
Loop also could have no successor. In that case, nullptr
is returned.
|
private |
Returns PHI copies for the given basic block currBB and its successor succ.
|
private |
Returns number of statements in parent statement (body of if/while etc.)
|
private |
Creates a new body of the given node node successor succ.
|
private |
Creates a new body of the given node node successor succ. The body of the successor is cloned.
|
private |
Returns a vector of clauses of the given switch node switchNode.
[in] | switchNode | Given switch node. |
[in] | hasDefault | Has switch default clause? |
|
private |
Returns new switch
statement which is created from the given switch node switchNode.
[in] | switchNode | Given switch node. |
[in] | switchSuccessor | Successor of the switch. |
[in] | hasDefault | Has switch default clause? |
|
private |
Returns successor of the given switch node switchNode.
Switch also could have no successor. In that case, nullptr
is returned.
|
private |
Returns number of iterations for the given for
loop loop. If loop is not a for
loop, it returns zero.
|
private |
Determines whether the given switch node switchNode has a default clause.
[in] | switchNode | Given switch node. |
[in] | switchSuccessor | Successor of the switch. |
|
private |
Determines whether the given switch clause clauseNode has only switch node or other clauses in predecessors.
[in] | clauseNode | Given switch clause node. |
[in] | switchNode | Given switch node. |
[in] | hasDefault | Has switch default clause? |
|
private |
Initializes required LLVM analyses for converted function func.
|
private |
Inserts cloned break/continue stmts in case they need replacing.
Inspects the given CFG node node and tries to reduce this and neighboring nodes to any control-flow statement.
true
if the node have been reduced.
|
private |
Determines whether the given switch clause clauseNode is terminated by a break statement.
[in] | clauseNode | Given switch clause node. |
[in] | switchSuccessor | Successor of the switch. |
|
private |
Determines whether the given node node is terminated by continue statement.
|
private |
Determines whether the given node node is a reducible for
loop.
|
private |
Determines whether the given the given node node is an if statement with else clause.
|
private |
Determines whether the given node node is an if statement without else clause and in its successor on the index succ schould be continue.
|
private |
Determines whether the given node node is an if statement without else clause and if body is in the successor on index succ.
|
private |
Determines whether the given node node is an if statement without else clause and in its successor on the index succ is outside loop.
|
private |
Determines whether the given node node is an if statement without else clause and in its successor on the index succ schould be break.
|
private |
Determines whether the given node node is an if statement and successor on the index succ is terminated (e.g. by return).
|
private |
Determines whether the given node node is an if statement and successor on the index succ is terminated (e.g. by return).
In comparation to method isIfStatementWithTerminatingBranch(), in this case cannot body of the terminating node be already reduced and in usage, body must be cloned.
|
private |
Determines whether the given node node is in the parent loop of the given loop loop.
This method returns true
also if loop does not have a parent and node is outside loop.
|
private |
Determines whether the given node node is a loop header.
|
private |
Determines whether the given node node is a header of the given loop loop.
|
private |
Determines whether the given node node is a while(true) statement, when on the index succ is the body of the loop and on the other index is continue
statement to the parent loop.
|
private |
Determines whether the given node node is after all clauses of the given switch switchNode.
|
private |
Determines whether the given node node is after the given switch clause clauseNode.
|
private |
Determines whether the given node node is outside of the given loop loop.
|
private |
Determines whether the given switch clause clauseNode is a clause ready to be reduced.
Clause is ready to be reduced, when it is in one of these states:
[in] | clauseNode | Given switch clause node. |
[in] | switchNode | Given switch node. |
[in] | switchSuccessor | Successor of the switch. |
[in] | hasDefault | Has switch default clause? |
|
private |
Determines whether the given node node can be reduced with following node as a sequence.
|
private |
Determines whether the given node node can be reduced with following node as a sequence, where is cloned the terminating successor.
|
private |
Determines whether the given node node is a switch statement.
|
private |
Determines whether the given node node is a while(true) loop.
|
private |
Pop and return node from the given queue queue.
Traverses the given control-flow graph cfg and tries to reduce some nodes to control-flow statements.
true
if any node have been reduced.Reduces node node into a node with the switch statement.
|
private |
Reduces node node into a node which is terminated by switch statement.
Reduces node node into a node with for
loop.
|
private |
Reduces node node and both its successors into a single node with if statement with else clause.
|
private |
Reduces node node and its successor on index succ into a single node with if statement with goto statement inside.
|
private |
Reduces node node and its successor on index succ into a single node with if statement with break statement inside.
|
private |
Reduces node node and its successor on index succ into a single node with if statement with continue statement inside.
|
private |
Reduces node node and its successor on index succ into a single node with if statement without else clause.
|
private |
Reduces node node and its successor on index succ into a single node with if statement without else clause. The body of the node on index succ is cloned.
|
private |
Reduces the given node node is into a while(true) statement, when on the index succ is the body of the loop and on the other index is continue
statement to the parent loop.
Reduces node node and its only successor into a single node which contains merged bodies of both nodes.
Reduces node node and its only successor into a single node which contains merged bodies of both nodes, where is cloned the terminating successor.
Reduces node node into a node with while(true) loop.
|
private |
Removes reduced successors of the given switch node switchNode.
[in] | switchNode | Given switch node. |
[in] | hasDefault | Has switch default clause? |
|
private |
Replaces break/continue statements that are outside of loop with goto statements.
|
private |
Replaces goto with code if there is only one reference to it.
|
private |
Returns sorted vector of switch clauses clauses.
[in] | clauses | Switch clauses to be sorted. |
[in] | switchSuccessor | Successor of the switch. |
Completely structures given CFG cfg using goto
statements.
|
private |
Pass that have instantiated the converter.
|
private |
A converter of the LLVM basic block.
|
private |
A converter from LLVM values to values in BIR.
|
private |
|
private |
A map of already generated phi nodes from specific basic blocks.
|
private |
|
private |
|
private |
A map of goto target statements to cfg nodes.
|
private |
A handler of labels.
|
private |
A map of the corresponding loops and loop headers represented by CFG nodes.
|
private |
Information about loops.
|
private |
A map of targets for break and continue statements.
|
private |
|
private |
The resulting module in BIR.
|
private |
|
private |
|
private |
|
private |
A map of clones of statement.
|
private |
A map of references for goto targets.