diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-05-07 22:53:14 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-05-07 22:53:14 +0000 |
commit | 83533dd617a1d1ba0e43f60d161f3813d39a6fb0 (patch) | |
tree | fd1f4c05f4c58b948e9a2895c01224bb2f8d38db /lib/LTO | |
parent | 57b4c5d4730081ea4e8bd21cd747865411ad5cf3 (diff) | |
download | llvm-83533dd617a1d1ba0e43f60d161f3813d39a6fb0.tar.gz llvm-83533dd617a1d1ba0e43f60d161f3813d39a6fb0.tar.bz2 llvm-83533dd617a1d1ba0e43f60d161f3813d39a6fb0.tar.xz |
LTO: Check local linkage first
Since visibility is meaningless for symbols with local linkage, check
local linkage before visibility when setting symbol attributes.
When linkage is `internal` and the visibility is `hidden`, the exposed
attribute is now `LTO_SYMBOL_SCOPE_INTERNAL` instead of
`LTO_SYMBOL_SCOPE_HIDDEN`. Although the bitfield allows *both* to be
specified, the combination is nonsense anyway.
Given changes (in progress) to drop visibility when a symbol has local
linkage, this almost has no functionality change: it's mostly a cleanup
to clarify the logic.
The exception is when something has `appending` linkage. Before this
change, such symbols would be advertised as `LTO_SYMBOL_SCOPE_INTERNAL`;
now, they'll be given `LTO_SYMBOL_SCOPE_COMMON`.
Unfortunately this is really awkward to test. This only changes what we
advertise to linkers (before running LTO), not what the final object
looks like. In theory I could add `DEBUG` output to `llvm-lto` (and
test with "REQUIRES: asserts"), but follow-up commits to disallow
`internal hidden` simplify this anyway.
<rdar://problem/16141113>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208261 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/LTO')
-rw-r--r-- | lib/LTO/LTOModule.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/LTO/LTOModule.cpp b/lib/LTO/LTOModule.cpp index b687f29c65..93730ddb45 100644 --- a/lib/LTO/LTOModule.cpp +++ b/lib/LTO/LTOModule.cpp @@ -418,17 +418,17 @@ void LTOModule::addDefinedSymbol(const GlobalValue *def, bool isFunction) { attr |= LTO_SYMBOL_DEFINITION_REGULAR; // set scope part - if (def->hasHiddenVisibility()) + if (def->hasLocalLinkage()) + // Ignore visibility if linkage is local. + attr |= LTO_SYMBOL_SCOPE_INTERNAL; + else if (def->hasHiddenVisibility()) attr |= LTO_SYMBOL_SCOPE_HIDDEN; else if (def->hasProtectedVisibility()) attr |= LTO_SYMBOL_SCOPE_PROTECTED; else if (canBeHidden(def)) attr |= LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN; - else if (def->hasExternalLinkage() || def->hasWeakLinkage() || - def->hasLinkOnceLinkage() || def->hasCommonLinkage()) - attr |= LTO_SYMBOL_SCOPE_DEFAULT; else - attr |= LTO_SYMBOL_SCOPE_INTERNAL; + attr |= LTO_SYMBOL_SCOPE_DEFAULT; StringSet::value_type &entry = _defines.GetOrCreateValue(Buffer); entry.setValue(1); |