[PATCH] D110534: [llvm-reduce] Reduce metadata references.

Michael Kruse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 27 05:06:51 PDT 2021


Meinersbur created this revision.
Meinersbur added reviewers: aeubanks, nikic, swamulism, diegotf, dblaikie, nickdesaulniers, lebedev.ri.
Herald added subscribers: jeroen.dobbelaere, kosarev.
Meinersbur requested review of this revision.
Herald added a project: LLVM.

The ReduceMetadata pass before this patch removed metadata on a per-MDNode (or NamedMDNode) basis. Either all references to an MDNode are kept, or all of them are removed. However, MDNodes are uniqued, meaning that references to MDNodes with the same data become references to the same MDNodes. As a consequence, e.g. tbaa references to the same type will all have the same MDNode reference and hence make it impossible to reduce only keeping metadata on those memory access for which they are interesting.
Moreover, MDNodes can also be referenced by some intrinsics or other MDNodes. These references were not considered for removal leading to the possibility that MDNodes are not actually removed even if selected to be removed by the oracle.

This patch changes ReduceMetadata to reduces based on removable metadata references instead. MDNodes without references implicitly dropped anyway. References by intrinsic calls should be removed by ReduceOperands or ReduceInstructions. References in other MDNodes cannot be removed as it would violate the immutability of MDNodes.

Additionally, ReduceMetadata pass before this patch used `setMetadata(I, NULL)` to remove references, where `I` is the index in the array returned by `getAllMetadata`. However, `setMetadata` expects a MDKind (such as `MD_tbaa`) as first argument. `getAllMetadata` does not return those in consecutive order (otherwise it would not need to be a `std::pair` with `first` representing the MDKind).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110534

Files:
  llvm/test/tools/llvm-reduce/remove-metadata-args.ll
  llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110534.375204.patch
Type: text/x-patch
Size: 6907 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210927/b63e30f8/attachment.bin>


More information about the llvm-commits mailing list