[clang] [clang codegen][regression] Add dso_local/hidden/etc. markings to VTT definitions and declarations (PR #72452)

via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 18 12:37:22 PST 2023


bd1976bris wrote:

> I mean, looking at the code, as far as I can tell, we always call GetAddrOfVTT immediately before EmitVTTDefinition, so setGVProperties() has already run, so running it again shouldn't do anything... unless somehow EmitVTTDefinition is overwriting the visibility, or setGVProperties() behaves differently for declarations vs. definitions. If something like that is happening, I'd like to explicitly document it.

Thanks for clarifying. Luckily a full understanding of the VTT emission isn't isn't needed to answer your question :)

When the visibility is applied via visibility attributes there is no difference for a definition or a declaration. However, for the visibility from -fvisibility=<visibility>, the visibility is applied only to definitions and not to declarations. My understanding is that this is by design - so that system headers do not have to be marked with explicit visibility annotations.

You can see this in the code in setGlobalVisibility():

```
  if (LV.isVisibilityExplicit() || getLangOpts().SetVisibilityForExternDecls ||
      !GV->isDeclarationForLinker())
    GV->setVisibility(GetLLVMVisibility(LV.getVisibility()));
```

https://github.com/llvm/llvm-project/pull/72452


More information about the cfe-commits mailing list