summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjorn Steinbrink <bsteinbr@gmail.com>2017-12-20 10:01:30 +0000
committerBjorn Steinbrink <bsteinbr@gmail.com>2017-12-20 10:01:30 +0000
commit030123e8e8fe46be132cbf4b4d1240e8d5c446fe (patch)
treeba522c833223350111da9cbf932913fbdf622757
parentc067c30d9ee767907fab866d919d545181f96a78 (diff)
downloadbcm5719-llvm-030123e8e8fe46be132cbf4b4d1240e8d5c446fe.tar.gz
bcm5719-llvm-030123e8e8fe46be132cbf4b4d1240e8d5c446fe.zip
Give up on array allocas in getPointerDereferenceableBytes
Summary: As suggested by Eli Friedman, don't try to handle array allocas here, because of possible overflows, instead rely on instcombine converting them to allocations of array types. Reviewers: efriedma Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D41398 llvm-svn: 321159
-rw-r--r--llvm/lib/IR/Value.cpp6
-rw-r--r--llvm/test/Analysis/ValueTracking/memory-dereferenceable.ll12
2 files changed, 2 insertions, 16 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp
index d36b7cd4c64..163c785f5d7 100644
--- a/llvm/lib/IR/Value.cpp
+++ b/llvm/lib/IR/Value.cpp
@@ -656,10 +656,8 @@ uint64_t Value::getPointerDereferenceableBytes(const DataLayout &DL,
CanBeNull = true;
}
} else if (auto *AI = dyn_cast<AllocaInst>(this)) {
- const ConstantInt *ArraySize = dyn_cast<ConstantInt>(AI->getArraySize());
- if (ArraySize && AI->getAllocatedType()->isSized()) {
- DerefBytes = DL.getTypeStoreSize(AI->getAllocatedType()) *
- ArraySize->getZExtValue();
+ if (!AI->isArrayAllocation()) {
+ DerefBytes = DL.getTypeStoreSize(AI->getAllocatedType());
CanBeNull = false;
}
} else if (auto *GV = dyn_cast<GlobalVariable>(this)) {
diff --git a/llvm/test/Analysis/ValueTracking/memory-dereferenceable.ll b/llvm/test/Analysis/ValueTracking/memory-dereferenceable.ll
index 8e474e5a95c..2e9453f670c 100644
--- a/llvm/test/Analysis/ValueTracking/memory-dereferenceable.ll
+++ b/llvm/test/Analysis/ValueTracking/memory-dereferenceable.ll
@@ -42,18 +42,6 @@ entry:
%empty_alloca = alloca i8, i64 0
%empty_load = load i8, i8* %empty_alloca
- ; Load from too small array alloca
-; CHECK-NOT: %small_array_alloca
- %small_array_alloca = alloca i8, i64 2
- %saa_cast = bitcast i8* %small_array_alloca to i32*
- %saa_load = load i32, i32* %saa_cast
-
- ; Load from array alloca
-; CHECK: %big_array_alloca{{.*}}(unaligned)
- %big_array_alloca = alloca i8, i64 4
- %baa_cast = bitcast i8* %big_array_alloca to i32*
- %baa_load = load i32, i32* %baa_cast
-
; Loads from sret arguments
; CHECK: %sret_gep{{.*}}(aligned)
%sret_gep = getelementptr inbounds %struct.A, %struct.A* %result, i64 0, i32 1, i64 2
OpenPOWER on IntegriCloud