[llvm] r221024 - IR: MDNode => Value: Instruction::getMetadata()

Duncan P. N. Exon Smith dexonsmith at apple.com
Fri Oct 31 17:10:31 PDT 2014


Author: dexonsmith
Date: Fri Oct 31 19:10:31 2014
New Revision: 221024

URL: http://llvm.org/viewvc/llvm-project?rev=221024&view=rev
Log:
IR: MDNode => Value: Instruction::getMetadata()

Change `Instruction::getMetadata()` to return `Value` as part of
PR21433.

Update most callers to use `Instruction::getMDNode()`, which wraps the
result in a `cast_or_null<MDNode>`.

Modified:
    llvm/trunk/include/llvm/IR/Instruction.h
    llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp
    llvm/trunk/lib/Analysis/LoopInfo.cpp
    llvm/trunk/lib/Analysis/ScalarEvolution.cpp
    llvm/trunk/lib/Analysis/ScopedNoAliasAA.cpp
    llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp
    llvm/trunk/lib/Analysis/ValueTracking.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
    llvm/trunk/lib/IR/AutoUpgrade.cpp
    llvm/trunk/lib/IR/DiagnosticInfo.cpp
    llvm/trunk/lib/IR/Instructions.cpp
    llvm/trunk/lib/IR/Metadata.cpp
    llvm/trunk/lib/IR/Verifier.cpp
    llvm/trunk/lib/Target/NVPTX/NVPTXUtilities.cpp
    llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
    llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
    llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
    llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
    llvm/trunk/lib/Transforms/Utils/Local.cpp
    llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
    llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp

Modified: llvm/trunk/include/llvm/IR/Instruction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Instruction.h?rev=221024&r1=221023&r2=221024&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Instruction.h (original)
+++ llvm/trunk/include/llvm/IR/Instruction.h Fri Oct 31 19:10:31 2014
@@ -141,14 +141,14 @@ public:
 
   /// getMetadata - Get the metadata of given kind attached to this Instruction.
   /// If the metadata is not found then return null.
-  MDNode *getMetadata(unsigned KindID) const {
+  Value *getMetadata(unsigned KindID) const {
     if (!hasMetadata()) return nullptr;
     return getMetadataImpl(KindID);
   }
 
   /// getMetadata - Get the metadata of given kind attached to this Instruction.
   /// If the metadata is not found then return null.
-  MDNode *getMetadata(StringRef Kind) const {
+  Value *getMetadata(StringRef Kind) const {
     if (!hasMetadata()) return nullptr;
     return getMetadataImpl(Kind);
   }
@@ -289,8 +289,8 @@ private:
   }
 
   // These are all implemented in Metadata.cpp.
-  MDNode *getMetadataImpl(unsigned KindID) const;
-  MDNode *getMetadataImpl(StringRef Kind) const;
+  Value *getMetadataImpl(unsigned KindID) const;
+  Value *getMetadataImpl(StringRef Kind) const;
   MDNode *getMDNodeImpl(unsigned KindID) const;
   MDNode *getMDNodeImpl(StringRef Kind) const;
   void getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned,MDNode*> > &)const;

Modified: llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp?rev=221024&r1=221023&r2=221024&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp Fri Oct 31 19:10:31 2014
@@ -180,7 +180,7 @@ bool BranchProbabilityInfo::calcMetadata
   if (!isa<BranchInst>(TI) && !isa<SwitchInst>(TI))
     return false;
 
-  MDNode *WeightsNode = TI->getMetadata(LLVMContext::MD_prof);
+  MDNode *WeightsNode = TI->getMDNode(LLVMContext::MD_prof);
   if (!WeightsNode)
     return false;
 

