diff options
| author | Johannes Doerfert <jdoerfert@anl.gov> | 2019-10-13 20:40:10 +0000 |
|---|---|---|
| committer | Johannes Doerfert <jdoerfert@anl.gov> | 2019-10-13 20:40:10 +0000 |
| commit | db6efb017f246e2492ccd00613d079de96d8f705 (patch) | |
| tree | 7e3ab813fb0558cdf4ace7eb2aaa77891681ea99 /llvm/lib | |
| parent | 7a9fa897ec3539430170009d4c390518e1e78d13 (diff) | |
| download | bcm5719-llvm-db6efb017f246e2492ccd00613d079de96d8f705.tar.gz bcm5719-llvm-db6efb017f246e2492ccd00613d079de96d8f705.zip | |
[Attributor][FIX] Use check prefix that is actually tested
Summary:
This changes "CHECK" check lines to "ATTRIBUTOR" check lines where
necessary and also fixes the now exposed, mostly minor, problems.
Reviewers: sstefan1, uenoku
Subscribers: hiraditya, bollu, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D68929
llvm-svn: 374735
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Transforms/IPO/Attributor.cpp | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp index 2778daf9fab..dadf3722a6f 100644 --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -593,8 +593,9 @@ struct AAComposeTwoGenericDeduction /// See AbstractAttribute::updateImpl(...). ChangeStatus updateImpl(Attributor &A) override { - return F<AAType, G<AAType, Base, StateType>, StateType>::updateImpl(A) | - G<AAType, Base, StateType>::updateImpl(A); + ChangeStatus ChangedF = F<AAType, G<AAType, Base, StateType>, StateType>::updateImpl(A); + ChangeStatus ChangedG = G<AAType, Base, StateType>::updateImpl(A); + return ChangedF | ChangedG; } }; @@ -1535,11 +1536,16 @@ struct AANoFreeCallSite final : AANoFreeImpl { static int64_t getKnownNonNullAndDerefBytesForUse( Attributor &A, AbstractAttribute &QueryingAA, Value &AssociatedValue, const Use *U, const Instruction *I, bool &IsNonNull, bool &TrackUse) { - // TODO: Add GEP support TrackUse = false; + const Value *UseV = U->get(); + if (!UseV->getType()->isPointerTy()) + return 0; + + Type *PtrTy = UseV->getType(); const Function *F = I->getFunction(); - bool NullPointerIsDefined = F ? F->nullPointerIsDefined() : true; + bool NullPointerIsDefined = + F ? llvm::NullPointerIsDefined(F, PtrTy->getPointerAddressSpace()) : true; const DataLayout &DL = A.getInfoCache().getDL(); if (ImmutableCallSite ICS = ImmutableCallSite(I)) { if (ICS.isBundleOperand(U)) @@ -1559,19 +1565,28 @@ static int64_t getKnownNonNullAndDerefBytesForUse( int64_t Offset; if (const Value *Base = getBasePointerOfAccessPointerOperand(I, Offset, DL)) { - if (Base == &AssociatedValue) { + if (Base == &AssociatedValue && getPointerOperand(I) == UseV) { int64_t DerefBytes = - Offset + - (int64_t)DL.getTypeStoreSize( - getPointerOperand(I)->getType()->getPointerElementType()); + Offset + (int64_t)DL.getTypeStoreSize(PtrTy->getPointerElementType()); IsNonNull |= !NullPointerIsDefined; return DerefBytes; } } + if (const Value *Base = + GetPointerBaseWithConstantOffset(UseV, Offset, DL, + /*AllowNonInbounds*/ false)) { + auto &DerefAA = + A.getAAFor<AADereferenceable>(QueryingAA, IRPosition::value(*Base)); + IsNonNull |= (!NullPointerIsDefined && DerefAA.isKnownNonNull()); + IsNonNull |= (!NullPointerIsDefined && (Offset != 0)); + int64_t DerefBytes = DerefAA.getKnownDereferenceableBytes(); + return std::max(int64_t(0), DerefBytes - Offset); + } return 0; } + struct AANonNullImpl : AANonNull { AANonNullImpl(const IRPosition &IRP) : AANonNull(IRP) {} @@ -2539,7 +2554,7 @@ struct AADereferenceableFloating // for overflows of the dereferenceable bytes. int64_t OffsetSExt = Offset.getSExtValue(); if (OffsetSExt < 0) - Offset = 0; + OffsetSExt = 0; T.takeAssumedDerefBytesMinimum( std::max(int64_t(0), DerefBytes - OffsetSExt)); |

