@@ -644,6 +644,13 @@ static void AddNonNullPointersByInstruction(
644644 AddNonNullPointer (MI->getRawDest (), PtrSet);
645645 if (MemTransferInst *MTI = dyn_cast<MemTransferInst>(MI))
646646 AddNonNullPointer (MTI->getRawSource (), PtrSet);
647+ } else if (auto *CB = dyn_cast<CallBase>(I)) {
648+ for (auto &U : CB->args ()) {
649+ if (U->getType ()->isPointerTy () &&
650+ CB->paramHasNonNullAttr (CB->getArgOperandNo (&U),
651+ /* AllowUndefOrPoison=*/ false ))
652+ AddNonNullPointer (U.get (), PtrSet);
653+ }
647654 }
648655}
649656
@@ -780,25 +787,12 @@ void LazyValueInfoImpl::intersectAssumeOrGuardBlockValueConstantRange(
780787 }
781788
782789 if (BBLV.isOverdefined ()) {
783- if (PointerType *PTy = dyn_cast<PointerType>(Val->getType ())) {
784- // Check whether we're checking at the terminator, and the pointer has
785- // been dereferenced in this block.
786- if (BB->getTerminator () == BBI && isNonNullAtEndOfBlock (Val, BB))
787- BBLV = ValueLatticeElement::getNot (ConstantPointerNull::get (PTy));
788- else {
789- for (Use &U : Val->uses ()) {
790- if (auto *CB = dyn_cast<CallBase>(U.getUser ())) {
791- if (CB->isArgOperand (&U) &&
792- CB->paramHasNonNullAttr (CB->getArgOperandNo (&U),
793- /* AllowUndefOrPoison=*/ false ) &&
794- isValidAssumeForContext (CB, BBI)) {
795- BBLV = ValueLatticeElement::getNot (ConstantPointerNull::get (PTy));
796- break ;
797- }
798- }
799- }
800- }
801- }
790+ // Check whether we're checking at the terminator, and the pointer has
791+ // been dereferenced in this block.
792+ PointerType *PTy = dyn_cast<PointerType>(Val->getType ());
793+ if (PTy && BB->getTerminator () == BBI &&
794+ isNonNullAtEndOfBlock (Val, BB))
795+ BBLV = ValueLatticeElement::getNot (ConstantPointerNull::get (PTy));
802796 }
803797}
804798
0 commit comments