[cfe-commits] r47292 - in /cfe/trunk: CodeGen/CodeGenModule.cpp test/CodeGen/weak-global.c

Lauro Ramos Venancio lauro.venancio at gmail.com
Mon Feb 18 16:04:16 PST 2008


Author: laurov
Date: Mon Feb 18 18:04:15 2008
New Revision: 47292

URL: http://llvm.org/viewvc/llvm-project?rev=47292&view=rev
Log:
A global without initializer must be emitted as weak.
Fix Olden/bh test.


Added:
    cfe/trunk/test/CodeGen/weak-global.c
Modified:
    cfe/trunk/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenModule.cpp?rev=47292&r1=47291&r2=47292&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/CodeGen/CodeGenModule.cpp Mon Feb 18 18:04:15 2008
@@ -244,6 +244,9 @@
   case VarDecl::Register:
     assert(0 && "Can't have auto or register globals");
   case VarDecl::None:
+    if (!D->getInit())
+      GV->setLinkage(llvm::GlobalVariable::WeakLinkage);
+    break;
   case VarDecl::Extern:
   case VarDecl::PrivateExtern:
     // todo: common

Added: cfe/trunk/test/CodeGen/weak-global.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/weak-global.c?rev=47292&view=auto

==============================================================================
--- cfe/trunk/test/CodeGen/weak-global.c (added)
+++ cfe/trunk/test/CodeGen/weak-global.c Mon Feb 18 18:04:15 2008
@@ -0,0 +1,3 @@
+// RUN: clang -emit-llvm < %s | grep weak
+
+int i;





More information about the cfe-commits mailing list