Skip to content

Commit b5ac169

Browse files
committed
[BOLT] Give precedence to first AddressMap entries
When parsing AddressMap and there is a conflict in keys, where two entries share the same key, consider the first entry as the correct one, instead of the last. This matches previous behavior in BOLT and covers case such as BOLT creating a new basic block but sharing the same input offset of the previous (or entry) basic block. In this case, instead of translating debuginfo to use the newly created BB, translate using the BB that was originally read from input. This will increase our chances of getting debuginfo right. Tested via binary comparison in tests: X86/dwarf4-df-input-lowpc-ranges.test X86/dwarf5-df-input-lowpc-ranges.test Reviewed By: #bolt, maksfb, jobnoorman Differential Revision: https://reviews.llvm.org/D158686
1 parent 4d27dff commit b5ac169

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

bolt/lib/Core/AddressMap.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ AddressMap AddressMap::parse(StringRef Buffer, const BinaryContext &BC) {
5252
while (Cursor && !DE.eof(Cursor)) {
5353
const auto Input = DE.getAddress(Cursor);
5454
const auto Output = DE.getAddress(Cursor);
55-
Parsed.Map.insert({Input, Output});
55+
if (!Parsed.Map.count(Input))
56+
Parsed.Map.insert({Input, Output});
5657
}
5758

5859
assert(Cursor && "Error reading address map section");

0 commit comments

Comments
 (0)