1; RUN: opt -function-specialization -force-function-specialization -S < %s | FileCheck %s
2
3; Check that we don't crash and specialise on a function call with byval attribute.
4
5; CHECK-NOT: wombat.{{[0-9]+}}
6
7declare i32* @quux()
8declare i32* @eggs()
9
10define i32 @main() {
11; CHECK:       bb:
12; CHECK-NEXT:    tail call void @wombat(i8* undef, i64 undef, i64 undef, i32* byval(i32) bitcast (i32* ()* @quux to i32*))
13; CHECK-NEXT:    tail call void @wombat(i8* undef, i64 undef, i64 undef, i32* byval(i32) bitcast (i32* ()* @eggs to i32*))
14; CHECK-NEXT:    ret i32 undef
15;
16bb:
17  tail call void @wombat(i8* undef, i64 undef, i64 undef, i32* byval(i32) bitcast (i32* ()* @quux to i32*))
18  tail call void @wombat(i8* undef, i64 undef, i64 undef, i32* byval(i32) bitcast (i32* ()* @eggs to i32*))
19  ret i32 undef
20}
21
22define internal void @wombat(i8* %arg, i64 %arg1, i64 %arg2, i32* byval(i32) %func) {
23; CHECK:       bb2:
24; CHECK-NEXT:    [[FUNPTR:%.*]] = bitcast i32* %func to i32* (i8*, i8*)*
25; CHECK-NEXT:    [[TMP:%.*]] = tail call i32* [[FUNPTR]](i8* undef, i8* undef)
26; CHECK-NEXT:    ret void
27;
28bb2:
29  %mycall = bitcast i32* %func to i32* (i8*, i8*)*
30  %tmp = tail call i32* %mycall(i8* undef, i8* undef)
31  ret void
32}
33