summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/wasm-traversal.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/wasm-traversal.h b/src/wasm-traversal.h
index 80378242a..212ded365 100644
--- a/src/wasm-traversal.h
+++ b/src/wasm-traversal.h
@@ -124,7 +124,12 @@ struct Walker : public VisitorType {
// Copy debug info, if present.
if (currFunction) {
auto& debugLocations = currFunction->debugLocations;
- if (!debugLocations.empty()) {
+ // Early exit if there is no debug info at all. Also, leave if we already
+ // have debug info on the new expression, which we don't want to trample:
+ // if there is no debug info we do want to copy, as a replacement
+ // operation suggests the new code plays the same role (it is an optimized
+ // version of the old), but if the code is already annotated, trust that.
+ if (!debugLocations.empty() && !debugLocations.count(expression)) {
auto* curr = getCurrent();
auto iter = debugLocations.find(curr);
if (iter != debugLocations.end()) {