summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorBjorn Steinbrink <bsteinbr@gmail.com>2017-12-17 21:20:16 +0000
committerBjorn Steinbrink <bsteinbr@gmail.com>2017-12-17 21:20:16 +0000
commit3603de2fa22288e5d9237277ead132ca07e3c0a6 (patch)
tree0cd75c4802b5d8cbf8229d2b17cea348f4e6a7c9 /llvm/lib
parent5cc82f24ff01c00559c123de3b9cd121956a4308 (diff)
downloadbcm5719-llvm-3603de2fa22288e5d9237277ead132ca07e3c0a6.tar.gz
bcm5719-llvm-3603de2fa22288e5d9237277ead132ca07e3c0a6.zip
Re-commit "Properly handle multi-element and dynamically sized allocas in getPointerDereferenceableBytes()""
llvm-clang-x86_64-expensive-checks-win is still broken, so the failure seems unrelated. llvm-svn: 320953
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/IR/Value.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp
index 773ed89db04..eae697b2e4b 100644
--- a/llvm/lib/IR/Value.cpp
+++ b/llvm/lib/IR/Value.cpp
@@ -619,11 +619,11 @@ const Value *Value::stripInBoundsOffsets() const {
return stripPointerCastsAndOffsets<PSK_InBounds>(this);
}
-unsigned Value::getPointerDereferenceableBytes(const DataLayout &DL,
+uint64_t Value::getPointerDereferenceableBytes(const DataLayout &DL,
bool &CanBeNull) const {
assert(getType()->isPointerTy() && "must be pointer");
- unsigned DerefBytes = 0;
+ uint64_t DerefBytes = 0;
CanBeNull = false;
if (const Argument *A = dyn_cast<Argument>(this)) {
DerefBytes = A->getDereferenceableBytes();
@@ -655,8 +655,10 @@ unsigned Value::getPointerDereferenceableBytes(const DataLayout &DL,
CanBeNull = true;
}
} else if (auto *AI = dyn_cast<AllocaInst>(this)) {
- if (AI->getAllocatedType()->isSized()) {
- DerefBytes = DL.getTypeStoreSize(AI->getAllocatedType());
+ const ConstantInt *ArraySize = dyn_cast<ConstantInt>(AI->getArraySize());
+ if (ArraySize && AI->getAllocatedType()->isSized()) {
+ DerefBytes = DL.getTypeStoreSize(AI->getAllocatedType()) *
+ ArraySize->getZExtValue();
CanBeNull = false;
}
} else if (auto *GV = dyn_cast<GlobalVariable>(this)) {
OpenPOWER on IntegriCloud