summaryrefslogtreecommitdiff
path: root/src/passes/DeadArgumentElimination.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/DeadArgumentElimination.cpp')
-rw-r--r--src/passes/DeadArgumentElimination.cpp19
1 files changed, 2 insertions, 17 deletions
diff --git a/src/passes/DeadArgumentElimination.cpp b/src/passes/DeadArgumentElimination.cpp
index 4a341571e..83cd7e86d 100644
--- a/src/passes/DeadArgumentElimination.cpp
+++ b/src/passes/DeadArgumentElimination.cpp
@@ -42,6 +42,7 @@
#include "ir/find_all.h"
#include "ir/lubs.h"
#include "ir/module-utils.h"
+#include "ir/return-utils.h"
#include "ir/type-updating.h"
#include "ir/utils.h"
#include "param-utils.h"
@@ -358,23 +359,7 @@ private:
}
}
// Remove any return values.
- struct ReturnUpdater : public PostWalker<ReturnUpdater> {
- Module* module;
- ReturnUpdater(Function* func, Module* module) : module(module) {
- walk(func->body);
- }
- void visitReturn(Return* curr) {
- auto* value = curr->value;
- assert(value);
- curr->value = nullptr;
- Builder builder(*module);
- replaceCurrent(builder.makeSequence(builder.makeDrop(value), curr));
- }
- } returnUpdater(func, module);
- // Remove any value flowing out.
- if (func->body->type.isConcrete()) {
- func->body = Builder(*module).makeDrop(func->body);
- }
+ ReturnUtils::removeReturns(func, *module);
}
// Given a function and all the calls to it, see if we can refine the type of