aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorHuihui Zhang <huihuiz@quicinc.com>2020-03-20 16:52:03 -0700
committerHuihui Zhang <huihuiz@quicinc.com>2020-03-20 16:52:15 -0700
commit4f5af9d70dcca15bb639042cdf054b57a7e4836f (patch)
tree62f778d6833e4827d9683b64a0275e3d41447854 /llvm/lib/Analysis/ValueTracking.cpp
parent0a5fbf30937a12b0330ca0a59fe123f4992873f7 (diff)
downloadllvm-4f5af9d70dcca15bb639042cdf054b57a7e4836f.zip
llvm-4f5af9d70dcca15bb639042cdf054b57a7e4836f.tar.gz
llvm-4f5af9d70dcca15bb639042cdf054b57a7e4836f.tar.bz2
[ValueTracking] Fix usage of DataLayout::getTypeStoreSize()
Summary: DataLayout::getTypeStoreSize() returns TypeSize. For cases where it can not be scalable vector (e.g., GlobalVariable), explicitly call TypeSize::getFixedSize(). For cases where scalable property doesn't matter, (e.g., check for zero-sized type), use TypeSize::isNonZero(). Reviewers: sdesmalen, efriedma, apazos, reames Reviewed By: efriedma Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D76454
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 3e62c45..d337371 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -3561,8 +3561,8 @@ Value *llvm::isBytewiseValue(Value *V, const DataLayout &DL) {
if (isa<UndefValue>(V))
return UndefInt8;
- const uint64_t Size = DL.getTypeStoreSize(V->getType());
- if (!Size)
+ // Return Undef for zero-sized type.
+ if (!DL.getTypeStoreSize(V->getType()).isNonZero())
return UndefInt8;
Constant *C = dyn_cast<Constant>(V);
@@ -3880,7 +3880,7 @@ bool llvm::getConstantDataArrayInfo(const Value *V,
Array = nullptr;
} else {
const DataLayout &DL = GV->getParent()->getDataLayout();
- uint64_t SizeInBytes = DL.getTypeStoreSize(GVTy);
+ uint64_t SizeInBytes = DL.getTypeStoreSize(GVTy).getFixedSize();
uint64_t Length = SizeInBytes / (ElementSize / 8);
if (Length <= Offset)
return false;