28template <
typename ListT>
33 List.insert(AccGroups);
37 for (
const auto &AccGroupListOp : AccGroups->
operands()) {
49 if (AccGroups1 == AccGroups2)
56 if (Union.size() == 0)
58 if (Union.size() == 1)
70 if (!MayAccessMem1 && !MayAccessMem2)
73 return Inst2->
getMetadata(LLVMContext::MD_access_group);
75 return Inst1->
getMetadata(LLVMContext::MD_access_group);
91 if (AccGroupSet2.
count(MD1))
97 if (AccGroupSet2.
count(Item))
102 if (Intersection.
size() == 0)
104 if (Intersection.
size() == 1)
117 static const unsigned SupportedIDs[] = {
118 LLVMContext::MD_tbaa, LLVMContext::MD_alias_scope,
119 LLVMContext::MD_noalias, LLVMContext::MD_fpmath,
120 LLVMContext::MD_nontemporal, LLVMContext::MD_invariant_load,
121 LLVMContext::MD_access_group, LLVMContext::MD_mmra};
124 for (
unsigned Idx = 0; Idx !=
Metadata.size();) {
152 for (
int J = 1, E = VL.
size(); MD && J != E; ++J) {
157 case LLVMContext::MD_mmra: {
161 case LLVMContext::MD_tbaa:
164 case LLVMContext::MD_alias_scope:
167 case LLVMContext::MD_fpmath:
170 case LLVMContext::MD_noalias:
171 case LLVMContext::MD_nontemporal:
172 case LLVMContext::MD_invariant_load:
175 case LLVMContext::MD_access_group:
192 bool DoesKMove,
bool AAOnly =
false) {
194 K->getAllMetadataOtherThanDebugLoc(
Metadata);
196 unsigned Kind = MD.first;
203 K->setMetadata(Kind,
nullptr);
205 case LLVMContext::MD_dbg:
207 case LLVMContext::MD_DIAssignID:
209 K->mergeDIAssignID(J);
211 case LLVMContext::MD_tbaa:
215 case LLVMContext::MD_alias_scope:
219 case LLVMContext::MD_noalias:
220 case LLVMContext::MD_mem_parallel_loop_access:
224 case LLVMContext::MD_access_group:
226 K->setMetadata(LLVMContext::MD_access_group,
229 case LLVMContext::MD_range:
230 if (!AAOnly && (DoesKMove || !
K->hasMetadata(LLVMContext::MD_noundef)))
233 case LLVMContext::MD_nofpclass:
234 if (!AAOnly && (DoesKMove || !
K->hasMetadata(LLVMContext::MD_noundef)))
237 case LLVMContext::MD_fpmath:
241 case LLVMContext::MD_invariant_load:
242 case LLVMContext::MD_invariant_group:
248 K->setMetadata(Kind, JMD);
250 case LLVMContext::MD_nonnull:
251 if (!AAOnly && (DoesKMove || !
K->hasMetadata(LLVMContext::MD_noundef)))
252 K->setMetadata(Kind, JMD);
257 case LLVMContext::MD_prof:
258 case LLVMContext::MD_mmra:
259 case LLVMContext::MD_memprof:
260 case LLVMContext::MD_callsite:
261 case LLVMContext::MD_pcsections:
263 case LLVMContext::MD_callee_type:
265 K->setMetadata(LLVMContext::MD_callee_type,
269 case LLVMContext::MD_callees:
272 if (!AAOnly && DoesKMove)
275 case LLVMContext::MD_align:
276 if (!AAOnly && (DoesKMove || !
K->hasMetadata(LLVMContext::MD_noundef)))
280 case LLVMContext::MD_dereferenceable:
281 case LLVMContext::MD_dereferenceable_or_null:
282 if (!AAOnly && DoesKMove)
286 case LLVMContext::MD_preserve_access_index:
289 case LLVMContext::MD_noundef:
291 if (!AAOnly && DoesKMove)
292 K->setMetadata(Kind, JMD);
294 case LLVMContext::MD_nontemporal:
297 K->setMetadata(Kind, JMD);
299 case LLVMContext::MD_mem_cache_hint:
302 if (!AAOnly && KMD != JMD)
303 K->setMetadata(Kind,
nullptr);
305 case LLVMContext::MD_noalias_addrspace:
309 case LLVMContext::MD_nosanitize:
311 K->setMetadata(Kind, JMD);
313 case LLVMContext::MD_captures:
319 case LLVMContext::MD_alloc_token:
320 if (!AAOnly && KMD != JMD)
330 auto KMMRA =
K->getMetadata(LLVMContext::MD_mmra);
331 if (JMMRA || KMMRA) {
332 K->setMetadata(LLVMContext::MD_mmra,
339 auto *JMemProf = J->
getMetadata(LLVMContext::MD_memprof);
340 auto *KMemProf =
K->getMetadata(LLVMContext::MD_memprof);
341 if (!AAOnly && (JMemProf || KMemProf)) {
342 K->setMetadata(LLVMContext::MD_memprof,
349 auto *JCallSite = J->
getMetadata(LLVMContext::MD_callsite);
350 auto *KCallSite =
K->getMetadata(LLVMContext::MD_callsite);
351 if (!AAOnly && (JCallSite || KCallSite)) {
352 K->setMetadata(LLVMContext::MD_callsite,
360 K->setMetadata(LLVMContext::MD_pcsections,
362 K->getMetadata(LLVMContext::MD_pcsections),
368 auto *JProf = J->
getMetadata(LLVMContext::MD_prof);
369 auto *KProf =
K->getMetadata(LLVMContext::MD_prof);
370 if (!AAOnly && (JProf || KProf)) {
376 K->setMetadata(LLVMContext::MD_prof,
392 Source.getAllMetadata(MD);
396 for (
const auto &MDPair : MD) {
397 unsigned ID = MDPair.first;
407 case LLVMContext::MD_dbg:
408 case LLVMContext::MD_tbaa:
409 case LLVMContext::MD_prof:
410 case LLVMContext::MD_fpmath:
411 case LLVMContext::MD_tbaa_struct:
412 case LLVMContext::MD_invariant_load:
413 case LLVMContext::MD_alias_scope:
414 case LLVMContext::MD_noalias:
415 case LLVMContext::MD_nontemporal:
416 case LLVMContext::MD_mem_cache_hint:
417 case LLVMContext::MD_mem_parallel_loop_access:
418 case LLVMContext::MD_access_group:
419 case LLVMContext::MD_noundef:
420 case LLVMContext::MD_noalias_addrspace:
421 case LLVMContext::MD_invariant_group:
422 case LLVMContext::MD_mmra:
427 case LLVMContext::MD_nonnull:
431 case LLVMContext::MD_align:
432 case LLVMContext::MD_dereferenceable:
433 case LLVMContext::MD_dereferenceable_or_null:
439 case LLVMContext::MD_range:
443 case LLVMContext::MD_nofpclass:
447 if (NewType->
getScalarType() == Source.getType()->getScalarType())
459 if (NewTy->isPointerTy()) {
466 if (!NewTy->isIntegerTy())
483 if (NewTy == OldLI.
getType()) {
492 if (!NewTy->isPointerTy())
495 unsigned BitWidth =
DL.getPointerTypeSizeInBits(NewTy);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements a class to represent arbitrary precision integral constant values and operations...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file provides utility for Memory Model Relaxation Annotations (MMRAs).
This file contains the declarations for profiling metadata utility functions.
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallPtrSet class.
Class for arbitrary precision integers.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
bool empty() const
Check if the array is empty.
static LLVM_ABI Constant * getPtrToInt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static LLVM_ABI Constant * getAdd(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
static LLVM_ABI ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
A parsed version of the target data layout string in and methods for querying it.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
void getAllMetadataOtherThanDebugLoc(SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
This does the same thing as getAllMetadata, except that it filters out the debug location.
LLVM_ABI bool mayReadOrWriteMemory() const LLVM_READONLY
Return true if this instruction may read or write memory.
This is an important class for using LLVM in a threaded context.
An instruction for reading from memory.
Value * getPointerOperand()
LLVM_ABI MDNode * createRange(const APInt &Lo, const APInt &Hi)
Return metadata describing the range [Lo, Hi).
static LLVM_ABI MDNode * getMostGenericAliasScope(MDNode *A, MDNode *B)
static LLVM_ABI MDNode * getMergedCallsiteMetadata(MDNode *A, MDNode *B)
static LLVM_ABI CaptureComponents toCaptureComponents(const MDNode *MD)
Convert !captures metadata to CaptureComponents. MD may be nullptr.
static LLVM_ABI MDNode * getMergedCalleeTypeMetadata(const MDNode *A, const MDNode *B)
static LLVM_ABI MDNode * getMergedPCSectionsMetadata(MDNode *A, MDNode *B)
Merge !pcsections of two merged instructions: the result requests every section that either requests.
static LLVM_ABI MDNode * getMostGenericTBAA(MDNode *A, MDNode *B)
static LLVM_ABI MDNode * getMostGenericNoaliasAddrspace(MDNode *A, MDNode *B)
ArrayRef< MDOperand > operands() const
static LLVM_ABI MDNode * getMergedCalleesMetadata(MDNode *A, MDNode *B)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static LLVM_ABI MDNode * getMergedProfMetadata(MDNode *A, MDNode *B, const Instruction *AInstr, const Instruction *BInstr)
Merge !prof metadata from two instructions.
static LLVM_ABI MDNode * getMergedAllocTokenMetadata(const MDNode *A, const MDNode *B)
static LLVM_ABI MDNode * getMostGenericFPMath(MDNode *A, MDNode *B)
unsigned getNumOperands() const
Return number of MDNode operands.
static LLVM_ABI MDNode * getMostGenericRange(MDNode *A, MDNode *B)
static LLVM_ABI MDNode * getMergedMemProfMetadata(MDNode *A, MDNode *B)
static LLVM_ABI MDNode * intersect(MDNode *A, MDNode *B)
static LLVM_ABI MDNode * getMostGenericNoFPClass(MDNode *A, MDNode *B)
LLVMContext & getContext() const
static LLVM_ABI MDNode * fromCaptureComponents(LLVMContext &Ctx, CaptureComponents CC)
Convert CaptureComponents to !captures metadata.
static LLVM_ABI MDNode * getMostGenericAlignmentOrDereferenceable(MDNode *A, MDNode *B)
Tracking metadata reference owned by Metadata.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
A SetVector that performs no allocations if smaller than a certain size.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
The instances of the Type class are immutable: once they are created, they are never changed.
bool isPointerTy() const
True if this is an instance of PointerType.
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVMContext & getContext() const
All values hold a context through their type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI cl::opt< bool > ProfcheckDisableMetadataFixes
LLVM_ABI bool canInstructionHaveMMRAs(const Instruction &I)
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 void propagateMemCacheHint(Instruction &Dest, ArrayRef< Value * > Sources)
Copy identical source cache-hint attachments to Dest, or clear its attachment if propagation fails.
LLVM_ABI ConstantRange getConstantRangeFromMetadata(const MDNode &RangeMD)
Parse out a conservative ConstantRange from !range metadata.
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...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
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 bool isValidAsAccessGroup(MDNode *AccGroup)
Return whether an MDNode might represent an access group.
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.
constexpr unsigned BitWidth
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
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.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.