diff options
-rw-r--r-- | src/wasm/wasm-debug.cpp | 20 | ||||
-rw-r--r-- | test/passes/fannkuch3_manyopts.bin.txt | 4 |
2 files changed, 19 insertions, 5 deletions
diff --git a/src/wasm/wasm-debug.cpp b/src/wasm/wasm-debug.cpp index 286b63e69..93eb259e9 100644 --- a/src/wasm/wasm-debug.cpp +++ b/src/wasm/wasm-debug.cpp @@ -897,9 +897,23 @@ static void updateLoc(llvm::DWARFYAML::Data& yaml, // This part of the loc no longer has a mapping, so we must ignore it. newStart = newEnd = IGNOREABLE_LOCATION; } else { - // Finally, relativize it against the base. - newStart -= base; - newEnd -= base; + // See if we can relativize it against the base. If things moved around + // so that the base is no longer before the start or the end, then we + // must skip this. That is, if we had something like + // + // [base] [start] [end] + // + // (where the X axis is the offset) and transforms led to + // + // [start] [base] [end] + // + // or such, then give up TODO: perhaps remap with a new base? + if (newStart >= base && newEnd >= base) { + newStart -= base; + newEnd -= base; + } else { + newStart = newEnd = IGNOREABLE_LOCATION; + } } // The loc start and end markers have been preserved. However, TODO // instructions in the middle may have moved around, making the loc no diff --git a/test/passes/fannkuch3_manyopts.bin.txt b/test/passes/fannkuch3_manyopts.bin.txt index f5cefa301..627fccd30 100644 --- a/test/passes/fannkuch3_manyopts.bin.txt +++ b/test/passes/fannkuch3_manyopts.bin.txt @@ -2842,7 +2842,7 @@ Abbrev table for offset: 0x00000000 0x00000269: DW_TAG_variable [13] DW_AT_location [DW_FORM_sec_offset] (0x00000267: [0xffffffff, 0x0000039f): - [0xffffffe7, 0xffffffec): DW_OP_WASM_location 0x0 +4, DW_OP_stack_value) + [0x00000001, 0x00000001): DW_OP_WASM_location 0x0 +4, DW_OP_stack_value) DW_AT_name [DW_FORM_strp] ( .debug_str[0x000000dc] = "n") DW_AT_decl_file [DW_FORM_data1] ("/usr/local/google/home/azakai/Dev/emscripten/tests/fannkuch.cpp") DW_AT_decl_line [DW_FORM_data1] (153) @@ -3066,7 +3066,7 @@ Abbrev table for offset: 0x00000000 0x00000267: [0xffffffff, 0x0000039f): - [0xffffffe7, 0xffffffec): DW_OP_WASM_location 0x0 +4, DW_OP_stack_value + [0x00000001, 0x00000001): DW_OP_WASM_location 0x0 +4, DW_OP_stack_value 0x00000285: [0xffffffff, 0x0000039f): |