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