forked from OSchip/llvm-project
[Attributor][FIX] Do not request an AANonNull for non-pointer types
This commit is contained in:
parent
ad03d0647f
commit
5dfc207c53
|
@ -2017,7 +2017,7 @@ struct AAUndefinedBehaviorImpl : public AAUndefinedBehavior {
|
|||
if (idx >= Callee->arg_size())
|
||||
break;
|
||||
Value *ArgVal = CB.getArgOperand(idx);
|
||||
if (!ArgVal)
|
||||
if (!ArgVal || !ArgVal->getType()->isPointerTy())
|
||||
continue;
|
||||
IRPosition CalleeArgumentIRP =
|
||||
IRPosition::argument(*Callee->getArg(idx));
|
||||
|
@ -2068,10 +2068,12 @@ struct AAUndefinedBehaviorImpl : public AAUndefinedBehavior {
|
|||
if (isa<UndefValue>(V)) {
|
||||
FoundUB = true;
|
||||
} else {
|
||||
auto &NonNullAA = A.getAAFor<AANonNull>(
|
||||
*this, IRPosition::returned(*getAnchorScope()));
|
||||
if (NonNullAA.isKnownNonNull() && isa<ConstantPointerNull>(V))
|
||||
FoundUB = true;
|
||||
if (isa<ConstantPointerNull>(V)) {
|
||||
auto &NonNullAA = A.getAAFor<AANonNull>(
|
||||
*this, IRPosition::returned(*getAnchorScope()));
|
||||
if (NonNullAA.isKnownNonNull())
|
||||
FoundUB = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (FoundUB)
|
||||
|
|
|
@ -1004,3 +1004,37 @@ onone:
|
|||
ondefault:
|
||||
ret i32* undef
|
||||
}
|
||||
|
||||
define noundef i32 @returned_nonnnull_noundef_int() {
|
||||
; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
|
||||
; IS__TUNIT____-LABEL: define {{[^@]+}}@returned_nonnnull_noundef_int()
|
||||
; IS__TUNIT____-NEXT: ret i32 0
|
||||
;
|
||||
; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
|
||||
; IS__CGSCC____-LABEL: define {{[^@]+}}@returned_nonnnull_noundef_int()
|
||||
; IS__CGSCC____-NEXT: ret i32 0
|
||||
;
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @callee_int_arg(i32)
|
||||
|
||||
define void @callsite_noundef_1() {
|
||||
; CHECK-LABEL: define {{[^@]+}}@callsite_noundef_1()
|
||||
; CHECK-NEXT: call void @callee_int_arg(i32 noundef 0)
|
||||
; CHECK-NEXT: ret void
|
||||
;
|
||||
call void @callee_int_arg(i32 noundef 0)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @callee_ptr_arg(i32*)
|
||||
|
||||
define void @callsite_noundef_2() {
|
||||
; CHECK-LABEL: define {{[^@]+}}@callsite_noundef_2()
|
||||
; CHECK-NEXT: call void @callee_ptr_arg(i32* noundef undef)
|
||||
; CHECK-NEXT: ret void
|
||||
;
|
||||
call void @callee_ptr_arg(i32* noundef undef)
|
||||
ret void
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue