[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
Thu Jun 17 07:09:45 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfa1de88f81e9: [DebugInfo] Prevent non-determinism when updating DIArgList users of a value (authored by StephenTozer).

Changed prior to commit:
  https://reviews.llvm.org/D104105?vs=351390&id=352710#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104105

Files:
  llvm/lib/IR/Metadata.cpp


Index: llvm/lib/IR/Metadata.cpp
===================================================================
--- llvm/lib/IR/Metadata.cpp
+++ llvm/lib/IR/Metadata.cpp
@@ -196,15 +196,21 @@
 }
 
 SmallVector<Metadata *, 4> ReplaceableMetadataImpl::getAllArgListUsers() {
-  SmallVector<Metadata *, 4> MDUsers;
+  SmallVector<std::pair<OwnerTy, uint64_t> *> MDUsersWithID;
   for (auto Pair : UseMap) {
     OwnerTy Owner = Pair.second.first;
     if (!Owner.is<Metadata *>())
       continue;
     Metadata *OwnerMD = Owner.get<Metadata *>();
     if (OwnerMD->getMetadataID() == Metadata::DIArgListKind)
-      MDUsers.push_back(OwnerMD);
+      MDUsersWithID.push_back(&UseMap[Pair.first]);
   }
+  llvm::sort(MDUsersWithID, [](auto UserA, auto UserB) {
+    return UserA->second < UserB->second;
+  });
+  SmallVector<Metadata *> MDUsers;
+  for (auto UserWithID : MDUsersWithID)
+    MDUsers.push_back(UserWithID->first.get<Metadata *>());
   return MDUsers;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104105.352710.patch
Type: text/x-patch
Size: 958 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210617/d7e4cc76/attachment.bin>


More information about the llvm-commits mailing list