[llvm] r271456 - Inline isDereferenceableFromAttribute; NFC

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 1 17:52:53 PDT 2016


Author: sanjoy
Date: Wed Jun  1 19:52:53 2016
New Revision: 271456

URL: http://llvm.org/viewvc/llvm-project?rev=271456&view=rev
Log:
Inline isDereferenceableFromAttribute; NFC

Now that `Value::getPointerDereferenceableBytes` looks beyond just
attributes, the name `isDereferenceableFromAttribute` is misleading.
Just inline the function, since it is small and only used once.

Modified:
    llvm/trunk/lib/Analysis/Loads.cpp

Modified: llvm/trunk/lib/Analysis/Loads.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/Loads.cpp?rev=271456&r1=271455&r2=271456&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/Loads.cpp (original)
+++ llvm/trunk/lib/Analysis/Loads.cpp Wed Jun  1 19:52:53 2016
@@ -25,23 +25,6 @@
 
 using namespace llvm;
 
-static bool isDereferenceableFromAttribute(const Value *BV, APInt Size,
-                                           const DataLayout &DL,
-                                           const Instruction *CtxI,
-                                           const DominatorTree *DT,
-                                           const TargetLibraryInfo *TLI) {
-  bool CheckForNonNull = false;
-  APInt DerefBytes(Size.getBitWidth(),
-                   BV->getPointerDereferenceableBytes(DL, CheckForNonNull));
-
-  if (DerefBytes.getBoolValue())
-    if (DerefBytes.uge(Size))
-      if (!CheckForNonNull || isKnownNonNullAt(BV, CtxI, DT, TLI))
-        return true;
-
-  return false;
-}
-
 static bool isAligned(const Value *Base, APInt Offset, unsigned Align,
                       const DataLayout &DL) {
   APInt BaseAlign(Offset.getBitWidth(), Base->getPointerAlignment(DL));
@@ -80,8 +63,14 @@ static bool isDereferenceableAndAlignedP
     return isDereferenceableAndAlignedPointer(BC->getOperand(0), Align, Size,
                                               DL, CtxI, DT, TLI, Visited);
 
-  if (isDereferenceableFromAttribute(V, Size, DL, CtxI, DT, TLI))
-    return isAligned(V, Align, DL);
+  bool CheckForNonNull = false;
+  APInt KnownDerefBytes(Size.getBitWidth(),
+                        V->getPointerDereferenceableBytes(DL, CheckForNonNull));
+  if (KnownDerefBytes.getBoolValue()) {
+    if (KnownDerefBytes.uge(Size))
+      if (!CheckForNonNull || isKnownNonNullAt(V, CtxI, DT, TLI))
+        return isAligned(V, Align, DL);
+  }
 
   // For GEPs, determine if the indexing lands within the allocated object.
   if (const GEPOperator *GEP = dyn_cast<GEPOperator>(V)) {




More information about the llvm-commits mailing list