1; RUN: opt < %s -S -forceattrs | FileCheck %s --check-prefix=CHECK-CONTROL
2; RUN: opt < %s -S -forceattrs -force-attribute foo:noinline | FileCheck %s --check-prefix=CHECK-FOO
3; RUN: opt < %s -S -passes=forceattrs -force-attribute foo:noinline | FileCheck %s --check-prefix=CHECK-FOO
4; RUN: opt < %s -S -passes=forceattrs -force-remove-attribute goo:cold | FileCheck %s --check-prefix=REMOVE-COLD
5; RUN: opt < %s -S -passes=forceattrs -force-remove-attribute goo:noinline | FileCheck %s --check-prefix=REMOVE-NOINLINE
6; RUN: opt < %s -S -passes=forceattrs -force-attribute goo:cold -force-remove-attribute goo:noinline | FileCheck %s --check-prefix=ADD-COLD-REMOVE-NOINLINE
7; RUN: opt < %s -S -passes=forceattrs -force-attribute goo:noinline -force-remove-attribute goo:noinline | FileCheck %s --check-prefix=ADD-NOINLINE-REMOVE-NOINLINE
8
9; CHECK-CONTROL: define void @foo() {
10; CHECK-FOO: define void @foo() #0 {
11define void @foo() {
12  ret void
13}
14
15; Ignore `cold` which does not exist before.
16; REMOVE-COLD: define void @goo() #0 {
17
18; Remove `noinline` attribute.
19; REMOVE-NOINLINE: define void @goo() {
20
21; Add `cold` and remove `noinline` leaving `cold` only.
22; ADD-COLD-REMOVE-NOINLINE: define void @goo() #0 {
23
24; `force-remove` takes precedence over `force`.
25; `noinline` is removed.
26; ADD-NOINLINE-REMOVE-NOINLINE: define void @goo() {
27
28define void @goo() #0 {
29  ret void
30}
31attributes #0 = { noinline }
32
33; CHECK-FOO: attributes #0 = { noinline }
34; REMOVE-COLD: attributes #0 = { noinline }
35; ADD-COLD-REMOVE-NOINLINE: attributes #0 = { cold }
36