LLVM 24.0.0git
MetadataUtils.h
Go to the documentation of this file.
1//===- MetadataUtils.h - Metadata utilities ---------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_TRANSFORMS_UTILS_METADATAUTILS_H
10#define LLVM_TRANSFORMS_UTILS_METADATAUTILS_H
11
12#include "llvm/ADT/ArrayRef.h"
15#include <utility>
16
17namespace llvm {
18class DataLayout;
19class LoadInst;
20class Instruction;
21class MDNode;
22class Value;
23
24/// Combine the metadata of two instructions so that K can replace J. This
25/// specifically handles the case of CSE-like transformations. Some
26/// metadata can only be kept if K dominates J. For this to be correct,
27/// K cannot be hoisted.
28///
29/// Unknown metadata is removed.
31 bool DoesKMove);
32
33/// Combine metadata of two instructions, where instruction J is a memory
34/// access that has been merged into K. This will intersect alias-analysis
35/// metadata, while preserving other known metadata.
37
38/// Copy the metadata from the source instruction to the destination (the
39/// replacement for the source instruction).
40LLVM_ABI void copyMetadataForLoad(LoadInst &Dest, const LoadInst &Source);
41
42/// Copy a nonnull metadata node to a new load instruction.
43///
44/// This handles mapping it to range metadata if the new load is an integer
45/// load instead of a pointer load.
46LLVM_ABI void copyNonnullMetadata(const LoadInst &OldLI, MDNode *N,
47 LoadInst &NewLI);
48
49/// Copy a range metadata node to a new load instruction.
50///
51/// This handles mapping it to nonnull metadata if the new load is a pointer
52/// load instead of an integer load and the range doesn't cover null.
53LLVM_ABI void copyRangeMetadata(const DataLayout &DL, const LoadInst &OldLI,
54 MDNode *N, LoadInst &NewLI);
55
56/// Compute the union of two access-group lists.
57///
58/// If the list contains just one access group, it is returned directly. If the
59/// list is empty, returns nullptr.
60LLVM_ABI MDNode *uniteAccessGroups(MDNode *AccGroups1, MDNode *AccGroups2);
61
62/// Compute the access-group list of access groups that @p Inst1 and @p Inst2
63/// are both in. If either instruction does not access memory at all, it is
64/// considered to be in every list.
65///
66/// If the list contains just one access group, it is returned directly. If the
67/// list is empty, returns nullptr.
69 const Instruction *Inst2);
70
71/// Add metadata from \p Inst to \p Metadata, if it can be preserved after
72/// vectorization. It can be preserved after vectorization if the kind is one of
73/// [MD_tbaa, MD_alias_scope, MD_noalias, MD_fpmath, MD_nontemporal,
74/// MD_access_group, MD_mmra, MD_invariant_load].
76 Instruction *Inst,
77 SmallVectorImpl<std::pair<unsigned, MDNode *>> &Metadata);
78
79/// Propagate metadata that can be preserved after vectorization from \p VL to
80/// \p I, retaining only information valid for all sources and the destination.
81/// Return \p I.
84
85} // namespace llvm
86
87#endif // LLVM_TRANSFORMS_UTILS_METADATAUTILS_H
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
#define LLVM_ABI
Definition Compiler.h:211
#define I(x, y, z)
Definition MD5.cpp:57
This file defines the SmallVector class.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:63
An instruction for reading from memory.
Metadata node.
Definition Metadata.h:1087
Root of the metadata hierarchy.
Definition Metadata.h:65
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
LLVM Value Representation.
Definition Value.h:75
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void copyMetadataForLoad(LoadInst &Dest, const LoadInst &Source)
Copy the metadata from the source instruction to the destination (the replacement for the source inst...
LLVM_ABI MDNode * intersectAccessGroups(const Instruction *Inst1, const Instruction *Inst2)
Compute the access-group list of access groups that Inst1 and Inst2 are both in.
LLVM_ABI Instruction * propagateMetadataForVectorization(Instruction *I, ArrayRef< Value * > VL)
Propagate metadata that can be preserved after vectorization from VL to I, retaining only information...
LLVM_ABI void combineMetadataForCSE(Instruction *K, const Instruction *J, bool DoesKMove)
Combine the metadata of two instructions so that K can replace J.
LLVM_ABI void copyRangeMetadata(const DataLayout &DL, const LoadInst &OldLI, MDNode *N, LoadInst &NewLI)
Copy a range metadata node to a new load instruction.
LLVM_ABI void copyNonnullMetadata(const LoadInst &OldLI, MDNode *N, LoadInst &NewLI)
Copy a nonnull metadata node to a new load instruction.
LLVM_ABI MDNode * uniteAccessGroups(MDNode *AccGroups1, MDNode *AccGroups2)
Compute the union of two access-group lists.
LLVM_ABI void combineAAMetadata(Instruction *K, const Instruction *J)
Combine metadata of two instructions, where instruction J is a memory access that has been merged int...
LLVM_ABI void getMetadataForVectorization(Instruction *Inst, SmallVectorImpl< std::pair< unsigned, MDNode * > > &Metadata)
Add metadata from Inst to Metadata, if it can be preserved after vectorization.
#define N