1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes='cgscc(inline)' %s -S -pass-remarks-missed=inline 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-INLINE %s
3 ; RUN: opt -passes=always-inline -o - -S %s | FileCheck %s
5 ; CHECK-INLINE: 'ssp' not inlined into 'nossp_caller' because it should never be inlined (cost=never): stack protected callee but caller requested no stack protector
6 ; CHECK-INLINE: 'nossp' not inlined into 'ssp_caller' because it should never be inlined (cost=never): stack protected caller but callee requested no stack protector
8 ; Not interesting to test.
9 define i32 @nossp() { ret i32 41 }
10 define i32 @ssp() sspstrong { ret i32 42 }
11 define i32 @nossp_alwaysinline() alwaysinline { ret i32 43 }
12 define i32 @ssp_alwaysinline() sspstrong alwaysinline { ret i32 44 }
14 ; @ssp should not be inlined due to mismatch stack protector.
15 ; @ssp_alwaysinline should be inlined due to alwaysinline.
16 define i32 @nossp_caller() {
17 ; CHECK-LABEL: @nossp_caller(
18 ; CHECK-NEXT: [[TMP1:%.*]] = call i32 @ssp()
19 ; CHECK-NEXT: ret i32 44
22 %2 = call i32 @ssp_alwaysinline()
25 ; @nossp should not be inlined due to mismatch stack protector.
26 ; @nossp_alwaysinline should be inlined due to alwaysinline.
27 define i32 @ssp_caller() sspstrong {
28 ; CHECK-LABEL: @ssp_caller(
29 ; CHECK-NEXT: [[TMP1:%.*]] = call i32 @nossp()
30 ; CHECK-NEXT: ret i32 43
33 %2 = call i32 @nossp_alwaysinline()
37 ; The alwaysinline attribute can also appear on the CallBase (ie. the call
38 ; site), ie. when __attribute__((flatten)) is used on the caller. Treat this
39 ; the same as if the caller had the fn attr alwaysinline and permit inline
40 ; substitution, despite the mismatch between caller and callee on ssp attrs.
42 ; Curiously, the always_inline attribute on a CallInst is only expanded by the
43 ; inline pass, but not always_inline pass!
44 define i32 @nossp_alwaysinline_caller() {
45 ; CHECK-INLINE-LABEL: @nossp_alwaysinline_caller(
46 ; CHECK-INLINE-NEXT: ret i32 42
48 %1 = call i32 @ssp() alwaysinline