summaryrefslogtreecommitdiff
path: root/src/passes
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes')
-rw-r--r--src/passes/DeadCodeElimination.cpp8
-rw-r--r--src/passes/NameManager.cpp3
-rw-r--r--src/passes/Print.cpp16
-rw-r--r--src/passes/RemoveUnusedNames.cpp28
4 files changed, 14 insertions, 41 deletions
diff --git a/src/passes/DeadCodeElimination.cpp b/src/passes/DeadCodeElimination.cpp
index 866b3cb73..b30b8ffbd 100644
--- a/src/passes/DeadCodeElimination.cpp
+++ b/src/passes/DeadCodeElimination.cpp
@@ -132,12 +132,8 @@ struct DeadCodeElimination : public WalkerPass<PostWalker<DeadCodeElimination, V
}
void visitLoop(Loop* curr) {
- if (curr->in.is()) {
- reachableBreaks.erase(curr->in);
- }
- if (curr->out.is()) {
- reachable = reachable || reachableBreaks.count(curr->out);
- reachableBreaks.erase(curr->out);
+ if (curr->name.is()) {
+ reachableBreaks.erase(curr->name);
}
if (isDead(curr->body)) {
replaceCurrent(curr->body);
diff --git a/src/passes/NameManager.cpp b/src/passes/NameManager.cpp
index df8b34557..9f0198c2f 100644
--- a/src/passes/NameManager.cpp
+++ b/src/passes/NameManager.cpp
@@ -37,8 +37,7 @@ void NameManager::visitBlock(Block* curr) {
names.insert(curr->name);
}
void NameManager::visitLoop(Loop* curr) {
- names.insert(curr->out);
- names.insert(curr->in);
+ names.insert(curr->name);
}
void NameManager::visitBreak(Break* curr) {
names.insert(curr->name);
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index e54468c41..4fb9274c7 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -64,7 +64,9 @@ struct PrintSExpression : public Visitor<PrintSExpression> {
}
void printFullLine(Expression *expression) {
!minify && doIndent(o, indent);
- //o << "[" << printWasmType(expression->type) << "] "; // debugging tool
+#ifdef DEBUG_TYPES
+ o << "[" << printWasmType(expression->type) << "] ";
+#endif
visit(expression);
o << maybeNewLine;
}
@@ -152,12 +154,8 @@ struct PrintSExpression : public Visitor<PrintSExpression> {
}
void visitLoop(Loop *curr) {
printOpening(o, "loop");
- if (curr->out.is()) {
- o << ' ' << curr->out;
- assert(curr->in.is()); // if just one is printed, it must be the in
- }
- if (curr->in.is()) {
- o << ' ' << curr->in;
+ if (curr->name.is()) {
+ o << ' ' << curr->name;
}
incIndent();
auto block = curr->body->dynCast<Block>();
@@ -734,7 +732,9 @@ Pass *createFullPrinterPass() {
std::ostream& WasmPrinter::printExpression(Expression* expression, std::ostream& o, bool minify) {
PrintSExpression print(o);
print.setMinify(minify);
- //o << "[" << printWasmType(expression->type) << "] "; // debugging tool
+#ifdef DEBUG_TYPES
+ o << "[" << printWasmType(expression->type) << "] ";
+#endif
print.visit(expression);
return o;
}
diff --git a/src/passes/RemoveUnusedNames.cpp b/src/passes/RemoveUnusedNames.cpp
index 9c6743479..8e24f9549 100644
--- a/src/passes/RemoveUnusedNames.cpp
+++ b/src/passes/RemoveUnusedNames.cpp
@@ -76,34 +76,12 @@ struct RemoveUnusedNames : public WalkerPass<PostWalker<RemoveUnusedNames, Visit
}
}
handleBreakTarget(curr->name);
- if (curr->name.is() && curr->list.size() == 1) {
- auto* child = curr->list[0]->dynCast<Loop>();
- if (child && !child->out.is()) {
- // we have just one child, this loop, and it lacks an out label. So this block's name is doing just that!
- child->out = curr->name;
- replaceCurrent(child);
- }
- }
}
void visitLoop(Loop *curr) {
- handleBreakTarget(curr->in);
- // Loops can have just 'in', but cannot have just 'out'
- auto out = curr->out;
- handleBreakTarget(curr->out);
- if (curr->out.is() && !curr->in.is()) {
- auto* block = getModule()->allocator.alloc<Block>();
- block->name = out;
- block->list.push_back(curr->body);
- replaceCurrent(block);
- }
- if (curr->in.is() && !curr->out.is()) {
- auto* child = curr->body->dynCast<Block>();
- if (child && child->name.is()) {
- // we have just one child, this block, and we lack an out label. So we can take the block's!
- curr->out = child->name;
- child->name = Name();
- }
+ handleBreakTarget(curr->name);
+ if (!curr->name.is()) {
+ replaceCurrent(curr->body);
}
}