diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-11-01 00:10:31 +0000 |
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-11-01 00:10:31 +0000 |
| commit | 3872d0084c4f479020ce01b4db5d1bd414c57fb8 (patch) | |
| tree | fd1a9e83666fa84a3916b46a94cca32978b34794 /llvm/lib/Analysis | |
| parent | 7c4fc4e5ae4c8145974397da295587e77c770f62 (diff) | |
| download | bcm5719-llvm-3872d0084c4f479020ce01b4db5d1bd414c57fb8.tar.gz bcm5719-llvm-3872d0084c4f479020ce01b4db5d1bd414c57fb8.zip | |
IR: MDNode => Value: Instruction::getMetadata()
Change `Instruction::getMetadata()` to return `Value` as part of
PR21433.
Update most callers to use `Instruction::getMDNode()`, which wraps the
result in a `cast_or_null<MDNode>`.
llvm-svn: 221024
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/BranchProbabilityInfo.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/Analysis/LoopInfo.cpp | 6 | ||||
| -rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/Analysis/ScopedNoAliasAA.cpp | 16 | ||||
| -rw-r--r-- | llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp | 28 | ||||
| -rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 6 |
6 files changed, 29 insertions, 31 deletions
diff --git a/llvm/lib/Analysis/BranchProbabilityInfo.cpp b/llvm/lib/Analysis/BranchProbabilityInfo.cpp index bbd87505952..4e083d2f877 100644 --- a/llvm/lib/Analysis/BranchProbabilityInfo.cpp +++ b/llvm/lib/Analysis/BranchProbabilityInfo.cpp @@ -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; diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp index 2e0fdeca948..fd4382902bf 100644 --- a/llvm/lib/Analysis/LoopInfo.cpp +++ b/llvm/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/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 7324344c3e0..a47568e0c7f 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -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); diff --git a/llvm/lib/Analysis/ScopedNoAliasAA.cpp b/llvm/lib/Analysis/ScopedNoAliasAA.cpp index e6f24dd879d..0c341d9ee4f 100644 --- a/llvm/lib/Analysis/ScopedNoAliasAA.cpp +++ b/llvm/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/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp b/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp index 27b469a43b0..1f288b1a328 100644 --- a/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp +++ b/llvm/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/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index da5ba0b8520..141f2e812e8 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/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<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())) { |

