mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:57:45 +00:00
JSSpecCompiler: Add control flow graph simplification pass
It removes empty `BasicBlock`s with an unconditional jump continuation and then removes unreferenced blocks from the graph.
This commit is contained in:
parent
475ef6965a
commit
12072dbac5
7 changed files with 215 additions and 1 deletions
|
@ -80,7 +80,11 @@ protected:
|
|||
// ```.
|
||||
class Statement : public Node { };
|
||||
class Expression : public Node { };
|
||||
class ControlFlowOperator : public Statement { };
|
||||
|
||||
class ControlFlowOperator : public Statement {
|
||||
public:
|
||||
virtual Vector<BasicBlockRef*> references() = 0;
|
||||
};
|
||||
|
||||
class ErrorNode : public Expression {
|
||||
public:
|
||||
|
@ -106,6 +110,8 @@ public:
|
|||
|
||||
VariableRef m_return_value;
|
||||
|
||||
Vector<BasicBlockRef*> references() override { return {}; }
|
||||
|
||||
protected:
|
||||
void dump_tree(StringBuilder& builder) override;
|
||||
};
|
||||
|
@ -117,6 +123,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
Vector<BasicBlockRef*> references() override;
|
||||
|
||||
BasicBlockRef m_block;
|
||||
|
||||
protected:
|
||||
|
@ -135,6 +143,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
Vector<BasicBlockRef*> references() override;
|
||||
|
||||
Tree m_condition;
|
||||
BasicBlockRef m_then;
|
||||
BasicBlockRef m_else;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue