llvm.org GIT mirror llvm / ea96fe1
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321159 91177308-0d34-0410-b5e6-96231b3b80d8 Bjorn Steinbrink 2 years ago
2 changed file(s) with 2 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
655655 CanBeNull = true;
656656 }
657657 } else if (auto *AI = dyn_cast(this)) {
658 const ConstantInt *ArraySize = dyn_cast(AI->getArraySize());
659 if (ArraySize && AI->getAllocatedType()->isSized()) {
660 DerefBytes = DL.getTypeStoreSize(AI->getAllocatedType()) *
661 ArraySize->getZExtValue();
658 if (!AI->isArrayAllocation()) {
659 DerefBytes = DL.getTypeStoreSize(AI->getAllocatedType());
662660 CanBeNull = false;
663661 }
664662 } else if (auto *GV = dyn_cast(this)) {
4040 ; CHECK-NOT: %empty_alloca
4141 %empty_alloca = alloca i8, i64 0
4242 %empty_load = load i8, i8* %empty_alloca
43
44 ; Load from too small array alloca
45 ; CHECK-NOT: %small_array_alloca
46 %small_array_alloca = alloca i8, i64 2
47 %saa_cast = bitcast i8* %small_array_alloca to i32*
48 %saa_load = load i32, i32* %saa_cast
49
50 ; Load from array alloca
51 ; CHECK: %big_array_alloca{{.*}}(unaligned)
52 %big_array_alloca = alloca i8, i64 4
53 %baa_cast = bitcast i8* %big_array_alloca to i32*
54 %baa_load = load i32, i32* %baa_cast
5543
5644 ; Loads from sret arguments
5745 ; CHECK: %sret_gep{{.*}}(aligned)