aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2021-01-27 10:43:51 -0800
committerFangrui Song <i@maskray.me>2021-01-27 10:43:51 -0800
commit54fb3ca96e261f7107cb1b5778c34cb0e0808be6 (patch)
tree8d6091e77327a0695d974602db03808433461666 /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
parent0b50fa99452f7f3077e62348b6cf6850a65930af (diff)
downloadllvm-54fb3ca96e261f7107cb1b5778c34cb0e0808be6.zip
llvm-54fb3ca96e261f7107cb1b5778c34cb0e0808be6.tar.gz
llvm-54fb3ca96e261f7107cb1b5778c34cb0e0808be6.tar.bz2
[ThinLTO] Add Visibility bits to GlobalValueSummary::GVFlags
Imported functions and variable get the visibility from the module supplying the definition. However, non-imported definitions do not get the visibility from (ELF) the most constraining visibility among all modules (Mach-O) the visibility of the prevailing definition. This patch * adds visibility bits to GlobalValueSummary::GVFlags * computes the result visibility and propagates it to all definitions Protected/hidden can imply dso_local which can enable some optimizations (this is stronger than GVFlags::DSOLocal because the implied dso_local can be leveraged for ELF -shared while default visibility dso_local has to be cleared for ELF -shared). Note: we don't have summaries for declarations, so for ELF if a declaration has the most constraining visibility, the result visibility may not be that one. Differential Revision: https://reviews.llvm.org/D92900
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 37ecb99..19e7e18 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -1044,7 +1044,8 @@ static uint64_t getEncodedFFlags(FunctionSummary::FFlags Flags) {
return RawFlags;
}
-// Decode the flags for GlobalValue in the summary
+// Decode the flags for GlobalValue in the summary. See getDecodedGVSummaryFlags
+// in BitcodeReader.cpp.
static uint64_t getEncodedGVSummaryFlags(GlobalValueSummary::GVFlags Flags) {
uint64_t RawFlags = 0;
@@ -1058,6 +1059,8 @@ static uint64_t getEncodedGVSummaryFlags(GlobalValueSummary::GVFlags Flags) {
// account here as well.
RawFlags = (RawFlags << 4) | Flags.Linkage; // 4 bits
+ RawFlags |= (Flags.Visibility << 8); // 2 bits
+
return RawFlags;
}