From 5461d45abf940b51cfe97eaa0a7cf274d43cb394 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Thu, 23 Apr 2015 17:36:48 +0000 Subject: Move Value.isDereferenceablePointer to ValueTracking [NFC] Move isDereferenceablePointer function to Analysis. This function recursively tracks dereferencability over a chain of values like other functions in ValueTracking. This refactoring is motivated by further changes to support dereferenceable_or_null attribute (http://reviews.llvm.org/D8650). isDereferenceablePointer will be extended to perform context-sensitive analysis and IR is not a good place to have such functionality. Patch by: Artur Pilipenko Differential Revision: reviews.llvm.org/D9075 llvm-svn: 235611 --- llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp') diff --git a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 03fff1d..5b47ef9 100644 --- a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -1140,8 +1140,8 @@ public: /// the select can be loaded unconditionally. static bool isSafeSelectToSpeculate(SelectInst *SI) { const DataLayout &DL = SI->getModule()->getDataLayout(); - bool TDerefable = SI->getTrueValue()->isDereferenceablePointer(DL); - bool FDerefable = SI->getFalseValue()->isDereferenceablePointer(DL); + bool TDerefable = isDereferenceablePointer(SI->getTrueValue(), DL); + bool FDerefable = isDereferenceablePointer(SI->getFalseValue(), DL); for (User *U : SI->users()) { LoadInst *LI = dyn_cast(U); @@ -1228,7 +1228,7 @@ static bool isSafePHIToSpeculate(PHINode *PN) { // If this pointer is always safe to load, or if we can prove that there is // already a load in the block, then we can move the load to the pred block. - if (InVal->isDereferenceablePointer(DL) || + if (isDereferenceablePointer(InVal, DL) || isSafeToLoadUnconditionally(InVal, Pred->getTerminator(), MaxAlign)) continue; -- cgit v1.1