[all-commits] [llvm/llvm-project] d9562a: [llvm-reduce] Reduce metadata references.
Michael Kruse via All-commits
all-commits at lists.llvm.org
Wed Sep 29 09:25:50 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d9562a8e4528411aa22bd960a6487c0e2708dd4e
https://github.com/llvm/llvm-project/commit/d9562a8e4528411aa22bd960a6487c0e2708dd4e
Author: Michael Kruse <llvm-project at meinersbur.de>
Date: 2021-09-29 (Wed, 29 Sep 2021)
Changed paths:
A llvm/test/tools/llvm-reduce/remove-metadata-args.ll
M llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp
Log Message:
-----------
[llvm-reduce] Reduce metadata references.
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).
Reviewed By: aeubanks, swamulism
Differential Revision: https://reviews.llvm.org/D110534
More information about the All-commits
mailing list