From a0f63c22708a9e761330b7569b7909dd2438f188 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Tue, 14 Feb 2023 11:02:12 -0800 Subject: [PATCH] X86: force enable the mandatory tailcall on Win64 Enable the guaranteed tailcall on Windows x86_64 when we encounter a Swift function call. This function will not conform to the Windows prologue requirements which will implicitly break the unwinder and the debugger, but is required to enable the proper Concurrency behaviour for non-trivial programs. This requires associated changes in the Swift repository to update the test expectations. --- clang/lib/Basic/Targets/X86.h | 3 +-- llvm/lib/Target/X86/X86FrameLowering.cpp | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h index e34ce0aece511..ffa444ccd8be9 100644 --- a/clang/lib/Basic/Targets/X86.h +++ b/clang/lib/Basic/Targets/X86.h @@ -809,11 +809,10 @@ class LLVM_LIBRARY_VISIBILITY WindowsX86_64TargetInfo case CC_PreserveAll: case CC_X86_64SysV: case CC_Swift: + case CC_SwiftAsync: case CC_X86RegCall: case CC_OpenCLKernel: return CCCR_OK; - case CC_SwiftAsync: - return CCCR_Error; default: return CCCR_Warning; } diff --git a/llvm/lib/Target/X86/X86FrameLowering.cpp b/llvm/lib/Target/X86/X86FrameLowering.cpp index 005ccad0afef7..d978e95057f86 100644 --- a/llvm/lib/Target/X86/X86FrameLowering.cpp +++ b/llvm/lib/Target/X86/X86FrameLowering.cpp @@ -1526,7 +1526,8 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF, // Space reserved for stack-based arguments when making a (ABI-guaranteed) // tail call. unsigned TailCallArgReserveSize = -X86FI->getTCReturnAddrDelta(); - if (TailCallArgReserveSize && IsWin64Prologue) + if (TailCallArgReserveSize && IsWin64Prologue && + !MF.getFunction().getAttributes().hasAttrSomewhere(Attribute::SwiftAsync)) report_fatal_error("Can't handle guaranteed tail call under win64 yet"); const bool EmitStackProbeCall =