[cfe-commits] r94525 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp test/CodeGenCXX/anonymous-namespaces.cpp
Anders Carlsson
andersca at mac.com
Mon Jan 25 22:15:16 PST 2010
Author: andersca
Date: Tue Jan 26 00:15:16 2010
New Revision: 94525
URL: http://llvm.org/viewvc/llvm-project?rev=94525&view=rev
Log:
If a global variable has an initializer with side effects, it can never be deferred (even if it's in an anonymous namespace).
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCXX/anonymous-namespaces.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=94525&r1=94524&r2=94525&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Jan 26 00:15:16 2010
@@ -580,9 +580,8 @@
// Static data may be deferred, but out-of-line static data members
// cannot be.
- if (VD->isInAnonymousNamespace())
- return true;
- if (VD->getLinkage() == VarDecl::InternalLinkage) {
+ if (VD->getLinkage() == VarDecl::InternalLinkage ||
+ VD->isInAnonymousNamespace()) {
// Initializer has side effects?
if (VD->getInit() && VD->getInit()->HasSideEffects(Context))
return false;
Modified: cfe/trunk/test/CodeGenCXX/anonymous-namespaces.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/anonymous-namespaces.cpp?rev=94525&r1=94524&r2=94525&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/anonymous-namespaces.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/anonymous-namespaces.cpp Tue Jan 26 00:15:16 2010
@@ -1,9 +1,25 @@
// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+int f();
+
namespace {
+ // CHECK: @_ZN12_GLOBAL__N_11bE = internal global i32 0
+ // CHECK: @_ZN12_GLOBAL__N_1L1cE = internal global i32 0
+ // CHECK: @_ZN12_GLOBAL__N_11D1dE = internal global i32 0
// CHECK: @_ZN12_GLOBAL__N_11aE = internal global i32 0
int a = 0;
+ int b = f();
+
+ static int c = f();
+
+ class D {
+ static int d;
+ };
+
+ int D::d = f();
+
// CHECK: define internal i32 @_ZN12_GLOBAL__N_13fooEv()
int foo() {
return 32;
More information about the cfe-commits
mailing list