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:
parent
c2189b8311
commit
432b88e5f4
|
@ -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)
|
||||
|
|
|
@ -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>>,
|
||||
|
||||
|
|
|
@ -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
|
||||
|
Loading…
Reference in New Issue