1d87e607eSRoman Lebedev; RUN: opt < %s -S -passes=forceattrs | FileCheck %s --check-prefix=CHECK-CONTROL 2d87e607eSRoman Lebedev; RUN: opt < %s -S -passes=forceattrs -force-attribute foo:noinline | FileCheck %s --check-prefix=CHECK-FOO 37a028fe7SKyungwoo Lee; RUN: opt < %s -S -passes=forceattrs -force-remove-attribute goo:cold | FileCheck %s --check-prefix=REMOVE-COLD 47a028fe7SKyungwoo Lee; RUN: opt < %s -S -passes=forceattrs -force-remove-attribute goo:noinline | FileCheck %s --check-prefix=REMOVE-NOINLINE 57a028fe7SKyungwoo Lee; RUN: opt < %s -S -passes=forceattrs -force-attribute goo:cold -force-remove-attribute goo:noinline | FileCheck %s --check-prefix=ADD-COLD-REMOVE-NOINLINE 67a028fe7SKyungwoo Lee; RUN: opt < %s -S -passes=forceattrs -force-attribute goo:noinline -force-remove-attribute goo:noinline | FileCheck %s --check-prefix=ADD-NOINLINE-REMOVE-NOINLINE 7*17b48de1SAiden Grossman; RUN: opt < %s -S -passes=forceattrs -force-attribute optsize | FileCheck %s --check-prefix=CHECK-ADD-ALL 8*17b48de1SAiden Grossman; RUN: opt < %s -S -passes=forceattrs -force-remove-attribute noinline | FileCheck %s --check-prefix=CHECK-REMOVE-ALL 9cee313d2SEric Christopher 10cee313d2SEric Christopher; CHECK-CONTROL: define void @foo() { 11cee313d2SEric Christopher; CHECK-FOO: define void @foo() #0 { 12cee313d2SEric Christopherdefine void @foo() { 13cee313d2SEric Christopher ret void 14cee313d2SEric Christopher} 15cee313d2SEric Christopher 167a028fe7SKyungwoo Lee; Ignore `cold` which does not exist before. 177a028fe7SKyungwoo Lee; REMOVE-COLD: define void @goo() #0 { 187a028fe7SKyungwoo Lee 197a028fe7SKyungwoo Lee; Remove `noinline` attribute. 207a028fe7SKyungwoo Lee; REMOVE-NOINLINE: define void @goo() { 217a028fe7SKyungwoo Lee 227a028fe7SKyungwoo Lee; Add `cold` and remove `noinline` leaving `cold` only. 237a028fe7SKyungwoo Lee; ADD-COLD-REMOVE-NOINLINE: define void @goo() #0 { 247a028fe7SKyungwoo Lee 257a028fe7SKyungwoo Lee; `force-remove` takes precedence over `force`. 267a028fe7SKyungwoo Lee; `noinline` is removed. 277a028fe7SKyungwoo Lee; ADD-NOINLINE-REMOVE-NOINLINE: define void @goo() { 287a028fe7SKyungwoo Lee 297a028fe7SKyungwoo Leedefine void @goo() #0 { 307a028fe7SKyungwoo Lee ret void 317a028fe7SKyungwoo Lee} 327a028fe7SKyungwoo Leeattributes #0 = { noinline } 33cee313d2SEric Christopher 34cee313d2SEric Christopher; CHECK-FOO: attributes #0 = { noinline } 357a028fe7SKyungwoo Lee; REMOVE-COLD: attributes #0 = { noinline } 367a028fe7SKyungwoo Lee; ADD-COLD-REMOVE-NOINLINE: attributes #0 = { cold } 37*17b48de1SAiden Grossman 38*17b48de1SAiden Grossman; When passing an attribute without specifying a function, the attribute 39*17b48de1SAiden Grossman; should be added to all functions in the module. 40*17b48de1SAiden Grossman; CHECK-ADD-ALL: define void @foo() #0 { 41*17b48de1SAiden Grossman; CHECK-ADD-ALL: define void @goo() #1 { 42*17b48de1SAiden Grossman; CHECK-ADD-ALL: attributes #0 = { optsize } 43*17b48de1SAiden Grossman; CHECK-ADD-ALL: attributes #1 = { noinline optsize } 44*17b48de1SAiden Grossman 45*17b48de1SAiden Grossman; When passing an attribute to be removed without specifying a function, 46*17b48de1SAiden Grossman; the attribute should be removed from all functions in the module that 47*17b48de1SAiden Grossman; have it. 48*17b48de1SAiden Grossman; CHECK-REMOVE-ALL: define void @foo() { 49*17b48de1SAiden Grossman; CHECK-REMOVE-ALL: define void @goo() { 50*17b48de1SAiden Grossman; CHECK-REMOVE-ALL-NOT: attributes #0 51*17b48de1SAiden Grossman 52