summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/optnone-and-attributes.cpp
diff options
context:
space:
mode:
authorPaul Robinson <paul_robinson@playstation.sony.com>2016-01-04 17:03:58 +0000
committerPaul Robinson <paul_robinson@playstation.sony.com>2016-01-04 17:03:58 +0000
commit9d6940ba096ac9ce964c4996a1c26562d2d5893e (patch)
treef2c526c52e8914c1d8c271815c95fd85f7562b27 /clang/test/CodeGenCXX/optnone-and-attributes.cpp
parent947ca8ac5209b9f4da32ffbf31b943947a4022a9 (diff)
downloadbcm5719-llvm-9d6940ba096ac9ce964c4996a1c26562d2d5893e.tar.gz
bcm5719-llvm-9d6940ba096ac9ce964c4996a1c26562d2d5893e.zip
Add some overlooked optnone tests, and tighten up an existing test.
Differential Revision: http://reviews.llvm.org/D15704 llvm-svn: 256762
Diffstat (limited to 'clang/test/CodeGenCXX/optnone-and-attributes.cpp')
-rw-r--r--clang/test/CodeGenCXX/optnone-and-attributes.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/optnone-and-attributes.cpp b/clang/test/CodeGenCXX/optnone-and-attributes.cpp
new file mode 100644
index 00000000000..56173b5a360
--- /dev/null
+++ b/clang/test/CodeGenCXX/optnone-and-attributes.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 < %s -triple i386-mingw32 -fms-extensions -emit-llvm -x c++ | FileCheck %s
+
+// optnone wins over inlinehint.
+// Test that both func1 and func2 are marked optnone and noinline.
+
+// Definition with both optnone and inlinehint.
+__attribute__((optnone))
+inline int func1(int a) {
+ return a + a + a + a;
+}
+// CHECK: @_Z5func1i({{.*}}) [[OPTNONE:#[0-9]+]]
+
+// optnone declaration, inlinehint definition.
+__attribute__((optnone))
+int func2(int a);
+
+inline int func2(int a) {
+ return a + a + a + a;
+}
+// CHECK: @_Z5func2i({{.*}}) [[OPTNONE]]
+
+// Keep alive the definitions of func1 and func2.
+int foo() {
+ int val = func1(1);
+ return val + func2(2);
+}
+
+// optnone wins over minsize.
+__attribute__((optnone))
+int func3(int a);
+
+__attribute__((minsize))
+int func3(int a) {
+ return a + a + a + a;
+}
+// Same attribute set as everything else, therefore no 'minsize'.
+// CHECK: @_Z5func3i({{.*}}) [[OPTNONE]]
+
+
+// Verify that noreturn is compatible with optnone.
+__attribute__((noreturn))
+extern void exit_from_function();
+
+__attribute__((noreturn)) __attribute((optnone))
+extern void noreturn_function(int a) { exit_from_function(); }
+// CHECK: @_Z17noreturn_functioni({{.*}}) [[NORETURN:#[0-9]+]]
+
+
+// Verify that __declspec(noinline) is compatible with optnone.
+__declspec(noinline) __attribute__((optnone))
+void func4() { return; }
+// CHECK: @_Z5func4v() [[OPTNONE]]
+
+__declspec(noinline)
+extern void func5();
+
+__attribute__((optnone))
+void func5() { return; }
+// CHECK: @_Z5func5v() [[OPTNONE]]
+
+
+// Verify also that optnone can be used on dllexport functions.
+// Adding attribute optnone on a dllimport function has no effect.
+
+__attribute__((dllimport))
+__attribute__((optnone))
+int imported_optnone_func(int a);
+
+__attribute__((dllexport))
+__attribute__((optnone))
+int exported_optnone_func(int a) {
+ return imported_optnone_func(a); // use of imported func
+}
+// CHECK: @_Z21exported_optnone_funci({{.*}}) [[OPTNONE]]
+// CHECK: declare dllimport {{.*}} @_Z21imported_optnone_funci({{.*}}) [[DLLIMPORT:#[0-9]+]]
+
+
+// CHECK: attributes [[OPTNONE]] = { noinline {{.*}} optnone
+// CHECK: attributes [[NORETURN]] = { noinline noreturn {{.*}} optnone
+
+// CHECK: attributes [[DLLIMPORT]] =
+// CHECK-SAME-NOT: optnone
OpenPOWER on IntegriCloud