[llvm] 02f50d0 - [Assignment Tracking][9/*] Don't drop DIAssignID in dropUnknownNonDebugMetadata
via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 9 03:01:35 PST 2022
Author: OCHyams
Date: 2022-11-09T10:49:55Z
New Revision: 02f50d05d5fea4e9c5fac310abccc5f7d770b25b
URL: https://github.com/llvm/llvm-project/commit/02f50d05d5fea4e9c5fac310abccc5f7d770b25b
DIFF: https://github.com/llvm/llvm-project/commit/02f50d05d5fea4e9c5fac310abccc5f7d770b25b.diff
LOG: [Assignment Tracking][9/*] Don't drop DIAssignID in dropUnknownNonDebugMetadata
The Assignment Tracking debug-info feature is outlined in this RFC:
https://discourse.llvm.org/t/
rfc-assignment-tracking-a-better-way-of-specifying-variable-locations-in-ir
A DIAssignID attachment is debug metadata, so don't drop it.
Reviewed By: jmorse
Differential Revision: https://reviews.llvm.org/D133292
Added:
Modified:
llvm/lib/IR/Metadata.cpp
llvm/unittests/IR/DebugInfoTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index 533690203189..bde83717ebef 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -1403,15 +1403,12 @@ void Instruction::dropUnknownNonDebugMetadata(ArrayRef<unsigned> KnownIDs) {
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");
diff --git a/llvm/unittests/IR/DebugInfoTest.cpp b/llvm/unittests/IR/DebugInfoTest.cpp
index 970de06e2325..bf676f9d5f1c 100644
--- a/llvm/unittests/IR/DebugInfoTest.cpp
+++ b/llvm/unittests/IR/DebugInfoTest.cpp
@@ -665,6 +665,17 @@ TEST(AssignmentTrackingTest, InstrMethods) {
EXPECT_EQ(NewID0, NewID1);
EXPECT_EQ(Markers[0]->getAssignID(), NewID0);
}
+
+ // Test 5 - 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
More information about the llvm-commits
mailing list