1 ; RUN: opt < %s -S -passes=forceattrs | FileCheck %s --check-prefix=CHECK-CONTROL
2 ; RUN: opt < %s -S -passes=forceattrs -force-attribute foo:noinline | FileCheck %s --check-prefix=CHECK-FOO
3 ; RUN: opt < %s -S -passes=forceattrs -force-remove-attribute goo:cold | FileCheck %s --check-prefix=REMOVE-COLD
4 ; RUN: opt < %s -S -passes=forceattrs -force-remove-attribute goo:noinline | FileCheck %s --check-prefix=REMOVE-NOINLINE
5 ; RUN: opt < %s -S -passes=forceattrs -force-attribute goo:cold -force-remove-attribute goo:noinline | FileCheck %s --check-prefix=ADD-COLD-REMOVE-NOINLINE
6 ; RUN: opt < %s -S -passes=forceattrs -force-attribute goo:noinline -force-remove-attribute goo:noinline | FileCheck %s --check-prefix=ADD-NOINLINE-REMOVE-NOINLINE
7 ; RUN: opt < %s -S -passes=forceattrs -force-attribute optsize | FileCheck %s --check-prefix=CHECK-ADD-ALL
8 ; RUN: opt < %s -S -passes=forceattrs -force-remove-attribute noinline | FileCheck %s --check-prefix=CHECK-REMOVE-ALL
10 ; CHECK-CONTROL: define void @foo() {
11 ; CHECK-FOO: define void @foo() #0 {
16 ; Ignore `cold` which does not exist before.
17 ; REMOVE-COLD: define void @goo() #0 {
19 ; Remove `noinline` attribute.
20 ; REMOVE-NOINLINE: define void @goo() {
22 ; Add `cold` and remove `noinline` leaving `cold` only.
23 ; ADD-COLD-REMOVE-NOINLINE: define void @goo() #0 {
25 ; `force-remove` takes precedence over `force`.
26 ; `noinline` is removed.
27 ; ADD-NOINLINE-REMOVE-NOINLINE: define void @goo() {
29 define void @goo() #0 {
32 attributes #0 = { noinline }
34 ; CHECK-FOO: attributes #0 = { noinline }
35 ; REMOVE-COLD: attributes #0 = { noinline }
36 ; ADD-COLD-REMOVE-NOINLINE: attributes #0 = { cold }
38 ; When passing an attribute without specifying a function, the attribute
39 ; should be added to all functions in the module.
40 ; CHECK-ADD-ALL: define void @foo() #0 {
41 ; CHECK-ADD-ALL: define void @goo() #1 {
42 ; CHECK-ADD-ALL: attributes #0 = { optsize }
43 ; CHECK-ADD-ALL: attributes #1 = { noinline optsize }
45 ; When passing an attribute to be removed without specifying a function,
46 ; the attribute should be removed from all functions in the module that
48 ; CHECK-REMOVE-ALL: define void @foo() {
49 ; CHECK-REMOVE-ALL: define void @goo() {
50 ; CHECK-REMOVE-ALL-NOT: attributes #0