1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00
llvm-mirror/test/Verifier/swifterror.ll
Nikita Popov b227a46d3d [Verifier] Improve incompatible attribute type check
A couple of attributes had explicit checks for incompatibility
with pointer types. However, this is already handled generically
by the typeIncompatible() check. We can drop these after adding
SwiftError to typeIncompatible().

However, the previous implementation of the check prints out all
attributes that are incompatible with a given type, even though
those attributes aren't actually used. This has the annoying
result that the error message changes every time a new attribute
is added to the list. Improve this by explicitly finding which
attribute isn't compatible and printing just that.
2021-07-14 21:02:10 +02:00

32 lines
1.2 KiB
LLVM

; 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' applied to incompatible 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)