Revert "IR: MDNode => Value"
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 11 Nov 2014 21:30:22 +0000 (21:30 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 11 Nov 2014 21:30:22 +0000 (21:30 +0000)
Instead, we're going to separate metadata from the Value hierarchy.  See
PR21532.

This reverts commit r221375.
This reverts commit r221373.
This reverts commit r221359.
This reverts commit r221167.
This reverts commit r221027.
This reverts commit r221024.
This reverts commit r221023.
This reverts commit r220995.
This reverts commit r220994.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221711 91177308-0d34-0410-b5e6-96231b3b80d8

46 files changed:
include/llvm/IR/IRBuilder.h
include/llvm/IR/Instruction.h
include/llvm/IR/Metadata.h
lib/Analysis/BranchProbabilityInfo.cpp
lib/Analysis/LoopInfo.cpp
lib/Analysis/ScalarEvolution.cpp
lib/Analysis/ScopedNoAliasAA.cpp
lib/Analysis/TypeBasedAliasAnalysis.cpp
lib/Analysis/ValueTracking.cpp
lib/Bitcode/Writer/BitcodeWriter.cpp
lib/Bitcode/Writer/ValueEnumerator.cpp
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
lib/CodeGen/SelectionDAG/FastISel.cpp
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
lib/IR/AsmWriter.cpp
lib/IR/AutoUpgrade.cpp
lib/IR/Core.cpp
lib/IR/DebugInfo.cpp
lib/IR/DiagnosticInfo.cpp
lib/IR/Instruction.cpp
lib/IR/Instructions.cpp
lib/IR/Metadata.cpp
lib/IR/Module.cpp
lib/IR/TypeFinder.cpp
lib/IR/Verifier.cpp
lib/Linker/LinkModules.cpp
lib/Target/NVPTX/NVPTXGenericToNVVM.cpp
lib/Target/NVPTX/NVPTXUtilities.cpp
lib/Target/R600/SITypeRewriter.cpp
lib/Transforms/InstCombine/InstCombineCalls.cpp
lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
lib/Transforms/Instrumentation/AddressSanitizer.cpp
lib/Transforms/Instrumentation/DebugIR.cpp
lib/Transforms/Instrumentation/GCOVProfiling.cpp
lib/Transforms/Instrumentation/ThreadSanitizer.cpp
lib/Transforms/ObjCARC/ObjCARCContract.cpp
lib/Transforms/ObjCARC/ObjCARCOpts.cpp
lib/Transforms/Scalar/Scalarizer.cpp
lib/Transforms/Utils/InlineFunction.cpp
lib/Transforms/Utils/Local.cpp
lib/Transforms/Utils/SimplifyCFG.cpp
lib/Transforms/Utils/ValueMapper.cpp
lib/Transforms/Vectorize/LoopVectorize.cpp
lib/Transforms/Vectorize/SLPVectorizer.cpp
tools/opt/BreakpointPrinter.cpp

index 35dda0b9aa0b57472097b432613c8f725dfc0951..088c7b4636af2dd9d0cd4194bcf7a6d516b55fd3 100644 (file)
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/LLVMContext.h"
-#include "llvm/IR/Metadata.h"
 #include "llvm/IR/Operator.h"
 #include "llvm/IR/ValueHandle.h"
 #include "llvm/Support/CBindingWrapping.h"
 
 namespace llvm {
 #include "llvm/IR/Operator.h"
 #include "llvm/IR/ValueHandle.h"
 #include "llvm/Support/CBindingWrapping.h"
 
 namespace llvm {
+class MDNode;
 
 /// \brief This provides the default implementation of the IRBuilder
 /// 'InsertHelper' method that is called whenever an instruction is created by
 
 /// \brief This provides the default implementation of the IRBuilder
 /// 'InsertHelper' method that is called whenever an instruction is created by
index a46485d83cec110bb8f6cfdfe0da80c16fa1ed88..ba7791c99b6a113102c0f2a9e6639c74afd0af18 100644 (file)
@@ -141,41 +141,23 @@ public:
 
   /// getMetadata - Get the metadata of given kind attached to this Instruction.
   /// If the metadata is not found then return null.
 
   /// getMetadata - Get the metadata of given kind attached to this Instruction.
   /// If the metadata is not found then return null.
-  Value *getMetadata(unsigned KindID) const {
+  MDNode *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.
     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.
-  Value *getMetadata(StringRef Kind) const {
+  MDNode *getMetadata(StringRef Kind) const {
     if (!hasMetadata()) return nullptr;
     return getMetadataImpl(Kind);
   }
 
     if (!hasMetadata()) return nullptr;
     return getMetadataImpl(Kind);
   }
 
-  /// Get the the metadata as an MDNode.
-  ///
-  /// \pre Any KindID metadata is implemented using \a MDNode.
-  MDNode *getMDNode(unsigned KindID) const {
-    if (!hasMetadata())
-      return nullptr;
-    return getMDNodeImpl(KindID);
-  }
-
-  /// Get the the metadata as an MDNode.
-  ///
-  /// \pre Any KindID metadata is implemented using \a MDNode.
-  MDNode *getMDNode(StringRef Kind) const {
-    if (!hasMetadata())
-      return nullptr;
-    return getMDNodeImpl(Kind);
-  }
-
   /// getAllMetadata - Get all metadata attached to this Instruction.  The first
   /// element of each pair returned is the KindID, the second element is the
   /// metadata value.  This list is returned sorted by the KindID.
   void
   /// getAllMetadata - Get all metadata attached to this Instruction.  The first
   /// element of each pair returned is the KindID, the second element is the
   /// metadata value.  This list is returned sorted by the KindID.
   void
-  getAllMetadata(SmallVectorImpl<std::pair<unsigned, Value *>> &MDs) const {
+  getAllMetadata(SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs) const {
     if (hasMetadata())
       getAllMetadataImpl(MDs);
   }
     if (hasMetadata())
       getAllMetadataImpl(MDs);
   }
@@ -183,7 +165,7 @@ public:
   /// getAllMetadataOtherThanDebugLoc - This does the same thing as
   /// getAllMetadata, except that it filters out the debug location.
   void getAllMetadataOtherThanDebugLoc(
   /// getAllMetadataOtherThanDebugLoc - This does the same thing as
   /// getAllMetadata, except that it filters out the debug location.
   void getAllMetadataOtherThanDebugLoc(
-      SmallVectorImpl<std::pair<unsigned, Value *>> &MDs) const {
+      SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs) const {
     if (hasMetadataOtherThanDebugLoc())
       getAllMetadataOtherThanDebugLocImpl(MDs);
   }
     if (hasMetadataOtherThanDebugLoc())
       getAllMetadataOtherThanDebugLocImpl(MDs);
   }
@@ -195,9 +177,9 @@ public:
 
   /// setMetadata - Set the metadata of the specified kind to the specified
   /// node.  This updates/replaces metadata if already present, or removes it if
 
   /// setMetadata - Set the metadata of the specified kind to the specified
   /// node.  This updates/replaces metadata if already present, or removes it if
-  /// MD is null.
-  void setMetadata(unsigned KindID, Value *MD);
-  void setMetadata(StringRef Kind, Value *MD);
+  /// Node is null.
+  void setMetadata(unsigned KindID, MDNode *Node);
+  void setMetadata(StringRef Kind, MDNode *Node);
 
   /// \brief Drop unknown metadata.
   /// Passes are required to drop metadata they don't understand. This is a
 
   /// \brief Drop unknown metadata.
   /// Passes are required to drop metadata they don't understand. This is a
@@ -290,14 +272,12 @@ private:
   }
 
   // These are all implemented in Metadata.cpp.
   }
 
   // These are all implemented in Metadata.cpp.
-  Value *getMetadataImpl(unsigned KindID) const;
-  Value *getMetadataImpl(StringRef Kind) const;
-  MDNode *getMDNodeImpl(unsigned KindID) const;
-  MDNode *getMDNodeImpl(StringRef Kind) const;
+  MDNode *getMetadataImpl(unsigned KindID) const;
+  MDNode *getMetadataImpl(StringRef Kind) const;
   void
   void
-  getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned, Value *>> &) const;
+  getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned, MDNode *>> &) const;
   void getAllMetadataOtherThanDebugLocImpl(
   void getAllMetadataOtherThanDebugLocImpl(
-      SmallVectorImpl<std::pair<unsigned, Value *>> &) const;
+      SmallVectorImpl<std::pair<unsigned, MDNode *>> &) const;
   void clearMetadataHashEntries();
 public:
   //===--------------------------------------------------------------------===//
   void clearMetadataHashEntries();
 public:
   //===--------------------------------------------------------------------===//
index fa325e7adb51e2b341fd5af51d99105628b9477d..9d3950f90633243d54c422811f35c6c65def8c97 100644 (file)
@@ -237,10 +237,10 @@ private:
 };
 
 //===----------------------------------------------------------------------===//
 };
 
 //===----------------------------------------------------------------------===//
-/// \brief A tuple of metadata nodes.
+/// \brief A tuple of MDNodes.
 ///
 /// Despite its name, a NamedMDNode isn't itself an MDNode. NamedMDNodes belong
 ///
 /// Despite its name, a NamedMDNode isn't itself an MDNode. NamedMDNodes belong
