1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

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
This commit is contained in:
Sanjoy Das 2016-06-02 00:52:53 +00:00
parent 23a5b9d8fc
commit 97c2cde156

View File

@ -25,23 +25,6 @@
using namespace llvm; 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, static bool isAligned(const Value *Base, APInt Offset, unsigned Align,
const DataLayout &DL) { const DataLayout &DL) {
APInt BaseAlign(Offset.getBitWidth(), Base->getPointerAlignment(DL)); APInt BaseAlign(Offset.getBitWidth(), Base->getPointerAlignment(DL));
@ -80,8 +63,14 @@ static bool isDereferenceableAndAlignedPointer(
return isDereferenceableAndAlignedPointer(BC->getOperand(0), Align, Size, return isDereferenceableAndAlignedPointer(BC->getOperand(0), Align, Size,
DL, CtxI, DT, TLI, Visited); DL, CtxI, DT, TLI, Visited);
if (isDereferenceableFromAttribute(V, Size, DL, CtxI, DT, TLI)) bool CheckForNonNull = false;
return isAligned(V, Align, DL); 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. // For GEPs, determine if the indexing lands within the allocated object.
if (const GEPOperator *GEP = dyn_cast<GEPOperator>(V)) { if (const GEPOperator *GEP = dyn_cast<GEPOperator>(V)) {