[cfe-commits] r60462 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp test/CodeGen/global-init.c
Anders Carlsson
andersca at mac.com
Tue Dec 2 21:51:24 PST 2008
Author: andersca
Date: Tue Dec 2 23:51:23 2008
New Revision: 60462
URL: http://llvm.org/viewvc/llvm-project?rev=60462&view=rev
Log:
If a global var decl has an initializer, make sure to always set its linkage to external.
Added:
cfe/trunk/test/CodeGen/global-init.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=60462&r1=60461&r2=60462&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Dec 2 23:51:23 2008
@@ -607,6 +607,8 @@
case VarDecl::None:
if (!D->getInit())
GV->setLinkage(llvm::GlobalVariable::CommonLinkage);
+ else
+ GV->setLinkage(llvm::GlobalVariable::ExternalLinkage);
break;
case VarDecl::Extern:
case VarDecl::PrivateExtern:
Added: cfe/trunk/test/CodeGen/global-init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/global-init.c?rev=60462&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/global-init.c (added)
+++ cfe/trunk/test/CodeGen/global-init.c Tue Dec 2 23:51:23 2008
@@ -0,0 +1,7 @@
+// RUN: clang -emit-llvm -o - %s | not grep "common"
+
+// This checks that the global won't be marked as common.
+// (It shouldn't because it's being initialized).
+
+int a;
+int a = 242;
More information about the cfe-commits
mailing list