diff options
Diffstat (limited to 'src/passes/NoExitRuntime.cpp')
-rw-r--r-- | src/passes/NoExitRuntime.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/passes/NoExitRuntime.cpp b/src/passes/NoExitRuntime.cpp index 82a296cfc..deffccd36 100644 --- a/src/passes/NoExitRuntime.cpp +++ b/src/passes/NoExitRuntime.cpp @@ -46,7 +46,17 @@ struct NoExitRuntime : public WalkerPass<PostWalker<NoExitRuntime>> { } for (auto name : ATEXIT_NAMES) { if (name == import->base) { - replaceCurrent(Builder(*getModule()).replaceWithIdenticalType(curr)); + // Remove the call, and drop the arguments (which may have side + // effects); let other passes clean that up more. + Builder builder(*getModule()); + std::vector<Expression*> args; + for (auto* operand : curr->operands) { + args.push_back(builder.makeDrop(operand)); + } + // Ensure the block has the right type using the last arg. + args.push_back(builder.replaceWithIdenticalType(curr)); + replaceCurrent(builder.makeBlock(args)); + break; } } } |