File tree Expand file tree Collapse file tree 2 files changed +22
-12
lines changed
test/Transforms/CorrelatedValuePropagation Expand file tree Collapse file tree 2 files changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -780,12 +780,25 @@ void LazyValueInfoImpl::intersectAssumeOrGuardBlockValueConstantRange(
780780 }
781781
782782 if (BBLV.isOverdefined ()) {
783- // Check whether we're checking at the terminator, and the pointer has
784- // been dereferenced in this block.
785- PointerType *PTy = dyn_cast<PointerType>(Val->getType ());
786- if (PTy && BB->getTerminator () == BBI &&
787- isNonNullAtEndOfBlock (Val, BB))
788- BBLV = ValueLatticeElement::getNot (ConstantPointerNull::get (PTy));
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+ }
789802 }
790803}
791804
Original file line number Diff line number Diff line change @@ -349,8 +349,7 @@ define i1 @test_known_nonnull_at_callsite(ptr %src) {
349349; CHECK-LABEL: @test_known_nonnull_at_callsite(
350350; CHECK-NEXT: entry:
351351; CHECK-NEXT: call void @callee(ptr noundef nonnull [[SRC:%.*]])
352- ; CHECK-NEXT: [[NONNULL:%.*]] = icmp eq ptr [[SRC]], null
353- ; CHECK-NEXT: ret i1 [[NONNULL]]
352+ ; CHECK-NEXT: ret i1 false
354353;
355354entry:
356355 call void @callee (ptr noundef nonnull %src )
@@ -362,8 +361,7 @@ define i1 @test_known_nonnull_mixed(ptr %src) {
362361; CHECK-LABEL: @test_known_nonnull_mixed(
363362; CHECK-NEXT: entry:
364363; CHECK-NEXT: call void @callee2(ptr nonnull [[SRC:%.*]])
365- ; CHECK-NEXT: [[NONNULL:%.*]] = icmp eq ptr [[SRC]], null
366- ; CHECK-NEXT: ret i1 [[NONNULL]]
364+ ; CHECK-NEXT: ret i1 false
367365;
368366entry:
369367 call void @callee2 (ptr nonnull %src )
@@ -375,8 +373,7 @@ define i1 @test_known_nonnull_at_callsite_dereferenceable(ptr %src) {
375373; CHECK-LABEL: @test_known_nonnull_at_callsite_dereferenceable(
376374; CHECK-NEXT: entry:
377375; CHECK-NEXT: call void @callee(ptr dereferenceable(1) [[SRC:%.*]])
378- ; CHECK-NEXT: [[NONNULL:%.*]] = icmp eq ptr [[SRC]], null
379- ; CHECK-NEXT: ret i1 [[NONNULL]]
376+ ; CHECK-NEXT: ret i1 false
380377;
381378entry:
382379 call void @callee (ptr dereferenceable (1 ) %src )
You can’t perform that action at this time.
0 commit comments