[cfe-commits] r50611 - in /cfe/trunk/lib/CodeGen: CodeGenFunction.cpp CodeGenModule.cpp

Chris Lattner sabre at nondot.org
Sat May 3 18:44:26 PDT 2008


Author: lattner
Date: Sat May  3 20:44:26 2008
New Revision: 50611

URL: http://llvm.org/viewvc/llvm-project?rev=50611&view=rev
Log:
if a decl is both 'static' and weak or static and inline, its linkage
type should be internal, not weak/linkonce.

Modified:
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=50611&r1=50610&r2=50611&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Sat May  3 20:44:26 2008
@@ -159,14 +159,14 @@
   
   // TODO: Set up linkage and many other things.  Note, this is a simple 
   // approximation of what we really want.
-  if (FD->getAttr<DLLImportAttr>())
+  if (FD->getStorageClass() == FunctionDecl::Static)
+    CurFn->setLinkage(llvm::Function::InternalLinkage);
+  else if (FD->getAttr<DLLImportAttr>())
     CurFn->setLinkage(llvm::Function::DLLImportLinkage);
   else if (FD->getAttr<DLLExportAttr>())
     CurFn->setLinkage(llvm::Function::DLLExportLinkage);
   else if (FD->getAttr<WeakAttr>() || FD->isInline())
     CurFn->setLinkage(llvm::Function::WeakLinkage);
-  else if (FD->getStorageClass() == FunctionDecl::Static)
-    CurFn->setLinkage(llvm::Function::InternalLinkage);
 
   if (FD->getAttr<FastCallAttr>())
     CurFn->setCallingConv(llvm::CallingConv::Fast);

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sat May  3 20:44:26 2008
@@ -459,17 +459,19 @@
   // FIXME: else handle -fvisibility
   
   // Set the llvm linkage type as appropriate.
-  if (D->getAttr<DLLImportAttr>())
+  if (D->getStorageClass() == VarDecl::Static)
+    GV->setLinkage(llvm::Function::InternalLinkage);
+  else if (D->getAttr<DLLImportAttr>())
     GV->setLinkage(llvm::Function::DLLImportLinkage);
   else if (D->getAttr<DLLExportAttr>())
     GV->setLinkage(llvm::Function::DLLExportLinkage);
-  else if (D->getAttr<WeakAttr>()) {
+  else if (D->getAttr<WeakAttr>())
     GV->setLinkage(llvm::GlobalVariable::WeakLinkage);
-
-  } else {
+  else {
     // FIXME: This isn't right.  This should handle common linkage and other
     // stuff.
     switch (D->getStorageClass()) {
+    case VarDecl::Static: assert(0 && "This case handled above");
     case VarDecl::Auto:
     case VarDecl::Register:
       assert(0 && "Can't have auto or register globals");
@@ -481,9 +483,6 @@
     case VarDecl::PrivateExtern:
       // todo: common
       break;
-    case VarDecl::Static:
-      GV->setLinkage(llvm::GlobalVariable::InternalLinkage);
-      break;
     }
   }
 }





More information about the cfe-commits mailing list