summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Desaulniers <ndesaulniers@google.com>2019-06-05 01:28:55 +0000
committerNick Desaulniers <ndesaulniers@google.com>2019-06-05 01:28:55 +0000
commit2e05045e2601da7f88d93661b24277dd8790a0c8 (patch)
tree7e2c486f25cf203dc6a38fe642465538c26538f0
parentc012188adaf740592b3bb8d13e4297721e2c8417 (diff)
downloadbcm5719-llvm-2e05045e2601da7f88d93661b24277dd8790a0c8.tar.gz
bcm5719-llvm-2e05045e2601da7f88d93661b24277dd8790a0c8.zip
[TargetTransformInfo] assert on nullptr
Summary: This was flagged in https://www.viva64.com/en/b/0629/ under "Snippet No. 38". Add an assertion, since it's unlikely that this parameter is nullptr. Reviewers: RKSimon, fhahn Reviewed By: RKSimon Subscribers: fhahn, llvm-commits, RKSimon, srhines Tags: #llvm Differential Revision: https://reviews.llvm.org/D62229 llvm-svn: 362567
-rw-r--r--llvm/include/llvm/Analysis/TargetTransformInfoImpl.h21
1 files changed, 8 insertions, 13 deletions
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
index af250aa638e..bb290ec898e 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -681,14 +681,12 @@ public:
int getGEPCost(Type *PointeeType, const Value *Ptr,
ArrayRef<const Value *> Operands) {
- const GlobalValue *BaseGV = nullptr;
- if (Ptr != nullptr) {
- // TODO: will remove this when pointers have an opaque type.
- assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
- PointeeType &&
- "explicit pointee type doesn't match operand's pointee type");
- BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
- }
+ assert(PointeeType && Ptr && "can't get GEPCost of nullptr");
+ // TODO: will remove this when pointers have an opaque type.
+ assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
+ PointeeType &&
+ "explicit pointee type doesn't match operand's pointee type");
+ auto *BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
bool HasBaseReg = (BaseGV == nullptr);
auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
@@ -731,13 +729,10 @@ public:
}
}
- // Assumes the address space is 0 when Ptr is nullptr.
- unsigned AS =
- (Ptr == nullptr ? 0 : Ptr->getType()->getPointerAddressSpace());
-
if (static_cast<T *>(this)->isLegalAddressingMode(
TargetType, const_cast<GlobalValue *>(BaseGV),
- BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
+ BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale,
+ Ptr->getType()->getPointerAddressSpace()))
return TTI::TCC_Free;
return TTI::TCC_Basic;
}
OpenPOWER on IntegriCloud