[PATCH] D158686: [BOLT] Give precedence to first AddressMap entries

Rafael Auler via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 23 17:12:46 PDT 2023


rafauler created this revision.
rafauler added a reviewer: bolt.
Herald added subscribers: treapster, ayermolo, pengfei.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
rafauler requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158686

Files:
  bolt/lib/Core/AddressMap.cpp


Index: bolt/lib/Core/AddressMap.cpp
===================================================================
--- bolt/lib/Core/AddressMap.cpp
+++ bolt/lib/Core/AddressMap.cpp
@@ -52,7 +52,8 @@
   while (Cursor && !DE.eof(Cursor)) {
     const auto Input = DE.getAddress(Cursor);
     const auto Output = DE.getAddress(Cursor);
-    Parsed.Map.insert({Input, Output});
+    if (!Parsed.Map.count(Input))
+      Parsed.Map.insert({Input, Output});
   }
 
   assert(Cursor && "Error reading address map section");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158686.552928.patch
Type: text/x-patch
Size: 506 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230824/f7a312af/attachment.bin>


More information about the llvm-commits mailing list