CodeGen: support SwiftError SwiftCC on Windows x64

Add support for passing SwiftError through a register on the Windows x64
calling convention.  This allows the use of swifterror attributes on
parameters which is used by the swift front end for the `Error`
parameter.  This partially enables building the swift standard library
for Windows x86_64.

llvm-svn: 313791
This commit is contained in:
Saleem Abdulrasool 2017-09-20 18:40:59 +00:00
parent c2189b8311
commit 432b88e5f4
3 changed files with 23 additions and 0 deletions

View File

@ -1253,6 +1253,8 @@ static void propagateSwiftErrorVRegs(FunctionLoweringInfo *FuncInfo) {
// If we don't need a phi create a copy to the upward exposed vreg.
if (!needPHI) {
assert(UpwardsUse);
assert(!VRegs.empty() &&
"No predecessors? Is the Calling Convention correct?");
unsigned DestReg = UUseVReg;
BuildMI(*MBB, MBB->getFirstNonPHI(), DLoc, TII->get(TargetOpcode::COPY),
DestReg)

View File

@ -592,6 +592,9 @@ def CC_X86_Win64_C : CallingConv<[
// The 'nest' parameter, if any, is passed in R10.
CCIfNest<CCAssignToReg<[R10]>>,
// A SwiftError is passed in R12.
CCIfSwiftError<CCIfType<[i64], CCAssignToReg<[R12]>>>,
// 128 bit vectors are passed by pointer
CCIfType<[v16i8, v8i16, v4i32, v2i64, v4f32, v2f64], CCPassIndirect<i64>>,

View File

@ -0,0 +1,18 @@
; RUN: llc -mtriple x86_64-unknown-windows-msvc -filetype asm -o - %s | FileCheck %s
%swift.error = type opaque
declare swiftcc void @f(%swift.error** swifterror)
define swiftcc void @g(i8*, i8*, i8*, i8*, %swift.error** swifterror %error) {
entry:
call swiftcc void @f(%swift.error** nonnull nocapture swifterror %error)
ret void
}
; CHECK-LABEL: g
; CHECK: pushq %r12
; CHECK: callq f
; CHECK: popq %r12
; CHECK: retq