summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/Loads.cpp
diff options
context:
space:
mode:
authorArtur Pilipenko <apilipenko@azulsystems.com>2016-02-11 13:42:59 +0000
committerArtur Pilipenko <apilipenko@azulsystems.com>2016-02-11 13:42:59 +0000
commit66d6d3eb2d51808e72bc8af7fc3d176d7a2acdea (patch)
tree93887ab128ce746bb5ce732bd5cc8a7ddcb06a75 /llvm/lib/Analysis/Loads.cpp
parent5dfd5b651af1626e2124ae40d1032438c21c219d (diff)
downloadbcm5719-llvm-66d6d3eb2d51808e72bc8af7fc3d176d7a2acdea.tar.gz
bcm5719-llvm-66d6d3eb2d51808e72bc8af7fc3d176d7a2acdea.zip
Make context-sensitive isDereferenceable queries in isSafeToLoadUnconditionally
This is a part of the refactoring to unify isSafeToLoadUnconditionally and isDereferenceablePointer functions. In the subsequent change isSafeToSpeculativelyExecute will be modified to use isSafeToLoadUnconditionally instead of isDereferenceableAndAlignedPointer. Reviewed By: reames Differential Revision: http://reviews.llvm.org/D16227 llvm-svn: 260520
Diffstat (limited to 'llvm/lib/Analysis/Loads.cpp')
-rw-r--r--llvm/lib/Analysis/Loads.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp
index 1fb46b691d1..c91b892b493 100644
--- a/llvm/lib/Analysis/Loads.cpp
+++ b/llvm/lib/Analysis/Loads.cpp
@@ -56,6 +56,8 @@ static bool AreEquivalentAddressValues(const Value *A, const Value *B) {
/// \brief Check if executing a load of this pointer value cannot trap.
///
+/// If DT is specified this method performs context-sensitive analysis.
+///
/// If it is not obviously safe to load from the specified pointer, we do
/// a quick local scan of the basic block containing \c ScanFrom, to determine
/// if the address is already accessed.
@@ -63,7 +65,9 @@ static bool AreEquivalentAddressValues(const Value *A, const Value *B) {
/// This uses the pointee type to determine how many bytes need to be safe to
/// load from the pointer.
bool llvm::isSafeToLoadUnconditionally(Value *V, unsigned Align,
- Instruction *ScanFrom) {
+ Instruction *ScanFrom,
+ const DominatorTree *DT,
+ const TargetLibraryInfo *TLI) {
const DataLayout &DL = ScanFrom->getModule()->getDataLayout();
// Zero alignment means that the load has the ABI alignment for the target
@@ -71,7 +75,9 @@ bool llvm::isSafeToLoadUnconditionally(Value *V, unsigned Align,
Align = DL.getABITypeAlignment(V->getType()->getPointerElementType());
assert(isPowerOf2_32(Align));
- if (isDereferenceableAndAlignedPointer(V, Align, DL))
+ // If DT is not specified we can't make context-sensitive query
+ const Instruction* CtxI = DT ? ScanFrom : nullptr;
+ if (isDereferenceableAndAlignedPointer(V, Align, DL, CtxI, DT, TLI))
return true;
int64_t ByteOffset = 0;
OpenPOWER on IntegriCloud