Skip to content

Commit 790bcec

Browse files
authored
[GlobalISel] Fix a check that aligned tail call is lowered (llvm#82016)
Despite of a valid tail call opportunity, backends still may not generate a tail call or such lowering is not implemented yet. Check that lowering has happened instead of its possibility when generating G_ASSERT_ALIGN.
1 parent e7c6091 commit 790bcec

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

llvm/lib/CodeGen/GlobalISel/CallLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &CB,
187187
if (!lowerCall(MIRBuilder, Info))
188188
return false;
189189

190-
if (ReturnHintAlignReg && !Info.IsTailCall) {
190+
if (ReturnHintAlignReg && !Info.LoweredTailCall) {
191191
MIRBuilder.buildAssertAlign(ResRegs[0], ReturnHintAlignReg,
192192
ReturnHintAlign);
193193
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2+
; RUN: llc -mtriple=x86_64-linux-gnu -global-isel < %s | FileCheck %s --check-prefix=X64
3+
; RUN: llc -mtriple=i686-linux-gnu -global-isel < %s | FileCheck %s --check-prefix=X86
4+
5+
declare ptr @foo()
6+
7+
define ptr @aligned_tailcall() nounwind {
8+
; X64-LABEL: aligned_tailcall:
9+
; X64: # %bb.0: # %entry
10+
; X64-NEXT: pushq %rax
11+
; X64-NEXT: callq foo
12+
; X64-NEXT: popq %rcx
13+
; X64-NEXT: retq
14+
;
15+
; X86-LABEL: aligned_tailcall:
16+
; X86: # %bb.0: # %entry
17+
; X86-NEXT: subl $12, %esp
18+
; X86-NEXT: calll foo
19+
; X86-NEXT: addl $12, %esp
20+
; X86-NEXT: retl
21+
entry:
22+
%call = tail call align 8 ptr @foo()
23+
ret ptr %call
24+
}

0 commit comments

Comments
 (0)