r203052 - Construct GlobalValues with the correct linkage instead of using setLinkage.

jahanian fjahanian at apple.com
Thu Mar 6 08:38:48 PST 2014


On Mar 5, 2014, at 5:10 PM, Rafael Espindola <rafael.espindola at gmail.com> wrote:

> Author: rafael
> Date: Wed Mar  5 19:10:46 2014
> New Revision: 203052
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=203052&view=rev
> Log:
> Construct GlobalValues with the correct linkage instead of using setLinkage.
> 
> Modified:
>    cfe/trunk/lib/CodeGen/CGObjCMac.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=203052&r1=203051&r2=203052&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Wed Mar  5 19:10:46 2014
> @@ -2660,8 +2660,8 @@ llvm::Constant *CGObjCMac::GetOrEmitProt
>                                                    Values);
> 
>   if (Entry) {
> -    // Already created, fix the linkage and update the initializer.
> -    Entry->setLinkage(llvm::GlobalValue::PrivateLinkage);
> +    // Already created, update the initializer.
> +    assert(Entry->getLinkage() == llvm::GlobalValue::PrivateLinkage);
>     Entry->setInitializer(Init);
>   } else {
>     Entry =
> @@ -6242,10 +6242,9 @@ llvm::Constant *CGObjCNonFragileABIMac::
>     // reference or not. At module finalization we add the empty
>     // contents for protocols which were referenced but never defined.
>     Entry =
> -      new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ProtocolnfABITy, false,
> -                               llvm::GlobalValue::ExternalLinkage,
> -                               0,
> -                               "\01l_OBJC_PROTOCOL_$_" + PD->getName());
> +        new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ProtocolnfABITy,
> +                                 false, llvm::GlobalValue::WeakAnyLinkage, 0,
> +                                 "\01l_OBJC_PROTOCOL_$_" + PD->getName());

This is changing the linkage. Can you add comment why changing this will not change visibility of the symbol.
Also, please add a test for this change. 

- Fariborz

>     Entry->setSection("__DATA,__datacoal_nt,coalesced");
>   }
> 
> @@ -6358,8 +6357,8 @@ llvm::Constant *CGObjCNonFragileABIMac::
>                                                    Values);
> 
>   if (Entry) {
> -    // Already created, fix the linkage and update the initializer.
> -    Entry->setLinkage(llvm::GlobalValue::WeakAnyLinkage);
> +    // Already created, update the initializer.
> +    assert(Entry->getLinkage() == llvm::GlobalValue::WeakAnyLinkage);
>     Entry->setInitializer(Init);
>   } else {
>     Entry =
> 
> 
> _______________________________________________
> 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