From 126d4fab3e00f003a06dac23f96aa70cbb75aa67 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 31 Aug 2023 15:41:03 -0700 Subject: DebugInfo: Don't trample in replaceCurrent() (#5915) Copy the old expression's debug info if the new has none. But if the new has its own, trust that. Followup to #5914 --- src/wasm-traversal.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') 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()) { -- cgit v1.2.3