Page MenuHomePhabricator

[Metadata][NFC] Refactor allocation, initialization, and deletion of MDNodes
ClosedPublic

Authored by wolfgangp on May 12 2022, 11:32 AM.

Details

Summary

This patch is refactoring the allocation, initialization and deletion of MDNodes. It is intended as a preparatory patch for the upcoming
addition of dynamic resizability of MDNodes. It is fundamentally NFC, but removes the necessity for suppressing the memory sanitizer for
MDNode's operator delete.

Refer to the discussion in D124548 for more context.

The intended usage of SmallVector to handle the operands of "large" and resizable MDNodes seems to require that we define move constructors, copy constructors and the respective assignment operators for MDOperand. I've saved these for a later patch, as they're not required for this one.

The refactoring of operator new() requiring an extra parameter (Storage) is preparatory in the sense that operator new will have to decide whether to allocate a node for resizability based on storage type.

Diff Detail

Event Timeline

wolfgangp created this revision.May 12 2022, 11:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 12 2022, 11:32 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
wolfgangp requested review of this revision.May 12 2022, 11:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 12 2022, 11:33 AM
dexonsmith accepted this revision.May 12 2022, 3:22 PM

LGTM! Thanks for splitting this out (and fixing the MSan problem properly!).

llvm/lib/IR/Metadata.cpp
538–539

For reference, I dug this up as https://github.com/llvm/llvm-project/issues/24952.

This revision is now accepted and ready to land.May 12 2022, 3:22 PM
This revision was landed with ongoing or failed builds.May 13 2022, 4:09 PM
This revision was automatically updated to reflect the committed changes.