xref: /llvm-project/llvm/test/Transforms/MergeFunc/apply_function_attributes.ll (revision ee2789001b8558656a13502f0de2c81dcb419430)
1f38f99bdSRoman Lebedev; RUN: opt -S -passes=mergefunc < %s | FileCheck %s
2cee313d2SEric Christopher
3cee313d2SEric Christopher%Opaque_type = type opaque
4cee313d2SEric Christopher%S2i = type <{ i64, i64 }>
5cee313d2SEric Christopher%D2i = type <{ i64, i64 }>
6cee313d2SEric Christopher%Di = type <{ i32 }>
7cee313d2SEric Christopher%Si = type <{ i32 }>
8cee313d2SEric Christopher
9*ee278900SNikita Popovdefine void @B(ptr sret(%Opaque_type) %a, ptr %b, ptr %xp, ptr %yp) {
10*ee278900SNikita Popov  %x = load i32, ptr %xp
11*ee278900SNikita Popov  %y = load i32, ptr %yp
12cee313d2SEric Christopher  %sum = add i32 %x, %y
13cee313d2SEric Christopher  %sum2 = add i32 %sum, %y
14cee313d2SEric Christopher  %sum3 = add i32 %sum2, %y
15cee313d2SEric Christopher  ret void
16cee313d2SEric Christopher}
17cee313d2SEric Christopher
18*ee278900SNikita Popovdefine void @C(ptr sret(%Opaque_type) %a, ptr %b, ptr %xp, ptr %yp) {
19*ee278900SNikita Popov  %x = load i32, ptr %xp
20*ee278900SNikita Popov  %y = load i32, ptr %yp
21cee313d2SEric Christopher  %sum = add i32 %x, %y
22cee313d2SEric Christopher  %sum2 = add i32 %sum, %y
23cee313d2SEric Christopher  %sum3 = add i32 %sum2, %y
24cee313d2SEric Christopher  ret void
25cee313d2SEric Christopher}
26cee313d2SEric Christopher
27*ee278900SNikita Popovdefine void @A(ptr sret(%Opaque_type) %a, ptr %b, ptr %xp, ptr %yp) {
28*ee278900SNikita Popov  %x = load i32, ptr %xp
29*ee278900SNikita Popov  %y = load i32, ptr %yp
30cee313d2SEric Christopher  %sum = add i32 %x, %y
31cee313d2SEric Christopher  %sum2 = add i32 %sum, %y
32cee313d2SEric Christopher  %sum3 = add i32 %sum2, %y
33cee313d2SEric Christopher  ret void
34cee313d2SEric Christopher}
35cee313d2SEric Christopher
36cee313d2SEric Christopher; Make sure we transfer the parameter attributes to the call site.
37*ee278900SNikita Popov; CHECK-LABEL: define void @C(ptr sret
38*ee278900SNikita Popov; CHECK:  tail call void @A(ptr sret(%Opaque_type) %0, ptr %1, ptr %2, ptr %3)
39cee313d2SEric Christopher; CHECK:  ret void
40cee313d2SEric Christopher
41cee313d2SEric Christopher
42cee313d2SEric Christopher; Make sure we transfer the parameter attributes to the call site.
43*ee278900SNikita Popov; CHECK-LABEL: define void @B(ptr sret
44*ee278900SNikita Popov; CHECK:  tail call void @A(ptr sret(%Opaque_type) %0, ptr %1, ptr %2, ptr %3)
45cee313d2SEric Christopher; CHECK:  ret void
46cee313d2SEric Christopher
47