[PATCH] D133292: [Assignment Tracking][9/*] Don't drop DIAssignID in dropUnknownNonDebugMetadata

Orlando Cazalet-Hyams via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 8 05:54:43 PDT 2022


Orlando updated this revision to Diff 458710.
Orlando marked an inline comment as done.

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

https://reviews.llvm.org/D133292

Files:
  llvm/lib/IR/Metadata.cpp
  llvm/unittests/IR/DebugInfoTest.cpp


Index: llvm/unittests/IR/DebugInfoTest.cpp
===================================================================
--- llvm/unittests/IR/DebugInfoTest.cpp
+++ llvm/unittests/IR/DebugInfoTest.cpp
@@ -589,6 +589,17 @@
     EXPECT_EQ(NewID0, NewID1);
     EXPECT_EQ(Markers[0]->getAssignID(), NewID0);
   }
+
+  // Test 4 - dropUnknownNonDebugMetadata.
+  //
+  // Input            store0->dropUnknownNonDebugMetadata()
+  // -----            -------------------------
+  // store0 !x        store0 !x
+  {
+    Stores[0]->dropUnknownNonDebugMetadata();
+    Metadata *NewID0 = Stores[0]->getMetadata(LLVMContext::MD_DIAssignID);
+    EXPECT_NE(NewID0, nullptr);
+  }
 }
 
 } // end namespace
Index: llvm/lib/IR/Metadata.cpp
===================================================================
--- llvm/lib/IR/Metadata.cpp
+++ llvm/lib/IR/Metadata.cpp
@@ -1307,15 +1307,12 @@
   if (!Value::hasMetadata())
     return; // Nothing to remove!
 
-  if (KnownIDs.empty()) {
-    // Just drop our entry at the store.
-    clearMetadata();
-    return;
-  }
-
   SmallSet<unsigned, 4> KnownSet;
   KnownSet.insert(KnownIDs.begin(), KnownIDs.end());
 
+  // A DIAssignID attachment is debug metadata, don't drop it.
+  KnownSet.insert(LLVMContext::MD_DIAssignID);
+
   auto &MetadataStore = getContext().pImpl->ValueMetadata;
   auto &Info = MetadataStore[this];
   assert(!Info.empty() && "bit out of sync with hash table");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133292.458710.patch
Type: text/x-patch
Size: 1411 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220908/f6833630/attachment.bin>


More information about the llvm-commits mailing list