summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/code-seg3.cpp
diff options
context:
space:
mode:
authorErich Keane <erich.keane@intel.com>2018-07-18 20:04:48 +0000
committerErich Keane <erich.keane@intel.com>2018-07-18 20:04:48 +0000
commit7963e8bebb90543d997bf99ae5f8cf9be579d9ea (patch)
treeeed213e87bc7545d24a1c012d25cd471591d6df0 /clang/test/CodeGenCXX/code-seg3.cpp
parentd4b82da1136ff60df4ba9da99aa260a2d7f02de1 (diff)
downloadbcm5719-llvm-7963e8bebb90543d997bf99ae5f8cf9be579d9ea.tar.gz
bcm5719-llvm-7963e8bebb90543d997bf99ae5f8cf9be579d9ea.zip
Add support for __declspec(code_seg("segname"))
This patch uses CodeSegAttr to represent __declspec(code_seg) rather than building on the existing support for #pragma code_seg. The code_seg declspec is applied on functions and classes. This attribute enables the placement of code into separate named segments, including compiler- generated codes and template instantiations. For more information, please see the following: https://msdn.microsoft.com/en-us/library/dn636922.aspx This patch fixes the regression for the support for attribute ((section). https://github.com/llvm-mirror/clang/commit/746b78de7812bc785fbb5207b788348040b23fa7 Patch by Soumi Manna (Manna) Differential Revision: https://reviews.llvm.org/D48841 llvm-svn: 337420
Diffstat (limited to 'clang/test/CodeGenCXX/code-seg3.cpp')
-rw-r--r--clang/test/CodeGenCXX/code-seg3.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/code-seg3.cpp b/clang/test/CodeGenCXX/code-seg3.cpp
new file mode 100644
index 00000000000..d6f267747e3
--- /dev/null
+++ b/clang/test/CodeGenCXX/code-seg3.cpp
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple x86_64-pc-win32
+// expected-no-diagnostics
+
+// Non-Member Function Overloading is involved
+
+int __declspec(code_seg("foo_one")) bar_one(int) { return 1; }
+//CHECK: define {{.*}}bar_one{{.*}} section "foo_one"
+int __declspec(code_seg("foo_two")) bar_one(int,float) { return 11; }
+//CHECK: define {{.*}}bar_one{{.*}} section "foo_two"
+int __declspec(code_seg("foo_three")) bar_one(float) { return 12; }
+//CHECK: define {{.*}}bar_one{{.*}} section "foo_three"
+
+// virtual function overloading is involved
+
+struct __declspec(code_seg("my_one")) Base3 {
+ virtual int barA(int) { return 1; }
+ virtual int barA(int,float) { return 2; }
+ virtual int barA(float) { return 3; }
+
+ virtual void __declspec(code_seg("my_two")) barB(int) { }
+ virtual void __declspec(code_seg("my_three")) barB(float) { }
+ virtual void __declspec(code_seg("my_four")) barB(int, float) { }
+
+};
+
+//CHECK: define {{.*}}barA@Base3{{.*}} section "my_one"
+//CHECK: define {{.*}}barA@Base3{{.*}} section "my_one"
+//CHECK: define {{.*}}barA@Base3{{.*}} section "my_one"
+//CHECK: define {{.*}}barB@Base3{{.*}} section "my_two"
+//CHECK: define {{.*}}barB@Base3{{.*}} section "my_three"
+//CHECK: define {{.*}}barB@Base3{{.*}} section "my_four"
+
+#pragma code_seg("another")
+// Member functions
+struct __declspec(code_seg("foo_four")) Foo {
+ int bar3() {return 0;}
+ __declspec(code_seg("foo_lala")) int bar4() {return 0;} }; int caller() {Foo f; return f.bar3() + f.bar4(); }
+
+//CHECK: define {{.*}}bar3@Foo{{.*}} section "foo_four"
+//CHECK: define {{.*}}bar4@Foo{{.*}} section "foo_lala"
+
+// Lambdas
+#pragma code_seg("something")
+
+int __declspec(code_seg("foo")) bar1()
+{
+ int lala = 4;
+ auto l = [=](int i) { return i+4; };
+ return l(-4);
+}
+
+//CHECK: define {{.*}}bar1{{.*}} section "foo"
+//CHECK: define {{.*}}lambda{{.*}}bar1{{.*}} section "something"
+
+double __declspec(code_seg("foo")) bar2()
+{
+ double lala = 4.0;
+ auto l = [=](double d) __declspec(code_seg("another")) { return d+4.0; };
+ return l(4.0);
+}
+
+//CHECK: define {{.*}}bar2{{.*}} section "foo"
+//CHECK: define {{.*}}lambda{{.*}}bar2{{.*}} section "another"
+
+
OpenPOWER on IntegriCloud