Commit 647b99e8 authored by Marius Wachtler's avatar Marius Wachtler Committed by Boxiang Sun

BST: skip visiting the body of BST_ClassDef and BST_FunctionDef nodes

now that the FlattenVisitor is gone nobody uses this anymore
parent 1f0c55a7
......@@ -70,9 +70,7 @@ private:
public:
LivenessBBVisitor(LivenessAnalysis* analysis)
: NoopBSTVisitor(true /* skip child CFG nodes */),
statuses(analysis->cfg->getVRegInfo().getTotalNumOfVRegs()),
analysis(analysis) {}
: statuses(analysis->cfg->getVRegInfo().getTotalNumOfVRegs()), analysis(analysis) {}
bool firstIsUse(int vreg) const { return getStatusFirst(vreg) == Status::USED; }
bool firstIsDef(int vreg) const { return getStatusFirst(vreg) == Status::DEFINED; }
......@@ -212,7 +210,7 @@ private:
}
public:
DefinednessVisitor(Map& state) : NoopBSTVisitor(true /* skip child CFG nodes */), state(state) {}
DefinednessVisitor(Map& state) : state(state) {}
bool visit_vreg(int* vreg, bool is_dest) override {
if (*vreg < 0)
return false;
......
......@@ -344,8 +344,7 @@ private:
SymbolTable* sym_table;
bool created_new_sym_table;
SymTableDstVRegDeleter(SymbolTable* sym_table)
: NoopBSTVisitor(true /* skip child CFG nodes */), sym_table(sym_table), created_new_sym_table(false) {}
SymTableDstVRegDeleter(SymbolTable* sym_table) : sym_table(sym_table), created_new_sym_table(false) {}
protected:
bool visit_vreg(int* vreg, bool is_dst = false) override {
......
......@@ -43,12 +43,6 @@ template <class T> static void visitVector(const std::vector<T*>& vec, BSTVisito
}
}
static void visitCFG(CFG* cfg, BSTVisitor* v) {
for (auto bb : cfg->blocks)
for (auto e : bb->body)
e->accept(v);
}
void BST_Assert::accept(BSTVisitor* v) {
bool skip = v->visit_assert(this);
if (skip)
......@@ -180,8 +174,7 @@ void BST_ClassDef::accept(BSTVisitor* v) {
v->visit_vreg(&decorator[i]);
}
if (!v->skip_visit_child_cfg)
visitCFG(this->code->source->cfg, v);
// we dont't visit the body
}
void BST_ClassDef::accept_stmt(StmtVisitor* v) {
......@@ -272,8 +265,7 @@ void BST_FunctionDef::accept(BSTVisitor* v) {
for (int i = 0; i < num_decorator + num_defaults; ++i) {
v->visit_vreg(&elts[i]);
}
if (!v->skip_visit_child_cfg)
visitCFG(code->source->cfg, v);
// we dont't visit the body
}
void BST_FunctionDef::accept_stmt(StmtVisitor* v) {
......
......@@ -725,9 +725,7 @@ template <typename T> T* bst_cast(BST_stmt* node) {
class BSTVisitor {
public:
const bool skip_visit_child_cfg;
// if skip_visit_child_cfg is set function and class defs will not visit their body nodes.
BSTVisitor(bool skip_visit_child_cfg) : skip_visit_child_cfg(skip_visit_child_cfg) {}
BSTVisitor() {}
virtual ~BSTVisitor() {}
// pseudo
......@@ -790,7 +788,7 @@ public:
class NoopBSTVisitor : public BSTVisitor {
protected:
public:
NoopBSTVisitor(bool skip_visit_child_cfg) : BSTVisitor(skip_visit_child_cfg) {}
NoopBSTVisitor() {}
virtual ~NoopBSTVisitor() {}
virtual bool visit_assert(BST_Assert* node) override { return false; }
......@@ -919,7 +917,7 @@ private:
public:
PrintVisitor(const CodeConstants& code_constants, int indent, llvm::raw_ostream& stream)
: BSTVisitor(false /* visit child CFG */), stream(stream), code_constants(code_constants), indent(indent) {}
: stream(stream), code_constants(code_constants), indent(indent) {}
virtual ~PrintVisitor() {}
void flush() { stream.flush(); }
......
......@@ -2917,7 +2917,7 @@ public:
enum Step { TrackBlockUsage = 0, UserVisible, CrossBlock, SingleBlockUse } step;
AssignVRegsVisitor(llvm::DenseMap<int*, InternedString>& id_vreg)
: NoopBSTVisitor(true /* skip child CFG nodes */), current_block(0), next_vreg(0), id_vreg(id_vreg) {}
: current_block(0), next_vreg(0), id_vreg(id_vreg) {}
bool visit_vreg(int* vreg, bool is_dst = false) override {
if (is_dst) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment