[llvm] ae990a3 - [Analysis] Attribute noundef should not prevent tail call optimization
Dávid Bolvanský via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 31 06:14:00 PST 2022
Author: Dávid Bolvanský
Date: 2022-01-31T15:13:52+01:00
New Revision: ae990a3cbd05f4a94be2e3daa93d5d078ac133d3
URL: https://github.com/llvm/llvm-project/commit/ae990a3cbd05f4a94be2e3daa93d5d078ac133d3
DIFF: https://github.com/llvm/llvm-project/commit/ae990a3cbd05f4a94be2e3daa93d5d078ac133d3.diff
LOG: [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
Added:
Modified:
llvm/lib/CodeGen/Analysis.cpp
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/test/CodeGen/X86/tail-calls-compatible-attrs.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/Analysis.cpp b/llvm/lib/CodeGen/Analysis.cpp
index e8fef505e43d..cdf5586766da 100644
--- a/llvm/lib/CodeGen/Analysis.cpp
+++ b/llvm/lib/CodeGen/Analysis.cpp
@@ -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);
}
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index ff57725ba846..cdd51bb88bea 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -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())
diff --git a/llvm/test/CodeGen/X86/tail-calls-compatible-attrs.ll b/llvm/test/CodeGen/X86/tail-calls-compatible-attrs.ll
index e7f38a7f8563..ab876f487b28 100644
--- a/llvm/test/CodeGen/X86/tail-calls-compatible-attrs.ll
+++ b/llvm/test/CodeGen/X86/tail-calls-compatible-attrs.ll
@@ -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
+}
More information about the llvm-commits
mailing list