summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/Loads.cpp
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2016-06-02 00:52:53 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2016-06-02 00:52:53 +0000
commit48cad712437291f48443b43fb4d91d9ea2e99ef5 (patch)
tree278df87a6977c038377ffe486329410058c532cb /llvm/lib/Analysis/Loads.cpp
parent00953cbe1d981eb1a12558b060611170c7641c0e (diff)
downloadbcm5719-llvm-48cad712437291f48443b43fb4d91d9ea2e99ef5.tar.gz
bcm5719-llvm-48cad712437291f48443b43fb4d91d9ea2e99ef5.zip
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. llvm-svn: 271456
Diffstat (limited to 'llvm/lib/Analysis/Loads.cpp')
-rw-r--r--llvm/lib/Analysis/Loads.cpp27
1 files changed, 8 insertions, 19 deletions
diff --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp
index aa0b62638b1..a687eccf3e9 100644
--- a/llvm/lib/Analysis/Loads.cpp
+++ b/llvm/lib/Analysis/Loads.cpp
@@ -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 isDereferenceableAndAlignedPointer(
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)) {
OpenPOWER on IntegriCloud