[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
Mon Sep 5 05:14:46 PDT 2022
Orlando created this revision.
Orlando added a project: debug-info.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Orlando requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Make it difficult to accidently drop `DIAssignID` metadata attachments.
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,14 +1307,11 @@
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());
+ // We rarely want to drop DIAssignID so make it difficult to do so
+ // accidentally.
+ KnownSet.insert(LLVMContext::MD_DIAssignID);
auto &MetadataStore = getContext().pImpl->ValueMetadata;
auto &Info = MetadataStore[this];
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133292.457902.patch
Type: text/x-patch
Size: 1372 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220905/6fc84425/attachment.bin>
More information about the llvm-commits
mailing list