IR: MDNode => Value: Instruction::getMetadata()
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Sat, 1 Nov 2014 00:10:31 +0000 (00:10 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Sat, 1 Nov 2014 00:10:31 +0000 (00:10 +0000)
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>`.

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

22 files changed:
include/llvm/IR/Instruction.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/CodeGen/SelectionDAG/FastISel.cpp
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
lib/IR/AutoUpgrade.cpp
lib/IR/DiagnosticInfo.cpp
lib/IR/Instructions.cpp
lib/IR/Metadata.cpp
lib/IR/Verifier.cpp
lib/Target/NVPTX/NVPTXUtilities.cpp
lib/Transforms/InstCombine/InstCombineCalls.cpp
lib/Transforms/Instrumentation/ThreadSanitizer.cpp
lib/Transforms/ObjCARC/ObjCARCOpts.cpp
lib/Transforms/Utils/InlineFunction.cpp
lib/Transforms/Utils/Local.cpp
lib/Transforms/Utils/SimplifyCFG.cpp
lib/Transforms/Vectorize/SLPVectorizer.cpp

index ac042ff7ba99b80e81028452c083df2a438e67ae..8030b2b1498b58a293b4f4d348e7a94086aab8a5 100644 (file)
@@ -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;
index bbd87505952216d88b8cad5f042b36e03ecf7288..4e083d2f877bc2af810fec95d1900efe7d4b2dd8 100644 (file)
@@ -180,7 +180,7 @@ bool BranchProbabilityInfo::calcMetadataWeights(BasicBlock *BB) {
   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;
 
index 2e0fdeca9481b35042f2f81242ce6da765cef065..fd4382902bf5cc97a52f43baeab6f51925ceaf3f 100644 (file)
@@ -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;
index 7324344c3e0e71ec421ce8d4061fd2985bf628bb..a47568e0c7f3d6f76ab3de28786ee5e9c03e1c7d 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)) {
-    if (MDNode *MD = I->getMetadata(LLVMContext::MD_range)) {
+    if (MDNode *MD = I->getMDNode(LLVMContext::MD_range)) {
       ConstantRange TotalRange(
           cast<IntegerType>(I->getType())->getBitWidth(), false);
 
index e6f24dd879d4e08b477b602917d6288e4266715f..0c341d9ee4fff53dfce72033fbdad63a890df36f 100644 (file)
@@ -213,13 +213,13 @@ ScopedNoAliasAA::getModRefInfo(ImmutableCallSite CS, const Location &Loc) {
   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(ImmutableCallSite CS1, ImmutableCallSite CS2) {
     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);
index 27b469a43b01f4998a19c15d7e4ffe434671bdf2..1f288b1a3282c112b52f75367999370a7b6826af 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 (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(ImmutableCallSite CS,
     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(ImmutableCallSite CS1,
   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(MDNode *A, MDNode *B) {
 
 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);
 }
 
index da5ba0b8520f4acecff88d12bf21068ea14adad7..141f2e812e88091eb1ec426515ce58ca568d4b30 100644 (file)
@@ -862,7 +862,7 @@ void computeKnownBits(Value *V, APInt &KnownZero, APInt &KnownOne,
   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 &KnownZero, APInt &KnownOne,
   }
   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 DataLayout *TD, unsigned Depth,
   }
 
   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())) {
index 0b2e22486e3db516cf0d208ddf74c08cd252fe59..593173d9c2ccce6fce02d4df6817d0410f0614fc 100644 (file)
@@ -2122,9 +2122,9 @@ FastISel::createMachineMemOperandFor(const Instruction *I) const {
   } 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);
index 4b4b90b58373f977777170afcc4606dfecb72e38..cf030b30659c444a7bea030f661fd8113cd17fce 100644 (file)
@@ -3480,13 +3480,13 @@ void SelectionDAGBuilder::visitLoad(const LoadInst &I) {
   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(const StoreInst &I) {
                                           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(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.
-  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
index b4f327bab5ca4c8e09a5bdbf5ff6d67396d8dc47..0c0c51bd46caa779557504d9c20b440b7c2c2601 100644 (file)
@@ -579,7 +579,7 @@ void llvm::UpgradeCallsToIntrinsic(Function* F) {
 }
 
 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)
index 37cce2b0d7819b502c80ff332f42750bcd9c119e..c0552c90ae6ac173131952ab550f8df3899f9ee0 100644 (file)
@@ -96,7 +96,7 @@ DiagnosticInfoInlineAsm::DiagnosticInfoInlineAsm(const Instruction &I,
                                                  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();
index 1497aa885c531794dbeb110cb956d2e7191ac332..6aaea75896e359963b82f738c147c7af0f9ac2f9 100644 (file)
@@ -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 Value *V) {
 /// 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));
index 60cd2fc9061b7556259133824de662a6cce75b02..6c335c787294c34186eb7fe25186df3f09a71bc6 100644 (file)
@@ -605,16 +605,16 @@ void Instruction::setMetadata(StringRef Kind, Value *MD) {
   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 AAMDNodes &N) {
   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());
index b7c2ee24111a9b67c93c8779c706b82d8dccbb51..e2fb62fdeef76e9f4f066a2dd4656ededc887505 100644 (file)
@@ -2267,7 +2267,7 @@ void Verifier::visitInstruction(Instruction &I) {
     }
   }
 
-  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(Instruction &I) {
     }
   }
 
-  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);
index 5caa8bd12cafc6dd23dea4f18d781ab04232c8d0..d6a14250a4351a9d5eb683b8efef7bb5488faa2a 100644 (file)
@@ -319,7 +319,7 @@ bool llvm::getAlign(const Function &F, unsigned index, unsigned &align) {
 }
 
 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))) {
index 5a70d8bb64014049472e0e18f59e67c22ddedede..3b20662068ddfed8ec7408fe481fa9ec555e6d4e 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 (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)) &&
index 417f2a1649b6517c3d0f70e9eedd86aa920cc9cd..4536510c8e5f6cb9af7d1d5428423130e4467d77 100644 (file)
@@ -231,7 +231,7 @@ bool ThreadSanitizer::doInitialization(Module &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;
 }
index 3da2a54308326a0fd82e86a9d615126234ee6634..4846282e90eb7d40279bc46dfb0fdb3f5566f55f 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;
-    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(Instruction *Inst,
       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(Instruction *Inst,
 
     Sequence OldSeq = S.GetSeq();
 
-    MDNode *ReleaseMetadata = Inst->getMetadata(ImpreciseReleaseMDKind);
+    MDNode *ReleaseMetadata = Inst->getMDNode(ImpreciseReleaseMDKind);
 
     switch (OldSeq) {
     case S_Retain:
index c1589400b85fc683ff3e47a553afc27e2166e85a..112bdcb72b180e8c0a54e5e611ac0a3c17374b47 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) {
-      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(CallSite CS, ValueToValueMapTy &VMap) {
     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(CallSite CS, ValueToValueMapTy &VMap,
       }
 
       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(CallSite CS, ValueToValueMapTy &VMap,
         }
 
       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)));
     }
   }
 }
index 5bf638692b74d2bd96a71d788ba4baef75891690..7c0e4c7f214e29916de1ddaf9ac14220362389d0 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) {
-        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(BasicBlock *BB, bool DeleteDeadConditions,
       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, const Instruction *J, ArrayRef<unsign
   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) {
index 0e4d779c52ea8bba158b7bf99c6ae02cb84f484b..bf7d5df3a5820cdd2c258a59dec69420efe845b2 100644 (file)
@@ -643,7 +643,7 @@ SimplifyEqualityComparisonWithOnlyPredecessor(TerminatorInst *TI,
 
     // 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(ConstantInt *const *P1,
 }
 
 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(const Instruction* I) {
 /// 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(BranchInst *BI,
                                   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));
index 16ba3167e8b3b93016214d19b38484d90061ce72..73767b46a36a8b45f92a53d54c9fff09d932ca67 100644 (file)
@@ -197,7 +197,7 @@ static Instruction *propagateMetadata(Instruction *I, ArrayRef<Value *> VL) {
 
     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: