[PATCH] D104105: [DebugInfo] Prevent non-determinism when updating DIArgList users of a value

Stephen Tozer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 14 03:44:26 PDT 2021


StephenTozer added inline comments.


================
Comment at: llvm/lib/IR/Metadata.cpp:199
 SmallVector<Metadata *, 4> ReplaceableMetadataImpl::getAllArgListUsers() {
-  SmallVector<Metadata *, 4> MDUsers;
+  SmallVector<std::pair<Metadata *, uint64_t>> MDUsersWithID;
   for (auto Pair : UseMap) {
----------------
StephenTozer wrote:
> rnk wrote:
> > This is a bit pedantic, but it seems like it could be less code to build a vector of pointers to pairs in the DenseMap, sort those pointers to pairs, and then extract the owners afterwards. Fewer new pairs with new implied meanings of .second, that sort of thing.
> 
I tried implementing this, but in this case it doesn't look to make the code any less verbose or easier to read in my opinion (see below).


================
Comment at: llvm/lib/IR/Metadata.cpp:199-214
+  SmallVector<std::pair<Metadata *, uint64_t>> MDUsersWithID;
   for (auto Pair : UseMap) {
     OwnerTy Owner = Pair.second.first;
+    uint64_t OwnerID = Pair.second.second;
     if (!Owner.is<Metadata *>())
       continue;
     Metadata *OwnerMD = Owner.get<Metadata *>();
----------------
rnk wrote:
> This is a bit pedantic, but it seems like it could be less code to build a vector of pointers to pairs in the DenseMap, sort those pointers to pairs, and then extract the owners afterwards. Fewer new pairs with new implied meanings of .second, that sort of thing.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104105/new/

https://reviews.llvm.org/D104105



More information about the llvm-commits mailing list