[cfe-commits] r97773 - /cfe/trunk/lib/CodeGen/CGCXX.cpp

Rafael Espindola rafael.espindola at gmail.com
Thu Mar 4 17:21:10 PST 2010


Author: rafael
Date: Thu Mar  4 19:21:10 2010
New Revision: 97773

URL: http://llvm.org/viewvc/llvm-project?rev=97773&view=rev
Log:
Don't produce an alias for a destructor if the target is weak.

This fixes bootstrap on ELF systems :-)


Modified:
    cfe/trunk/lib/CodeGen/CGCXX.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=97773&r1=97772&r2=97773&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Thu Mar  4 19:21:10 2010
@@ -109,6 +109,16 @@
                                   GlobalDecl(BaseD, Dtor_Base));
 }
 
+static bool isWeakForLinker(llvm::GlobalValue::LinkageTypes Linkage) {
+  return (Linkage == llvm::GlobalValue::AvailableExternallyLinkage ||
+          Linkage == llvm::GlobalValue::WeakAnyLinkage ||
+          Linkage == llvm::GlobalValue::WeakODRLinkage ||
+          Linkage == llvm::GlobalValue::LinkOnceAnyLinkage ||
+          Linkage == llvm::GlobalValue::LinkOnceODRLinkage ||
+          Linkage == llvm::GlobalValue::CommonLinkage ||
+          Linkage == llvm::GlobalValue::ExternalWeakLinkage);
+}
+
 /// Try to emit a definition as a global alias for another definition.
 bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl,
                                              GlobalDecl TargetDecl) {
@@ -142,6 +152,12 @@
     return true;
   }
 
+  llvm::GlobalValue::LinkageTypes TargetLinkage
+    = getFunctionLinkage(cast<FunctionDecl>(TargetDecl.getDecl()));
+
+  if (isWeakForLinker(TargetLinkage))
+    return true;
+
   // Derive the type for the alias.
   const llvm::PointerType *AliasType
     = getTypes().GetFunctionType(AliasDecl)->getPointerTo();





More information about the cfe-commits mailing list