-/// to modules, have names, and contain lists of metadata nodes.
+/// to modules, have names, and contain lists of MDNodes.
 class NamedMDNode : public ilist_node<NamedMDNode> {
   friend class SymbolTableListTraits<NamedMDNode, Module>;
   friend struct ilist_traits<NamedMDNode>;
 class NamedMDNode : public ilist_node<NamedMDNode> {
   friend class SymbolTableListTraits<NamedMDNode, Module>;
   friend struct ilist_traits<NamedMDNode>;
@@ -250,7 +250,7 @@ class NamedMDNode : public ilist_node<NamedMDNode> {
 
   std::string Name;
   Module *Parent;
 
   std::string Name;
   Module *Parent;
-  void *Operands; // SmallVector<TrackingVH<Value>, 4>
+  void *Operands; // SmallVector<TrackingVH<MDNode>, 4>
 
   void setParent(Module *M) { Parent = M; }
 
 
   void setParent(Module *M) { Parent = M; }
 
@@ -305,12 +305,9 @@ public:
   inline Module *getParent() { return Parent; }
   inline const Module *getParent() const { return Parent; }
 
   inline Module *getParent() { return Parent; }
   inline const Module *getParent() const { return Parent; }
 
-  Value *getOperand(unsigned i) const;
-  MDNode *getOperandAsMDNode(unsigned i) const {
-    return cast_or_null<MDNode>(getOperand(i));
-  }
+  MDNode *getOperand(unsigned i) const;
   unsigned getNumOperands() const;
   unsigned getNumOperands() const;
-  void addOperand(Value *M);
+  void addOperand(MDNode *M);
   StringRef getName() const;
   void print(raw_ostream &ROS) const;
   void dump() const;
   StringRef getName() const;
   void print(raw_ostream &ROS) const;
   void dump() const;
@@ -318,11 +315,11 @@ public:
   // ---------------------------------------------------------------------------
   // Operand Iterator interface...
   //
   // ---------------------------------------------------------------------------
   // Operand Iterator interface...
   //
-  typedef op_iterator_impl<Value *, Value> op_iterator;
+  typedef op_iterator_impl<MDNode *, MDNode> op_iterator;
   op_iterator op_begin() { return op_iterator(this, 0); }
   op_iterator op_end()   { return op_iterator(this, getNumOperands()); }
 
   op_iterator op_begin() { return op_iterator(this, 0); }
   op_iterator op_end()   { return op_iterator(this, getNumOperands()); }
 
-  typedef op_iterator_impl<const Value *, Value> const_op_iterator;
+  typedef op_iterator_impl<const MDNode *, MDNode> const_op_iterator;
   const_op_iterator op_begin() const { return const_op_iterator(this, 0); }
   const_op_iterator op_end()   const { return const_op_iterator(this, getNumOperands()); }
 
   const_op_iterator op_begin() const { return const_op_iterator(this, 0); }
   const_op_iterator op_end()   const { return const_op_iterator(this, getNumOperands()); }
 
index 4e083d2f877bc2af810fec95d1900efe7d4b2dd8..bbd87505952216d88b8cad5f042b36e03ecf7288 100644 (file)
@@ -180,7 +180,7 @@ bool BranchProbabilityInfo::calcMetadataWeights(BasicBlock *BB) {
   if (!isa<BranchInst>(TI) && !isa<SwitchInst>(TI))
     return false;
 
   if (!isa<BranchInst>(TI) && !isa<SwitchInst>(TI))
     return false;
 
-  MDNode *WeightsNode = TI->getMDNode(LLVMContext::MD_prof);
+  MDNode *WeightsNode = TI->getMetadata(LLVMContext::MD_prof);
   if (!WeightsNode)
     return false;
 
   if (!WeightsNode)
     return false;
 
index fd4382902bf5cc97a52f43baeab6f51925ceaf3f..b1f62c437326ab071ee29ab3e82cbb73f1e5d501 100644 (file)
@@ -235,7 +235,7 @@ bool Loop::isSafeToClone() const {
 MDNode *Loop::getLoopID() const {
   MDNode *LoopID = nullptr;
   if (isLoopSimplifyForm()) {
 MDNode *Loop::getLoopID() const {
   MDNode *LoopID = nullptr;
   if (isLoopSimplifyForm()) {
-    LoopID = getLoopLatch()->getTerminator()->getMDNode(LoopMDName);
+    LoopID = getLoopLatch()->getTerminator()->getMetadata(LoopMDName);
   } else {
     // Go through each predecessor of the loop header and check the
     // terminator for the metadata.
   } 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) {
       // 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->getMDNode(LoopMDName);
+          MD = TI->getMetadata(LoopMDName);
           break;
         }
       }
           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 =
       // nested parallel loops). The loop identifier metadata refers to
       // itself so we can check both cases with the same routine.
       MDNode *loopIdMD =
-          II->getMDNode(LLVMContext::MD_mem_parallel_loop_access);
+          II->getMetadata(LLVMContext::MD_mem_parallel_loop_access);
 
       if (!loopIdMD)
         return false;
 
       if (!loopIdMD)
         return false;
index a47568e0c7f3d6f76ab3de28786ee5e9c03e1c7d..7324344c3e0e71ec421ce8d4061fd2985bf628bb 100644 (file)
@@ -3668,7 +3668,7 @@ ScalarEvolution::GetMinTrailingZeros(const SCEV *S) {
 /// metadata present in the IR.
 static Optional<ConstantRange> GetRangeFromMetadata(Value *V) {
   if (Instruction *I = dyn_cast<Instruction>(V)) {
 /// metadata present in the IR.
 static Optional<ConstantRange> GetRangeFromMetadata(Value *V) {
   if (Instruction *I = dyn_cast<Instruction>(V)) {
-    if (MDNode *MD = I->getMDNode(LLVMContext::MD_range)) {
+    if (MDNode *MD = I->getMetadata(LLVMContext::MD_range)) {
       ConstantRange TotalRange(
           cast<IntegerType>(I->getType())->getBitWidth(), false);
 
       ConstantRange TotalRange(
           cast<IntegerType>(I->getType())->getBitWidth(), false);
 
index 0c341d9ee4fff53dfce72033fbdad63a890df36f..f6c300aa0e2759a59099e4c2db365ec5a532a1a8 100644 (file)
@@ -213,12 +213,12 @@ ScopedNoAliasAA::getModRefInfo(ImmutableCallSite CS, const Location &Loc) {
   if (!EnableScopedNoAlias)
     return AliasAnalysis::getModRefInfo(CS, Loc);
 
   if (!EnableScopedNoAlias)
     return AliasAnalysis::getModRefInfo(CS, Loc);
 
-  if (!mayAliasInScopes(Loc.AATags.Scope, CS.getInstruction()->getMDNode(
+  if (!mayAliasInScopes(Loc.AATags.Scope, CS.getInstruction()->getMetadata(
                                               LLVMContext::MD_noalias)))
     return NoModRef;
 
   if (!mayAliasInScopes(
                                               LLVMContext::MD_noalias)))
     return NoModRef;
 
   if (!mayAliasInScopes(
-          CS.getInstruction()->getMDNode(LLVMContext::MD_alias_scope),
+          CS.getInstruction()->getMetadata(LLVMContext::MD_alias_scope),
           Loc.AATags.NoAlias))
     return NoModRef;
 
           Loc.AATags.NoAlias))
     return NoModRef;
 
@@ -231,13 +231,13 @@ ScopedNoAliasAA::getModRefInfo(ImmutableCallSite CS1, ImmutableCallSite CS2) {
     return AliasAnalysis::getModRefInfo(CS1, CS2);
 
   if (!mayAliasInScopes(
     return AliasAnalysis::getModRefInfo(CS1, CS2);
 
   if (!mayAliasInScopes(
-          CS1.getInstruction()->getMDNode(LLVMContext::MD_alias_scope),
-          CS2.getInstruction()->getMDNode(LLVMContext::MD_noalias)))
+          CS1.getInstruction()->getMetadata(LLVMContext::MD_alias_scope),
+          CS2.getInstruction()->getMetadata(LLVMContext::MD_noalias)))
     return NoModRef;
 
   if (!mayAliasInScopes(
     return NoModRef;
 
   if (!mayAliasInScopes(
-          CS2.getInstruction()->getMDNode(LLVMContext::MD_alias_scope),
-          CS1.getInstruction()->getMDNode(LLVMContext::MD_noalias)))
+          CS2.getInstruction()->getMetadata(LLVMContext::MD_alias_scope),
+          CS1.getInstruction()->getMetadata(LLVMContext::MD_noalias)))
     return NoModRef;
 
   return AliasAnalysis::getModRefInfo(CS1, CS2);
     return NoModRef;
 
   return AliasAnalysis::getModRefInfo(CS1, CS2);
index 1f288b1a3282c112b52f75367999370a7b6826af..f347eb5f1915ac2de354d1ec6ff4e43b9e8c89e3 100644 (file)
@@ -493,7 +493,7 @@ TypeBasedAliasAnalysis::getModRefBehavior(ImmutableCallSite CS) {
 
   // If this is an "immutable" type, we can assume the call doesn't write
   // to memory.
 
   // If this is an "immutable" type, we can assume the call doesn't write
   // to memory.
-  if (const MDNode *M = CS.getInstruction()->getMDNode(LLVMContext::MD_tbaa))
+  if (const MDNode *M = CS.getInstruction()->getMetadata(LLVMContext::MD_tbaa))
     if ((!isStructPathTBAA(M) && TBAANode(M).TypeIsImmutable()) ||
         (isStructPathTBAA(M) && TBAAStructTagNode(M).TypeIsImmutable()))
       Min = OnlyReadsMemory;
     if ((!isStructPathTBAA(M) && TBAANode(M).TypeIsImmutable()) ||
         (isStructPathTBAA(M) && TBAAStructTagNode(M).TypeIsImmutable()))
       Min = OnlyReadsMemory;
@@ -514,7 +514,8 @@ TypeBasedAliasAnalysis::getModRefInfo(ImmutableCallSite CS,
     return AliasAnalysis::getModRefInfo(CS, Loc);
 
   if (const MDNode *L = Loc.AATags.TBAA)
     return AliasAnalysis::getModRefInfo(CS, Loc);
 
   if (const MDNode *L = Loc.AATags.TBAA)
-    if (const MDNode *M = CS.getInstruction()->getMDNode(LLVMContext::MD_tbaa))
+    if (const MDNode *M =
+            CS.getInstruction()->getMetadata(LLVMContext::MD_tbaa))
       if (!Aliases(L, M))
         return NoModRef;
 
       if (!Aliases(L, M))
         return NoModRef;
 
@@ -527,9 +528,10 @@ TypeBasedAliasAnalysis::getModRefInfo(ImmutableCallSite CS1,
   if (!EnableTBAA)
     return AliasAnalysis::getModRefInfo(CS1, CS2);
 
   if (!EnableTBAA)
     return AliasAnalysis::getModRefInfo(CS1, CS2);
 
-  if (const MDNode *M1 = CS1.getInstruction()->getMDNode(LLVMContext::MD_tbaa))
+  if (const MDNode *M1 =
+          CS1.getInstruction()->getMetadata(LLVMContext::MD_tbaa))
     if (const MDNode *M2 =
     if (const MDNode *M2 =
-            CS2.getInstruction()->getMDNode(LLVMContext::MD_tbaa))
+            CS2.getInstruction()->getMetadata(LLVMContext::MD_tbaa))
       if (!Aliases(M1, M2))
         return NoModRef;
 
       if (!Aliases(M1, M2))
         return NoModRef;
 
@@ -613,20 +615,20 @@ MDNode *MDNode::getMostGenericTBAA(MDNode *A, MDNode *B) {
 void Instruction::getAAMetadata(AAMDNodes &N, bool Merge) const {
   if (Merge)
     N.TBAA =
 void Instruction::getAAMetadata(AAMDNodes &N, bool Merge) const {
   if (Merge)
     N.TBAA =
-        MDNode::getMostGenericTBAA(N.TBAA, getMDNode(LLVMContext::MD_tbaa));
+        MDNode::getMostGenericTBAA(N.TBAA, getMetadata(LLVMContext::MD_tbaa));
   else
   else
-    N.TBAA = getMDNode(LLVMContext::MD_tbaa);
+    N.TBAA = getMetadata(LLVMContext::MD_tbaa);
 
   if (Merge)
     N.Scope =
 
   if (Merge)
     N.Scope =
-        MDNode::intersect(N.Scope, getMDNode(LLVMContext::MD_alias_scope));
+        MDNode::intersect(N.Scope, getMetadata(LLVMContext::MD_alias_scope));
   else
   else
-    N.Scope = getMDNode(LLVMContext::MD_alias_scope);
+    N.Scope = getMetadata(LLVMContext::MD_alias_scope);
 
   if (Merge)
     N.NoAlias =
 
   if (Merge)
     N.NoAlias =
-        MDNode::intersect(N.NoAlias, getMDNode(LLVMContext::MD_noalias));
+        MDNode::intersect(N.NoAlias, getMetadata(LLVMContext::MD_noalias));
   else
   else
-    N.NoAlias = getMDNode(LLVMContext::MD_noalias);
+    N.NoAlias = getMetadata(LLVMContext::MD_noalias);
 }
 
 }
 
index f8b226d95158a5165f62c78e28a2e83f71673ed5..9532e34a8c31edac2bce1645d18bb7f244a1df2b 100644 (file)
@@ -862,7 +862,7 @@ void computeKnownBits(Value *V, APInt &KnownZero, APInt &KnownOne,
   switch (I->getOpcode()) {
   default: break;
   case Instruction::Load:
   switch (I->getOpcode()) {
   default: break;
   case Instruction::Load:
-    if (MDNode *MD = cast<LoadInst>(I)->getMDNode(LLVMContext::MD_range))
+    if (MDNode *MD = cast<LoadInst>(I)->getMetadata(LLVMContext::MD_range))
       computeKnownBitsFromRangeMetadata(*MD, KnownZero);
     break;
   case Instruction::And: {
       computeKnownBitsFromRangeMetadata(*MD, KnownZero);
     break;
   case Instruction::And: {
@@ -1258,7 +1258,7 @@ void computeKnownBits(Value *V, APInt &KnownZero, APInt &KnownOne,
   }
   case Instruction::Call:
   case Instruction::Invoke:
   }
   case Instruction::Call:
   case Instruction::Invoke:
-    if (MDNode *MD = cast<Instruction>(I)->getMDNode(LLVMContext::MD_range))
+    if (MDNode *MD = cast<Instruction>(I)->getMetadata(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
       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
@@ -1533,7 +1533,7 @@ bool isKnownNonZero(Value *V, const DataLayout *TD, unsigned Depth,
   }
 
   if (Instruction* I = dyn_cast<Instruction>(V)) {
   }
 
   if (Instruction* I = dyn_cast<Instruction>(V)) {
-    if (MDNode *Ranges = I->getMDNode(LLVMContext::MD_range)) {
+    if (MDNode *Ranges = I->getMetadata(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())) {
       // If the possible ranges don't contain zero, then the value is
       // definitely non-zero.
       if (IntegerType* Ty = dyn_cast<IntegerType>(V->getType())) {
index ef7a456a35ca0244db60589d91730848231c6810..96181e54cb1607ba6c17ba695d176b16ffab33b8 100644 (file)
@@ -848,7 +848,7 @@ static void WriteMetadataAttachment(const Function &F,
 
   // Write metadata attachments
   // METADATA_ATTACHMENT - [m x [value, [n x [id, mdnode]]]
 
   // Write metadata attachments
   // METADATA_ATTACHMENT - [m x [value, [n x [id, mdnode]]]
-  SmallVector<std::pair<unsigned, Value *>, 4> MDs;
+  SmallVector<std::pair<unsigned, MDNode *>, 4> MDs;
 
   for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
     for (BasicBlock::const_iterator I = BB->begin(), E = BB->end();
 
   for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
     for (BasicBlock::const_iterator I = BB->begin(), E = BB->end();
index 902bb27c1e9805974f80d05b613e3baac9390172..d72e66c7be2e6e356a24bff65d60aa2bf162fe7b 100644 (file)
@@ -321,7 +321,7 @@ ValueEnumerator::ValueEnumerator(const Module *M) {
   EnumerateValueSymbolTable(M->getValueSymbolTable());
   EnumerateNamedMetadata(M);
 
   EnumerateValueSymbolTable(M->getValueSymbolTable());
   EnumerateNamedMetadata(M);
 
-  SmallVector<std::pair<unsigned, Value *>, 8> MDs;
+  SmallVector<std::pair<unsigned, MDNode *>, 8> MDs;
 
   // Enumerate types used by function bodies and argument lists.
   for (const Function &F : *M) {
 
   // Enumerate types used by function bodies and argument lists.
   for (const Function &F : *M) {
@@ -347,7 +347,7 @@ ValueEnumerator::ValueEnumerator(const Module *M) {
         MDs.clear();
         I.getAllMetadataOtherThanDebugLoc(MDs);
         for (unsigned i = 0, e = MDs.size(); i != e; ++i)
         MDs.clear();
         I.getAllMetadataOtherThanDebugLoc(MDs);
         for (unsigned i = 0, e = MDs.size(); i != e; ++i)
-          EnumerateMetadata(cast<MDNode>(MDs[i].second));
+          EnumerateMetadata(MDs[i].second);
 
         if (!I.getDebugLoc().isUnknown()) {
           MDNode *Scope, *IA;
 
         if (!I.getDebugLoc().isUnknown()) {
           MDNode *Scope, *IA;
@@ -741,10 +741,10 @@ void ValueEnumerator::incorporateFunction(const Function &F) {
             FnLocalMDVector.push_back(MD);
       }
 
             FnLocalMDVector.push_back(MD);
       }
 
-      SmallVector<std::pair<unsigned, Value *>, 8> MDs;
+      SmallVector<std::pair<unsigned, MDNode *>, 8> MDs;
       I->getAllMetadataOtherThanDebugLoc(MDs);
       for (unsigned i = 0, e = MDs.size(); i != e; ++i) {
       I->getAllMetadataOtherThanDebugLoc(MDs);
       for (unsigned i = 0, e = MDs.size(); i != e; ++i) {
-        auto *N = cast<MDNode>(MDs[i].second);
+        MDNode *N = MDs[i].second;
         if (N->isFunctionLocal() && N->getFunction())
           FnLocalMDVector.push_back(N);
       }
         if (N->isFunctionLocal() && N->getFunction())
           FnLocalMDVector.push_back(N);
       }
index 087836901a77819ce7ed92f58d73f90ca32bc275..32bcd6b8158104de8f550af356abda25feea6ff5 100644 (file)
@@ -1399,7 +1399,7 @@ void AsmPrinter::EmitModuleIdents(Module &M) {
 
   if (const NamedMDNode *NMD = M.getNamedMetadata("llvm.ident")) {
     for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
 
   if (const NamedMDNode *NMD = M.getNamedMetadata("llvm.ident")) {
     for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
-      const MDNode *N = NMD->getOperandAsMDNode(i);
+      const MDNode *N = NMD->getOperand(i);
       assert(N->getNumOperands() == 1 &&
              "llvm.ident metadata entry can have only one operand");
       const MDString *S = cast<MDString>(N->getOperand(0));
       assert(N->getNumOperands() == 1 &&
              "llvm.ident metadata entry can have only one operand");
       const MDString *S = cast<MDString>(N->getOperand(0));
index 9523446bd2205730572403afd64b398fe91f70ca..4acd7271be9aff13f1fcb8ec6818e51365f581f1 100644 (file)
@@ -450,8 +450,8 @@ void DwarfDebug::beginModule() {
 
   SingleCU = CU_Nodes->getNumOperands() == 1;
 
 
   SingleCU = CU_Nodes->getNumOperands() == 1;
 
-  for (Value *N : CU_Nodes->operands()) {
-    DICompileUnit CUNode(cast<MDNode>(N));
+  for (MDNode *N : CU_Nodes->operands()) {
+    DICompileUnit CUNode(N);
     DwarfCompileUnit &CU = constructDwarfCompileUnit(CUNode);
     DIArray ImportedEntities = CUNode.getImportedEntities();
     for (unsigned i = 0, e = ImportedEntities.getNumElements(); i != e; ++i)
     DwarfCompileUnit &CU = constructDwarfCompileUnit(CUNode);
     DIArray ImportedEntities = CUNode.getImportedEntities();
     for (unsigned i = 0, e = ImportedEntities.getNumElements(); i != e; ++i)
@@ -526,8 +526,8 @@ void DwarfDebug::collectDeadVariables() {
   const Module *M = MMI->getModule();
 
   if (NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu")) {
   const Module *M = MMI->getModule();
 
   if (NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu")) {
-    for (Value *N : CU_Nodes->operands()) {
-      DICompileUnit TheCU(cast<MDNode>(N));
+    for (MDNode *N : CU_Nodes->operands()) {
+      DICompileUnit TheCU(N);
       // Construct subprogram DIE and add variables DIEs.
       DwarfCompileUnit *SPCU =
           static_cast<DwarfCompileUnit *>(CUMap.lookup(TheCU));
       // Construct subprogram DIE and add variables DIEs.
       DwarfCompileUnit *SPCU =
           static_cast<DwarfCompileUnit *>(CUMap.lookup(TheCU));
index 593173d9c2ccce6fce02d4df6817d0410f0614fc..0b2e22486e3db516cf0d208ddf74c08cd252fe59 100644 (file)
@@ -2122,9 +2122,9 @@ FastISel::createMachineMemOperandFor(const Instruction *I) const {
   } else
     return nullptr;
 
   } else
     return nullptr;
 
-  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);
+  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;
   I->getAAMetadata(AAInfo);
 
   AAMDNodes AAInfo;
   I->getAAMetadata(AAInfo);
index cf030b30659c444a7bea030f661fd8113cd17fce..4b4b90b58373f977777170afcc4606dfecb72e38 100644 (file)
@@ -3480,13 +3480,13 @@ void SelectionDAGBuilder::visitLoad(const LoadInst &I) {
   Type *Ty = I.getType();
 
   bool isVolatile = I.isVolatile();
   Type *Ty = I.getType();
 
   bool isVolatile = I.isVolatile();
-  bool isNonTemporal = I.getMDNode(LLVMContext::MD_nontemporal) != nullptr;
-  bool isInvariant = I.getMDNode(LLVMContext::MD_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;
   I.getAAMetadata(AAInfo);
   unsigned Alignment = I.getAlignment();
 
   AAMDNodes AAInfo;
   I.getAAMetadata(AAInfo);
-  const MDNode *Ranges = I.getMDNode(LLVMContext::MD_range);
+  const MDNode *Ranges = I.getMetadata(LLVMContext::MD_range);
 
   const TargetLowering &TLI = DAG.getTargetLoweringInfo();
   SmallVector<EVT, 4> ValueVTs;
 
   const TargetLowering &TLI = DAG.getTargetLoweringInfo();
   SmallVector<EVT, 4> ValueVTs;
@@ -3584,7 +3584,7 @@ void SelectionDAGBuilder::visitStore(const StoreInst &I) {
                                           NumValues));
   EVT PtrVT = Ptr.getValueType();
   bool isVolatile = I.isVolatile();
                                           NumValues));
   EVT PtrVT = Ptr.getValueType();
   bool isVolatile = I.isVolatile();
-  bool isNonTemporal = I.getMDNode(LLVMContext::MD_nontemporal) != nullptr;
+  bool isNonTemporal = I.getMetadata(LLVMContext::MD_nontemporal) != nullptr;
   unsigned Alignment = I.getAlignment();
 
   AAMDNodes AAInfo;
   unsigned Alignment = I.getAlignment();
 
   AAMDNodes AAInfo;
@@ -6479,7 +6479,7 @@ void SelectionDAGBuilder::visitInlineAsm(ImmutableCallSite CS) {
   // 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.
   // 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()->getMDNode("srcloc");
+  const MDNode *SrcLoc = CS.getInstruction()->getMetadata("srcloc");
   AsmNodeOperands.push_back(DAG.getMDNode(SrcLoc));
 
   // Remember the HasSideEffect, AlignStack, AsmDialect, MayLoad and MayStore
   AsmNodeOperands.push_back(DAG.getMDNode(SrcLoc));
 
   // Remember the HasSideEffect, AlignStack, AsmDialect, MayLoad and MayStore
index d9e3131ce3ce1475360d8c48b37de24d1d01470e..1961a20901eea4e491d0e376f31d07b91c831b5f 100644 (file)
@@ -545,7 +545,7 @@ public:
   /// plane.  If something is not in the SlotTracker, return -1.
   int getLocalSlot(const Value *V);
   int getGlobalSlot(const GlobalValue *V);
   /// plane.  If something is not in the SlotTracker, return -1.
   int getLocalSlot(const Value *V);
   int getGlobalSlot(const GlobalValue *V);
-  int getMetadataSlot(const Value *MD);
+  int getMetadataSlot(const MDNode *N);
   int getAttributeGroupSlot(AttributeSet AS);
 
   /// If you'd like to deal with a function instead of just a module, use
   int getAttributeGroupSlot(AttributeSet AS);
 
   /// If you'd like to deal with a function instead of just a module, use
@@ -585,7 +585,7 @@ private:
   void CreateModuleSlot(const GlobalValue *V);
 
   /// CreateMetadataSlot - Insert the specified MDNode* into the slot table.
   void CreateModuleSlot(const GlobalValue *V);
 
   /// CreateMetadataSlot - Insert the specified MDNode* into the slot table.
-  void CreateMetadataSlot(const Value *MD);
+  void CreateMetadataSlot(const MDNode *N);
 
   /// CreateFunctionSlot - Insert the specified Value* into the slot table.
   void CreateFunctionSlot(const Value *V);
 
   /// CreateFunctionSlot - Insert the specified Value* into the slot table.
   void CreateFunctionSlot(const Value *V);
@@ -718,7 +718,7 @@ void SlotTracker::processFunction() {
 
   ST_DEBUG("Inserting Instructions:\n");
 
 
   ST_DEBUG("Inserting Instructions:\n");
 
-  SmallVector<std::pair<unsigned, Value *>, 4> MDForInst;
+  SmallVector<std::pair<unsigned, MDNode *>, 4> MDForInst;
 
   // Add all of the basic blocks and instructions with no names.
   for (Function::const_iterator BB = TheFunction->begin(),
 
   // Add all of the basic blocks and instructions with no names.
   for (Function::const_iterator BB = TheFunction->begin(),
@@ -755,7 +755,7 @@ void SlotTracker::processFunction() {
       // Process metadata attached with this instruction.
       I->getAllMetadata(MDForInst);
       for (unsigned i = 0, e = MDForInst.size(); i != e; ++i)
       // Process metadata attached with this instruction.
       I->getAllMetadata(MDForInst);
       for (unsigned i = 0, e = MDForInst.size(); i != e; ++i)
-        CreateMetadataSlot(cast<MDNode>(MDForInst[i].second));
+        CreateMetadataSlot(MDForInst[i].second);
       MDForInst.clear();
     }
   }
       MDForInst.clear();
     }
   }
@@ -786,13 +786,13 @@ int SlotTracker::getGlobalSlot(const GlobalValue *V) {
   return MI == mMap.end() ? -1 : (int)MI->second;
 }
 
   return MI == mMap.end() ? -1 : (int)MI->second;
 }
 
-/// getMetadataSlot - Get the slot number of a metadata node.
-int SlotTracker::getMetadataSlot(const Value *MD) {
+/// getMetadataSlot - Get the slot number of a MDNode.
+int SlotTracker::getMetadataSlot(const MDNode *N) {
   // Check for uninitialized state and do lazy initialization.
   initialize();
 
   // Find the MDNode in the module map
   // Check for uninitialized state and do lazy initialization.
   initialize();
 
   // Find the MDNode in the module map
-  mdn_iterator MI = mdnMap.find(cast<MDNode>(MD));
+  mdn_iterator MI = mdnMap.find(N);
   return MI == mdnMap.end() ? -1 : (int)MI->second;
 }
 
   return MI == mdnMap.end() ? -1 : (int)MI->second;
 }
 
@@ -846,10 +846,9 @@ void SlotTracker::CreateFunctionSlot(const Value *V) {
            DestSlot << " [o]\n");
 }
 
            DestSlot << " [o]\n");
 }
 
-/// CreateModuleSlot - Insert the specified metadata into the slot table.
-void SlotTracker::CreateMetadataSlot(const Value *MD) {
-  assert(MD && "Can't insert a null Value into SlotTracker!");
-  const MDNode *N = cast<MDNode>(MD);
+/// CreateModuleSlot - Insert the specified MDNode* into the slot table.
+void SlotTracker::CreateMetadataSlot(const MDNode *N) {
+  assert(N && "Can't insert a null Value into SlotTracker!");
 
   // Don't insert if N is a function-local metadata, these are always printed
   // inline.
 
   // Don't insert if N is a function-local metadata, these are always printed
   // inline.
@@ -2316,7 +2315,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
   }
 
   // Print Metadata info.
   }
 
   // Print Metadata info.
-  SmallVector<std::pair<unsigned, Value *>, 4> InstMD;
+  SmallVector<std::pair<unsigned, MDNode *>, 4> InstMD;
   I.getAllMetadata(InstMD);
   if (!InstMD.empty()) {
     SmallVector<StringRef, 8> MDNames;
   I.getAllMetadata(InstMD);
   if (!InstMD.empty()) {
     SmallVector<StringRef, 8> MDNames;
@@ -2329,8 +2328,8 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
          Out << ", !<unknown kind #" << Kind << ">";
        }
       Out << ' ';
          Out << ", !<unknown kind #" << Kind << ">";
        }
       Out << ' ';
-      WriteAsOperandInternal(Out, cast<MDNode>(InstMD[i].second), &TypePrinter,
-                             &Machine, TheModule);
+      WriteAsOperandInternal(Out, InstMD[i].second, &TypePrinter, &Machine,
+                             TheModule);
     }
   }
   printInfoComment(I);
     }
   }
   printInfoComment(I);
index 3800d70fc6cff8346d7a1dccbea68bd96fb6ad4c..c24dfead433d04d5158a5218989887b8a6d0bde9 100644 (file)
@@ -571,7 +571,7 @@ void llvm::UpgradeCallsToIntrinsic(Function* F) {
 }
 
 void llvm::UpgradeInstWithTBAATag(Instruction *I) {
 }
 
 void llvm::UpgradeInstWithTBAATag(Instruction *I) {
-  MDNode *MD = I->getMDNode(LLVMContext::MD_tbaa);
+  MDNode *MD = I->getMetadata(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)
   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)
index 7e60e05fd009416b7e5c15b843137afb8d9ca4dc..3576137dd30693a7d3739250c54a9afef5f925e8 100644 (file)
@@ -561,7 +561,7 @@ LLVMValueRef LLVMGetMetadata(LLVMValueRef Inst, unsigned KindID) {
 
 void LLVMSetMetadata(LLVMValueRef Inst, unsigned KindID, LLVMValueRef MD) {
   unwrap<Instruction>(Inst)
 
 void LLVMSetMetadata(LLVMValueRef Inst, unsigned KindID, LLVMValueRef MD) {
   unwrap<Instruction>(Inst)
-      ->setMetadata(KindID, MD ? unwrap<Value>(MD) : nullptr);
+      ->setMetadata(KindID, MD ? unwrap<MDNode>(MD) : nullptr);
 }
 
 /*--.. Conversion functions ................................................--*/
 }
 
 /*--.. Conversion functions ................................................--*/
@@ -720,7 +720,7 @@ void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char* name,
   NamedMDNode *N = unwrap(M)->getOrInsertNamedMetadata(name);
   if (!N)
     return;
   NamedMDNode *N = unwrap(M)->getOrInsertNamedMetadata(name);
   if (!N)
     return;
-  Value *Op = Val ? unwrap<Value>(Val) : nullptr;
+  MDNode *Op = Val ? unwrap<MDNode>(Val) : nullptr;
   if (Op)
     N->addOperand(Op);
 }
   if (Op)
     N->addOperand(Op);
 }
index 38389e8ca1ebd23e5d2d98a6eb0a630c9b5ca642..60904c2b356b2cf780a91ad4ab9207904777f2a0 100644 (file)
@@ -949,7 +949,7 @@ DITypeIdentifierMap
 llvm::generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes) {
   DITypeIdentifierMap Map;
   for (unsigned CUi = 0, CUe = CU_Nodes->getNumOperands(); CUi != CUe; ++CUi) {
 llvm::generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes) {
   DITypeIdentifierMap Map;
   for (unsigned CUi = 0, CUe = CU_Nodes->getNumOperands(); CUi != CUe; ++CUi) {
-    DICompileUnit CU(CU_Nodes->getOperandAsMDNode(CUi));
+    DICompileUnit CU(CU_Nodes->getOperand(CUi));
     DIArray Retain = CU.getRetainedTypes();
     for (unsigned Ti = 0, Te = Retain.getNumElements(); Ti != Te; ++Ti) {
       if (!Retain.getElement(Ti).isCompositeType())
     DIArray Retain = CU.getRetainedTypes();
     for (unsigned Ti = 0, Te = Retain.getNumElements(); Ti != Te; ++Ti) {
       if (!Retain.getElement(Ti).isCompositeType())
@@ -997,7 +997,7 @@ void DebugInfoFinder::processModule(const Module &M) {
   InitializeTypeMap(M);
   if (NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu")) {
     for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
   InitializeTypeMap(M);
   if (NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu")) {
     for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
-      DICompileUnit CU(CU_Nodes->getOperandAsMDNode(i));
+      DICompileUnit CU(CU_Nodes->getOperand(i));
       addCompileUnit(CU);
       DIArray GVs = CU.getGlobalVariables();
       for (unsigned i = 0, e = GVs.getNumElements(); i != e; ++i) {
       addCompileUnit(CU);
       DIArray GVs = CU.getGlobalVariables();
       for (unsigned i = 0, e = GVs.getNumElements(); i != e; ++i) {
@@ -1542,8 +1542,8 @@ llvm::makeSubprogramMap(const Module &M) {
   if (!CU_Nodes)
     return R;
 
   if (!CU_Nodes)
     return R;
 
-  for (Value *N : CU_Nodes->operands()) {
-    DICompileUnit CUNode(cast<MDNode>(N));
+  for (MDNode *N : CU_Nodes->operands()) {
+    DICompileUnit CUNode(N);
     DIArray SPs = CUNode.getSubprograms();
     for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i) {
       DISubprogram SP(SPs.getElement(i));
     DIArray SPs = CUNode.getSubprograms();
     for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i) {
       DISubprogram SP(SPs.getElement(i));
index c0552c90ae6ac173131952ab550f8df3899f9ee0..37cce2b0d7819b502c80ff332f42750bcd9c119e 100644 (file)
@@ -96,7 +96,7 @@ DiagnosticInfoInlineAsm::DiagnosticInfoInlineAsm(const Instruction &I,
                                                  DiagnosticSeverity Severity)
     : DiagnosticInfo(DK_InlineAsm, Severity), LocCookie(0), MsgStr(MsgStr),
       Instr(&I) {
                                                  DiagnosticSeverity Severity)
     : DiagnosticInfo(DK_InlineAsm, Severity), LocCookie(0), MsgStr(MsgStr),
       Instr(&I) {
-  if (const MDNode *SrcLoc = I.getMDNode("srcloc")) {
+  if (const MDNode *SrcLoc = I.getMetadata("srcloc")) {
     if (SrcLoc->getNumOperands() != 0)
       if (const ConstantInt *CI = dyn_cast<ConstantInt>(SrcLoc->getOperand(0)))
         LocCookie = CI->getZExtValue();
     if (SrcLoc->getNumOperands() != 0)
       if (const ConstantInt *CI = dyn_cast<ConstantInt>(SrcLoc->getOperand(0)))
         LocCookie = CI->getZExtValue();
index a2bbb563db43842e296610ed51bf32c0bde97a8e..3ee66f56981072271fc85cc83a3d4d7ad68ace66 100644 (file)
@@ -548,7 +548,7 @@ Instruction *Instruction::clone() const {
 
   // Otherwise, enumerate and copy over metadata from the old instruction to the
   // new one.
 
   // Otherwise, enumerate and copy over metadata from the old instruction to the
   // new one.
-  SmallVector<std::pair<unsigned, Value *>, 4> TheMDs;
+  SmallVector<std::pair<unsigned, MDNode *>, 4> TheMDs;
   getAllMetadataOtherThanDebugLoc(TheMDs);
   for (const auto &MD : TheMDs)
     New->setMetadata(MD.first, MD.second);
   getAllMetadataOtherThanDebugLoc(TheMDs);
   for (const auto &MD : TheMDs)
     New->setMetadata(MD.first, MD.second);
index 6aaea75896e359963b82f738c147c7af0f9ac2f9..4b48d7d6eb0cda8289c93b016358aaa3b1f5bb04 100644 (file)
@@ -791,7 +791,7 @@ void BranchInst::swapSuccessors() {
 
   // Update profile metadata if present and it matches our structural
   // expectations.
 
   // Update profile metadata if present and it matches our structural
   // expectations.
-  MDNode *ProfileData = getMDNode(LLVMContext::MD_prof);
+  MDNode *ProfileData = getMetadata(LLVMContext::MD_prof);
   if (!ProfileData || ProfileData->getNumOperands() != 3)
     return;
 
   if (!ProfileData || ProfileData->getNumOperands() != 3)
     return;
 
@@ -2072,7 +2072,8 @@ void BinaryOperator::andIRFlags(const Value *V) {
 /// An accuracy of 0.0 means that the operation should be performed with the
 /// default precision.
 float FPMathOperator::getFPAccuracy() const {
 /// 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)->getMDNode(LLVMContext::MD_fpmath);
+  const MDNode *MD =
+      cast<Instruction>(this)->getMetadata(LLVMContext::MD_fpmath);
   if (!MD)
     return 0.0;
   ConstantFP *Accuracy = cast<ConstantFP>(MD->getOperand(0));
   if (!MD)
     return 0.0;
   ConstantFP *Accuracy = cast<ConstantFP>(MD->getOperand(0));
index 59beb7341843edab52efe6a3dfa97a70c578f180..1fb15a075a617d632bab53955d31a3a01aa58dcb 100644 (file)
@@ -555,13 +555,13 @@ MDNode *MDNode::getMostGenericRange(MDNode *A, MDNode *B) {
 // NamedMDNode implementation.
 //
 
 // NamedMDNode implementation.
 //
 
-static SmallVector<TrackingVH<Value>, 4> &getNMDOps(void *Operands) {
-  return *(SmallVector<TrackingVH<Value>, 4> *)Operands;
+static SmallVector<TrackingVH<MDNode>, 4> &getNMDOps(void *Operands) {
+  return *(SmallVector<TrackingVH<MDNode>, 4> *)Operands;
 }
 
 NamedMDNode::NamedMDNode(const Twine &N)
     : Name(N.str()), Parent(nullptr),
 }
 
 NamedMDNode::NamedMDNode(const Twine &N)
     : Name(N.str()), Parent(nullptr),
-      Operands(new SmallVector<TrackingVH<Value>, 4>()) {}
+      Operands(new SmallVector<TrackingVH<MDNode>, 4>()) {}
 
 NamedMDNode::~NamedMDNode() {
   dropAllReferences();
 
 NamedMDNode::~NamedMDNode() {
   dropAllReferences();
@@ -572,16 +572,15 @@ unsigned NamedMDNode::getNumOperands() const {
   return (unsigned)getNMDOps(Operands).size();
 }
 
   return (unsigned)getNMDOps(Operands).size();
 }
 
-Value *NamedMDNode::getOperand(unsigned i) const {
+MDNode *NamedMDNode::getOperand(unsigned i) const {
   assert(i < getNumOperands() && "Invalid Operand number!");
   return &*getNMDOps(Operands)[i];
 }
 
   assert(i < getNumOperands() && "Invalid Operand number!");
   return &*getNMDOps(Operands)[i];
 }
 
-void NamedMDNode::addOperand(Value *V) {
-  auto *M = cast<MDNode>(V);
+void NamedMDNode::addOperand(MDNode *M) {
   assert(!M->isFunctionLocal() &&
          "NamedMDNode operands must not be function-local!");
   assert(!M->isFunctionLocal() &&
          "NamedMDNode operands must not be function-local!");
-  getNMDOps(Operands).push_back(TrackingVH<Value>(M));
+  getNMDOps(Operands).push_back(TrackingVH<MDNode>(M));
 }
 
 void NamedMDNode::eraseFromParent() {
 }
 
 void NamedMDNode::eraseFromParent() {
@@ -600,23 +599,16 @@ StringRef NamedMDNode::getName() const {
 // Instruction Metadata method implementations.
 //
 
 // Instruction Metadata method implementations.
 //
 
-void Instruction::setMetadata(StringRef Kind, Value *MD) {
-  if (!MD && !hasMetadata()) return;
-  setMetadata(getContext().getMDKindID(Kind), MD);
+void Instruction::setMetadata(StringRef Kind, MDNode *Node) {
+  if (!Node && !hasMetadata())
+    return;
+  setMetadata(getContext().getMDKindID(Kind), Node);
 }
 
 }
 
-Value *Instruction::getMetadataImpl(StringRef Kind) const {
+MDNode *Instruction::getMetadataImpl(StringRef Kind) const {
   return getMetadataImpl(getContext().getMDKindID(Kind));
 }
 
   return getMetadataImpl(getContext().getMDKindID(Kind));
 }
 
-MDNode *Instruction::getMDNodeImpl(unsigned KindID) const {
-  return cast_or_null<MDNode>(getMetadataImpl(KindID));
-}
-
-MDNode *Instruction::getMDNodeImpl(StringRef Kind) const {
-  return cast_or_null<MDNode>(getMetadataImpl(Kind));
-}
-
 void Instruction::dropUnknownMetadata(ArrayRef<unsigned> KnownIDs) {
   SmallSet<unsigned, 5> KnownSet;
   KnownSet.insert(KnownIDs.begin(), KnownIDs.end());
 void Instruction::dropUnknownMetadata(ArrayRef<unsigned> KnownIDs) {
   SmallSet<unsigned, 5> KnownSet;
   KnownSet.insert(KnownIDs.begin(), KnownIDs.end());
@@ -663,12 +655,10 @@ void Instruction::dropUnknownMetadata(ArrayRef<unsigned> KnownIDs) {
 
 /// setMetadata - Set the metadata of of the specified kind to the specified
 /// node.  This updates/replaces metadata if already present, or removes it if
 
 /// setMetadata - Set the metadata of of the specified kind to the specified
 /// node.  This updates/replaces metadata if already present, or removes it if
-/// MD is null.
-void Instruction::setMetadata(unsigned KindID, Value *MD) {
-  if (!MD && !hasMetadata()) return;
-
-  // For now, we only expect MDNodes here.
-  MDNode *Node = cast_or_null<MDNode>(MD);
+/// Node is null.
+void Instruction::setMetadata(unsigned KindID, MDNode *Node) {
+  if (!Node && !hasMetadata())
+    return;
 
   // Handle 'dbg' as a special case since it is not stored in the hash table.
   if (KindID == LLVMContext::MD_dbg) {
 
   // Handle 'dbg' as a special case since it is not stored in the hash table.
   if (KindID == LLVMContext::MD_dbg) {
@@ -729,7 +719,7 @@ void Instruction::setAAMetadata(const AAMDNodes &N) {
   setMetadata(LLVMContext::MD_noalias, N.NoAlias);
 }
 
   setMetadata(LLVMContext::MD_noalias, N.NoAlias);
 }
 
-Value *Instruction::getMetadataImpl(unsigned KindID) const {
+MDNode *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());
   // Handle 'dbg' as a special case since it is not stored in the hash table.
   if (KindID == LLVMContext::MD_dbg)
     return DbgLoc.getAsMDNode(getContext());
@@ -746,7 +736,7 @@ Value *Instruction::getMetadataImpl(unsigned KindID) const {
 }
 
 void Instruction::getAllMetadataImpl(
 }
 
 void Instruction::getAllMetadataImpl(
-    SmallVectorImpl<std::pair<unsigned, Value *>> &Result) const {
+    SmallVectorImpl<std::pair<unsigned, MDNode *>> &Result) const {
   Result.clear();
   
   // Handle 'dbg' as a special case since it is not stored in the hash table.
   Result.clear();
   
   // Handle 'dbg' as a special case since it is not stored in the hash table.
@@ -771,7 +761,7 @@ void Instruction::getAllMetadataImpl(
 }
 
 void Instruction::getAllMetadataOtherThanDebugLocImpl(
 }
 
 void Instruction::getAllMetadataOtherThanDebugLocImpl(
-    SmallVectorImpl<std::pair<unsigned, Value *>> &Result) const {
+    SmallVectorImpl<std::pair<unsigned, MDNode *>> &Result) const {
   Result.clear();
   assert(hasMetadataHashEntry() &&
          getContext().pImpl->MetadataStore.count(this) &&
   Result.clear();
   assert(hasMetadataHashEntry() &&
          getContext().pImpl->MetadataStore.count(this) &&
index bc50db3f56c7c3c937de5589fc887136a408b270..28743fae6cda3982c8c18487286c6b56ee529903 100644 (file)
@@ -276,8 +276,7 @@ getModuleFlagsMetadata(SmallVectorImpl<ModuleFlagEntry> &Flags) const {
   const NamedMDNode *ModFlags = getModuleFlagsMetadata();
   if (!ModFlags) return;
 
   const NamedMDNode *ModFlags = getModuleFlagsMetadata();
   if (!ModFlags) return;
 
-  for (const Value *FlagMD : ModFlags->operands()) {
-    const MDNode *Flag = cast<MDNode>(FlagMD);
+  for (const MDNode *Flag : ModFlags->operands()) {
     ModFlagBehavior MFB;
     if (Flag->getNumOperands() >= 3 &&
         isValidModFlagBehavior(Flag->getOperand(0), MFB) &&
     ModFlagBehavior MFB;
     if (Flag->getNumOperands() >= 3 &&
         isValidModFlagBehavior(Flag->getOperand(0), MFB) &&
index 3aae4e69ec1f3f56c23659d5213682a2724eaef6..6796075bfc20f1d26b1c42ecbd2e72637c226804 100644 (file)
@@ -40,7 +40,7 @@ void TypeFinder::run(const Module &M, bool onlyNamed) {
   }
 
   // Get types from functions.
   }
 
   // Get types from functions.
-  SmallVector<std::pair<unsigned, Value *>, 4> MDForInst;
+  SmallVector<std::pair<unsigned, MDNode *>, 4> MDForInst;
   for (Module::const_iterator FI = M.begin(), E = M.end(); FI != E; ++FI) {
     incorporateType(FI->getType());
 
   for (Module::const_iterator FI = M.begin(), E = M.end(); FI != E; ++FI) {
     incorporateType(FI->getType());
 
@@ -71,7 +71,7 @@ void TypeFinder::run(const Module &M, bool onlyNamed) {
         // Incorporate types hiding in metadata.
         I.getAllMetadataOtherThanDebugLoc(MDForInst);
         for (unsigned i = 0, e = MDForInst.size(); i != e; ++i)
         // Incorporate types hiding in metadata.
         I.getAllMetadataOtherThanDebugLoc(MDForInst);
         for (unsigned i = 0, e = MDForInst.size(); i != e; ++i)
-          incorporateMDNode(cast<MDNode>(MDForInst[i].second));
+          incorporateMDNode(MDForInst[i].second);
 
         MDForInst.clear();
       }
 
         MDForInst.clear();
       }
@@ -81,7 +81,7 @@ void TypeFinder::run(const Module &M, bool onlyNamed) {
          E = M.named_metadata_end(); I != E; ++I) {
     const NamedMDNode *NMD = I;
     for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i)
          E = M.named_metadata_end(); I != E; ++I) {
     const NamedMDNode *NMD = I;
     for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i)
-      incorporateMDNode(NMD->getOperandAsMDNode(i));
+      incorporateMDNode(NMD->getOperand(i));
   }
 }
 
   }
 }
 
index 395f2e74d61f0bc1a01b13ea1d34edc16df8c463..f9302910d395dfc04b591a6cad5e3c63bbc8627b 100644 (file)
@@ -555,7 +555,7 @@ void Verifier::visitGlobalAlias(const GlobalAlias &GA) {
 
 void Verifier::visitNamedMDNode(const NamedMDNode &NMD) {
   for (unsigned i = 0, e = NMD.getNumOperands(); i != e; ++i) {
 
 void Verifier::visitNamedMDNode(const NamedMDNode &NMD) {
   for (unsigned i = 0, e = NMD.getNumOperands(); i != e; ++i) {
-    MDNode *MD = NMD.getOperandAsMDNode(i);
+    MDNode *MD = NMD.getOperand(i);
     if (!MD)
       continue;
 
     if (!MD)
       continue;
 
@@ -624,7 +624,7 @@ void Verifier::visitModuleIdents(const Module &M) {
   // llvm.ident takes a list of metadata entry. Each entry has only one string.
   // Scan each llvm.ident entry and make sure that this requirement is met.
   for (unsigned i = 0, e = Idents->getNumOperands(); i != e; ++i) {
   // llvm.ident takes a list of metadata entry. Each entry has only one string.
   // Scan each llvm.ident entry and make sure that this requirement is met.
   for (unsigned i = 0, e = Idents->getNumOperands(); i != e; ++i) {
-    const MDNode *N = Idents->getOperandAsMDNode(i);
+    const MDNode *N = Idents->getOperand(i);
     Assert1(N->getNumOperands() == 1,
             "incorrect number of operands in llvm.ident metadata", N);
     Assert1(isa<MDString>(N->getOperand(0)),
     Assert1(N->getNumOperands() == 1,
             "incorrect number of operands in llvm.ident metadata", N);
     Assert1(isa<MDString>(N->getOperand(0)),
@@ -642,7 +642,7 @@ void Verifier::visitModuleFlags(const Module &M) {
   DenseMap<const MDString*, const MDNode*> SeenIDs;
   SmallVector<const MDNode*, 16> Requirements;
   for (unsigned I = 0, E = Flags->getNumOperands(); I != E; ++I) {
   DenseMap<const MDString*, const MDNode*> SeenIDs;
   SmallVector<const MDNode*, 16> Requirements;
   for (unsigned I = 0, E = Flags->getNumOperands(); I != E; ++I) {
-    visitModuleFlag(Flags->getOperandAsMDNode(I), SeenIDs, Requirements);
+    visitModuleFlag(Flags->getOperand(I), SeenIDs, Requirements);
   }
 
   // Validate that the requirements in the module are valid.
   }
 
   // Validate that the requirements in the module are valid.
@@ -2267,7 +2267,7 @@ void Verifier::visitInstruction(Instruction &I) {
     }
   }
 
     }
   }
 
-  if (MDNode *MD = I.getMDNode(LLVMContext::MD_fpmath)) {
+  if (MDNode *MD = I.getMetadata(LLVMContext::MD_fpmath)) {
     Assert1(I.getType()->isFPOrFPVectorTy(),
             "fpmath requires a floating point result!", &I);
     Assert1(MD->getNumOperands() == 1, "fpmath takes one operand!", &I);
     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(Instruction &I) {
     }
   }
 
     }
   }
 
-  if (MDNode *Range = I.getMDNode(LLVMContext::MD_range)) {
+  if (MDNode *Range = I.getMetadata(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());
     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) {
 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->getMDNode(LLVMContext::MD_dbg))
+      if (MDNode *MD = I->getMetadata(LLVMContext::MD_dbg))
         Finder.processLocation(*M, DILocation(MD));
       if (const CallInst *CI = dyn_cast<CallInst>(&*I))
         processCallInst(Finder, *CI);
         Finder.processLocation(*M, DILocation(MD));
       if (const CallInst *CI = dyn_cast<CallInst>(&*I))
         processCallInst(Finder, *CI);
index 3a2eb6c178c74b7acd7754518850a119bfbde126..bac187bb3a39b7c3631ea614290305bd0643c2d6 100644 (file)
@@ -1287,7 +1287,7 @@ bool ModuleLinker::linkModuleFlagsMetadata() {
   DenseMap<MDString*, MDNode*> Flags;
   SmallSetVector<MDNode*, 16> Requirements;
   for (unsigned I = 0, E = DstModFlags->getNumOperands(); I != E; ++I) {
   DenseMap<MDString*, MDNode*> Flags;
   SmallSetVector<MDNode*, 16> Requirements;
   for (unsigned I = 0, E = DstModFlags->getNumOperands(); I != E; ++I) {
-    MDNode *Op = DstModFlags->getOperandAsMDNode(I);
+    MDNode *Op = DstModFlags->getOperand(I);
     ConstantInt *Behavior = cast<ConstantInt>(Op->getOperand(0));
     MDString *ID = cast<MDString>(Op->getOperand(1));
 
     ConstantInt *Behavior = cast<ConstantInt>(Op->getOperand(0));
     MDString *ID = cast<MDString>(Op->getOperand(1));
 
@@ -1302,7 +1302,7 @@ bool ModuleLinker::linkModuleFlagsMetadata() {
   // requirements.
   bool HasErr = false;
   for (unsigned I = 0, E = SrcModFlags->getNumOperands(); I != E; ++I) {
   // requirements.
   bool HasErr = false;
   for (unsigned I = 0, E = SrcModFlags->getNumOperands(); I != E; ++I) {
-    MDNode *SrcOp = SrcModFlags->getOperandAsMDNode(I);
+    MDNode *SrcOp = SrcModFlags->getOperand(I);
     ConstantInt *SrcBehavior = cast<ConstantInt>(SrcOp->getOperand(0));
     MDString *ID = cast<MDString>(SrcOp->getOperand(1));
     MDNode *DstOp = Flags.lookup(ID);
     ConstantInt *SrcBehavior = cast<ConstantInt>(SrcOp->getOperand(0));
     MDString *ID = cast<MDString>(SrcOp->getOperand(1));
     MDNode *DstOp = Flags.lookup(ID);
index 496cfbd7955d9595c1d13c9de514380db24d34df..58fa95b54ac4920172ef43513387204f83870950 100644 (file)
@@ -371,7 +371,7 @@ void GenericToNVVM::remapNamedMDNode(Module *M, NamedMDNode *N) {
   // Check if any operand is or contains a global variable in  GVMap, and thus
   // converted to another value.
   for (unsigned i = 0; i < NumOperands; ++i) {
   // Check if any operand is or contains a global variable in  GVMap, and thus
   // converted to another value.
   for (unsigned i = 0; i < NumOperands; ++i) {
-    MDNode *Operand = cast<MDNode>(N->getOperand(i));
+    MDNode *Operand = N->getOperand(i);
     MDNode *NewOperand = remapMDNode(M, Operand);
     OperandChanged |= Operand != NewOperand;
     NewOperands.push_back(NewOperand);
     MDNode *NewOperand = remapMDNode(M, Operand);
     OperandChanged |= Operand != NewOperand;
     NewOperands.push_back(NewOperand);
index f1a9a6cc1ea982da6a7e46b3da2cd5478385b8ae..5caa8bd12cafc6dd23dea4f18d781ab04232c8d0 100644 (file)
@@ -73,7 +73,7 @@ static void cacheAnnotationFromMD(const Module *m, const GlobalValue *gv) {
     return;
   key_val_pair_t tmp;
   for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
     return;
   key_val_pair_t tmp;
   for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
-    const MDNode *elem = NMD->getOperandAsMDNode(i);
+    const MDNode *elem = NMD->getOperand(i);
 
     Value *entity = elem->getOperand(0);
     // entity may be null due to DCE
 
     Value *entity = elem->getOperand(0);
     // entity may be null due to DCE
@@ -319,7 +319,7 @@ bool llvm::getAlign(const Function &F, unsigned index, unsigned &align) {
 }
 
 bool llvm::getAlign(const CallInst &I, unsigned index, unsigned &align) {
 }
 
 bool llvm::getAlign(const CallInst &I, unsigned index, unsigned &align) {
-  if (MDNode *alignNode = I.getMDNode("callalign")) {
+  if (MDNode *alignNode = I.getMetadata("callalign")) {
     for (int i = 0, n = alignNode->getNumOperands(); i < n; i++) {
       if (const ConstantInt *CI =
               dyn_cast<ConstantInt>(alignNode->getOperand(i))) {
     for (int i = 0, n = alignNode->getNumOperands(); i < n; i++) {
       if (const ConstantInt *CI =
               dyn_cast<ConstantInt>(alignNode->getOperand(i))) {
index f32b1e4ef7b3f1c6cad0a8767865aa3331e20013..9318dc11d55d3972d12b69b993b7defd1878aa0d 100644 (file)
@@ -87,8 +87,7 @@ void SITypeRewriter::visitLoadInst(LoadInst &I) {
     Value *BitCast = Builder.CreateBitCast(Ptr,
         PointerType::get(v4i32,PtrTy->getPointerAddressSpace()));
     LoadInst *Load = Builder.CreateLoad(BitCast);
     Value *BitCast = Builder.CreateBitCast(Ptr,
         PointerType::get(v4i32,PtrTy->getPointerAddressSpace()));
     LoadInst *Load = Builder.CreateLoad(BitCast);
-    // FIXME: Should the DebugLoc really get dropped here?
-    SmallVector<std::pair<unsigned, Value *>, 8> MD;
+    SmallVector<std::pair<unsigned, MDNode *>, 8> MD;
     I.getAllMetadataOtherThanDebugLoc(MD);
     for (unsigned i = 0, e = MD.size(); i != e; ++i) {
       Load->setMetadata(MD[i].first, MD[i].second);
     I.getAllMetadataOtherThanDebugLoc(MD);
     for (unsigned i = 0, e = MD.size(); i != e; ++i) {
       Load->setMetadata(MD[i].first, MD[i].second);
index 3b20662068ddfed8ec7408fe481fa9ec555e6d4e..5a70d8bb64014049472e0e18f59e67c22ddedede 100644 (file)
@@ -117,7 +117,7 @@ Instruction *InstCombiner::SimplifyMemTransfer(MemIntrinsic *MI) {
 
         // If the memcpy has metadata describing the members, see if we can
         // get the TBAA tag describing our copy.
 
         // If the memcpy has metadata describing the members, see if we can
         // get the TBAA tag describing our copy.
-        if (MDNode *M = MI->getMDNode(LLVMContext::MD_tbaa_struct)) {
+        if (MDNode *M = MI->getMetadata(LLVMContext::MD_tbaa_struct)) {
           if (M->getNumOperands() == 3 &&
               M->getOperand(0) &&
               isa<ConstantInt>(M->getOperand(0)) &&
           if (M->getNumOperands() == 3 &&
               M->getOperand(0) &&
               isa<ConstantInt>(M->getOperand(0)) &&
index ebbb9ec08c56782246834964a3b8c2ed737de9f7..f3ac44cbd6bcc06075b07fb26682ec2391a0f102 100644 (file)
@@ -304,7 +304,7 @@ Instruction *InstCombiner::visitAllocaInst(AllocaInst &AI) {
 static LoadInst *combineLoadToNewType(InstCombiner &IC, LoadInst &LI, Type *NewTy) {
   Value *Ptr = LI.getPointerOperand();
   unsigned AS = LI.getPointerAddressSpace();
 static LoadInst *combineLoadToNewType(InstCombiner &IC, LoadInst &LI, Type *NewTy) {
   Value *Ptr = LI.getPointerOperand();
   unsigned AS = LI.getPointerAddressSpace();
-  SmallVector<std::pair<unsigned, Value *>, 8> MD;
+  SmallVector<std::pair<unsigned, MDNode *>, 8> MD;
   LI.getAllMetadata(MD);
 
   LoadInst *NewLoad = IC.Builder->CreateAlignedLoad(
   LI.getAllMetadata(MD);
 
   LoadInst *NewLoad = IC.Builder->CreateAlignedLoad(
@@ -312,7 +312,7 @@ static LoadInst *combineLoadToNewType(InstCombiner &IC, LoadInst &LI, Type *NewT
       LI.getAlignment(), LI.getName());
   for (const auto &MDPair : MD) {
     unsigned ID = MDPair.first;
       LI.getAlignment(), LI.getName());
   for (const auto &MDPair : MD) {
     unsigned ID = MDPair.first;
-    Value *N = MDPair.second;
+    MDNode *N = MDPair.second;
     // Note, essentially every kind of metadata should be preserved here! This
     // routine is supposed to clone a load instruction changing *only its type*.
     // The only metadata it makes sense to drop is metadata which is invalidated
     // Note, essentially every kind of metadata should be preserved here! This
     // routine is supposed to clone a load instruction changing *only its type*.
     // The only metadata it makes sense to drop is metadata which is invalidated
index 49eccad1d974b29300b7dc22cab1f437dd8f1a7d..3e62165c7b4af5307de85b3b9c3801ea97b2f600 100644 (file)
@@ -256,9 +256,7 @@ class GlobalsMetadata {
     NamedMDNode *Globals = M.getNamedMetadata("llvm.asan.globals");
     if (!Globals)
       return;
     NamedMDNode *Globals = M.getNamedMetadata("llvm.asan.globals");
     if (!Globals)
       return;
-    for (const Value *MDV : Globals->operands()) {
-      const MDNode *MDN = cast<MDNode>(MDV);
-
+    for (auto MDN : Globals->operands()) {
       // Metadata node contains the global and the fields of "Entry".
       assert(MDN->getNumOperands() == 5);
       Value *V = MDN->getOperand(0);
       // Metadata node contains the global and the fields of "Entry".
       assert(MDN->getNumOperands() == 5);
       Value *V = MDN->getOperand(0);
index 7a0ed81eed6b914628bfd87d2e9b6690004f3477..5234341b32edc8a156fc16afe9af382890df0170 100644 (file)
@@ -474,7 +474,7 @@ bool getSourceInfoFromDI(const Module &M, std::string &Directory,
   if (!CUNode || CUNode->getNumOperands() == 0)
     return false;
 
   if (!CUNode || CUNode->getNumOperands() == 0)
     return false;
 
-  DICompileUnit CU(cast<MDNode>(CUNode->getOperand(0)));
+  DICompileUnit CU(CUNode->getOperand(0));
   if (!CU.Verify())
     return false;
 
   if (!CU.Verify())
     return false;
 
index 0c666ffea6a87e5125ef594b916569f0586bdcf5..220d7f8b490824fb5f7422ab1d857d6c8e93ee4c 100644 (file)
@@ -417,7 +417,7 @@ namespace {
 std::string GCOVProfiler::mangleName(DICompileUnit CU, const char *NewStem) {
   if (NamedMDNode *GCov = M->getNamedMetadata("llvm.gcov")) {
     for (int i = 0, e = GCov->getNumOperands(); i != e; ++i) {
 std::string GCOVProfiler::mangleName(DICompileUnit CU, const char *NewStem) {
   if (NamedMDNode *GCov = M->getNamedMetadata("llvm.gcov")) {
     for (int i = 0, e = GCov->getNumOperands(); i != e; ++i) {
-      MDNode *N = GCov->getOperandAsMDNode(i);
+      MDNode *N = GCov->getOperand(i);
       if (N->getNumOperands() != 2) continue;
       MDString *GCovFile = dyn_cast<MDString>(N->getOperand(0));
       MDNode *CompileUnit = dyn_cast<MDNode>(N->getOperand(1));
       if (N->getNumOperands() != 2) continue;
       MDString *GCovFile = dyn_cast<MDString>(N->getOperand(0));
       MDNode *CompileUnit = dyn_cast<MDNode>(N->getOperand(1));
@@ -479,7 +479,7 @@ void GCOVProfiler::emitProfileNotes() {
     // this pass over the original .o's as they're produced, or run it after
     // LTO, we'll generate the same .gcno files.
 
     // this pass over the original .o's as they're produced, or run it after
     // LTO, we'll generate the same .gcno files.
 
-    DICompileUnit CU(CU_Nodes->getOperandAsMDNode(i));
+    DICompileUnit CU(CU_Nodes->getOperand(i));
     std::error_code EC;
     raw_fd_ostream out(mangleName(CU, "gcno"), EC, sys::fs::F_None);
     std::string EdgeDestinations;
     std::error_code EC;
     raw_fd_ostream out(mangleName(CU, "gcno"), EC, sys::fs::F_None);
     std::string EdgeDestinations;
@@ -566,7 +566,7 @@ bool GCOVProfiler::emitProfileArcs() {
   bool Result = false;
   bool InsertIndCounterIncrCode = false;
   for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
   bool Result = false;
   bool InsertIndCounterIncrCode = false;
   for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
-    DICompileUnit CU(CU_Nodes->getOperandAsMDNode(i));
+    DICompileUnit CU(CU_Nodes->getOperand(i));
     DIArray SPs = CU.getSubprograms();
     SmallVector<std::pair<GlobalVariable *, MDNode *>, 8> CountersBySP;
     for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i) {
     DIArray SPs = CU.getSubprograms();
     SmallVector<std::pair<GlobalVariable *, MDNode *>, 8> CountersBySP;
     for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i) {
@@ -847,7 +847,7 @@ Function *GCOVProfiler::insertCounterWriteout(
   NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu");
   if (CU_Nodes) {
     for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
   NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu");
   if (CU_Nodes) {
     for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
-      DICompileUnit CU(CU_Nodes->getOperandAsMDNode(i));
+      DICompileUnit CU(CU_Nodes->getOperand(i));
       std::string FilenameGcda = mangleName(CU, "gcda");
       uint32_t CfgChecksum = FileChecksums.empty() ? 0 : FileChecksums[i];
       Builder.CreateCall3(StartFile,
       std::string FilenameGcda = mangleName(CU, "gcda");
       uint32_t CfgChecksum = FileChecksums.empty() ? 0 : FileChecksums[i];
       Builder.CreateCall3(StartFile,
index 4536510c8e5f6cb9af7d1d5428423130e4467d77..417f2a1649b6517c3d0f70e9eedd86aa920cc9cd 100644 (file)
@@ -231,7 +231,7 @@ bool ThreadSanitizer::doInitialization(Module &M) {
 }
 
 static bool isVtableAccess(Instruction *I) {
 }
 
 static bool isVtableAccess(Instruction *I) {
-  if (MDNode *Tag = I->getMDNode(LLVMContext::MD_tbaa))
+  if (MDNode *Tag = I->getMetadata(LLVMContext::MD_tbaa))
     return Tag->isTBAAVtableAccess();
   return false;
 }
     return Tag->isTBAAVtableAccess();
   return false;
 }
index 04a0d917224b9176fd3f07fa0e04f874b1a59830..eb325eb9417f775697312e2aefd81c9f47d0f158 100644 (file)
@@ -305,7 +305,7 @@ bool ObjCARCContract::doInitialization(Module &M) {
   if (NamedMDNode *NMD =
         M.getNamedMetadata("clang.arc.retainAutoreleasedReturnValueMarker"))
     if (NMD->getNumOperands() == 1) {
   if (NamedMDNode *NMD =
         M.getNamedMetadata("clang.arc.retainAutoreleasedReturnValueMarker"))
     if (NMD->getNumOperands() == 1) {
-      const MDNode *N = NMD->getOperandAsMDNode(0);
+      const MDNode *N = NMD->getOperand(0);
       if (N->getNumOperands() == 1)
         if (const MDString *S = dyn_cast<MDString>(N->getOperand(0)))
           RetainRVMarker = S;
       if (N->getNumOperands() == 1)
         if (const MDString *S = dyn_cast<MDString>(N->getOperand(0)))
           RetainRVMarker = S;
index 4846282e90eb7d40279bc46dfb0fdb3f5566f55f..3da2a54308326a0fd82e86a9d615126234ee6634 100644 (file)
@@ -825,7 +825,7 @@ static MDString *AppendMDNodeToSourcePtr(unsigned NodeId,
   // reference to said Node. Otherwise just return 0.
   if (Instruction *Inst = dyn_cast<Instruction>(Ptr)) {
     MDNode *Node;
   // reference to said Node. Otherwise just return 0.
   if (Instruction *Inst = dyn_cast<Instruction>(Ptr)) {
     MDNode *Node;
-    if (!(Node = Inst->getMDNode(NodeId))) {
+    if (!(Node = Inst->getMetadata(NodeId))) {
       // We do not have any node. Generate and attatch the hash MDString to the
       // instruction.
 
       // We do not have any node. Generate and attatch the hash MDString to the
       // instruction.
 
@@ -1736,7 +1736,7 @@ ObjCARCOpt::VisitInstructionBottomUp(Instruction *Inst,
       NestingDetected = true;
     }
 
       NestingDetected = true;
     }
 
-    MDNode *ReleaseMetadata = Inst->getMDNode(ImpreciseReleaseMDKind);
+    MDNode *ReleaseMetadata = Inst->getMetadata(ImpreciseReleaseMDKind);
     Sequence NewSeq = ReleaseMetadata ? S_MovableRelease : S_Release;
     ANNOTATE_BOTTOMUP(Inst, Arg, S.GetSeq(), NewSeq);
     S.ResetSequenceProgress(NewSeq);
     Sequence NewSeq = ReleaseMetadata ? S_MovableRelease : S_Release;
     ANNOTATE_BOTTOMUP(Inst, Arg, S.GetSeq(), NewSeq);
     S.ResetSequenceProgress(NewSeq);
@@ -2017,7 +2017,7 @@ ObjCARCOpt::VisitInstructionTopDown(Instruction *Inst,
 
     Sequence OldSeq = S.GetSeq();
 
 
     Sequence OldSeq = S.GetSeq();
 
-    MDNode *ReleaseMetadata = Inst->getMDNode(ImpreciseReleaseMDKind);
+    MDNode *ReleaseMetadata = Inst->getMetadata(ImpreciseReleaseMDKind);
 
     switch (OldSeq) {
     case S_Retain:
 
     switch (OldSeq) {
     case S_Retain:
index 0ad7cea63922eef1f075ac65fb2fa34b02ba159b..6036c099be0eafbb5c3e4101ef8a1f725adfa021 100644 (file)
@@ -327,11 +327,14 @@ bool Scalarizer::canTransferMetadata(unsigned Tag) {
 // Transfer metadata from Op to the instructions in CV if it is known
 // to be safe to do so.
 void Scalarizer::transferMetadata(Instruction *Op, const ValueVector &CV) {
 // Transfer metadata from Op to the instructions in CV if it is known
 // to be safe to do so.
 void Scalarizer::transferMetadata(Instruction *Op, const ValueVector &CV) {
-  SmallVector<std::pair<unsigned, Value *>, 4> MDs;
+  SmallVector<std::pair<unsigned, MDNode *>, 4> MDs;
   Op->getAllMetadataOtherThanDebugLoc(MDs);
   for (unsigned I = 0, E = CV.size(); I != E; ++I) {
     if (Instruction *New = dyn_cast<Instruction>(CV[I])) {
   Op->getAllMetadataOtherThanDebugLoc(MDs);
   for (unsigned I = 0, E = CV.size(); I != E; ++I) {
     if (Instruction *New = dyn_cast<Instruction>(CV[I])) {
-      for (auto MI = MDs.begin(), ME = MDs.end(); MI != ME; ++MI)
+      for (SmallVectorImpl<std::pair<unsigned, MDNode *>>::iterator
+               MI = MDs.begin(),
+               ME = MDs.end();
+           MI != ME; ++MI)
         if (canTransferMetadata(MI->first))
           New->setMetadata(MI->first, MI->second);
       New->setDebugLoc(Op->getDebugLoc());
         if (canTransferMetadata(MI->first))
           New->setMetadata(MI->first, MI->second);
       New->setDebugLoc(Op->getDebugLoc());
index a1e42bbe70c1d000e2f9b94c10fa91d767e48779..2d0b7dcc71c9bae669f4a96ffd7c4240b9e9cb8f 100644 (file)
@@ -297,9 +297,9 @@ static void CloneAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap) {
   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) {
   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->getMDNode(LLVMContext::MD_alias_scope))
+      if (const MDNode *M = J->getMetadata(LLVMContext::MD_alias_scope))
         MD.insert(M);
         MD.insert(M);
-      if (const MDNode *M = J->getMDNode(LLVMContext::MD_noalias))
+      if (const MDNode *M = J->getMetadata(LLVMContext::MD_noalias))
         MD.insert(M);
     }
 
         MD.insert(M);
     }
 
@@ -359,31 +359,32 @@ static void CloneAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap) {
     if (!NI)
       continue;
 
     if (!NI)
       continue;
 
-    if (MDNode *M = NI->getMDNode(LLVMContext::MD_alias_scope)) {
+    if (MDNode *M = NI->getMetadata(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 =
       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()->getMDNode(LLVMContext::MD_alias_scope))
+              CS.getInstruction()->getMetadata(LLVMContext::MD_alias_scope))
         NewMD = MDNode::concatenate(NewMD, CSM);
       NI->setMetadata(LLVMContext::MD_alias_scope, NewMD);
     } else if (NI->mayReadOrWriteMemory()) {
       if (MDNode *M =
         NewMD = MDNode::concatenate(NewMD, CSM);
       NI->setMetadata(LLVMContext::MD_alias_scope, NewMD);
     } else if (NI->mayReadOrWriteMemory()) {
       if (MDNode *M =
-              CS.getInstruction()->getMDNode(LLVMContext::MD_alias_scope))
+              CS.getInstruction()->getMetadata(LLVMContext::MD_alias_scope))
         NI->setMetadata(LLVMContext::MD_alias_scope, M);
     }
 
         NI->setMetadata(LLVMContext::MD_alias_scope, M);
     }
 
-    if (MDNode *M = NI->getMDNode(LLVMContext::MD_noalias)) {
+    if (MDNode *M = NI->getMetadata(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.
       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()->getMDNode(LLVMContext::MD_noalias))
+      if (MDNode *CSM =
+              CS.getInstruction()->getMetadata(LLVMContext::MD_noalias))
         NewMD = MDNode::concatenate(NewMD, CSM);
       NI->setMetadata(LLVMContext::MD_noalias, NewMD);
     } else if (NI->mayReadOrWriteMemory()) {
         NewMD = MDNode::concatenate(NewMD, CSM);
       NI->setMetadata(LLVMContext::MD_noalias, NewMD);
     } else if (NI->mayReadOrWriteMemory()) {
-      if (MDNode *M = CS.getInstruction()->getMDNode(LLVMContext::MD_noalias))
+      if (MDNode *M = CS.getInstruction()->getMetadata(LLVMContext::MD_noalias))
         NI->setMetadata(LLVMContext::MD_noalias, M);
     }
   }
         NI->setMetadata(LLVMContext::MD_noalias, M);
     }
   }
@@ -589,7 +590,7 @@ static void AddAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap,
       if (!NoAliases.empty())
         NI->setMetadata(LLVMContext::MD_noalias,
                         MDNode::concatenate(
       if (!NoAliases.empty())
         NI->setMetadata(LLVMContext::MD_noalias,
                         MDNode::concatenate(
-                            NI->getMDNode(LLVMContext::MD_noalias),
+                            NI->getMetadata(LLVMContext::MD_noalias),
                             MDNode::get(CalledFunc->getContext(), NoAliases)));
 
       // Next, we want to figure out all of the sets to which we might belong.
                             MDNode::get(CalledFunc->getContext(), NoAliases)));
 
       // Next, we want to figure out all of the sets to which we might belong.
@@ -615,7 +616,7 @@ static void AddAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap,
       if (!Scopes.empty())
         NI->setMetadata(
             LLVMContext::MD_alias_scope,
       if (!Scopes.empty())
         NI->setMetadata(
             LLVMContext::MD_alias_scope,
-            MDNode::concatenate(NI->getMDNode(LLVMContext::MD_alias_scope),
+            MDNode::concatenate(NI->getMetadata(LLVMContext::MD_alias_scope),
                                 MDNode::get(CalledFunc->getContext(), Scopes)));
     }
   }
                                 MDNode::get(CalledFunc->getContext(), Scopes)));
     }
   }
index c6229b1028cdebbe366bc2acef5a143488e68e0e..a2ba2b8cc06734a4369882fbbe51e6758138a228 100644 (file)
@@ -128,7 +128,7 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB, bool DeleteDeadConditions,
       // 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) {
       // 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->getMDNode(LLVMContext::MD_prof);
+        MDNode *MD = SI->getMetadata(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.
         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(BasicBlock *BB, bool DeleteDeadConditions,
       BranchInst *NewBr = Builder.CreateCondBr(Cond,
                                                FirstCase.getCaseSuccessor(),
                                                SI->getDefaultDest());
       BranchInst *NewBr = Builder.CreateCondBr(Cond,
                                                FirstCase.getCaseSuccessor(),
                                                SI->getDefaultDest());
-      MDNode *MD = SI->getMDNode(LLVMContext::MD_prof);
+      MDNode *MD = SI->getMetadata(LLVMContext::MD_prof);
       if (MD && MD->getNumOperands() == 3) {
         ConstantInt *SICase = dyn_cast<ConstantInt>(MD->getOperand(2));
         ConstantInt *SIDef = dyn_cast<ConstantInt>(MD->getOperand(1));
       if (MD && MD->getNumOperands() == 3) {
         ConstantInt *SICase = dyn_cast<ConstantInt>(MD->getOperand(2));
         ConstantInt *SIDef = dyn_cast<ConstantInt>(MD->getOperand(1));
@@ -1308,13 +1308,13 @@ bool llvm::removeUnreachableBlocks(Function &F) {
 }
 
 void llvm::combineMetadata(Instruction *K, const Instruction *J, ArrayRef<unsigned> KnownIDs) {
 }
 
 void llvm::combineMetadata(Instruction *K, const Instruction *J, ArrayRef<unsigned> KnownIDs) {
-  SmallVector<std::pair<unsigned, Value *>, 4> Metadata;
+  SmallVector<std::pair<unsigned, MDNode *>, 4> Metadata;
   K->dropUnknownMetadata(KnownIDs);
   K->getAllMetadataOtherThanDebugLoc(Metadata);
   for (unsigned i = 0, n = Metadata.size(); i < n; ++i) {
     unsigned Kind = Metadata[i].first;
   K->dropUnknownMetadata(KnownIDs);
   K->getAllMetadataOtherThanDebugLoc(Metadata);
   for (unsigned i = 0, n = Metadata.size(); i < n; ++i) {
     unsigned Kind = Metadata[i].first;
-    MDNode *JMD = J->getMDNode(Kind);
-    MDNode *KMD = cast<MDNode>(Metadata[i].second);
+    MDNode *JMD = J->getMetadata(Kind);
+    MDNode *KMD = Metadata[i].second;
 
     switch (Kind) {
       default:
 
     switch (Kind) {
       default:
index bf7d5df3a5820cdd2c258a59dec69420efe845b2..6037b1ffc2439f072edf7f42915b4074f6d0eca1 100644 (file)
@@ -643,7 +643,7 @@ SimplifyEqualityComparisonWithOnlyPredecessor(TerminatorInst *TI,
 
     // Collect branch weights into a vector.
     SmallVector<uint32_t, 8> Weights;
 
     // Collect branch weights into a vector.
     SmallVector<uint32_t, 8> Weights;
-    MDNode *MD = SI->getMDNode(LLVMContext::MD_prof);
+    MDNode *MD = SI->getMetadata(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;
     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(ConstantInt *const *P1,
 }
 
 static inline bool HasBranchWeights(const Instruction* I) {
 }
 
 static inline bool HasBranchWeights(const Instruction* I) {
-  MDNode *ProfMD = I->getMDNode(LLVMContext::MD_prof);
+  MDNode *ProfMD = I->getMetadata(LLVMContext::MD_prof);
   if (ProfMD && ProfMD->getOperand(0))
     if (MDString* MDS = dyn_cast<MDString>(ProfMD->getOperand(0)))
       return MDS->getString().equals("branch_weights");
   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(const Instruction* I) {
 /// metadata.
 static void GetBranchWeights(TerminatorInst *TI,
                              SmallVectorImpl<uint64_t> &Weights) {
 /// metadata.
 static void GetBranchWeights(TerminatorInst *TI,
                              SmallVectorImpl<uint64_t> &Weights) {
-  MDNode *MD = TI->getMDNode(LLVMContext::MD_prof);
+  MDNode *MD = TI->getMetadata(LLVMContext::MD_prof);
   assert(MD);
   for (unsigned i = 1, e = MD->getNumOperands(); i < e; ++i) {
     ConstantInt *CI = cast<ConstantInt>(MD->getOperand(i));
   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(BranchInst *BI,
                                   uint64_t &ProbTrue, uint64_t &ProbFalse) {
   assert(BI->isConditional() &&
          "Looking for probabilities on unconditional branch?");
                                   uint64_t &ProbTrue, uint64_t &ProbFalse) {
   assert(BI->isConditional() &&
          "Looking for probabilities on unconditional branch?");
-  MDNode *ProfileData = BI->getMDNode(LLVMContext::MD_prof);
+  MDNode *ProfileData = BI->getMetadata(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));
   if (!ProfileData || ProfileData->getNumOperands() != 3) return false;
   ConstantInt *CITrue = dyn_cast<ConstantInt>(ProfileData->getOperand(1));
   ConstantInt *CIFalse = dyn_cast<ConstantInt>(ProfileData->getOperand(2));
index 31755427d775b1bca978dbeacd5d43553143671b..a2f69d1f10b49b9b3501685c94b08ccf8cfe5ca0 100644 (file)
@@ -208,11 +208,14 @@ void llvm::RemapInstruction(Instruction *I, ValueToValueMapTy &VMap,
   }
 
   // Remap attached metadata.
   }
 
   // Remap attached metadata.
-  SmallVector<std::pair<unsigned, Value *>, 4> MDs;
+  SmallVector<std::pair<unsigned, MDNode *>, 4> MDs;
   I->getAllMetadata(MDs);
   I->getAllMetadata(MDs);
-  for (auto MI = MDs.begin(), ME = MDs.end(); MI != ME; ++MI) {
-    Value *Old = MI->second;
-    Value *New = MapValue(Old, VMap, Flags, TypeMapper, Materializer);
+  for (SmallVectorImpl<std::pair<unsigned, MDNode *>>::iterator
+           MI = MDs.begin(),
+           ME = MDs.end();
+       MI != ME; ++MI) {
+    MDNode *Old = MI->second;
+    MDNode *New = MapValue(Old, VMap, Flags, TypeMapper, Materializer);
     if (New != Old)
       I->setMetadata(MI->first, New);
   }
     if (New != Old)
       I->setMetadata(MI->first, New);
   }
index 0a472dc7d89277a779aad3ae36c493b4910a647a..20e7ce63abf712060f8ebd1cf2239a83246efd4d 100644 (file)
@@ -531,7 +531,7 @@ static std::string getDebugLocString(const Loop *L) {
 
 /// \brief Propagate known metadata from one instruction to another.
 static void propagateMetadata(Instruction *To, const Instruction *From) {
 
 /// \brief Propagate known metadata from one instruction to another.
 static void propagateMetadata(Instruction *To, const Instruction *From) {
-  SmallVector<std::pair<unsigned, Value *>, 4> Metadata;
+  SmallVector<std::pair<unsigned, MDNode *>, 4> Metadata;
   From->getAllMetadataOtherThanDebugLoc(Metadata);
 
   for (auto M : Metadata) {
   From->getAllMetadataOtherThanDebugLoc(Metadata);
 
   for (auto M : Metadata) {
index 5771582896dde49cf132ad141b23b14c7575d23f..16ba3167e8b3b93016214d19b38484d90061ce72 100644 (file)
@@ -188,16 +188,16 @@ static void propagateIRFlags(Value *I, ArrayRef<Value *> VL) {
 /// \returns \p I after propagating metadata from \p VL.
 static Instruction *propagateMetadata(Instruction *I, ArrayRef<Value *> VL) {
   Instruction *I0 = cast<Instruction>(VL[0]);
 /// \returns \p I after propagating metadata from \p VL.
 static Instruction *propagateMetadata(Instruction *I, ArrayRef<Value *> VL) {
   Instruction *I0 = cast<Instruction>(VL[0]);
-  SmallVector<std::pair<unsigned, Value *>, 4> Metadata;
+  SmallVector<std::pair<unsigned, MDNode *>, 4> Metadata;
   I0->getAllMetadataOtherThanDebugLoc(Metadata);
 
   for (unsigned i = 0, n = Metadata.size(); i != n; ++i) {
     unsigned Kind = Metadata[i].first;
   I0->getAllMetadataOtherThanDebugLoc(Metadata);
 
   for (unsigned i = 0, n = Metadata.size(); i != n; ++i) {
     unsigned Kind = Metadata[i].first;
-    MDNode *MD = cast_or_null<MDNode>(Metadata[i].second);
+    MDNode *MD = Metadata[i].second;
 
     for (int i = 1, e = VL.size(); MD && i != e; i++) {
       Instruction *I = cast<Instruction>(VL[i]);
 
     for (int i = 1, e = VL.size(); MD && i != e; i++) {
       Instruction *I = cast<Instruction>(VL[i]);
-      MDNode *IMD = I->getMDNode(Kind);
+      MDNode *IMD = I->getMetadata(Kind);
 
       switch (Kind) {
       default:
 
       switch (Kind) {
       default:
index e557875546ab08eb6ec0194b810a001cb45a1ca6..44f4a11773ef43bad82520c13919ac107bd7854e 100644 (file)
@@ -55,7 +55,7 @@ struct BreakpointPrinter : public ModulePass {
     if (NamedMDNode *NMD = M.getNamedMetadata("llvm.dbg.sp"))
       for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
         std::string Name;
     if (NamedMDNode *NMD = M.getNamedMetadata("llvm.dbg.sp"))
       for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
         std::string Name;
-        DISubprogram SP(cast_or_null<MDNode>(NMD->getOperand(i)));
+        DISubprogram SP(NMD->getOperand(i));
         assert((!SP || SP.isSubprogram()) &&
                "A MDNode in llvm.dbg.sp should be null or a DISubprogram.");
         if (!SP)
         assert((!SP || SP.isSubprogram()) &&
                "A MDNode in llvm.dbg.sp should be null or a DISubprogram.");
         if (!SP)