]> granicus.if.org Git - llvm/commitdiff
Make visible isDereferenceableAndAlignedPointer(..., const APInt &Size, ...)
authorVitaly Buka <vitalybuka@google.com>
Sat, 24 Jun 2017 01:35:13 +0000 (01:35 +0000)
committerVitaly Buka <vitalybuka@google.com>
Sat, 24 Jun 2017 01:35:13 +0000 (01:35 +0000)
Summary: Used by D34311 and D34467

Reviewers: hfinkel, efriedma

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D34585

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306193 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/Loads.h
lib/Analysis/Loads.cpp

index a59c1f88e229f7f17c1013fa483783c54c786a2c..f110c28bfc6d2feff77d3d1901ae25eb84a7c893 100644 (file)
@@ -39,6 +39,15 @@ bool isDereferenceableAndAlignedPointer(const Value *V, unsigned Align,
                                         const Instruction *CtxI = nullptr,
                                         const DominatorTree *DT = nullptr);
 
+/// Returns true if V is always dereferenceable for Size byte with alignment
+/// greater or equal than requested. If the context instruction is specified
+/// performs context-sensitive analysis and returns true if the pointer is
+/// dereferenceable at the specified instruction.
+bool isDereferenceableAndAlignedPointer(const Value *V, unsigned Align,
+                                        const APInt &Size, const DataLayout &DL,
+                                        const Instruction *CtxI = nullptr,
+                                        const DominatorTree *DT = nullptr);
+
 /// Return true if we know that executing a load from this value cannot trap.
 ///
 /// If DT and ScanFrom are specified this method performs context-sensitive
index 96799a459bfc48a4726c650bd38d6fd922714880..591b0fc481d24ec62f20c2efe9f4daa07b160255 100644 (file)
@@ -116,6 +116,16 @@ static bool isDereferenceableAndAlignedPointer(
   return false;
 }
 
+bool llvm::isDereferenceableAndAlignedPointer(const Value *V, unsigned Align,
+                                              const APInt &Size,
+                                              const DataLayout &DL,
+                                              const Instruction *CtxI,
+                                              const DominatorTree *DT) {
+  SmallPtrSet<const Value *, 32> Visited;
+  return ::isDereferenceableAndAlignedPointer(V, Align, Size, DL, CtxI, DT,
+                                              Visited);
+}
+
 bool llvm::isDereferenceableAndAlignedPointer(const Value *V, unsigned Align,
                                               const DataLayout &DL,
                                               const Instruction *CtxI,