LLVM 24.0.0git
MetadataUtils.cpp
Go to the documentation of this file.
1//===- MetadataUtils.cpp - Metadata utilities --------------------------===//
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
10#include "llvm/ADT/APInt.h"
11#include "llvm/ADT/STLExtras.h"
12#include "llvm/ADT/SetVector.h"
16#include "llvm/IR/Constants.h"
17#include "llvm/IR/DataLayout.h"
19#include "llvm/IR/MDBuilder.h"
22#include "llvm/IR/Metadata.h"
24
25using namespace llvm;
26
27/// Add all access groups in @p AccGroups to @p List.
28template <typename ListT>
29static void addToAccessGroupList(ListT &List, MDNode *AccGroups) {
30 // Interpret an access group as a list containing itself.
31 if (AccGroups->getNumOperands() == 0) {
32 assert(isValidAsAccessGroup(AccGroups) && "Node must be an access group");
33 List.insert(AccGroups);
34 return;
35 }
36
37 for (const auto &AccGroupListOp : AccGroups->operands()) {
38 auto *Item = cast<MDNode>(AccGroupListOp.get());
39 assert(isValidAsAccessGroup(Item) && "List item must be an access group");
40 List.insert(Item);
41 }
42}
43
44MDNode *llvm::uniteAccessGroups(MDNode *AccGroups1, MDNode *AccGroups2) {
45 if (!AccGroups1)
46 return AccGroups2;
47 if (!AccGroups2)
48 return AccGroups1;
49 if (AccGroups1 == AccGroups2)
50 return AccGroups1;
51
53 addToAccessGroupList(Union, AccGroups1);
54 addToAccessGroupList(Union, AccGroups2);
55
56 if (Union.size() == 0)
57 return nullptr;
58 if (Union.size() == 1)
59 return cast<MDNode>(Union.front());
60
61 LLVMContext &Ctx = AccGroups1->getContext();
62 return MDNode::get(Ctx, Union.getArrayRef());
63}
64
66 const Instruction *Inst2) {
67 bool MayAccessMem1 = Inst1->mayReadOrWriteMemory();
68 bool MayAccessMem2 = Inst2->mayReadOrWriteMemory();
69
70 if (!MayAccessMem1 && !MayAccessMem2)
71 return nullptr;
72 if (!MayAccessMem1)
73 return Inst2->getMetadata(LLVMContext::MD_access_group);
74 if (!MayAccessMem2)
75 return Inst1->getMetadata(LLVMContext::MD_access_group);
76
77 MDNode *MD1 = Inst1->getMetadata(LLVMContext::MD_access_group);
78 MDNode *MD2 = Inst2->getMetadata(LLVMContext::MD_access_group);
79 if (!MD1 || !MD2)
80 return nullptr;
81 if (MD1 == MD2)
82 return MD1;
83
84 // Use set for scalable 'contains' check.
85 SmallPtrSet<Metadata *, 4> AccGroupSet2;
86 addToAccessGroupList(AccGroupSet2, MD2);
87
88 SmallVector<Metadata *, 4> Intersection;
89 if (MD1->getNumOperands() == 0) {
90 assert(isValidAsAccessGroup(MD1) && "Node must be an access group");
91 if (AccGroupSet2.count(MD1))
92 Intersection.push_back(MD1);
93 } else {
94 for (const MDOperand &Node : MD1->operands()) {
95 auto *Item = cast<MDNode>(Node.get());
96 assert(isValidAsAccessGroup(Item) && "List item must be an access group");
97 if (AccGroupSet2.count(Item))
98 Intersection.push_back(Item);
99 }
100 }
101
102 if (Intersection.size() == 0)
103 return nullptr;
104 if (Intersection.size() == 1)
105 return cast<MDNode>(Intersection.front());
106
107 LLVMContext &Ctx = Inst1->getContext();
108 return MDNode::get(Ctx, Intersection);
109}
110
111/// Add metadata from \p Inst to \p Metadata, if it can be preserved after
112/// vectorization.
114 Instruction *Inst,
115 SmallVectorImpl<std::pair<unsigned, MDNode *>> &Metadata) {
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};
122
123 // Remove any unsupported metadata kinds from Metadata.
124 for (unsigned Idx = 0; Idx != Metadata.size();) {
125 if (is_contained(SupportedIDs, Metadata[Idx].first)) {
126 ++Idx;
127 } else {
128 // Swap element to end and remove it.
129 std::swap(Metadata[Idx], Metadata.back());
130 Metadata.pop_back();
131 }
132 }
133}
134
137 if (VL.empty())
138 return Inst;
139
140 // Keep cache hints out of getMetadataForVectorization(): VPlan changes
141 // operand layouts without remapping cache-hint indices.
142 propagateMemCacheHint(*Inst, VL);
143
146
147 for (auto &[Kind, MD] : Metadata) {
148 // Skip MMRA metadata if the instruction cannot have it.
149 if (Kind == LLVMContext::MD_mmra && !canInstructionHaveMMRAs(*Inst))
150 continue;
151
152 for (int J = 1, E = VL.size(); MD && J != E; ++J) {
153 const Instruction *IJ = cast<Instruction>(VL[J]);
154 MDNode *IMD = IJ->getMetadata(Kind);
155
156 switch (Kind) {
157 case LLVMContext::MD_mmra: {
158 MD = MMRAMetadata::combine(Inst->getContext(), MD, IMD);
159 break;
160 }
161 case LLVMContext::MD_tbaa:
162 MD = MDNode::getMostGenericTBAA(MD, IMD);
163 break;
164 case LLVMContext::MD_alias_scope:
166 break;
167 case LLVMContext::MD_fpmath:
168 MD = MDNode::getMostGenericFPMath(MD, IMD);
169 break;
170 case LLVMContext::MD_noalias:
171 case LLVMContext::MD_nontemporal:
172 case LLVMContext::MD_invariant_load:
173 MD = MDNode::intersect(MD, IMD);
174 break;
175 case LLVMContext::MD_access_group:
176 MD = intersectAccessGroups(Inst, IJ);
177 break;
178 default:
179 llvm_unreachable("unhandled metadata");
180 }
181 }
182
183 Inst->setMetadata(Kind, MD);
184 }
185
186 return Inst;
187}
188
189/// If AAOnly is set, only intersect alias analysis metadata and preserve other
190/// known metadata. Unknown metadata is always dropped.
192 bool DoesKMove, bool AAOnly = false) {
194 K->getAllMetadataOtherThanDebugLoc(Metadata);
195 for (const auto &MD : Metadata) {
196 unsigned Kind = MD.first;
197 MDNode *JMD = J->getMetadata(Kind);
198 MDNode *KMD = MD.second;
199
200 // TODO: Assert that this switch is exhaustive for fixed MD kinds.
201 switch (Kind) {
202 default:
203 K->setMetadata(Kind, nullptr); // Remove unknown metadata
204 break;
205 case LLVMContext::MD_dbg:
206 llvm_unreachable("getAllMetadataOtherThanDebugLoc returned a MD_dbg");
207 case LLVMContext::MD_DIAssignID:
208 if (!AAOnly)
209 K->mergeDIAssignID(J);
210 break;
211 case LLVMContext::MD_tbaa:
212 if (DoesKMove)
213 K->setMetadata(Kind, MDNode::getMostGenericTBAA(JMD, KMD));
214 break;
215 case LLVMContext::MD_alias_scope:
216 if (DoesKMove)
217 K->setMetadata(Kind, MDNode::getMostGenericAliasScope(JMD, KMD));
218 break;
219 case LLVMContext::MD_noalias:
220 case LLVMContext::MD_mem_parallel_loop_access:
221 if (DoesKMove)
222 K->setMetadata(Kind, MDNode::intersect(JMD, KMD));
223 break;
224 case LLVMContext::MD_access_group:
225 if (DoesKMove)
226 K->setMetadata(LLVMContext::MD_access_group,
228 break;
229 case LLVMContext::MD_range:
230 if (!AAOnly && (DoesKMove || !K->hasMetadata(LLVMContext::MD_noundef)))
231 K->setMetadata(Kind, MDNode::getMostGenericRange(JMD, KMD));
232 break;
233 case LLVMContext::MD_nofpclass:
234 if (!AAOnly && (DoesKMove || !K->hasMetadata(LLVMContext::MD_noundef)))
235 K->setMetadata(Kind, MDNode::getMostGenericNoFPClass(JMD, KMD));
236 break;
237 case LLVMContext::MD_fpmath:
238 if (!AAOnly)
239 K->setMetadata(Kind, MDNode::getMostGenericFPMath(JMD, KMD));
240 break;
241 case LLVMContext::MD_invariant_load:
242 case LLVMContext::MD_invariant_group:
243 // If K moves, only keep the invariant metadata if it is present on
244 // both instructions; otherwise the invariant would be asserted on a
245 // path (J's) that never promised it. If K does not move, K stays on
246 // its original path, so its existing metadata remains valid.
247 if (DoesKMove)
248 K->setMetadata(Kind, JMD);
249 break;
250 case LLVMContext::MD_nonnull:
251 if (!AAOnly && (DoesKMove || !K->hasMetadata(LLVMContext::MD_noundef)))
252 K->setMetadata(Kind, JMD);
253 break;
254 // Keep empty cases for prof, mmra, memprof, callsite, and pcsections to
255 // prevent them from being removed as unknown metadata. The actual merging
256 // is handled separately below.
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:
262 break;
263 case LLVMContext::MD_callee_type:
264 if (!AAOnly) {
265 K->setMetadata(LLVMContext::MD_callee_type,
267 }
268 break;
269 case LLVMContext::MD_callees:
270 // If K moves, it replaces J on J's path and must allow J's callees as
271 // well. If K does not move, its callees remain valid.
272 if (!AAOnly && DoesKMove)
273 K->setMetadata(Kind, MDNode::getMergedCalleesMetadata(KMD, JMD));
274 break;
275 case LLVMContext::MD_align:
276 if (!AAOnly && (DoesKMove || !K->hasMetadata(LLVMContext::MD_noundef)))
277 K->setMetadata(
279 break;
280 case LLVMContext::MD_dereferenceable:
281 case LLVMContext::MD_dereferenceable_or_null:
282 if (!AAOnly && DoesKMove)
283 K->setMetadata(
285 break;
286 case LLVMContext::MD_preserve_access_index:
287 // Preserve !preserve.access.index in K.
288 break;
289 case LLVMContext::MD_noundef:
290 // If K does move, keep noundef if it is present in both instructions.
291 if (!AAOnly && DoesKMove)
292 K->setMetadata(Kind, JMD);
293 break;
294 case LLVMContext::MD_nontemporal:
295 // Preserve !nontemporal if it is present on both instructions.
296 if (!AAOnly)
297 K->setMetadata(Kind, JMD);
298 break;
299 case LLVMContext::MD_mem_cache_hint:
300 // Preserve !mem.cache_hint only if it is present and equivalent on both
301 // instructions.
302 if (!AAOnly && KMD != JMD)
303 K->setMetadata(Kind, nullptr);
304 break;
305 case LLVMContext::MD_noalias_addrspace:
306 if (DoesKMove)
307 K->setMetadata(Kind, MDNode::getMostGenericNoaliasAddrspace(JMD, KMD));
308 break;
309 case LLVMContext::MD_nosanitize:
310 // Preserve !nosanitize if both K and J have it.
311 K->setMetadata(Kind, JMD);
312 break;
313 case LLVMContext::MD_captures:
314 K->setMetadata(
316 K->getContext(), MDNode::toCaptureComponents(JMD) |
318 break;
319 case LLVMContext::MD_alloc_token:
320 if (!AAOnly && KMD != JMD)
321 K->setMetadata(Kind, MDNode::getMergedAllocTokenMetadata(KMD, JMD));
322 break;
323 }
324 }
325
326 // Merge MMRAs.
327 // This is handled separately because we also want to handle cases where K
328 // doesn't have tags but J does.
329 auto JMMRA = J->getMetadata(LLVMContext::MD_mmra);
330 auto KMMRA = K->getMetadata(LLVMContext::MD_mmra);
331 if (JMMRA || KMMRA) {
332 K->setMetadata(LLVMContext::MD_mmra,
333 MMRAMetadata::combine(K->getContext(), JMMRA, KMMRA));
334 }
335
336 // Merge memprof metadata.
337 // Handle separately to support cases where only one instruction has the
338 // metadata.
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,
343 MDNode::getMergedMemProfMetadata(KMemProf, JMemProf));
344 }
345
346 // Merge callsite metadata.
347 // Handle separately to support cases where only one instruction has the
348 // metadata.
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,
353 MDNode::getMergedCallsiteMetadata(KCallSite, JCallSite));
354 }
355
356 // Merge PC sections metadata: the merged instruction stands for both, so it
357 // requests the sections of either. Handled separately to support cases where
358 // only J has the metadata.
359 if (!AAOnly)
360 K->setMetadata(LLVMContext::MD_pcsections,
362 K->getMetadata(LLVMContext::MD_pcsections),
363 J->getMetadata(LLVMContext::MD_pcsections)));
364
365 // Merge prof metadata.
366 // Handle separately to support cases where only one instruction has the
367 // metadata.
368 auto *JProf = J->getMetadata(LLVMContext::MD_prof);
369 auto *KProf = K->getMetadata(LLVMContext::MD_prof);
370 if (!AAOnly && (JProf || KProf)) {
371 // We do not need to merge metadata if we have select instructions and the
372 // one we're keeping (K) does not move (explicitly merging would drop the
373 // information in this case). Otherwise, explicitly handle the merging.
374 if (DoesKMove || (!isa<SelectInst>(J) || !isa<SelectInst>(K)) ||
376 K->setMetadata(LLVMContext::MD_prof,
377 MDNode::getMergedProfMetadata(KProf, JProf, K, J));
378 }
379}
380
382 bool DoesKMove) {
383 combineMetadata(K, J, DoesKMove);
384}
385
387 combineMetadata(K, J, /*DoesKMove=*/true, /*AAOnly=*/true);
388}
389
390void llvm::copyMetadataForLoad(LoadInst &Dest, const LoadInst &Source) {
392 Source.getAllMetadata(MD);
393 MDBuilder MDB(Dest.getContext());
394 Type *NewType = Dest.getType();
395 const DataLayout &DL = Source.getDataLayout();
396 for (const auto &MDPair : MD) {
397 unsigned ID = MDPair.first;
398 MDNode *N = MDPair.second;
399 // Note, essentially every kind of metadata should be preserved here! This
400 // routine is supposed to clone a load instruction changing *only its type*.
401 // The only metadata it makes sense to drop is metadata which is invalidated
402 // when the pointer type changes. This should essentially never be the case
403 // in LLVM, but we explicitly switch over only known metadata to be
404 // conservatively correct. If you are adding metadata to LLVM which pertains
405 // to loads, you almost certainly want to add it here.
406 switch (ID) {
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:
423 // All of these directly apply.
424 Dest.setMetadata(ID, N);
425 break;
426
427 case LLVMContext::MD_nonnull:
428 copyNonnullMetadata(Source, N, Dest);
429 break;
430
431 case LLVMContext::MD_align:
432 case LLVMContext::MD_dereferenceable:
433 case LLVMContext::MD_dereferenceable_or_null:
434 // These only directly apply if the new type is also a pointer.
435 if (NewType->isPointerTy())
436 Dest.setMetadata(ID, N);
437 break;
438
439 case LLVMContext::MD_range:
440 copyRangeMetadata(DL, Source, N, Dest);
441 break;
442
443 case LLVMContext::MD_nofpclass:
444 // This only applies if the floating-point type interpretation. This
445 // should handle degenerate cases like casting between a scalar and single
446 // element vector.
447 if (NewType->getScalarType() == Source.getType()->getScalarType())
448 Dest.setMetadata(ID, N);
449 break;
450 }
451 }
452}
453
455 LoadInst &NewLI) {
456 auto *NewTy = NewLI.getType();
457
458 // This only directly applies if the new type is also a pointer.
459 if (NewTy->isPointerTy()) {
460 NewLI.setMetadata(LLVMContext::MD_nonnull, N);
461 return;
462 }
463
464 // The only other translation we can do is to integral loads with !range
465 // metadata.
466 if (!NewTy->isIntegerTy())
467 return;
468
469 MDBuilder MDB(NewLI.getContext());
470 const Value *Ptr = OldLI.getPointerOperand();
471 auto *ITy = cast<IntegerType>(NewTy);
472 auto *NullInt = ConstantExpr::getPtrToInt(
474 auto *NonNullInt = ConstantExpr::getAdd(NullInt, ConstantInt::get(ITy, 1));
475 NewLI.setMetadata(LLVMContext::MD_range,
476 MDB.createRange(NonNullInt, NullInt));
477}
478
480 MDNode *N, LoadInst &NewLI) {
481 auto *NewTy = NewLI.getType();
482 // Simply copy the metadata if the type did not change.
483 if (NewTy == OldLI.getType()) {
484 NewLI.setMetadata(LLVMContext::MD_range, N);
485 return;
486 }
487
488 // Give up unless it is converted to a pointer where there is a single very
489 // valuable mapping we can do reliably.
490 // FIXME: It would be nice to propagate this in more ways, but the type
491 // conversions make it hard.
492 if (!NewTy->isPointerTy())
493 return;
494
495 unsigned BitWidth = DL.getPointerTypeSizeInBits(NewTy);
496 if (BitWidth == OldLI.getType()->getScalarSizeInBits() &&
497 !getConstantRangeFromMetadata(*N).contains(APInt(BitWidth, 0))) {
498 MDNode *NN = MDNode::get(OldLI.getContext(), {});
499 NewLI.setMetadata(LLVMContext::MD_nonnull, NN);
500 }
501}
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).
static void combineMetadata(Instruction *K, const Instruction *J, bool DoesKMove, bool AAOnly=false)
If AAOnly is set, only intersect alias analysis metadata and preserve other known metadata.
static void addToAccessGroupList(ListT &List, MDNode *AccGroups)
Add all access groups in AccGroups to List.
This file contains the declarations for metadata subclasses.
This file contains the declarations for profiling metadata utility functions.
This file contains some templates that are useful if you are working with the STL at all.
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallPtrSet class.
Class for arbitrary precision integers.
Definition APInt.h:78
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
size_t size() const
Get the array size.
Definition ArrayRef.h:141
bool empty() const
Check if the array is empty.
Definition ArrayRef.h:136
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.
Definition DataLayout.h:63
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.
Definition LLVMContext.h:76
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).
Definition MDBuilder.cpp:92
Metadata node.
Definition Metadata.h:1087
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
Definition Metadata.h:1441
static LLVM_ABI MDNode * getMergedCalleesMetadata(MDNode *A, MDNode *B)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1588
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.
Definition Metadata.h:1449
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
Definition Metadata.h:1251
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.
Definition Metadata.h:908
static LLVM_ABI MDNode * combine(LLVMContext &Ctx, const MMRAMetadata &A, const MMRAMetadata &B)
Combines A and B according to MMRA semantics.
Root of the metadata hierarchy.
Definition Metadata.h:65
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.
Definition SetVector.h:346
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.
Definition Type.h:46
bool isPointerTy() const
True if this is an instance of PointerType.
Definition Type.h:277
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
Definition Type.h:354
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
Definition Type.h:370
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:257
LLVMContext & getContext() const
All values hold a context through their type.
Definition Value.h:260
#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...
Definition Casting.h:547
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.
Definition Casting.h:559
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition STLExtras.h:1963
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.
Definition BitVector.h:881
#define N