summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-08-19 20:49:38 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-08-19 20:49:38 +0000
commit7747ce226051791be0a03ec106d9502e3564c1af (patch)
treeaee95454826c294c66952e75676eecd939ea4226 /clang/test
parent39259ffc65556b2e848ff691f6611f896c0ed6aa (diff)
downloadbcm5719-llvm-7747ce226051791be0a03ec106d9502e3564c1af.tar.gz
bcm5719-llvm-7747ce226051791be0a03ec106d9502e3564c1af.zip
Internal-linkage variables with constant-evaluatable initializers do not need to be emitted. (Also reduces the set of variables that need to be eagerly deserialized when using PCH / modules.)
llvm-svn: 245497
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CodeGen/block-with-perdefinedexpr.c1
-rw-r--r--clang/test/CodeGenCXX/const-init-cxx11.cpp1
-rw-r--r--clang/test/CodeGenCXX/dllimport.cpp2
-rw-r--r--clang/test/CodeGenCXX/typeid-cxx11.cpp4
-rw-r--r--clang/test/CodeGenObjC/local-static-block.m10
-rw-r--r--clang/test/PCH/check-deserializations.cpp15
6 files changed, 26 insertions, 7 deletions
diff --git a/clang/test/CodeGen/block-with-perdefinedexpr.c b/clang/test/CodeGen/block-with-perdefinedexpr.c
index 68fdea60f37..94d67c3b93b 100644
--- a/clang/test/CodeGen/block-with-perdefinedexpr.c
+++ b/clang/test/CodeGen/block-with-perdefinedexpr.c
@@ -5,6 +5,7 @@ void syslog(const char *, ...);
void handler( );
+__attribute__((used))
static void (^spd)() = ^()
{
handler( ^(){ syslog("%s", __FUNCTION__); } );
diff --git a/clang/test/CodeGenCXX/const-init-cxx11.cpp b/clang/test/CodeGenCXX/const-init-cxx11.cpp
index 5127c302aa0..99be265e212 100644
--- a/clang/test/CodeGenCXX/const-init-cxx11.cpp
+++ b/clang/test/CodeGenCXX/const-init-cxx11.cpp
@@ -350,6 +350,7 @@ namespace VirtualMembers {
virtual void f();
};
// CHECK: @_ZN14VirtualMembersL13sGlobalMemoryE = internal global { i8** } { i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTVN14VirtualMembers12nsMemoryImplE, i64 0, i64 2) }
+ __attribute__((used))
static nsMemoryImpl sGlobalMemory;
template<class T>
diff --git a/clang/test/CodeGenCXX/dllimport.cpp b/clang/test/CodeGenCXX/dllimport.cpp
index da8fb8d3802..c87d959c5b3 100644
--- a/clang/test/CodeGenCXX/dllimport.cpp
+++ b/clang/test/CodeGenCXX/dllimport.cpp
@@ -581,7 +581,7 @@ struct __declspec(dllimport) KeyFuncClass {
constexpr KeyFuncClass() {}
virtual void foo();
};
-constexpr KeyFuncClass keyFuncClassVar;
+extern constexpr KeyFuncClass keyFuncClassVar = {};
// G32-DAG: @_ZTV12KeyFuncClass = external dllimport unnamed_addr constant [3 x i8*]
struct __declspec(dllimport) X : public virtual W {};
diff --git a/clang/test/CodeGenCXX/typeid-cxx11.cpp b/clang/test/CodeGenCXX/typeid-cxx11.cpp
index 4e32d2dcb5a..5c10ca5b21a 100644
--- a/clang/test/CodeGenCXX/typeid-cxx11.cpp
+++ b/clang/test/CodeGenCXX/typeid-cxx11.cpp
@@ -18,8 +18,8 @@ struct A { virtual ~A(); };
struct B : virtual A {};
struct C { int n; };
-// CHECK: @_ZN5Test1L5itemsE = internal constant [4 x {{.*}}] [{{.*}} @_ZTIN5Test11AE {{.*}}, {{.*}}, {{.*}} @_ZN5Test19make_implINS_1AEEEPvv }, {{.*}} @_ZTIN5Test11BE {{.*}} @_ZN5Test19make_implINS_1BEEEPvv {{.*}} @_ZTIN5Test11CE {{.*}} @_ZN5Test19make_implINS_1CEEEPvv {{.*}} @_ZTIi {{.*}} @_ZN5Test19make_implIiEEPvv }]
-constexpr Item items[] = {
+// CHECK: @_ZN5Test15itemsE = constant [4 x {{.*}}] [{{.*}} @_ZTIN5Test11AE {{.*}}, {{.*}}, {{.*}} @_ZN5Test19make_implINS_1AEEEPvv }, {{.*}} @_ZTIN5Test11BE {{.*}} @_ZN5Test19make_implINS_1BEEEPvv {{.*}} @_ZTIN5Test11CE {{.*}} @_ZN5Test19make_implINS_1CEEEPvv {{.*}} @_ZTIi {{.*}} @_ZN5Test19make_implIiEEPvv }]
+extern constexpr Item items[] = {
item<A>("A"), item<B>("B"), item<C>("C"), item<int>("int")
};
diff --git a/clang/test/CodeGenObjC/local-static-block.m b/clang/test/CodeGenObjC/local-static-block.m
index b55cc6af4d6..73c670f5c92 100644
--- a/clang/test/CodeGenObjC/local-static-block.m
+++ b/clang/test/CodeGenObjC/local-static-block.m
@@ -14,8 +14,13 @@ static NSArray *(^ArrayRecurs)(NSArray *addresses, unsigned long level) = ^(NSA
return (NSArray *)0;
};
+extern NSArray *address;
+extern unsigned long level;
+
void FUNC()
{
+ ArrayRecurs(address, level);
+
static NSArray *(^ArrayRecurs)(NSArray *addresses, unsigned long level) = ^(NSArray *addresses, unsigned long level) {
for(id rawAddress in addresses)
@@ -25,6 +30,7 @@ void FUNC()
}
return (NSArray *)0;
};
+ ArrayRecurs(address, level);
if (ArrayRecurs) {
static NSArray *(^ArrayRecurs)(NSArray *addresses, unsigned long level) = ^(NSArray *addresses, unsigned long level) {
@@ -36,6 +42,7 @@ void FUNC()
}
return (NSArray *)0;
};
+ ArrayRecurs(address, level);
}
}
@@ -50,8 +57,9 @@ void FUNC1()
}
return (NSArray *)0;
};
+ ArrayRecurs(address, level);
}
// CHECK-LP64: @ArrayRecurs = internal global
// CHECK-LP64: @FUNC.ArrayRecurs = internal global
-// CHECK-LP64: @FUNC.ArrayRecurs.3 = internal global
+// CHECK-LP64: @FUNC.ArrayRecurs.1 = internal global
// CHECK-LP64: @FUNC1.ArrayRecurs = internal global
diff --git a/clang/test/PCH/check-deserializations.cpp b/clang/test/PCH/check-deserializations.cpp
index e24d2054938..50c84c89d1c 100644
--- a/clang/test/PCH/check-deserializations.cpp
+++ b/clang/test/PCH/check-deserializations.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-pch -o %t.1 %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -error-on-deserialized-decl S1_keyfunc -error-on-deserialized-decl S3 -include-pch %t.1 -emit-pch -o %t.2 %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -error-on-deserialized-decl S1_method -error-on-deserialized-decl S3 -include-pch %t.2 -emit-llvm-only %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -emit-pch -o %t.1 %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -error-on-deserialized-decl S1_keyfunc -error-on-deserialized-decl S3 -error-on-deserialized-decl DND -std=c++11 -include-pch %t.1 -emit-pch -o %t.2 %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -error-on-deserialized-decl S1_method -error-on-deserialized-decl S3 -error-on-deserialized-decl DND -std=c++11 -include-pch %t.2 -emit-llvm-only %s
// FIXME: Why does this require an x86 target?
// REQUIRES: x86-registered-target
@@ -20,6 +20,15 @@ struct S2 {
operator S3();
};
+namespace vars {
+ constexpr int f() { return 0; }
+ struct X { constexpr X() {} };
+ namespace v1 { const int DND = 0; }
+ namespace v2 { constexpr int DND = f(); }
+ namespace v3 { static X DND; }
+ namespace v4 { constexpr X DND = {}; }
+}
+
#elif !defined(HEADER2)
#define HEADER2
OpenPOWER on IntegriCloud