summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-12-05 06:49:57 +0000
committerChris Lattner <sabre@nondot.org>2009-12-05 06:49:57 +0000
commitffcd06ea7ca93e082d0ed3c87acabf53c9d70a32 (patch)
treef1e93e84079c2ed98c82074394723b4c7eb76b03 /clang/lib/CodeGen
parentc86b6fbb4084b04a90c85108c925d5dcdca094cc (diff)
downloadbcm5719-llvm-ffcd06ea7ca93e082d0ed3c87acabf53c9d70a32.tar.gz
bcm5719-llvm-ffcd06ea7ca93e082d0ed3c87acabf53c9d70a32.zip
simplify a condition and add a testcase.
llvm-svn: 90652
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index abb391af5d6..0950d916f7a 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -323,14 +323,16 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
if (Ty->isConstantSizeType()) {
if (!Target.useGlobalsForAutomaticVariables()) {
- // All constant structs and arrays should be global if
- // their initializer is constant and if the element type is POD.
- if (CGM.getCodeGenOpts().MergeAllConstants) {
- if (Ty.isConstant(getContext())
- && (Ty->isArrayType() || Ty->isRecordType())
- && (D.getInit()
- && D.getInit()->isConstantInitializer(getContext()))
- && Ty->isPODType()) {
+ // If this value is an array or struct, is POD, and if the initializer is
+ // a staticly determinable constant, try to optimize it.
+ if (D.getInit() &&
+ (Ty->isArrayType() || Ty->isRecordType()) &&
+ Ty->isPODType() &&
+ D.getInit()->isConstantInitializer(getContext())) {
+
+ // If this variable is marked 'const', emit the value as a global.
+ if (CGM.getCodeGenOpts().MergeAllConstants &&
+ Ty.isConstant(getContext())) {
EmitStaticBlockVarDecl(D);
return;
}
OpenPOWER on IntegriCloud