[llvm] r320945 - Revert "Properly handle multi-element and dynamically sized allocas in getPointerDereferenceableBytes()"

Bjorn Steinbrink via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 17 07:16:58 PST 2017


Author: bsteinbr
Date: Sun Dec 17 07:16:58 2017
New Revision: 320945

URL: http://llvm.org/viewvc/llvm-project?rev=320945&view=rev
Log:
Revert "Properly handle multi-element and dynamically sized allocas in getPointerDereferenceableBytes()"

This reverts commit 217067d5179882de9deb60d2e866befea4c126e7.

Fails on llvm-clang-x86_64-expensive-checks-win

Modified:
    llvm/trunk/include/llvm/IR/Value.h
    llvm/trunk/lib/IR/Value.cpp
    llvm/trunk/test/Analysis/ValueTracking/memory-dereferenceable.ll

Modified: llvm/trunk/include/llvm/IR/Value.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Value.h?rev=320945&r1=320944&r2=320945&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Value.h (original)
+++ llvm/trunk/include/llvm/IR/Value.h Sun Dec 17 07:16:58 2017
@@ -570,7 +570,7 @@ public:
   ///
   /// If CanBeNull is set by this function the pointer can either be null or be
   /// dereferenceable up to the returned number of bytes.
-  uint64_t getPointerDereferenceableBytes(const DataLayout &DL,
+  unsigned getPointerDereferenceableBytes(const DataLayout &DL,
                                           bool &CanBeNull) const;
 
   /// \brief Returns an alignment of the pointer value.

Modified: llvm/trunk/lib/IR/Value.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Value.cpp?rev=320945&r1=320944&r2=320945&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Value.cpp (original)
+++ llvm/trunk/lib/IR/Value.cpp Sun Dec 17 07:16:58 2017
@@ -619,11 +619,11 @@ const Value *Value::stripInBoundsOffsets
   return stripPointerCastsAndOffsets<PSK_InBounds>(this);
 }
 
-uint64_t Value::getPointerDereferenceableBytes(const DataLayout &DL,
+unsigned Value::getPointerDereferenceableBytes(const DataLayout &DL,
                                                bool &CanBeNull) const {
   assert(getType()->isPointerTy() && "must be pointer");
 
-  uint64_t DerefBytes = 0;
+  unsigned DerefBytes = 0;
   CanBeNull = false;
   if (const Argument *A = dyn_cast<Argument>(this)) {
     DerefBytes = A->getDereferenceableBytes();
@@ -655,10 +655,8 @@ uint64_t Value::getPointerDereferenceabl
       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->getAllocatedType()->isSized()) {
+      DerefBytes = DL.getTypeStoreSize(AI->getAllocatedType());
       CanBeNull = false;
     }
   } else if (auto *GV = dyn_cast<GlobalVariable>(this)) {

Modified: llvm/trunk/test/Analysis/ValueTracking/memory-dereferenceable.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ValueTracking/memory-dereferenceable.ll?rev=320945&r1=320944&r2=320945&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/ValueTracking/memory-dereferenceable.ll (original)
+++ llvm/trunk/test/Analysis/ValueTracking/memory-dereferenceable.ll Sun Dec 17 07:16:58 2017
@@ -36,23 +36,6 @@ entry:
     %alloca = alloca i1
     %load2 = load i1, i1* %alloca
 
-    ; Load from empty array alloca
-; CHECK-NOT: %empty_alloca
-    %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
-
 ; CHECK: %dparam{{.*}}(aligned)
     %load3 = load i32, i32 addrspace(1)* %dparam
 




More information about the llvm-commits mailing list