43 lines · c
1// RUN: %clang_cc1 -emit-llvm < %s > %t2// RUN: FileCheck %s --check-prefix=PRESENT < %t3// RUN: FileCheck %s --check-prefix=ABSENT < %t4// RUN: %clang_cc1 -emit-llvm -Os < %s > %t5// RUN: FileCheck %s --check-prefix=PRESENT < %t6// RUN: FileCheck %s --check-prefix=OPTSIZE < %t7// RUN: %clang_cc1 -emit-llvm -Oz < %s > %t8// RUN: FileCheck %s --check-prefix=PRESENT < %t9// RUN: FileCheck %s --check-prefix=MINSIZE < %t10 11__attribute__((always_inline))12int test2(void) { return 0; }13// OPTSIZE: @test2{{.*}}[[ATTR2:#[0-9]+]]14// MINSIZE: @test2{{.*}}[[ATTR2:#[0-9]+]]15 16__attribute__((optnone))17int test3(void) { return 0; }18// PRESENT-DAG: @test3{{.*}}[[ATTR3:#[0-9]+]]19 20__attribute__((optnone)) __attribute__((cold))21int test4(void) { return test2(); }22// PRESENT-DAG: @test4{{.*}}[[ATTR4:#[0-9]+]]23// Also check that test2 is inlined into test4 (always_inline still works).24// PRESENT-NOT: call i32 @test225 26// Check for both noinline and optnone on each optnone function.27// PRESENT-DAG: attributes [[ATTR3]] = { {{.*}}noinline{{.*}}optnone{{.*}} }28// PRESENT-DAG: attributes [[ATTR4]] = { {{.*}}noinline{{.*}}optnone{{.*}} }29 30// Check that no 'optsize' or 'minsize' attributes appear.31// ABSENT-NOT: optsize32// ABSENT-NOT: minsize33 34// With -Os, check that 'optsize' appears only on test2.35// OPTSIZE-NOT: optsize36// OPTSIZE: attributes [[ATTR2]] = { {{.*}}optsize{{.*}} }37// OPTSIZE-NOT: optsize38 39// With -Oz, check that 'minsize' appears only on test2.40// MINSIZE-NOT: minsize41// MINSIZE: attributes [[ATTR2]] = { {{.*}}minsize{{.*}} }42// MINSIZE-NOT: minsize43