Skip to content

Commit

Permalink
[Assignment Tracking][9/*] Don't drop DIAssignID in dropUnknownNonDeb…
Browse files Browse the repository at this point in the history
…ugMetadata

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
  • Loading branch information
OCHyams committed Nov 9, 2022
1 parent a9025f5 commit 02f50d0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
9 changes: 3 additions & 6 deletions llvm/lib/IR/Metadata.cpp
Expand Up @@ -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");
Expand Down
11 changes: 11 additions & 0 deletions llvm/unittests/IR/DebugInfoTest.cpp
Expand Up @@ -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

0 comments on commit 02f50d0

Please sign in to comment.