Author: hans
Date: Wed Feb 15 13:12:45 2017
New Revision: 295219

URL: http://llvm.org/viewvc/llvm-project?rev=295219&view=rev
Log:
Merging r294982:
------------------------------------------------------------------------
r294982 | arnolds | 2017-02-13 11:58:28 -0800 (Mon, 13 Feb 2017) | 6 lines

swiftcc: Don't emit tail calls from callers with swifterror parameters

Backends don't support this yet. They would have to move to the swifterror
register before the tail call to make sure it is live-in to the call.

rdar://30495920
------------------------------------------------------------------------

Modified:
    llvm/branches/release_40/   (props changed)
    llvm/branches/release_40/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
    llvm/branches/release_40/test/CodeGen/AArch64/swifterror.ll
    llvm/branches/release_40/test/CodeGen/ARM/swifterror.ll
    llvm/branches/release_40/test/CodeGen/X86/swifterror.ll

Propchange: llvm/branches/release_40/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Feb 15 13:12:45 2017
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,291858-291859,291863,291875,291909,291918,291966,291968,291979,292117,292133,292167,292169-292170,292242,292254-292255,292280,292323,292444,292467,292516,292583,292624-292625,292641,292651,292667,292711-292713,292758,292949,293017,293021,293025,293230,293259,293291,293293,293309,293345,293417,293522,293542,293629,293635,293658,293673,293727,293730,294102,294203,294267,294318,294348-294349,294357,294527,294551,295018
+/llvm/trunk:155241,291858-291859,291863,291875,291909,291918,291966,291968,291979,292117,292133,292167,292169-292170,292242,292254-292255,292280,292323,292444,292467,292516,292583,292624-292625,292641,292651,292667,292711-292713,292758,292949,293017,293021,293025,293230,293259,293291,293293,293309,293345,293417,293522,293542,293629,293635,293658,293673,293727,293730,294102,294203,294267,294318,294348-294349,294357,294527,294551,294982,295018

Modified: 
llvm/branches/release_40/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=295219&r1=295218&r2=295219&view=diff
==============================================================================
--- llvm/branches/release_40/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp 
(original)
+++ llvm/branches/release_40/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp 
Wed Feb 15 13:12:45 2017
@@ -5832,6 +5832,15 @@ void SelectionDAGBuilder::LowerCallTo(Im
 
   const Value *SwiftErrorVal = nullptr;
   const TargetLowering &TLI = DAG.getTargetLoweringInfo();
+
+  // We can't tail call inside a function with a swifterror argument. Lowering
+  // does not support this yet. It would have to move into the swifterror
+  // register before the call.
+  auto *Caller = CS.getInstruction()->getParent()->getParent();
+  if (TLI.supportSwiftError() &&
+      Caller->getAttributes().hasAttrSomewhere(Attribute::SwiftError))
+    isTailCall = false;
+
   for (ImmutableCallSite::arg_iterator i = CS.arg_begin(), e = CS.arg_end();
        i != e; ++i) {
     const Value *V = *i;

Modified: llvm/branches/release_40/test/CodeGen/AArch64/swifterror.ll
URL: 
http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/test/CodeGen/AArch64/swifterror.ll?rev=295219&r1=295218&r2=295219&view=diff
==============================================================================
--- llvm/branches/release_40/test/CodeGen/AArch64/swifterror.ll (original)
+++ llvm/branches/release_40/test/CodeGen/AArch64/swifterror.ll Wed Feb 15 
13:12:45 2017
@@ -583,3 +583,17 @@ define swiftcc { i64, i64, i64, i64, i64
 }
 
 declare swiftcc { i64, i64, i64, i64, i64, i64, i64, i64 } 
@params_and_return_in_reg2(i64, i64, i64, i64, i64, i64, i64, i64, i8* 
swiftself, %swift_error** nocapture swifterror %err)
+
+declare void @acallee(i8*)
+
+; Make sure we don't tail call if the caller returns a swifterror value. We
+; would have to move into the swifterror register before the tail call.
+; CHECK-APPLE: tailcall_from_swifterror:
+; CHECK-APPLE-NOT: b _acallee
+; CHECK-APPLE: bl _acallee
+
+define swiftcc void @tailcall_from_swifterror(%swift_error** swifterror 
%error_ptr_ref) {
+entry:
+  tail call void @acallee(i8* null)
+  ret void
+}

Modified: llvm/branches/release_40/test/CodeGen/ARM/swifterror.ll
URL: 
http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/test/CodeGen/ARM/swifterror.ll?rev=295219&r1=295218&r2=295219&view=diff
==============================================================================
--- llvm/branches/release_40/test/CodeGen/ARM/swifterror.ll (original)
+++ llvm/branches/release_40/test/CodeGen/ARM/swifterror.ll Wed Feb 15 13:12:45 
2017
@@ -513,3 +513,18 @@ define swiftcc { i32, i32, i32, i32} @pa
 }
 
 declare swiftcc { i32, i32, i32, i32 } @params_and_return_in_reg2(i32, i32, 
i32, i32, i8* swiftself, %swift_error** nocapture swifterror %err)
+
+
+declare void @acallee(i8*)
+
+; Make sure we don't tail call if the caller returns a swifterror value. We
+; would have to move into the swifterror register before the tail call.
+; CHECK-APPLE: tailcall_from_swifterror:
+; CHECK-APPLE-NOT: b _acallee
+; CHECK-APPLE: bl _acallee
+
+define swiftcc void @tailcall_from_swifterror(%swift_error** swifterror 
%error_ptr_ref) {
+entry:
+  tail call void @acallee(i8* null)
+  ret void
+}

Modified: llvm/branches/release_40/test/CodeGen/X86/swifterror.ll
URL: 
http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/test/CodeGen/X86/swifterror.ll?rev=295219&r1=295218&r2=295219&view=diff
==============================================================================
--- llvm/branches/release_40/test/CodeGen/X86/swifterror.ll (original)
+++ llvm/branches/release_40/test/CodeGen/X86/swifterror.ll Wed Feb 15 13:12:45 
2017
@@ -670,3 +670,18 @@ define swiftcc { i64, i64, i64, i64} @pa
 }
 
 declare swiftcc { i64, i64, i64, i64 } @params_and_return_in_reg2(i64, i64, 
i64, i64, i64, i64, i8* swiftself, %swift_error** nocapture swifterror %err)
+
+
+declare void @acallee(i8*)
+
+; Make sure we don't tail call if the caller returns a swifterror value. We
+; would have to move into the swifterror register before the tail call.
+; CHECK-APPLE: tailcall_from_swifterror:
+; CHECK-APPLE-NOT: jmp _acallee
+; CHECK-APPLE: callq _acallee
+
+define swiftcc void @tailcall_from_swifterror(%swift_error** swifterror 
%error_ptr_ref) {
+entry:
+  tail call void @acallee(i8* null)
+  ret void
+}


_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to