summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/static-init.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-05-25 04:30:21 +0000
committerJohn McCall <rjmccall@apple.com>2010-05-25 04:30:21 +0000
commit8b2423361648c39a7d8a3c5e8129e12006deac32 (patch)
tree8113ac1969dd99513a97a8c1d09d5aa00de67642 /test/CodeGenCXX/static-init.cpp
parent45806fe5b89de739af95bea2e0d1a5822d53ae9b (diff)
If a function definition has any sort of weak linkage, its static local
variables should have that linkage. Otherwise, its static local variables should have internal linkage. To avoid computing this excessively, set a function's linkage before we emit code for it. Previously we were assigning weak linkage to the static variables of static inline functions in C++, with predictably terrible results. This fixes that and also gives better linkage than 'weak' when merging is required. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104581 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/static-init.cpp')
-rw-r--r--test/CodeGenCXX/static-init.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/test/CodeGenCXX/static-init.cpp b/test/CodeGenCXX/static-init.cpp
index f9604d9643..9ad87df8f0 100644
--- a/test/CodeGenCXX/static-init.cpp
+++ b/test/CodeGenCXX/static-init.cpp
@@ -2,8 +2,9 @@
// CHECK: @_ZZ1hvE1i = internal global i32 0, align 4
-// CHECK: @_ZZ2h2vE1i = weak global i32 0
-// CHECK: @_ZGVZ2h2vE1i = weak global i64 0
+// CHECK: @_ZZN5test16getvarEiE3var = internal constant [4 x i32] [i32 1, i32 0, i32 2, i32 4], align 4
+// CHECK: @_ZZ2h2vE1i = linkonce_odr global i32 0
+// CHECK: @_ZGVZ2h2vE1i = linkonce_odr global i64 0
struct A {
A();
@@ -47,3 +48,13 @@ namespace test0 {
static A r;
}
}
+
+namespace test1 {
+ // CHECK: define internal i32 @_ZN5test16getvarEi(
+ static inline int getvar(int index) {
+ static const int var[] = { 1, 0, 2, 4 };
+ return var[index];
+ }
+
+ void test() { (void) getvar(2); }
+}