// RUN: %clang_cc1 %s -triple %itanium_abi_triple -fms-extensions -O2 -disable-llvm-passes -emit-llvm -o - | FileCheck %s
// Test optnone on both function declarations and function definitions.
// Verify also that we don't generate invalid IR functions with
// both alwaysinline and noinline. (optnone implies noinline and wins
// over alwaysinline, in all cases.)
// Test optnone on extern declaration only.
extern int ;
// This function should be marked 'optnone'.
int
// CHECK: define {{.*}} @_Z9decl_onlyi({{.*}}) [[OPTNONE:#[0-9]+]]
// Test optnone on definition but not extern declaration.
extern int ;
int
// Function def_only is a optnone function and therefore it should not be
// inlined inside 'user_of_def_only'.
int
// CHECK: define {{.*}} @_Z8def_onlyi({{.*}}) [[OPTNONE]]
// CHECK: define {{.*}} @_Z16user_of_def_onlyv() [[NORMAL:#[0-9]+]]
// Test optnone on both definition and declaration.
extern int ;
int
// CHECK: define {{.*}} @_Z12def_and_decli({{.*}}) [[OPTNONE]]
// Check that optnone wins over always_inline.
// Test optnone on definition and always_inline on declaration.
extern int ;
extern int
// CHECK: define {{.*}} @_Z22always_inline_functioni({{.*}}) [[OPTNONE]]
int
// CHECK: define {{.*}} @_Z30user_of_always_inline_functionv() [[NORMAL]]
// Test optnone on declaration and always_inline on definition.
extern int ;
int
// CHECK: define {{.*}} @_Z16optnone_functioni({{.*}}) [[OPTNONE]]
int
// CHECK: define {{.*}} @_Z24user_of_optnone_functionv() [[NORMAL]]
// Test the combination of optnone with forceinline (optnone wins).
extern __forceinline int ;
extern int
int
// CHECK: @_Z36user_of_forceinline_optnone_functionv() [[NORMAL]]
// CHECK: @_Z28forceinline_optnone_functionii({{.*}}) [[OPTNONE]]
// CHECK: attributes [[OPTNONE]] = { mustprogress noinline nounwind optnone {{.*}} }
// CHECK: attributes [[NORMAL]] =
// CHECK-NOT: noinline
// CHECK-NOT: optnone