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

Chris Lattner clattner at apple.com
Thu Mar 4 17:55:51 PST 2010


On Mar 4, 2010, at 5:21 PM, Rafael Espindola wrote:

> 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 :-)

Hi Rafael, can isWeakForLinker become a static method on llvm::GlobalValue?

-Chris

> 
> 
> 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();
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits





More information about the cfe-commits mailing list