[llvm] dee2c76 - Reapply "[DebugInfo] Prevent non-determinism when updating DIArgList users of a value"

Stephen Tozer via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 17 08:17:09 PDT 2021


Author: Stephen Tozer
Date: 2021-06-17T16:16:55+01:00
New Revision: dee2c76b4c46e71903e3d86ab7555a80d51d1288

URL: https://github.com/llvm/llvm-project/commit/dee2c76b4c46e71903e3d86ab7555a80d51d1288
DIFF: https://github.com/llvm/llvm-project/commit/dee2c76b4c46e71903e3d86ab7555a80d51d1288.diff

LOG: Reapply "[DebugInfo] Prevent non-determinism when updating DIArgList users of a value"

Reapply the commit which previously caused build failures due to the
mismatched template arguments between the return type and the returned
SmallVector.

This reverts commit e8991caea8690ec2d17b0b7e1c29bf0da6609076.

Added: 
    

Modified: 
    llvm/include/llvm/IR/Metadata.h
    llvm/lib/IR/Metadata.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/Metadata.h b/llvm/include/llvm/IR/Metadata.h
index 6a9d9455deb9d..aac03a531c5e6 100644
--- a/llvm/include/llvm/IR/Metadata.h
+++ b/llvm/include/llvm/IR/Metadata.h
@@ -304,7 +304,7 @@ class ReplaceableMetadataImpl {
   void replaceAllUsesWith(Metadata *MD);
 
   /// Returns the list of all DIArgList users of this.
-  SmallVector<Metadata *, 4> getAllArgListUsers();
+  SmallVector<Metadata *> getAllArgListUsers();
 
   /// Resolve all uses of this.
   ///
@@ -385,7 +385,7 @@ class ValueAsMetadata : public Metadata, ReplaceableMetadataImpl {
   Type *getType() const { return V->getType(); }
   LLVMContext &getContext() const { return V->getContext(); }
 
-  SmallVector<Metadata *, 4> getAllArgListUsers() {
+  SmallVector<Metadata *> getAllArgListUsers() {
     return ReplaceableMetadataImpl::getAllArgListUsers();
   }
 

diff  --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index 4d6ccfa43a640..4f87ef5377653 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -195,16 +195,22 @@ bool MetadataTracking::isReplaceable(const Metadata &MD) {
   return ReplaceableMetadataImpl::isReplaceable(MD);
 }
 
-SmallVector<Metadata *, 4> ReplaceableMetadataImpl::getAllArgListUsers() {
-  SmallVector<Metadata *, 4> MDUsers;
+SmallVector<Metadata *> ReplaceableMetadataImpl::getAllArgListUsers() {
+  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;
 }
 


        


More information about the llvm-commits mailing list