summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2014-10-21 00:13:20 +0000
committerPhilip Reames <listmail@philipreames.com>2014-10-21 00:13:20 +0000
commit5a3f5f751bdca3483e1edb0d3ac025a466c1ec2d (patch)
treedcbbec576b30401977a2b90e0be7ab28413101c0 /llvm
parent3eb69f5482199fe33c2963af380845238656c846 (diff)
downloadbcm5719-llvm-5a3f5f751bdca3483e1edb0d3ac025a466c1ec2d.tar.gz
bcm5719-llvm-5a3f5f751bdca3483e1edb0d3ac025a466c1ec2d.zip
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. llvm-svn: 220248
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/IR/LLVMContext.h5
-rw-r--r--llvm/lib/Analysis/LoopInfo.cpp4
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp2
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/FastISel.cpp4
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp6
-rw-r--r--llvm/lib/IR/LLVMContext.cpp17
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp8
-rw-r--r--llvm/lib/Transforms/Scalar/LICM.cpp2
8 files changed, 33 insertions, 15 deletions
diff --git a/llvm/include/llvm/IR/LLVMContext.h b/llvm/include/llvm/IR/LLVMContext.h
index 672bf15b147..2f18782a073 100644
--- a/llvm/include/llvm/IR/LLVMContext.h
+++ b/llvm/include/llvm/IR/LLVMContext.h
@@ -55,7 +55,10 @@ public:
MD_tbaa_struct = 5, // "tbaa.struct"
MD_invariant_load = 6, // "invariant.load"
MD_alias_scope = 7, // "alias.scope"
- MD_noalias = 8 // "noalias"
+ MD_noalias = 8, // "noalias",
+ MD_nontemporal = 9, // "nontemporal"
+ MD_mem_parallel_loop_access = 10, // "llvm.mem.parallel_loop_access"
+ MD_nonnull = 11 // "nonnull"
};
/// getMDKindID - Return a unique non-zero ID for the specified metadata kind.
diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp
index 46c0eaabe1a..2e0fdeca948 100644
--- a/llvm/lib/Analysis/LoopInfo.cpp
+++ b/llvm/lib/Analysis/LoopInfo.cpp
@@ -24,6 +24,7 @@
#include "llvm/IR/Constants.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Instructions.h"
+#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Metadata.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
@@ -307,7 +308,8 @@ bool Loop::isAnnotatedParallel() const {
// directly or indirectly through another list metadata (in case of
// nested parallel loops). The loop identifier metadata refers to
// itself so we can check both cases with the same routine.
- MDNode *loopIdMD = II->getMetadata("llvm.mem.parallel_loop_access");
+ MDNode *loopIdMD =
+ II->getMetadata(LLVMContext::MD_mem_parallel_loop_access);
if (!loopIdMD)
return false;
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 462d5b7cf0b..53f3be51665 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -2624,7 +2624,7 @@ bool llvm::isKnownNonNull(const Value *V, const TargetLibraryInfo *TLI) {
// A Load tagged w/nonnull metadata is never null.
if (const LoadInst *LI = dyn_cast<LoadInst>(V))
- return LI->getMetadata("nonnull");
+ return LI->getMetadata(LLVMContext::MD_nonnull);
if (ImmutableCallSite CS = V)
if (CS.isReturnNonNull())
diff --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
index 33ae609643b..0b2e22486e3 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -2122,8 +2122,8 @@ FastISel::createMachineMemOperandFor(const Instruction *I) const {
} else
return nullptr;
- bool IsNonTemporal = I->getMetadata("nontemporal") != nullptr;
- bool IsInvariant = I->getMetadata("invariant.load") != nullptr;
+ bool IsNonTemporal = I->getMetadata(LLVMContext::MD_nontemporal) != nullptr;
+ bool IsInvariant = I->getMetadata(LLVMContext::MD_invariant_load) != nullptr;
const MDNode *Ranges = I->getMetadata(LLVMContext::MD_range);
AAMDNodes AAInfo;
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 9dff2643fa3..3a14a3702e8 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -3480,8 +3480,8 @@ void SelectionDAGBuilder::visitLoad(const LoadInst &I) {
Type *Ty = I.getType();
bool isVolatile = I.isVolatile();
- bool isNonTemporal = I.getMetadata("nontemporal") != nullptr;
- bool isInvariant = I.getMetadata("invariant.load") != nullptr;
+ bool isNonTemporal = I.getMetadata(LLVMContext::MD_nontemporal) != nullptr;
+ bool isInvariant = I.getMetadata(LLVMContext::MD_invariant_load) != nullptr;
unsigned Alignment = I.getAlignment();
AAMDNodes AAInfo;
@@ -3584,7 +3584,7 @@ void SelectionDAGBuilder::visitStore(const StoreInst &I) {
NumValues));
EVT PtrVT = Ptr.getValueType();
bool isVolatile = I.isVolatile();
- bool isNonTemporal = I.getMetadata("nontemporal") != nullptr;
+ bool isNonTemporal = I.getMetadata(LLVMContext::MD_nontemporal) != nullptr;
unsigned Alignment = I.getAlignment();
AAMDNodes AAInfo;
diff --git a/llvm/lib/IR/LLVMContext.cpp b/llvm/lib/IR/LLVMContext.cpp
index 73ddc8cbe20..a1a4f63da32 100644
--- a/llvm/lib/IR/LLVMContext.cpp
+++ b/llvm/lib/IR/LLVMContext.cpp
@@ -76,6 +76,23 @@ LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) {
unsigned NoAliasID = getMDKindID("noalias");
assert(NoAliasID == MD_noalias && "noalias kind id drifted");
(void)NoAliasID;
+
+ // Create the 'nontemporal' metadata kind.
+ unsigned NonTemporalID = getMDKindID("nontemporal");
+ assert(NonTemporalID == MD_nontemporal && "nontemporal kind id drifted");
+ (void)NonTemporalID;
+
+ // Create the 'llvm.mem.parallel_loop_access' metadata kind.
+ unsigned MemParallelLoopAccessID = getMDKindID("llvm.mem.parallel_loop_access");
+ assert(MemParallelLoopAccessID == MD_mem_parallel_loop_access &&
+ "mem_parallel_loop_access kind id drifted");
+ (void)MemParallelLoopAccessID;
+
+
+ // Create the 'nonnull' metadata kind.
+ unsigned NonNullID = getMDKindID("nonnull");
+ assert(NonNullID == MD_nonnull && "nonnull kind id drifted");
+ (void)NonNullID;
}
LLVMContext::~LLVMContext() { delete pImpl; }
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
index 32ac62e74c0..3557ad72f49 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -329,6 +329,8 @@ static LoadInst *combineLoadToNewType(InstCombiner &IC, LoadInst &LI, Type *NewT
case LLVMContext::MD_invariant_load:
case LLVMContext::MD_alias_scope:
case LLVMContext::MD_noalias:
+ case LLVMContext::MD_nontemporal:
+ case LLVMContext::MD_mem_parallel_loop_access:
// All of these directly apply.
NewLoad->setMetadata(ID, N);
break;
@@ -339,12 +341,6 @@ static LoadInst *combineLoadToNewType(InstCombiner &IC, LoadInst &LI, Type *NewT
break;
}
}
- // FIXME: These metadata nodes should really have enumerators and be handled
- // above.
- if (MDNode *N = LI.getMetadata("nontemporal"))
- NewLoad->setMetadata("nontemporal", N);
- if (MDNode *N = LI.getMetadata("llvm.mem.parallel_loop_access"))
- NewLoad->setMetadata("llvm.mem.parallel_loop_access", N);
return NewLoad;
}
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index 4952a644ff2..5f00bb94188 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -444,7 +444,7 @@ bool LICM::canSinkOrHoistInst(Instruction &I) {
// in the same alias set as something that ends up being modified.
if (AA->pointsToConstantMemory(LI->getOperand(0)))
return true;
- if (LI->getMetadata("invariant.load"))
+ if (LI->getMetadata(LLVMContext::MD_invariant_load))
return true;
// Don't hoist loads which have may-aliased stores in loop.
OpenPOWER on IntegriCloud