llvm.org GIT mirror llvm / 9be9473
Introduce enum values for previously defined metadata types. (NFC) Our metadata scheme lazily assigns IDs to string metadata, but we have a mechanism to preassign them as well. Using a preassigned ID is helpful since we get compile time type checking, and avoid some (minimal) string construction and comparison. This change adds enum value for three existing metadata types: + MD_nontemporal = 9, // "nontemporal" + MD_mem_parallel_loop_access = 10, // "llvm.mem.parallel_loop_access" + MD_nonnull = 11 // "nonnull" I went through an updated various uses as well. I made no attempt to get all uses; I focused on the ones which were easily grepable and easily to translate. For example, there were several items in LoopInfo.cpp I chose not to update. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220248 91177308-0d34-0410-b5e6-96231b3b80d8 Philip Reames 5 years ago
8 changed file(s) with 33 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
5454 MD_tbaa_struct = 5, // "tbaa.struct"
5555 MD_invariant_load = 6, // "invariant.load"
5656 MD_alias_scope = 7, // "alias.scope"
57 MD_noalias = 8 // "noalias"
57 MD_noalias = 8, // "noalias",
58 MD_nontemporal = 9, // "nontemporal"
59 MD_mem_parallel_loop_access = 10, // "llvm.mem.parallel_loop_access"
60 MD_nonnull = 11 // "nonnull"
5861 };
5962
6063 /// getMDKindID - Return a unique non-zero ID for the specified metadata kind.
2323 #include "llvm/IR/Constants.h"
2424 #include "llvm/IR/Dominators.h"
2525 #include "llvm/IR/Instructions.h"
26 #include "llvm/IR/LLVMContext.h"
2627 #include "llvm/IR/Metadata.h"
2728 #include "llvm/Support/CommandLine.h"
2829 #include "llvm/Support/Debug.h"
306307 // directly or indirectly through another list metadata (in case of
307308 // nested parallel loops). The loop identifier metadata refers to
308309 // itself so we can check both cases with the same routine.
309 MDNode *loopIdMD = II->getMetadata("llvm.mem.parallel_loop_access");
310 MDNode *loopIdMD =
311 II->getMetadata(LLVMContext::MD_mem_parallel_loop_access);
310312
311313 if (!loopIdMD)
312314 return false;
26232623
26242624 // A Load tagged w/nonnull metadata is never null.
26252625 if (const LoadInst *LI = dyn_cast(V))
2626 return LI->getMetadata("nonnull");
2626 return LI->getMetadata(LLVMContext::MD_nonnull);
26272627
26282628 if (ImmutableCallSite CS = V)
26292629 if (CS.isReturnNonNull())
21212121 } else
21222122 return nullptr;
21232123
2124 bool IsNonTemporal = I->getMetadata("nontemporal") != nullptr;
2125 bool IsInvariant = I->getMetadata("invariant.load") != nullptr;
2124 bool IsNonTemporal = I->getMetadata(LLVMContext::MD_nontemporal) != nullptr;
2125 bool IsInvariant = I->getMetadata(LLVMContext::MD_invariant_load) != nullptr;
21262126 const MDNode *Ranges = I->getMetadata(LLVMContext::MD_range);
21272127
21282128 AAMDNodes AAInfo;
34793479 Type *Ty = I.getType();
34803480
34813481 bool isVolatile = I.isVolatile();
3482 bool isNonTemporal = I.getMetadata("nontemporal") != nullptr;
3483 bool isInvariant = I.getMetadata("invariant.load") != nullptr;
3482 bool isNonTemporal = I.getMetadata(LLVMContext::MD_nontemporal) != nullptr;
3483 bool isInvariant = I.getMetadata(LLVMContext::MD_invariant_load) != nullptr;
34843484 unsigned Alignment = I.getAlignment();
34853485
34863486 AAMDNodes AAInfo;
35833583 NumValues));
35843584 EVT PtrVT = Ptr.getValueType();
35853585 bool isVolatile = I.isVolatile();
3586 bool isNonTemporal = I.getMetadata("nontemporal") != nullptr;
3586 bool isNonTemporal = I.getMetadata(LLVMContext::MD_nontemporal) != nullptr;
35873587 unsigned Alignment = I.getAlignment();
35883588
35893589 AAMDNodes AAInfo;
7575 unsigned NoAliasID = getMDKindID("noalias");
7676 assert(NoAliasID == MD_noalias && "noalias kind id drifted");
7777 (void)NoAliasID;
78
79 // Create the 'nontemporal' metadata kind.
80 unsigned NonTemporalID = getMDKindID("nontemporal");
81 assert(NonTemporalID == MD_nontemporal && "nontemporal kind id drifted");
82 (void)NonTemporalID;
83
84 // Create the 'llvm.mem.parallel_loop_access' metadata kind.
85 unsigned MemParallelLoopAccessID = getMDKindID("llvm.mem.parallel_loop_access");
86 assert(MemParallelLoopAccessID == MD_mem_parallel_loop_access &&
87 "mem_parallel_loop_access kind id drifted");
88 (void)MemParallelLoopAccessID;
89
90
91 // Create the 'nonnull' metadata kind.
92 unsigned NonNullID = getMDKindID("nonnull");
93 assert(NonNullID == MD_nonnull && "nonnull kind id drifted");
94 (void)NonNullID;
7895 }
7996 LLVMContext::~LLVMContext() { delete pImpl; }
8097
328328 case LLVMContext::MD_invariant_load:
329329 case LLVMContext::MD_alias_scope:
330330 case LLVMContext::MD_noalias:
331 case LLVMContext::MD_nontemporal:
332 case LLVMContext::MD_mem_parallel_loop_access:
331333 // All of these directly apply.
332334 NewLoad->setMetadata(ID, N);
333335 break;
338340 break;
339341 }
340342 }
341 // FIXME: These metadata nodes should really have enumerators and be handled
342 // above.
343 if (MDNode *N = LI.getMetadata("nontemporal"))
344 NewLoad->setMetadata("nontemporal", N);
345 if (MDNode *N = LI.getMetadata("llvm.mem.parallel_loop_access"))
346 NewLoad->setMetadata("llvm.mem.parallel_loop_access", N);
347343 return NewLoad;
348344 }
349345
443443 // in the same alias set as something that ends up being modified.
444444 if (AA->pointsToConstantMemory(LI->getOperand(0)))
445445 return true;
446 if (LI->getMetadata("invariant.load"))
446 if (LI->getMetadata(LLVMContext::MD_invariant_load))
447447 return true;
448448
449449 // Don't hoist loads which have may-aliased stores in loop.