Skip to content

Commit de9f46e

Browse files
authored
DWARF: Never emit (0, 0) to mean an empty span in debug_loc (#2940)
After mapping to the new positions, and after relativizing to the base, if we end up with (0, 0) then we must emit something else, as that would be interpreted as the end of a list. As it is an empty span, the actual value doesn't matter, it just has to be != 0. This can happen if the very first span in a compile unit is an empty span, in which case relative to the base of the compile unit we would have (0, 0).
1 parent ca89a9f commit de9f46e

File tree

4 files changed

+733
-0
lines changed

4 files changed

+733
-0
lines changed

src/wasm/wasm-debug.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,16 @@ static void updateLoc(llvm::DWARFYAML::Data& yaml,
10011001
assert(newStart >= newBase && newEnd >= newBase);
10021002
newStart -= newBase;
10031003
newEnd -= newBase;
1004+
if (newStart == 0 && newEnd == 0) {
1005+
// After mapping to the new positions, and after relativizing to the
1006+
// base, if we end up with (0, 0) then we must emit something else, as
1007+
// that would be interpreted as the end of a list. As it is an empty
1008+
// span, the actual value doesn't matter, it just has to be != 0.
1009+
// This can happen if the very first span in a compile unit is an
1010+
// empty span, in which case relative to the base of the compile unit
1011+
// we would have (0, 0).
1012+
newStart = newEnd = IGNOREABLE_LOCATION;
1013+
}
10041014
}
10051015
// The loc start and end markers have been preserved. However, TODO
10061016
// instructions in the middle may have moved around, making the loc no

0 commit comments

Comments
 (0)