diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/pass.cpp | 18 | ||||
-rw-r--r-- | src/wasm-traversal.h | 13 |
2 files changed, 20 insertions, 11 deletions
diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp index 4b14186fb..58a5f2f0a 100644 --- a/src/passes/pass.cpp +++ b/src/passes/pass.cpp @@ -156,9 +156,7 @@ void PassRunner::addDefaultFunctionOptimizationPasses() { add("flatten"); add("local-cse"); } - if (!options.debugInfo) { // debug info must be preserved, do not dce it - add("dce"); - } + add("dce"); add("remove-unused-brs"); add("remove-unused-names"); add("optimize-instructions"); @@ -215,14 +213,12 @@ void PassRunner::addDefaultGlobalOptimizationPrePasses() { void PassRunner::addDefaultGlobalOptimizationPostPasses() { // inlining/dae+optimizing can remove debug annotations - if (!options.debugInfo) { - if (options.optimizeLevel >= 2 || options.shrinkLevel >= 1) { - add("dae-optimizing"); - } - // inline when working hard, and when not preserving debug info - if (options.optimizeLevel >= 2 || options.shrinkLevel >= 2) { - add("inlining-optimizing"); - } + if (options.optimizeLevel >= 2 || options.shrinkLevel >= 1) { + add("dae-optimizing"); + } + // inline when working hard, and when not preserving debug info + if (options.optimizeLevel >= 2 || options.shrinkLevel >= 2) { + add("inlining-optimizing"); } add("duplicate-function-elimination"); // optimizations show more functions as duplicate add("remove-unused-module-elements"); diff --git a/src/wasm-traversal.h b/src/wasm-traversal.h index 5bd316d89..541490418 100644 --- a/src/wasm-traversal.h +++ b/src/wasm-traversal.h @@ -302,6 +302,19 @@ struct Walker : public VisitorType { // just one visit*() method is called by the traversal; if you replace a node, // and you want to process the output, you must do that explicitly). Expression* replaceCurrent(Expression* expression) { + // Copy debug info, if present. + if (currFunction) { + auto& debugLocations = currFunction->debugLocations; + if (!debugLocations.empty()) { + auto* curr = getCurrent(); + auto iter = debugLocations.find(curr); + if (iter != debugLocations.end()) { + auto location = iter->second; + debugLocations.erase(iter); + debugLocations[expression] = location; + } + } + } return *replacep = expression; } |