summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/Loads.cpp
diff options
context:
space:
mode:
authorArtur Pilipenko <apilipenko@azulsystems.com>2016-05-11 14:43:28 +0000
committerArtur Pilipenko <apilipenko@azulsystems.com>2016-05-11 14:43:28 +0000
commit7a26326442ed1feadbeef62799daba43e2912a3c (patch)
treed6b74fce250e7a1a930d6bf17da025fe8fc435a4 /llvm/lib/Analysis/Loads.cpp
parent610a4e916e5ceb01386d8602f928c7c00f362168 (diff)
downloadbcm5719-llvm-7a26326442ed1feadbeef62799daba43e2912a3c.tar.gz
bcm5719-llvm-7a26326442ed1feadbeef62799daba43e2912a3c.zip
NFC. Introduce Value::isPointerDereferenceable
Extract a part of isDereferenceableAndAlignedPointer functionality to Value: Reviewed By: hfinkel, sanjoy Differential Revision: http://reviews.llvm.org/D17611 llvm-svn: 269190
Diffstat (limited to 'llvm/lib/Analysis/Loads.cpp')
-rw-r--r--llvm/lib/Analysis/Loads.cpp17
1 files changed, 5 insertions, 12 deletions
diff --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp
index 58a8723626b..b0355ccee87 100644
--- a/llvm/lib/Analysis/Loads.cpp
+++ b/llvm/lib/Analysis/Loads.cpp
@@ -91,9 +91,12 @@ static bool isDereferenceableAndAlignedPointer(
// Note that it is not safe to speculate into a malloc'd region because
// malloc may return null.
- // These are obviously ok if aligned.
- if (isa<AllocaInst>(V))
+ bool CheckForNonNull;
+ if (V->isPointerDereferenceable(CheckForNonNull)) {
+ if (CheckForNonNull && !isKnownNonNullAt(V, CtxI, DT, TLI))
+ return false;
return isAligned(V, Align, DL);
+ }
// It's not always safe to follow a bitcast, for example:
// bitcast i8* (alloca i8) to i32*
@@ -112,16 +115,6 @@ static bool isDereferenceableAndAlignedPointer(
CtxI, DT, TLI, Visited);
}
- // Global variables which can't collapse to null are ok.
- if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(V))
- if (!GV->hasExternalWeakLinkage())
- return isAligned(V, Align, DL);
-
- // byval arguments are okay.
- if (const Argument *A = dyn_cast<Argument>(V))
- if (A->hasByValAttr())
- return isAligned(V, Align, DL);
-
if (isDereferenceableFromAttribute(V, DL, CtxI, DT, TLI))
return isAligned(V, Align, DL);
OpenPOWER on IntegriCloud