forked from OSchip/llvm-project
[Analysis] Attribute noundef should not prevent tail call optimization
Very similar to https://reviews.llvm.org/D101230 Fixes https://github.com/llvm/llvm-project/issues/53501
This commit is contained in:
parent
7ec8fc2932
commit
ae990a3cbd
|
@ -585,7 +585,7 @@ bool llvm::attributesPermitTailCall(const Function *F, const Instruction *I,
|
|||
// goes, they shouldn't affect whether the call is a tail call.
|
||||
for (const auto &Attr : {Attribute::Alignment, Attribute::Dereferenceable,
|
||||
Attribute::DereferenceableOrNull, Attribute::NoAlias,
|
||||
Attribute::NonNull}) {
|
||||
Attribute::NonNull, Attribute::NoUndef}) {
|
||||
CallerAttrs.removeAttribute(Attr);
|
||||
CalleeAttrs.removeAttribute(Attr);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ bool TargetLowering::isInTailCallPosition(SelectionDAG &DAG, SDNode *Node,
|
|||
AttrBuilder CallerAttrs(F.getContext(), F.getAttributes().getRetAttrs());
|
||||
for (const auto &Attr : {Attribute::Alignment, Attribute::Dereferenceable,
|
||||
Attribute::DereferenceableOrNull, Attribute::NoAlias,
|
||||
Attribute::NonNull})
|
||||
Attribute::NonNull, Attribute::NoUndef})
|
||||
CallerAttrs.removeAttribute(Attr);
|
||||
|
||||
if (CallerAttrs.hasAttributes())
|
||||
|
|
|
@ -50,3 +50,20 @@ define i8* @test6() nounwind {
|
|||
%ret = tail call align 8 i8* @foo()
|
||||
ret i8* %ret
|
||||
}
|
||||
|
||||
|
||||
define noundef i8* @test7() nounwind {
|
||||
; CHECK-LABEL: test7:
|
||||
; CHECK: # %bb.0:
|
||||
; CHECK-NEXT: jmp foo # TAILCALL
|
||||
%ret = tail call i8* @foo()
|
||||
ret i8* %ret
|
||||
}
|
||||
|
||||
define i8* @test8() nounwind {
|
||||
; CHECK-LABEL: test8:
|
||||
; CHECK: # %bb.0:
|
||||
; CHECK-NEXT: jmp foo # TAILCALL
|
||||
%ret = tail call noundef i8* @foo()
|
||||
ret i8* %ret
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue