summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold Schwaighofer <aschwaighofer@apple.com>2016-09-21 16:53:36 +0000
committerArnold Schwaighofer <aschwaighofer@apple.com>2016-09-21 16:53:36 +0000
commitde2490d0dcff0dd4358456d94f88bdf99859fb5c (patch)
tree18fcc282a44fb6a3bd01c8b6003322ac305935e9
parent15869f86d84927ceb965eb5eaecabf523d8c7eb9 (diff)
downloadbcm5719-llvm-de2490d0dcff0dd4358456d94f88bdf99859fb5c.tar.gz
bcm5719-llvm-de2490d0dcff0dd4358456d94f88bdf99859fb5c.zip
Disable tail calls if there is an swifterror argument
ISel does not handle them correctly yet i.e we crash trying to emit tail call code. radar://28407842 llvm-svn: 282088
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp5
-rw-r--r--llvm/test/CodeGen/AArch64/swifterror.ll12
-rw-r--r--llvm/test/CodeGen/ARM/swifterror.ll12
-rw-r--r--llvm/test/CodeGen/X86/swifterror.ll12
4 files changed, 41 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index ceabccca2ab..a0db9ae34f8 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -5833,6 +5833,11 @@ void SelectionDAGBuilder::LowerCallTo(ImmutableCallSite CS, SDValue Callee,
if (isTailCall && !isInTailCallPosition(CS, DAG.getTarget()))
isTailCall = false;
+ // Disable tail calls if there is an swifterror argument. Targets have not
+ // been updated to support tail calls.
+ if (TLI.supportSwiftError() && SwiftErrorVal)
+ isTailCall = false;
+
TargetLowering::CallLoweringInfo CLI(DAG);
CLI.setDebugLoc(getCurSDLoc())
.setChain(getRoot())
diff --git a/llvm/test/CodeGen/AArch64/swifterror.ll b/llvm/test/CodeGen/AArch64/swifterror.ll
index a0bfffdef95..507ae4d37d5 100644
--- a/llvm/test/CodeGen/AArch64/swifterror.ll
+++ b/llvm/test/CodeGen/AArch64/swifterror.ll
@@ -383,3 +383,15 @@ handler:
call void @free(i8* %tmp)
ret float 1.0
}
+
+; Check that we don't blow up on tail calling swifterror argument functions.
+define float @tailcallswifterror(%swift_error** swifterror %error_ptr_ref) {
+entry:
+ %0 = tail call float @tailcallswifterror(%swift_error** swifterror %error_ptr_ref)
+ ret float %0
+}
+define swiftcc float @tailcallswifterror_swiftcc(%swift_error** swifterror %error_ptr_ref) {
+entry:
+ %0 = tail call swiftcc float @tailcallswifterror_swiftcc(%swift_error** swifterror %error_ptr_ref)
+ ret float %0
+}
diff --git a/llvm/test/CodeGen/ARM/swifterror.ll b/llvm/test/CodeGen/ARM/swifterror.ll
index 17bd7059f6d..29cd2ffc281 100644
--- a/llvm/test/CodeGen/ARM/swifterror.ll
+++ b/llvm/test/CodeGen/ARM/swifterror.ll
@@ -379,3 +379,15 @@ handler:
call void @free(i8* %tmp)
ret float 1.0
}
+
+; Check that we don't blow up on tail calling swifterror argument functions.
+define float @tailcallswifterror(%swift_error** swifterror %error_ptr_ref) {
+entry:
+ %0 = tail call float @tailcallswifterror(%swift_error** swifterror %error_ptr_ref)
+ ret float %0
+}
+define swiftcc float @tailcallswifterror_swiftcc(%swift_error** swifterror %error_ptr_ref) {
+entry:
+ %0 = tail call swiftcc float @tailcallswifterror_swiftcc(%swift_error** swifterror %error_ptr_ref)
+ ret float %0
+}
diff --git a/llvm/test/CodeGen/X86/swifterror.ll b/llvm/test/CodeGen/X86/swifterror.ll
index b1e82e54328..b7226eb2b4e 100644
--- a/llvm/test/CodeGen/X86/swifterror.ll
+++ b/llvm/test/CodeGen/X86/swifterror.ll
@@ -466,3 +466,15 @@ gen_error:
normal:
ret float 0.0
}
+
+; Check that we don't blow up on tail calling swifterror argument functions.
+define float @tailcallswifterror(%swift_error** swifterror %error_ptr_ref) {
+entry:
+ %0 = tail call float @tailcallswifterror(%swift_error** swifterror %error_ptr_ref)
+ ret float %0
+}
+define swiftcc float @tailcallswifterror_swiftcc(%swift_error** swifterror %error_ptr_ref) {
+entry:
+ %0 = tail call swiftcc float @tailcallswifterror_swiftcc(%swift_error** swifterror %error_ptr_ref)
+ ret float %0
+}
OpenPOWER on IntegriCloud