[cfe-commits] r124633 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp test/CodeGenCXX/visibility-hidden-extern-templates.cpp
John McCall
rjmccall at apple.com
Mon Jan 31 18:05:28 PST 2011
On Jan 31, 2011, at 4:37 PM, Rafael Espindola wrote:
> Author: rafael
> Date: Mon Jan 31 18:37:17 2011
> New Revision: 124633
>
> URL: http://llvm.org/viewvc/llvm-project?rev=124633&view=rev
> Log:
> Set visibility for available_externally globals. This is important for two reasons:
>
> * llvm-link would complains about mismatched visibility
> * If we produce a relocation with an available_externally, it is good to know that
> it is hidden.
>
> Modified:
> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> cfe/trunk/test/CodeGenCXX/visibility-hidden-extern-templates.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=124633&r1=124632&r2=124633&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Jan 31 18:37:17 2011
> @@ -174,8 +174,7 @@
>
> // Set visibility for definitions.
> NamedDecl::LinkageInfo LV = D->getLinkageAndVisibility();
> - if (LV.visibilityExplicit() || !GV->hasAvailableExternallyLinkage())
> - GV->setVisibility(GetLLVMVisibility(LV.visibility()));
> + GV->setVisibility(GetLLVMVisibility(LV.visibility()));
> }
Following GCC's lead, we should only restrict the visibility of external symbols (i.e. declarations and available_externally definitions) if they have an explicit visibility attribute. The idea is to allow users to build with -fvisibility=hidden and -fvisibility-inlines-hidden without needing to carefully tag all external declarations with default visibility. It leads to sub-optimal code, but it's absolutely required for compatibility.
John.
More information about the cfe-commits
mailing list