From 7004fd9aac144081f7f29fb081a56257ee9258d7 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Sat, 1 Nov 2014 00:10:31 +0000 Subject: [PATCH] IR: MDNode => Value: Instruction::getMetadata() Change `Instruction::getMetadata()` to return `Value` as part of PR21433. Update most callers to use `Instruction::getMDNode()`, which wraps the result in a `cast_or_null`. llvm-svn: 221024 --- include/llvm/IR/Instruction.h | 8 ++--- lib/Analysis/BranchProbabilityInfo.cpp | 2 +- lib/Analysis/LoopInfo.cpp | 6 ++-- lib/Analysis/ScalarEvolution.cpp | 2 +- lib/Analysis/ScopedNoAliasAA.cpp | 16 +++++----- lib/Analysis/TypeBasedAliasAnalysis.cpp | 28 ++++++++-------- lib/Analysis/ValueTracking.cpp | 6 ++-- lib/CodeGen/SelectionDAG/FastISel.cpp | 6 ++-- .../SelectionDAG/SelectionDAGBuilder.cpp | 10 +++--- lib/IR/AutoUpgrade.cpp | 2 +- lib/IR/DiagnosticInfo.cpp | 2 +- lib/IR/Instructions.cpp | 5 ++- lib/IR/Metadata.cpp | 8 ++--- lib/IR/Verifier.cpp | 6 ++-- lib/Target/NVPTX/NVPTXUtilities.cpp | 2 +- .../InstCombine/InstCombineCalls.cpp | 2 +- .../Instrumentation/ThreadSanitizer.cpp | 2 +- lib/Transforms/ObjCARC/ObjCARCOpts.cpp | 6 ++-- lib/Transforms/Utils/InlineFunction.cpp | 32 +++++++++---------- lib/Transforms/Utils/Local.cpp | 6 ++-- lib/Transforms/Utils/SimplifyCFG.cpp | 8 ++--- lib/Transforms/Vectorize/SLPVectorizer.cpp | 2 +- 22 files changed, 82 insertions(+), 85 deletions(-) diff --git a/include/llvm/IR/Instruction.h b/include/llvm/IR/Instruction.h index ac042ff7ba9..8030b2b1498 100644 --- a/include/llvm/IR/Instruction.h +++ b/include/llvm/IR/Instruction.h @@ -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 > &)const; diff --git a/lib/Analysis/BranchProbabilityInfo.cpp b/lib/Analysis/BranchProbabilityInfo.cpp index bbd87505952..4e083d2f877 100644 --- a/lib/Analysis/BranchProbabilityInfo.cpp +++ b/lib/Analysis/BranchProbabilityInfo.cpp @@ -180,7 +180,7 @@ bool BranchProbabilityInfo::calcMetadataWeights(BasicBlock *BB) { if (!isa(TI) && !isa(TI)) return false; - MDNode *WeightsNode = TI->getMetadata(LLVMContext::MD_prof); + MDNode *WeightsNode = TI->getMDNode(LLVMContext::MD_prof); if (!WeightsNode) return false; diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index 2e0fdeca948..fd4382902bf 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/lib/Analysis/LoopInfo.cpp @@ -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; diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 7324344c3e0..a47568e0c7f 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -3668,7 +3668,7 @@ ScalarEvolution::GetMinTrailingZeros(const SCEV *S) { /// metadata present in the IR. static Optional GetRangeFromMetadata(Value *V) { if (Instruction *I = dyn_cast(V)) { - if (MDNode *MD = I->getMetadata(LLVMContext::MD_range)) { + if (MDNode *MD = I->getMDNode(LLVMContext::MD_range)) { ConstantRange TotalRange( cast(I->getType())->getBitWidth(), false); diff --git a/lib/Analysis/ScopedNoAliasAA.cpp b/lib/Analysis/ScopedNoAliasAA.cpp index e6f24dd879d..0c341d9ee4f 100644 --- a/lib/Analysis/ScopedNoAliasAA.cpp +++ b/lib/Analysis/ScopedNoAliasAA.cpp @@ -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); diff --git a/lib/Analysis/TypeBasedAliasAnalysis.cpp b/lib/Analysis/TypeBasedAliasAnalysis.cpp index 27b469a43b0..1f288b1a328 100644 --- a/lib/Analysis/TypeBasedAliasAnalysis.cpp +++ b/lib/Analysis/TypeBasedAliasAnalysis.cpp @@ -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); } diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index da5ba0b8520..141f2e812e8 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -862,7 +862,7 @@ void computeKnownBits(Value *V, APInt &KnownZero, APInt &KnownOne, switch (I->getOpcode()) { default: break; case Instruction::Load: - if (MDNode *MD = cast(I)->getMetadata(LLVMContext::MD_range)) + if (MDNode *MD = cast(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(I)->getMetadata(LLVMContext::MD_range)) + if (MDNode *MD = cast(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(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(V->getType())) { diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp index 0b2e22486e3..593173d9c2c 100644 --- a/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -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); diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 4b4b90b5837..cf030b30659 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -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 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 diff --git a/lib/IR/AutoUpgrade.cpp b/lib/IR/AutoUpgrade.cpp index b4f327bab5c..0c0c51bd46c 100644 --- a/lib/IR/AutoUpgrade.cpp +++ b/lib/IR/AutoUpgrade.cpp @@ -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(MD->getOperand(0)) && MD->getNumOperands() >= 3) diff --git a/lib/IR/DiagnosticInfo.cpp b/lib/IR/DiagnosticInfo.cpp index 37cce2b0d78..c0552c90ae6 100644 --- a/lib/IR/DiagnosticInfo.cpp +++ b/lib/IR/DiagnosticInfo.cpp @@ -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(SrcLoc->getOperand(0))) LocCookie = CI->getZExtValue(); diff --git a/lib/IR/Instructions.cpp b/lib/IR/Instructions.cpp index 1497aa885c5..6aaea75896e 100644 --- a/lib/IR/Instructions.cpp +++ b/lib/IR/Instructions.cpp @@ -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(this)->getMetadata(LLVMContext::MD_fpmath); + const MDNode *MD = cast(this)->getMDNode(LLVMContext::MD_fpmath); if (!MD) return 0.0; ConstantFP *Accuracy = cast(MD->getOperand(0)); diff --git a/lib/IR/Metadata.cpp b/lib/IR/Metadata.cpp index 60cd2fc9061..6c335c78729 100644 --- a/lib/IR/Metadata.cpp +++ b/lib/IR/Metadata.cpp @@ -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(getMetadataImpl(KindID)); } MDNode *Instruction::getMDNodeImpl(StringRef Kind) const { - return getMetadataImpl(Kind); + return cast_or_null(getMetadataImpl(Kind)); } void Instruction::dropUnknownMetadata(ArrayRef 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()); diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp index b7c2ee24111..e2fb62fdeef 100644 --- a/lib/IR/Verifier.cpp +++ b/lib/IR/Verifier.cpp @@ -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(I) || isa(I) || isa(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(&*I)) processCallInst(Finder, *CI); diff --git a/lib/Target/NVPTX/NVPTXUtilities.cpp b/lib/Target/NVPTX/NVPTXUtilities.cpp index 5caa8bd12ca..d6a14250a43 100644 --- a/lib/Target/NVPTX/NVPTXUtilities.cpp +++ b/lib/Target/NVPTX/NVPTXUtilities.cpp @@ -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(alignNode->getOperand(i))) { diff --git a/lib/Transforms/InstCombine/InstCombineCalls.cpp b/lib/Transforms/InstCombine/InstCombineCalls.cpp index 5a70d8bb640..3b20662068d 100644 --- a/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -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(M->getOperand(0)) && diff --git a/lib/Transforms/Instrumentation/ThreadSanitizer.cpp b/lib/Transforms/Instrumentation/ThreadSanitizer.cpp index 417f2a1649b..4536510c8e5 100644 --- a/lib/Transforms/Instrumentation/ThreadSanitizer.cpp +++ b/lib/Transforms/Instrumentation/ThreadSanitizer.cpp @@ -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; } diff --git a/lib/Transforms/ObjCARC/ObjCARCOpts.cpp b/lib/Transforms/ObjCARC/ObjCARCOpts.cpp index 3da2a543083..4846282e90e 100644 --- a/lib/Transforms/ObjCARC/ObjCARCOpts.cpp +++ b/lib/Transforms/ObjCARC/ObjCARCOpts.cpp @@ -825,7 +825,7 @@ static MDString *AppendMDNodeToSourcePtr(unsigned NodeId, // reference to said Node. Otherwise just return 0. if (Instruction *Inst = dyn_cast(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: diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index c1589400b85..112bdcb72b1 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/lib/Transforms/Utils/InlineFunction.cpp @@ -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))); } } } diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp index 5bf638692b7..7c0e4c7f214 100644 --- a/lib/Transforms/Utils/Local.cpp +++ b/lib/Transforms/Utils/Local.cpp @@ -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(MD->getOperand(2)); ConstantInt *SIDef = dyn_cast(MD->getOperand(1)); @@ -1313,7 +1313,7 @@ void llvm::combineMetadata(Instruction *K, const Instruction *J, ArrayRefgetAllMetadataOtherThanDebugLoc(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) { diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 0e4d779c52e..bf7d5df3a58 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -643,7 +643,7 @@ SimplifyEqualityComparisonWithOnlyPredecessor(TerminatorInst *TI, // Collect branch weights into a vector. SmallVector 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(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 &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(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(ProfileData->getOperand(1)); ConstantInt *CIFalse = dyn_cast(ProfileData->getOperand(2)); diff --git a/lib/Transforms/Vectorize/SLPVectorizer.cpp b/lib/Transforms/Vectorize/SLPVectorizer.cpp index 16ba3167e8b..73767b46a36 100644 --- a/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -197,7 +197,7 @@ static Instruction *propagateMetadata(Instruction *I, ArrayRef VL) { for (int i = 1, e = VL.size(); MD && i != e; i++) { Instruction *I = cast(VL[i]); - MDNode *IMD = I->getMetadata(Kind); + MDNode *IMD = I->getMDNode(Kind); switch (Kind) { default: