1 // RUN: %clang_cc1 < %s -triple i386-mingw32 -fms-extensions -emit-llvm -x c++ | FileCheck %s 2 3 // optnone wins over inlinehint. 4 // Test that both func1 and func2 are marked optnone and noinline. 5 6 // Definition with both optnone and inlinehint. 7 __attribute__((optnone)) 8 inline int func1(int a) { 9 return a + a + a + a; 10 } 11 // CHECK: @_Z5func1i({{.*}}) [[OPTNONE:#[0-9]+]] 12 13 // optnone declaration, inlinehint definition. 14 __attribute__((optnone)) 15 int func2(int a); 16 17 inline int func2(int a) { 18 return a + a + a + a; 19 } 20 // CHECK: @_Z5func2i({{.*}}) [[OPTNONE]] 21 22 // Keep alive the definitions of func1 and func2. 23 int foo() { 24 int val = func1(1); 25 return val + func2(2); 26 } 27 28 // optnone wins over minsize. 29 __attribute__((optnone)) 30 int func3(int a); 31 32 __attribute__((minsize)) 33 int func3(int a) { 34 return a + a + a + a; 35 } 36 // Same attribute set as everything else, therefore no 'minsize'. 37 // CHECK: @_Z5func3i({{.*}}) [[OPTNONE]] 38 39 40 // Verify that noreturn is compatible with optnone. 41 __attribute__((noreturn)) 42 extern void exit_from_function(); 43 44 __attribute__((noreturn)) __attribute((optnone)) 45 extern void noreturn_function(int a) { exit_from_function(); } 46 // CHECK: @_Z17noreturn_functioni({{.*}}) [[NORETURN:#[0-9]+]] 47 48 49 // Verify that __declspec(noinline) is compatible with optnone. 50 __declspec(noinline) __attribute__((optnone)) 51 void func4() { return; } 52 // CHECK: @_Z5func4v() [[OPTNONE]] 53 54 __declspec(noinline) 55 extern void func5(); 56 57 __attribute__((optnone)) 58 void func5() { return; } 59 // CHECK: @_Z5func5v() [[OPTNONE]] 60 61 62 // Verify also that optnone can be used on dllexport functions. 63 // Adding attribute optnone on a dllimport function has no effect. 64 65 __attribute__((dllimport)) 66 __attribute__((optnone)) 67 int imported_optnone_func(int a); 68 69 __attribute__((dllexport)) 70 __attribute__((optnone)) 71 int exported_optnone_func(int a) { 72 return imported_optnone_func(a); // use of imported func 73 } 74 // CHECK: @_Z21exported_optnone_funci({{.*}}) [[OPTNONE]] 75 // CHECK: declare dllimport {{.*}} @_Z21imported_optnone_funci({{.*}}) [[DLLIMPORT:#[0-9]+]] 76 77 78 // CHECK: attributes [[OPTNONE]] = { noinline {{.*}} optnone 79 // CHECK: attributes [[NORETURN]] = { noinline noreturn {{.*}} optnone 80 81 // CHECK: attributes [[DLLIMPORT]] = 82 // CHECK-NOT: optnone 83