summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Bitcode/attributes.ll25
-rw-r--r--llvm/test/Verifier/swifterror.ll31
-rw-r--r--llvm/test/Verifier/swifterror2.ll4
-rw-r--r--llvm/test/Verifier/swifterror3.ll4
4 files changed, 64 insertions, 0 deletions
diff --git a/llvm/test/Bitcode/attributes.ll b/llvm/test/Bitcode/attributes.ll
index 74b0386c33d..dec3608fb2b 100644
--- a/llvm/test/Bitcode/attributes.ll
+++ b/llvm/test/Bitcode/attributes.ll
@@ -293,6 +293,31 @@ define void @f50(i8* swiftself)
ret void;
}
+; CHECK: define i32 @f51(i8** swifterror)
+define i32 @f51(i8** swifterror)
+{
+ ret i32 0
+}
+
+; CHECK: define i32 @f52(i32, i8** swifterror)
+define i32 @f52(i32, i8** swifterror)
+{
+ ret i32 0
+}
+
+%swift_error = type {i64, i8}
+declare float @foo(%swift_error** swifterror %error_ptr_ref)
+
+; CHECK: define float @f53
+; CHECK: alloca swifterror
+define float @f53(i8* %error_ref) {
+entry:
+ %error_ptr_ref = alloca swifterror %swift_error*
+ store %swift_error* null, %swift_error** %error_ptr_ref
+ %call = call float @foo(%swift_error** swifterror %error_ptr_ref)
+ ret float 1.0
+}
+
; CHECK: attributes #0 = { noreturn }
; CHECK: attributes #1 = { nounwind }
; CHECK: attributes #2 = { readnone }
diff --git a/llvm/test/Verifier/swifterror.ll b/llvm/test/Verifier/swifterror.ll
new file mode 100644
index 00000000000..d8eacf5480e
--- /dev/null
+++ b/llvm/test/Verifier/swifterror.ll
@@ -0,0 +1,31 @@
+; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
+
+%swift_error = type {i64, i8}
+
+; CHECK: swifterror value can only be loaded and stored from, or as a swifterror argument!
+; CHECK: %swift_error** %error_ptr_ref
+; CHECK: %t = getelementptr inbounds %swift_error*, %swift_error** %error_ptr_ref, i64 1
+define float @foo(%swift_error** swifterror %error_ptr_ref) {
+ %t = getelementptr inbounds %swift_error*, %swift_error** %error_ptr_ref, i64 1
+ ret float 1.0
+}
+
+; CHECK: swifterror argument for call has mismatched alloca
+; CHECK: %error_ptr_ref = alloca %swift_error*
+; CHECK: %call = call float @foo(%swift_error** swifterror %error_ptr_ref)
+define float @caller(i8* %error_ref) {
+entry:
+ %error_ptr_ref = alloca %swift_error*
+ store %swift_error* null, %swift_error** %error_ptr_ref
+ %call = call float @foo(%swift_error** swifterror %error_ptr_ref)
+ ret float 1.0
+}
+
+; CHECK: Cannot have multiple 'swifterror' parameters!
+declare void @a(i32** swifterror %a, i32** swifterror %b)
+
+; CHECK: Attribute 'swifterror' only applies to parameters with pointer type!
+declare void @b(i32 swifterror %a)
+
+; CHECK: Attribute 'swifterror' only applies to parameters with pointer to pointer type!
+declare void @c(i32* swifterror %a)
diff --git a/llvm/test/Verifier/swifterror2.ll b/llvm/test/Verifier/swifterror2.ll
new file mode 100644
index 00000000000..23d3b6321d6
--- /dev/null
+++ b/llvm/test/Verifier/swifterror2.ll
@@ -0,0 +1,4 @@
+; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
+
+; CHECK: invalid use of parameter-only attribute
+declare swifterror void @c(i32** swifterror %a)
diff --git a/llvm/test/Verifier/swifterror3.ll b/llvm/test/Verifier/swifterror3.ll
new file mode 100644
index 00000000000..bf2483f0a38
--- /dev/null
+++ b/llvm/test/Verifier/swifterror3.ll
@@ -0,0 +1,4 @@
+; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
+
+; CHECK: expected type
+declare void @c(swifterror i32* %a)
OpenPOWER on IntegriCloud