1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
3 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
5 ; When a function is marked `alwaysinline` and is able to be inlined,
6 ; we can IPO its boundaries
8 ; the function is not exactly defined, and marked alwaysinline and can be inlined,
9 ; so the function can be analyzed
10 define linkonce void @inner1() alwaysinline {
11 ; CHECK: Function Attrs: alwaysinline mustprogress nofree norecurse nosync nounwind willreturn memory(none)
12 ; CHECK-LABEL: define {{[^@]+}}@inner1
13 ; CHECK-SAME: () #[[ATTR0:[0-9]+]] {
15 ; CHECK-NEXT: ret void
21 define void @outer1() {
22 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
23 ; TUNIT-LABEL: define {{[^@]+}}@outer1
24 ; TUNIT-SAME: () #[[ATTR1:[0-9]+]] {
26 ; TUNIT-NEXT: ret void
28 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
29 ; CGSCC-LABEL: define {{[^@]+}}@outer1
30 ; CGSCC-SAME: () #[[ATTR1:[0-9]+]] {
32 ; CGSCC-NEXT: ret void
39 ; The function is not alwaysinline and is not exactly defined
40 ; so it will not be analyzed
41 define linkonce i32 @inner2() {
42 ; CHECK-LABEL: define {{[^@]+}}@inner2() {
44 ; CHECK-NEXT: ret i32 1
50 ; CHECK-NOT: Function Attrs
51 define i32 @outer2() {
52 ; CHECK-LABEL: define {{[^@]+}}@outer2() {
54 ; CHECK-NEXT: [[R:%.*]] = call i32 @inner2() #[[ATTR2:[0-9]+]]
55 ; CHECK-NEXT: ret i32 [[R]]
58 %r = call i32 @inner2() alwaysinline
62 ; This function cannot be inlined although it is marked alwaysinline
63 ; it is `unexactly defined` and alwaysinline but cannot be inlined.
64 ; so it will not be analyzed
65 define linkonce i32 @inner3(ptr %addr) alwaysinline {
66 ; CHECK: Function Attrs: alwaysinline
67 ; CHECK-LABEL: define {{[^@]+}}@inner3
68 ; CHECK-SAME: (ptr [[ADDR:%.*]]) #[[ATTR2]] {
70 ; CHECK-NEXT: indirectbr ptr [[ADDR]], [label [[ONE:%.*]], label %two]
72 ; CHECK-NEXT: ret i32 42
74 ; CHECK-NEXT: ret i32 44
77 indirectbr ptr %addr, [ label %one, label %two ]
86 define i32 @outer3(i32 %x) {
87 ; CHECK-LABEL: define {{[^@]+}}@outer3
88 ; CHECK-SAME: (i32 [[X:%.*]]) {
89 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X]], 42
90 ; CHECK-NEXT: [[ADDR:%.*]] = select i1 [[CMP]], ptr blockaddress(@inner3, [[ONE:%.*]]), ptr blockaddress(@inner3, [[TWO:%.*]])
91 ; CHECK-NEXT: [[CALL:%.*]] = call i32 @inner3(ptr [[ADDR]])
92 ; CHECK-NEXT: ret i32 [[CALL]]
94 %cmp = icmp slt i32 %x, 42
95 %addr = select i1 %cmp, ptr blockaddress(@inner3, %one), ptr blockaddress(@inner3, %two)
96 %call = call i32 @inner3(ptr %addr)
100 ; TUNIT: attributes #[[ATTR0]] = { alwaysinline mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
101 ; TUNIT: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
102 ; TUNIT: attributes #[[ATTR2]] = { alwaysinline }
104 ; CGSCC: attributes #[[ATTR0]] = { alwaysinline mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
105 ; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree nosync nounwind willreturn memory(none) }
106 ; CGSCC: attributes #[[ATTR2]] = { alwaysinline }