[llvm] r313791 - CodeGen: support SwiftError SwiftCC on Windows x64
Saleem Abdulrasool via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 20 11:40:59 PDT 2017
Author: compnerd
Date: Wed Sep 20 11:40:59 2017
New Revision: 313791
URL: http://llvm.org/viewvc/llvm-project?rev=313791&view=rev
Log:
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.
Added:
llvm/trunk/test/CodeGen/X86/swift-error.ll
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
llvm/trunk/lib/Target/X86/X86CallingConv.td
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=313791&r1=313790&r2=313791&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Wed Sep 20 11:40:59 2017
@@ -1253,6 +1253,8 @@ static void propagateSwiftErrorVRegs(Fun
// 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)
Modified: llvm/trunk/lib/Target/X86/X86CallingConv.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CallingConv.td?rev=313791&r1=313790&r2=313791&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86CallingConv.td (original)
+++ llvm/trunk/lib/Target/X86/X86CallingConv.td Wed Sep 20 11:40:59 2017
@@ -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>>,
Added: llvm/trunk/test/CodeGen/X86/swift-error.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/swift-error.ll?rev=313791&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/swift-error.ll (added)
+++ llvm/trunk/test/CodeGen/X86/swift-error.ll Wed Sep 20 11:40:59 2017
@@ -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
+
More information about the llvm-commits
mailing list