diff options
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/BranchProbabilityInfo.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp | 23 | ||||
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 12 |
4 files changed, 27 insertions, 17 deletions
diff --git a/llvm/lib/Analysis/BranchProbabilityInfo.cpp b/llvm/lib/Analysis/BranchProbabilityInfo.cpp index bbd87505952..2b39d47e5fa 100644 --- a/llvm/lib/Analysis/BranchProbabilityInfo.cpp +++ b/llvm/lib/Analysis/BranchProbabilityInfo.cpp @@ -196,7 +196,8 @@ bool BranchProbabilityInfo::calcMetadataWeights(BasicBlock *BB) { SmallVector<uint32_t, 2> Weights; Weights.reserve(TI->getNumSuccessors()); for (unsigned i = 1, e = WeightsNode->getNumOperands(); i != e; ++i) { - ConstantInt *Weight = dyn_cast<ConstantInt>(WeightsNode->getOperand(i)); + ConstantInt *Weight = + mdconst::dyn_extract<ConstantInt>(WeightsNode->getOperand(i)); if (!Weight) return false; Weights.push_back( diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 792542eab25..177bd23030a 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -3750,8 +3750,10 @@ static Optional<ConstantRange> GetRangeFromMetadata(Value *V) { assert(NumRanges >= 1); for (unsigned i = 0; i < NumRanges; ++i) { - ConstantInt *Lower = cast<ConstantInt>(MD->getOperand(2*i + 0)); - ConstantInt *Upper = cast<ConstantInt>(MD->getOperand(2*i + 1)); + ConstantInt *Lower = + mdconst::extract<ConstantInt>(MD->getOperand(2 * i + 0)); + ConstantInt *Upper = + mdconst::extract<ConstantInt>(MD->getOperand(2 * i + 1)); ConstantRange Range(Lower->getValue(), Upper->getValue()); TotalRange = TotalRange.unionWith(Range); } diff --git a/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp b/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp index f347eb5f191..085ce920139 100644 --- a/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp +++ b/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp @@ -167,7 +167,7 @@ namespace { bool TypeIsImmutable() const { if (Node->getNumOperands() < 3) return false; - ConstantInt *CI = dyn_cast<ConstantInt>(Node->getOperand(2)); + ConstantInt *CI = mdconst::dyn_extract<ConstantInt>(Node->getOperand(2)); if (!CI) return false; return CI->getValue()[0]; @@ -194,7 +194,7 @@ namespace { return dyn_cast_or_null<MDNode>(Node->getOperand(1)); } uint64_t getOffset() const { - return cast<ConstantInt>(Node->getOperand(2))->getZExtValue(); + return mdconst::extract<ConstantInt>(Node->getOperand(2))->getZExtValue(); } /// TypeIsImmutable - Test if this TBAAStructTagNode represents a type for /// objects which are not modified (by any means) in the context where this @@ -202,7 +202,7 @@ namespace { bool TypeIsImmutable() const { if (Node->getNumOperands() < 4) return false; - ConstantInt *CI = dyn_cast<ConstantInt>(Node->getOperand(3)); + ConstantInt *CI = mdconst::dyn_extract<ConstantInt>(Node->getOperand(3)); if (!CI) return false; return CI->getValue()[0]; @@ -233,8 +233,10 @@ namespace { // Fast path for a scalar type node and a struct type node with a single // field. if (Node->getNumOperands() <= 3) { - uint64_t Cur = Node->getNumOperands() == 2 ? 0 : - cast<ConstantInt>(Node->getOperand(2))->getZExtValue(); + uint64_t Cur = Node->getNumOperands() == 2 + ? 0 + : mdconst::extract<ConstantInt>(Node->getOperand(2)) + ->getZExtValue(); Offset -= Cur; MDNode *P = dyn_cast_or_null<MDNode>(Node->getOperand(1)); if (!P) @@ -246,8 +248,8 @@ namespace { // the current offset is bigger than the given offset. unsigned TheIdx = 0; for (unsigned Idx = 1; Idx < Node->getNumOperands(); Idx += 2) { - uint64_t Cur = cast<ConstantInt>(Node->getOperand(Idx + 1))-> - getZExtValue(); + uint64_t Cur = mdconst::extract<ConstantInt>(Node->getOperand(Idx + 1)) + ->getZExtValue(); if (Cur > Offset) { assert(Idx >= 3 && "TBAAStructTypeNode::getParent should have an offset match!"); @@ -258,8 +260,8 @@ namespace { // Move along the last field. if (TheIdx == 0) TheIdx = Node->getNumOperands() - 2; - uint64_t Cur = cast<ConstantInt>(Node->getOperand(TheIdx + 1))-> - getZExtValue(); + uint64_t Cur = mdconst::extract<ConstantInt>(Node->getOperand(TheIdx + 1)) + ->getZExtValue(); Offset -= Cur; MDNode *P = dyn_cast_or_null<MDNode>(Node->getOperand(TheIdx)); if (!P) @@ -608,7 +610,8 @@ MDNode *MDNode::getMostGenericTBAA(MDNode *A, MDNode *B) { return nullptr; // We need to convert from a type node to a tag node. Type *Int64 = IntegerType::get(A->getContext(), 64); - Value *Ops[3] = { Ret, Ret, ConstantInt::get(Int64, 0) }; + Metadata *Ops[3] = {Ret, Ret, + ConstantAsMetadata::get(ConstantInt::get(Int64, 0))}; return MDNode::get(A->getContext(), Ops); } diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index ced5151582f..fa428fa108d 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -312,8 +312,10 @@ void llvm::computeKnownBitsFromRangeMetadata(const MDNode &Ranges, // Use the high end of the ranges to find leading zeros. unsigned MinLeadingZeros = BitWidth; for (unsigned i = 0; i < NumRanges; ++i) { - ConstantInt *Lower = cast<ConstantInt>(Ranges.getOperand(2*i + 0)); - ConstantInt *Upper = cast<ConstantInt>(Ranges.getOperand(2*i + 1)); + ConstantInt *Lower = + mdconst::extract<ConstantInt>(Ranges.getOperand(2 * i + 0)); + ConstantInt *Upper = + mdconst::extract<ConstantInt>(Ranges.getOperand(2 * i + 1)); ConstantRange Range(Lower->getValue(), Upper->getValue()); if (Range.isWrappedSet()) MinLeadingZeros = 0; // -1 has no zeros @@ -1504,8 +1506,10 @@ static bool rangeMetadataExcludesValue(MDNode* Ranges, const unsigned NumRanges = Ranges->getNumOperands() / 2; assert(NumRanges >= 1); for (unsigned i = 0; i < NumRanges; ++i) { - ConstantInt *Lower = cast<ConstantInt>(Ranges->getOperand(2*i + 0)); - ConstantInt *Upper = cast<ConstantInt>(Ranges->getOperand(2*i + 1)); + ConstantInt *Lower = + mdconst::extract<ConstantInt>(Ranges->getOperand(2 * i + 0)); + ConstantInt *Upper = + mdconst::extract<ConstantInt>(Ranges->getOperand(2 * i + 1)); ConstantRange Range(Lower->getValue(), Upper->getValue()); if (Range.contains(Value)) return false; |