Modified: llvm/trunk/lib/Analysis/LoopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopInfo.cpp?rev=221024&r1=221023&r2=221024&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LoopInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/LoopInfo.cpp Fri Oct 31 19:10:31 2014
@@ -235,7 +235,7 @@ bool Loop::isSafeToClone() const {
 MDNode *Loop::getLoopID() const {
   MDNode *LoopID = nullptr;
   if (isLoopSimplifyForm()) {
-    LoopID = getLoopLatch()->getTerminator()->getMetadata(LoopMDName);
+    LoopID = getLoopLatch()->getTerminator()->getMDNode(LoopMDName);
   } else {
     // Go through each predecessor of the loop header and check the
     // terminator for the metadata.
@@ -247,7 +247,7 @@ MDNode *Loop::getLoopID() const {
       // Check if this terminator branches to the loop header.
       for (unsigned i = 0, ie = TI->getNumSuccessors(); i != ie; ++i) {
         if (TI->getSuccessor(i) == H) {
-          MD = TI->getMetadata(LoopMDName);
+          MD = TI->getMDNode(LoopMDName);
           break;
         }
       }
@@ -309,7 +309,7 @@ bool Loop::isAnnotatedParallel() const {
       // nested parallel loops). The loop identifier metadata refers to
       // itself so we can check both cases with the same routine.
       MDNode *loopIdMD =
-        II->getMetadata(LLVMContext::MD_mem_parallel_loop_access);
+          II->getMDNode(LLVMContext::MD_mem_parallel_loop_access);
 
       if (!loopIdMD)
         return false;

Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=221024&r1=221023&r2=221024&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Fri Oct 31 19:10:31 2014
@@ -3668,7 +3668,7 @@ ScalarEvolution::GetMinTrailingZeros(con
 /// metadata present in the IR.
 static Optional<ConstantRange> GetRangeFromMetadata(Value *V) {
   if (Instruction *I = dyn_cast<Instruction>(V)) {
-    if (MDNode *MD = I->getMetadata(LLVMContext::MD_range)) {
+    if (MDNode *MD = I->getMDNode(LLVMContext::MD_range)) {
       ConstantRange TotalRange(
           cast<IntegerType>(I->getType())->getBitWidth(), false);
 

Modified: llvm/trunk/lib/Analysis/ScopedNoAliasAA.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScopedNoAliasAA.cpp?rev=221024&r1=221023&r2=221024&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScopedNoAliasAA.cpp (original)
+++ llvm/trunk/lib/Analysis/ScopedNoAliasAA.cpp Fri Oct 31 19:10:31 2014
@@ -213,13 +213,13 @@ ScopedNoAliasAA::getModRefInfo(Immutable
   if (!EnableScopedNoAlias)
     return AliasAnalysis::getModRefInfo(CS, Loc);
 
-  if (!mayAliasInScopes(Loc.AATags.Scope,
-        CS.getInstruction()->getMetadata(LLVMContext::MD_noalias)))
+  if (!mayAliasInScopes(Loc.AATags.Scope, CS.getInstruction()->getMDNode(
+                                              LLVMContext::MD_noalias)))
     return NoModRef;
 
   if (!mayAliasInScopes(
-        CS.getInstruction()->getMetadata(LLVMContext::MD_alias_scope),
-        Loc.AATags.NoAlias))
+          CS.getInstruction()->getMDNode(LLVMContext::MD_alias_scope),
+          Loc.AATags.NoAlias))
     return NoModRef;
 
   return AliasAnalysis::getModRefInfo(CS, Loc);
@@ -231,13 +231,13 @@ ScopedNoAliasAA::getModRefInfo(Immutable
     return AliasAnalysis::getModRefInfo(CS1, CS2);
 
   if (!mayAliasInScopes(
-        CS1.getInstruction()->getMetadata(LLVMContext::MD_alias_scope),
-        CS2.getInstruction()->getMetadata(LLVMContext::MD_noalias)))
+          CS1.getInstruction()->getMDNode(LLVMContext::MD_alias_scope),
+          CS2.getInstruction()->getMDNode(LLVMContext::MD_noalias)))
     return NoModRef;
 
   if (!mayAliasInScopes(
-        CS2.getInstruction()->getMetadata(LLVMContext::MD_alias_scope),
-        CS1.getInstruction()->getMetadata(LLVMContext::MD_noalias)))
+          CS2.getInstruction()->getMDNode(LLVMContext::MD_alias_scope),
+          CS1.getInstruction()->getMDNode(LLVMContext::MD_noalias)))
     return NoModRef;
 
   return AliasAnalysis::getModRefInfo(CS1, CS2);

Modified: llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp?rev=221024&r1=221023&r2=221024&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp Fri Oct 31 19:10:31 2014
@@ -493,7 +493,7 @@ TypeBasedAliasAnalysis::getModRefBehavio
 
   // If this is an "immutable" type, we can assume the call doesn't write
   // to memory.
-  if (const MDNode *M = CS.getInstruction()->getMetadata(LLVMContext::MD_tbaa))
+  if (const MDNode *M = CS.getInstruction()->getMDNode(LLVMContext::MD_tbaa))
     if ((!isStructPathTBAA(M) && TBAANode(M).TypeIsImmutable()) ||
         (isStructPathTBAA(M) && TBAAStructTagNode(M).TypeIsImmutable()))
       Min = OnlyReadsMemory;
@@ -514,8 +514,7 @@ TypeBasedAliasAnalysis::getModRefInfo(Im
     return AliasAnalysis::getModRefInfo(CS, Loc);
 
   if (const MDNode *L = Loc.AATags.TBAA)
-    if (const MDNode *M =
-          CS.getInstruction()->getMetadata(LLVMContext::MD_tbaa))
+    if (const MDNode *M = CS.getInstruction()->getMDNode(LLVMContext::MD_tbaa))
       if (!Aliases(L, M))
         return NoModRef;
 
@@ -528,10 +527,9 @@ TypeBasedAliasAnalysis::getModRefInfo(Im
   if (!EnableTBAA)
     return AliasAnalysis::getModRefInfo(CS1, CS2);
 
-  if (const MDNode *M1 =
-        CS1.getInstruction()->getMetadata(LLVMContext::MD_tbaa))
+  if (const MDNode *M1 = CS1.getInstruction()->getMDNode(LLVMContext::MD_tbaa))
     if (const MDNode *M2 =
-          CS2.getInstruction()->getMetadata(LLVMContext::MD_tbaa))
+            CS2.getInstruction()->getMDNode(LLVMContext::MD_tbaa))
       if (!Aliases(M1, M2))
         return NoModRef;
 
@@ -614,21 +612,21 @@ MDNode *MDNode::getMostGenericTBAA(MDNod
 
 void Instruction::getAAMetadata(AAMDNodes &N, bool Merge) const {
   if (Merge)
-    N.TBAA = MDNode::getMostGenericTBAA(N.TBAA,
-                                        getMetadata(LLVMContext::MD_tbaa));
+    N.TBAA =
+        MDNode::getMostGenericTBAA(N.TBAA, getMDNode(LLVMContext::MD_tbaa));
   else
-    N.TBAA = getMetadata(LLVMContext::MD_tbaa);
+    N.TBAA = getMDNode(LLVMContext::MD_tbaa);
 
   if (Merge)
-    N.Scope = MDNode::intersect(N.Scope,
-                                getMetadata(LLVMContext::MD_alias_scope));
+    N.Scope =
+        MDNode::intersect(N.Scope, getMDNode(LLVMContext::MD_alias_scope));
   else
-    N.Scope = getMetadata(LLVMContext::MD_alias_scope);
+    N.Scope = getMDNode(LLVMContext::MD_alias_scope);
 
   if (Merge)
-    N.NoAlias = MDNode::intersect(N.NoAlias,
-                                  getMetadata(LLVMContext::MD_noalias));
+    N.NoAlias =
+        MDNode::intersect(N.NoAlias, getMDNode(LLVMContext::MD_noalias));
   else
-    N.NoAlias = getMetadata(LLVMContext::MD_noalias);
+    N.NoAlias = getMDNode(LLVMContext::MD_noalias);
 }
 

Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=221024&r1=221023&r2=221024&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Fri Oct 31 19:10:31 2014
@@ -862,7 +862,7 @@ void computeKnownBits(Value *V, APInt &K
   switch (I->getOpcode()) {
   default: break;
   case Instruction::Load:
-    if (MDNode *MD = cast<LoadInst>(I)->getMetadata(LLVMContext::MD_range))
+    if (MDNode *MD = cast<LoadInst>(I)->getMDNode(LLVMContext::MD_range))
       computeKnownBitsFromRangeMetadata(*MD, KnownZero);
     break;
   case Instruction::And: {
@@ -1261,7 +1261,7 @@ void computeKnownBits(Value *V, APInt &K
   }
   case Instruction::Call:
   case Instruction::Invoke:
-    if (MDNode *MD = cast<Instruction>(I)->getMetadata(LLVMContext::MD_range))
+    if (MDNode *MD = cast<Instruction>(I)->getMDNode(LLVMContext::MD_range))
       computeKnownBitsFromRangeMetadata(*MD, KnownZero);
     // If a range metadata is attached to this IntrinsicInst, intersect the
     // explicit range specified by the metadata and the implicit range of
@@ -1536,7 +1536,7 @@ bool isKnownNonZero(Value *V, const Data
   }
 
   if (Instruction* I = dyn_cast<Instruction>(V)) {
-    if (MDNode *Ranges = I->getMetadata(LLVMContext::MD_range)) {
+    if (MDNode *Ranges = I->getMDNode(LLVMContext::MD_range)) {
       // If the possible ranges don't contain zero, then the value is
       // definitely non-zero.
       if (IntegerType* Ty = dyn_cast<IntegerType>(V->getType())) {

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=221024&r1=221023&r2=221024&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Fri Oct 31 19:10:31 2014
@@ -2122,9 +2122,9 @@ FastISel::createMachineMemOperandFor(con
   } else
     return 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);
+  bool IsNonTemporal = I->getMDNode(LLVMContext::MD_nontemporal) != nullptr;
+  bool IsInvariant = I->getMDNode(LLVMContext::MD_invariant_load) != nullptr;
+  const MDNode *Ranges = I->getMDNode(LLVMContext::MD_range);
 
   AAMDNodes AAInfo;
   I->getAAMetadata(AAInfo);

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=221024&r1=221023&r2=221024&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Fri Oct 31 19:10:31 2014
@@ -3480,13 +3480,13 @@ void SelectionDAGBuilder::visitLoad(cons
   Type *Ty = I.getType();
 
   bool isVolatile = I.isVolatile();
-  bool isNonTemporal = I.getMetadata(LLVMContext::MD_nontemporal) != nullptr;
-  bool isInvariant = I.getMetadata(LLVMContext::MD_invariant_load) != nullptr;
+  bool isNonTemporal = I.getMDNode(LLVMContext::MD_nontemporal) != nullptr;
+  bool isInvariant = I.getMDNode(LLVMContext::MD_invariant_load) != nullptr;
   unsigned Alignment = I.getAlignment();
 
   AAMDNodes AAInfo;
   I.getAAMetadata(AAInfo);
-  const MDNode *Ranges = I.getMetadata(LLVMContext::MD_range);
+  const MDNode *Ranges = I.getMDNode(LLVMContext::MD_range);
 
   const TargetLowering &TLI = DAG.getTargetLoweringInfo();
   SmallVector<EVT, 4> ValueVTs;
@@ -3584,7 +3584,7 @@ void SelectionDAGBuilder::visitStore(con
                                           NumValues));
   EVT PtrVT = Ptr.getValueType();
   bool isVolatile = I.isVolatile();
-  bool isNonTemporal = I.getMetadata(LLVMContext::MD_nontemporal) != nullptr;
+  bool isNonTemporal = I.getMDNode(LLVMContext::MD_nontemporal) != nullptr;
   unsigned Alignment = I.getAlignment();
 
   AAMDNodes AAInfo;
@@ -6479,7 +6479,7 @@ void SelectionDAGBuilder::visitInlineAsm
   // If we have a !srcloc metadata node associated with it, we want to attach
   // this to the ultimately generated inline asm machineinstr.  To do this, we
   // pass in the third operand as this (potentially null) inline asm MDNode.
-  const MDNode *SrcLoc = CS.getInstruction()->getMetadata("srcloc");
+  const MDNode *SrcLoc = CS.getInstruction()->getMDNode("srcloc");
   AsmNodeOperands.push_back(DAG.getMDNode(SrcLoc));
 
   // Remember the HasSideEffect, AlignStack, AsmDialect, MayLoad and MayStore

Modified: llvm/trunk/lib/IR/AutoUpgrade.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AutoUpgrade.cpp?rev=221024&r1=221023&r2=221024&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AutoUpgrade.cpp (original)
+++ llvm/trunk/lib/IR/AutoUpgrade.cpp Fri Oct 31 19:10:31 2014
@@ -579,7 +579,7 @@ void llvm::UpgradeCallsToIntrinsic(Funct
 }
 
 void llvm::UpgradeInstWithTBAATag(Instruction *I) {
-  MDNode *MD = I->getMetadata(LLVMContext::MD_tbaa);
+  MDNode *MD = I->getMDNode(LLVMContext::MD_tbaa);
   assert(MD && "UpgradeInstWithTBAATag should have a TBAA tag");
   // Check if the tag uses struct-path aware TBAA format.
   if (isa<MDNode>(MD->getOperand(0)) && MD->getNumOperands() >= 3)

Modified: llvm/trunk/lib/IR/DiagnosticInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DiagnosticInfo.cpp?rev=221024&r1=221023&r2=221024&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DiagnosticInfo.cpp (original)
+++ llvm/trunk/lib/IR/DiagnosticInfo.cpp Fri Oct 31 19:10:31 2014
@@ -96,7 +96,7 @@ DiagnosticInfoInlineAsm::DiagnosticInfoI
                                                  DiagnosticSeverity Severity)
     : DiagnosticInfo(DK_InlineAsm, Severity), LocCookie(0), MsgStr(MsgStr),
       Instr(&I) {
-  if (const MDNode *SrcLoc = I.getMetadata("srcloc")) {
+  if (const MDNode *SrcLoc = I.getMDNode("srcloc")) {
     if (SrcLoc->getNumOperands() != 0)
       if (const ConstantInt *CI = dyn_cast<ConstantInt>(SrcLoc->getOperand(0)))
         LocCookie = CI->getZExtValue();

Modified: llvm/trunk/lib/IR/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Instructions.cpp?rev=221024&r1=221023&r2=221024&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Instructions.cpp (original)
+++ llvm/trunk/lib/IR/Instructions.cpp Fri Oct 31 19:10:31 2014
@@ -791,7 +791,7 @@ void BranchInst::swapSuccessors() {
 
   // Update profile metadata if present and it matches our structural
   // expectations.
-  MDNode *ProfileData = getMetadata(LLVMContext::MD_prof);
+  MDNode *ProfileData = getMDNode(LLVMContext::MD_prof);
   if (!ProfileData || ProfileData->getNumOperands() != 3)
     return;
 
@@ -2072,8 +2072,7 @@ void BinaryOperator::andIRFlags(const Va
 /// An accuracy of 0.0 means that the operation should be performed with the
 /// default precision.
 float FPMathOperator::getFPAccuracy() const {
-  const MDNode *MD =
-    cast<Instruction>(this)->getMetadata(LLVMContext::MD_fpmath);
+  const MDNode *MD = cast<Instruction>(this)->getMDNode(LLVMContext::MD_fpmath);
   if (!MD)
     return 0.0;
   ConstantFP *Accuracy = cast<ConstantFP>(MD->getOperand(0));

Modified: llvm/trunk/lib/IR/Metadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Metadata.cpp?rev=221024&r1=221023&r2=221024&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Metadata.cpp (original)
+++ llvm/trunk/lib/IR/Metadata.cpp Fri Oct 31 19:10:31 2014
@@ -605,16 +605,16 @@ void Instruction::setMetadata(StringRef
   setMetadata(getContext().getMDKindID(Kind), MD);
 }
 
-MDNode *Instruction::getMetadataImpl(StringRef Kind) const {
+Value *Instruction::getMetadataImpl(StringRef Kind) const {
   return getMetadataImpl(getContext().getMDKindID(Kind));
 }
 
 MDNode *Instruction::getMDNodeImpl(unsigned KindID) const {
-  return getMetadataImpl(KindID);
+  return cast_or_null<MDNode>(getMetadataImpl(KindID));
 }
 
 MDNode *Instruction::getMDNodeImpl(StringRef Kind) const {
-  return getMetadataImpl(Kind);
+  return cast_or_null<MDNode>(getMetadataImpl(Kind));
 }
 
 void Instruction::dropUnknownMetadata(ArrayRef<unsigned> KnownIDs) {
@@ -729,7 +729,7 @@ void Instruction::setAAMetadata(const AA
   setMetadata(LLVMContext::MD_noalias, N.NoAlias);
 }
 
-MDNode *Instruction::getMetadataImpl(unsigned KindID) const {
+Value *Instruction::getMetadataImpl(unsigned KindID) const {
   // Handle 'dbg' as a special case since it is not stored in the hash table.
   if (KindID == LLVMContext::MD_dbg)
     return DbgLoc.getAsMDNode(getContext());

Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=221024&r1=221023&r2=221024&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Fri Oct 31 19:10:31 2014
@@ -2267,7 +2267,7 @@ void Verifier::visitInstruction(Instruct
     }
   }
 
-  if (MDNode *MD = I.getMetadata(LLVMContext::MD_fpmath)) {
+  if (MDNode *MD = I.getMDNode(LLVMContext::MD_fpmath)) {
     Assert1(I.getType()->isFPOrFPVectorTy(),
             "fpmath requires a floating point result!", &I);
     Assert1(MD->getNumOperands() == 1, "fpmath takes one operand!", &I);
@@ -2281,7 +2281,7 @@ void Verifier::visitInstruction(Instruct
     }
   }
 
-  if (MDNode *Range = I.getMetadata(LLVMContext::MD_range)) {
+  if (MDNode *Range = I.getMDNode(LLVMContext::MD_range)) {
     Assert1(isa<LoadInst>(I) || isa<CallInst>(I) || isa<InvokeInst>(I),
             "Ranges are only for loads, calls and invokes!", &I);
     visitRangeMetadata(I, Range, I.getType());
@@ -2587,7 +2587,7 @@ void DebugInfoVerifier::verifyDebugInfo(
 void DebugInfoVerifier::processInstructions(DebugInfoFinder &Finder) {
   for (const Function &F : *M)
     for (auto I = inst_begin(&F), E = inst_end(&F); I != E; ++I) {
-      if (MDNode *MD = I->getMetadata(LLVMContext::MD_dbg))
+      if (MDNode *MD = I->getMDNode(LLVMContext::MD_dbg))
         Finder.processLocation(*M, DILocation(MD));
       if (const CallInst *CI = dyn_cast<CallInst>(&*I))
         processCallInst(Finder, *CI);

Modified: llvm/trunk/lib/Target/NVPTX/NVPTXUtilities.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXUtilities.cpp?rev=221024&r1=221023&r2=221024&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXUtilities.cpp (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXUtilities.cpp Fri Oct 31 19:10:31 2014
@@ -319,7 +319,7 @@ bool llvm::getAlign(const Function &F, u
 }
 
 bool llvm::getAlign(const CallInst &I, unsigned index, unsigned &align) {
-  if (MDNode *alignNode = I.getMetadata("callalign")) {
+  if (MDNode *alignNode = I.getMDNode("callalign")) {
     for (int i = 0, n = alignNode->getNumOperands(); i < n; i++) {
       if (const ConstantInt *CI =
               dyn_cast<ConstantInt>(alignNode->getOperand(i))) {

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=221024&r1=221023&r2=221024&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Fri Oct 31 19:10:31 2014
@@ -117,7 +117,7 @@ Instruction *InstCombiner::SimplifyMemTr
 
         // If the memcpy has metadata describing the members, see if we can
         // get the TBAA tag describing our copy.
-        if (MDNode *M = MI->getMetadata(LLVMContext::MD_tbaa_struct)) {
+        if (MDNode *M = MI->getMDNode(LLVMContext::MD_tbaa_struct)) {
           if (M->getNumOperands() == 3 &&
               M->getOperand(0) &&
               isa<ConstantInt>(M->getOperand(0)) &&

Modified: llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp?rev=221024&r1=221023&r2=221024&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp Fri Oct 31 19:10:31 2014
@@ -231,7 +231,7 @@ bool ThreadSanitizer::doInitialization(M
 }
 
 static bool isVtableAccess(Instruction *I) {
-  if (MDNode *Tag = I->getMetadata(LLVMContext::MD_tbaa))
+  if (MDNode *Tag = I->getMDNode(LLVMContext::MD_tbaa))
     return Tag->isTBAAVtableAccess();
   return false;
 }

Modified: llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp?rev=221024&r1=221023&r2=221024&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp (original)
+++ llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp Fri Oct 31 19:10:31 2014
@@ -825,7 +825,7 @@ static MDString *AppendMDNodeToSourcePtr
   // reference to said Node. Otherwise just return 0.
   if (Instruction *Inst = dyn_cast<Instruction>(Ptr)) {
     MDNode *Node;
-    if (!(Node = Inst->getMetadata(NodeId))) {
+    if (!(Node = Inst->getMDNode(NodeId))) {
       // We do not have any node. Generate and attatch the hash MDString to the
       // instruction.
 
@@ -1736,7 +1736,7 @@ ObjCARCOpt::VisitInstructionBottomUp(Ins
       NestingDetected = true;
     }
 
-    MDNode *ReleaseMetadata = Inst->getMetadata(ImpreciseReleaseMDKind);
+    MDNode *ReleaseMetadata = Inst->getMDNode(ImpreciseReleaseMDKind);
     Sequence NewSeq = ReleaseMetadata ? S_MovableRelease : S_Release;
     ANNOTATE_BOTTOMUP(Inst, Arg, S.GetSeq(), NewSeq);
     S.ResetSequenceProgress(NewSeq);
@@ -2017,7 +2017,7 @@ ObjCARCOpt::VisitInstructionTopDown(Inst
 
     Sequence OldSeq = S.GetSeq();
 
-    MDNode *ReleaseMetadata = Inst->getMetadata(ImpreciseReleaseMDKind);
+    MDNode *ReleaseMetadata = Inst->getMDNode(ImpreciseReleaseMDKind);
 
     switch (OldSeq) {
     case S_Retain:

Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=221024&r1=221023&r2=221024&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Fri Oct 31 19:10:31 2014
@@ -297,9 +297,9 @@ static void CloneAliasScopeMetadata(Call
   for (Function::const_iterator I = CalledFunc->begin(), IE = CalledFunc->end();
        I != IE; ++I)
     for (BasicBlock::const_iterator J = I->begin(), JE = I->end(); J != JE; ++J) {
-      if (const MDNode *M = J->getMetadata(LLVMContext::MD_alias_scope))
+      if (const MDNode *M = J->getMDNode(LLVMContext::MD_alias_scope))
         MD.insert(M);
-      if (const MDNode *M = J->getMetadata(LLVMContext::MD_noalias))
+      if (const MDNode *M = J->getMDNode(LLVMContext::MD_noalias))
         MD.insert(M);
     }
 
@@ -359,33 +359,31 @@ static void CloneAliasScopeMetadata(Call
     if (!NI)
       continue;
 
-    if (MDNode *M = NI->getMetadata(LLVMContext::MD_alias_scope)) {
+    if (MDNode *M = NI->getMDNode(LLVMContext::MD_alias_scope)) {
       MDNode *NewMD = MDMap[M];
       // If the call site also had alias scope metadata (a list of scopes to
       // which instructions inside it might belong), propagate those scopes to
       // the inlined instructions.
       if (MDNode *CSM =
-          CS.getInstruction()->getMetadata(LLVMContext::MD_alias_scope))
+              CS.getInstruction()->getMDNode(LLVMContext::MD_alias_scope))
         NewMD = MDNode::concatenate(NewMD, CSM);
       NI->setMetadata(LLVMContext::MD_alias_scope, NewMD);
     } else if (NI->mayReadOrWriteMemory()) {
       if (MDNode *M =
-          CS.getInstruction()->getMetadata(LLVMContext::MD_alias_scope))
+              CS.getInstruction()->getMDNode(LLVMContext::MD_alias_scope))
         NI->setMetadata(LLVMContext::MD_alias_scope, M);
     }
 
-    if (MDNode *M = NI->getMetadata(LLVMContext::MD_noalias)) {
+    if (MDNode *M = NI->getMDNode(LLVMContext::MD_noalias)) {
       MDNode *NewMD = MDMap[M];
       // If the call site also had noalias metadata (a list of scopes with
       // which instructions inside it don't alias), propagate those scopes to
       // the inlined instructions.
-      if (MDNode *CSM =
-          CS.getInstruction()->getMetadata(LLVMContext::MD_noalias))
+      if (MDNode *CSM = CS.getInstruction()->getMDNode(LLVMContext::MD_noalias))
         NewMD = MDNode::concatenate(NewMD, CSM);
       NI->setMetadata(LLVMContext::MD_noalias, NewMD);
     } else if (NI->mayReadOrWriteMemory()) {
-      if (MDNode *M =
-          CS.getInstruction()->getMetadata(LLVMContext::MD_noalias))
+      if (MDNode *M = CS.getInstruction()->getMDNode(LLVMContext::MD_noalias))
         NI->setMetadata(LLVMContext::MD_noalias, M);
     }
   }
@@ -589,9 +587,10 @@ static void AddAliasScopeMetadata(CallSi
       }
 
       if (!NoAliases.empty())
-        NI->setMetadata(LLVMContext::MD_noalias, MDNode::concatenate(
-          NI->getMetadata(LLVMContext::MD_noalias),
-            MDNode::get(CalledFunc->getContext(), NoAliases)));
+        NI->setMetadata(LLVMContext::MD_noalias,
+                        MDNode::concatenate(
+                            NI->getMDNode(LLVMContext::MD_noalias),
+                            MDNode::get(CalledFunc->getContext(), NoAliases)));
 
       // Next, we want to figure out all of the sets to which we might belong.
       // We might belong to a set if the noalias argument is in the set of
@@ -614,9 +613,10 @@ static void AddAliasScopeMetadata(CallSi
         }
 
       if (!Scopes.empty())
-        NI->setMetadata(LLVMContext::MD_alias_scope, MDNode::concatenate(
-          NI->getMetadata(LLVMContext::MD_alias_scope),
-            MDNode::get(CalledFunc->getContext(), Scopes)));
+        NI->setMetadata(
+            LLVMContext::MD_alias_scope,
+            MDNode::concatenate(NI->getMDNode(LLVMContext::MD_alias_scope),
+                                MDNode::get(CalledFunc->getContext(), Scopes)));
     }
   }
 }

Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=221024&r1=221023&r2=221024&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Fri Oct 31 19:10:31 2014
@@ -128,7 +128,7 @@ bool llvm::ConstantFoldTerminator(BasicB
       // Check to see if this branch is going to the same place as the default
       // dest.  If so, eliminate it as an explicit compare.
       if (i.getCaseSuccessor() == DefaultDest) {
-        MDNode* MD = SI->getMetadata(LLVMContext::MD_prof);
+        MDNode *MD = SI->getMDNode(LLVMContext::MD_prof);
         unsigned NCases = SI->getNumCases();
         // Fold the case metadata into the default if there will be any branches
         // left, unless the metadata doesn't match the switch.
@@ -206,7 +206,7 @@ bool llvm::ConstantFoldTerminator(BasicB
       BranchInst *NewBr = Builder.CreateCondBr(Cond,
                                                FirstCase.getCaseSuccessor(),
                                                SI->getDefaultDest());
-      MDNode* MD = SI->getMetadata(LLVMContext::MD_prof);
+      MDNode *MD = SI->getMDNode(LLVMContext::MD_prof);
       if (MD && MD->getNumOperands() == 3) {
         ConstantInt *SICase = dyn_cast<ConstantInt>(MD->getOperand(2));
         ConstantInt *SIDef = dyn_cast<ConstantInt>(MD->getOperand(1));
@@ -1313,7 +1313,7 @@ void llvm::combineMetadata(Instruction *
   K->getAllMetadataOtherThanDebugLoc(Metadata);
   for (unsigned i = 0, n = Metadata.size(); i < n; ++i) {
     unsigned Kind = Metadata[i].first;
-    MDNode *JMD = J->getMetadata(Kind);
+    MDNode *JMD = J->getMDNode(Kind);
     MDNode *KMD = Metadata[i].second;
 
     switch (Kind) {

Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=221024&r1=221023&r2=221024&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Fri Oct 31 19:10:31 2014
@@ -643,7 +643,7 @@ SimplifyEqualityComparisonWithOnlyPredec
 
     // Collect branch weights into a vector.
     SmallVector<uint32_t, 8> Weights;
-    MDNode* MD = SI->getMetadata(LLVMContext::MD_prof);
+    MDNode *MD = SI->getMDNode(LLVMContext::MD_prof);
     bool HasWeight = MD && (MD->getNumOperands() == 2 + SI->getNumCases());
     if (HasWeight)
       for (unsigned MD_i = 1, MD_e = MD->getNumOperands(); MD_i < MD_e;
@@ -738,7 +738,7 @@ static int ConstantIntSortPredicate(Cons
 }
 
 static inline bool HasBranchWeights(const Instruction* I) {
-  MDNode* ProfMD = I->getMetadata(LLVMContext::MD_prof);
+  MDNode *ProfMD = I->getMDNode(LLVMContext::MD_prof);
   if (ProfMD && ProfMD->getOperand(0))
     if (MDString* MDS = dyn_cast<MDString>(ProfMD->getOperand(0)))
       return MDS->getString().equals("branch_weights");
@@ -751,7 +751,7 @@ static inline bool HasBranchWeights(cons
 /// metadata.
 static void GetBranchWeights(TerminatorInst *TI,
                              SmallVectorImpl<uint64_t> &Weights) {
-  MDNode* MD = TI->getMetadata(LLVMContext::MD_prof);
+  MDNode *MD = TI->getMDNode(LLVMContext::MD_prof);
   assert(MD);
   for (unsigned i = 1, e = MD->getNumOperands(); i < e; ++i) {
     ConstantInt *CI = cast<ConstantInt>(MD->getOperand(i));
@@ -1970,7 +1970,7 @@ static bool ExtractBranchMetadata(Branch
                                   uint64_t &ProbTrue, uint64_t &ProbFalse) {
   assert(BI->isConditional() &&
          "Looking for probabilities on unconditional branch?");
-  MDNode *ProfileData = BI->getMetadata(LLVMContext::MD_prof);
+  MDNode *ProfileData = BI->getMDNode(LLVMContext::MD_prof);
   if (!ProfileData || ProfileData->getNumOperands() != 3) return false;
   ConstantInt *CITrue = dyn_cast<ConstantInt>(ProfileData->getOperand(1));
   ConstantInt *CIFalse = dyn_cast<ConstantInt>(ProfileData->getOperand(2));

Modified: llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp?rev=221024&r1=221023&r2=221024&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp Fri Oct 31 19:10:31 2014
@@ -197,7 +197,7 @@ static Instruction *propagateMetadata(In
 
     for (int i = 1, e = VL.size(); MD && i != e; i++) {
       Instruction *I = cast<Instruction>(VL[i]);
-      MDNode *IMD = I->getMetadata(Kind);
+      MDNode *IMD = I->getMDNode(Kind);
 
       switch (Kind) {
       default:





More information about the llvm-commits mailing list