mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:58:11 +00:00

It removes empty `BasicBlock`s with an unconditional jump continuation and then removes unreferenced blocks from the graph.
251 lines
4.9 KiB
Text
251 lines
4.9 KiB
Text
===== AST after parser =====
|
|
f():
|
|
TreeList
|
|
IfBranch
|
|
UnresolvedReference cond1
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
UnresolvedReference a
|
|
MathematicalConstant 1
|
|
IfBranch
|
|
UnresolvedReference cond2
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
UnresolvedReference b
|
|
UnresolvedReference a
|
|
ElseIfBranch Else
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
UnresolvedReference b
|
|
MathematicalConstant 3
|
|
ElseIfBranch Else
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
UnresolvedReference b
|
|
MathematicalConstant 4
|
|
ReturnNode
|
|
UnresolvedReference b
|
|
|
|
===== AST after function-call-canonicalization =====
|
|
f():
|
|
TreeList
|
|
IfBranch
|
|
UnresolvedReference cond1
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
UnresolvedReference a
|
|
MathematicalConstant 1
|
|
IfBranch
|
|
UnresolvedReference cond2
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
UnresolvedReference b
|
|
UnresolvedReference a
|
|
ElseIfBranch Else
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
UnresolvedReference b
|
|
MathematicalConstant 3
|
|
ElseIfBranch Else
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
UnresolvedReference b
|
|
MathematicalConstant 4
|
|
ReturnNode
|
|
UnresolvedReference b
|
|
|
|
===== AST after if-branch-merging =====
|
|
f():
|
|
TreeList
|
|
IfElseIfChain
|
|
UnresolvedReference cond1
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
UnresolvedReference a
|
|
MathematicalConstant 1
|
|
IfElseIfChain
|
|
UnresolvedReference cond2
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
UnresolvedReference b
|
|
UnresolvedReference a
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
UnresolvedReference b
|
|
MathematicalConstant 3
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
UnresolvedReference b
|
|
MathematicalConstant 4
|
|
ReturnNode
|
|
UnresolvedReference b
|
|
|
|
===== AST after reference-resolving =====
|
|
f():
|
|
TreeList
|
|
IfElseIfChain
|
|
UnresolvedReference cond1
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
Var a
|
|
MathematicalConstant 1
|
|
IfElseIfChain
|
|
UnresolvedReference cond2
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
Var b
|
|
Var a
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
Var b
|
|
MathematicalConstant 3
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
Var b
|
|
MathematicalConstant 4
|
|
ReturnNode
|
|
Var b
|
|
|
|
===== AST after cfg-building =====
|
|
f():
|
|
TreeList
|
|
IfElseIfChain
|
|
UnresolvedReference cond1
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
Var a
|
|
MathematicalConstant 1
|
|
IfElseIfChain
|
|
UnresolvedReference cond2
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
Var b
|
|
Var a
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
Var b
|
|
MathematicalConstant 3
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
Var b
|
|
MathematicalConstant 4
|
|
ReturnNode
|
|
Var b
|
|
|
|
===== CFG after cfg-building =====
|
|
f():
|
|
0:
|
|
ControlFlowBranch true=3 false=7
|
|
UnresolvedReference cond1
|
|
|
|
1:
|
|
ControlFlowFunctionReturn
|
|
Var $return
|
|
|
|
2:
|
|
BinaryOperation Assignment
|
|
Var $return
|
|
Var b
|
|
ControlFlowJump jump=1
|
|
|
|
3:
|
|
BinaryOperation Declaration
|
|
Var a
|
|
MathematicalConstant 1
|
|
ControlFlowBranch true=5 false=6
|
|
UnresolvedReference cond2
|
|
|
|
4:
|
|
ControlFlowJump jump=2
|
|
|
|
5:
|
|
BinaryOperation Declaration
|
|
Var b
|
|
Var a
|
|
ControlFlowJump jump=4
|
|
|
|
6:
|
|
BinaryOperation Declaration
|
|
Var b
|
|
MathematicalConstant 3
|
|
ControlFlowJump jump=4
|
|
|
|
7:
|
|
BinaryOperation Declaration
|
|
Var b
|
|
MathematicalConstant 4
|
|
ControlFlowJump jump=2
|
|
|
|
8:
|
|
BinaryOperation Assignment
|
|
Var $return
|
|
Error ""
|
|
ControlFlowJump jump=1
|
|
|
|
===== AST after cfg-simplification =====
|
|
f():
|
|
TreeList
|
|
IfElseIfChain
|
|
UnresolvedReference cond1
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
Var a
|
|
MathematicalConstant 1
|
|
IfElseIfChain
|
|
UnresolvedReference cond2
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
Var b
|
|
Var a
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
Var b
|
|
MathematicalConstant 3
|
|
TreeList
|
|
BinaryOperation Declaration
|
|
Var b
|
|
MathematicalConstant 4
|
|
ReturnNode
|
|
Var b
|
|
|
|
===== CFG after cfg-simplification =====
|
|
f():
|
|
0:
|
|
ControlFlowBranch true=3 false=6
|
|
UnresolvedReference cond1
|
|
|
|
1:
|
|
ControlFlowFunctionReturn
|
|
Var $return
|
|
|
|
2:
|
|
BinaryOperation Assignment
|
|
Var $return
|
|
Var b
|
|
ControlFlowJump jump=1
|
|
|
|
3:
|
|
BinaryOperation Declaration
|
|
Var a
|
|
MathematicalConstant 1
|
|
ControlFlowBranch true=4 false=5
|
|
UnresolvedReference cond2
|
|
|
|
4:
|
|
BinaryOperation Declaration
|
|
Var b
|
|
Var a
|
|
ControlFlowJump jump=2
|
|
|
|
5:
|
|
BinaryOperation Declaration
|
|
Var b
|
|
MathematicalConstant 3
|
|
ControlFlowJump jump=2
|
|
|
|
6:
|
|
BinaryOperation Declaration
|
|
Var b
|
|
MathematicalConstant 4
|
|
ControlFlowJump jump=2
|
|
|