diff options
author | Reid Kleckner <rnk@google.com> | 2019-07-04 00:03:30 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2019-07-04 00:03:30 +0000 |
commit | f7e52fbdb5a7af8ea0808e98458b497125a5eca1 (patch) | |
tree | e7ff60e16fd3a7c1b066d2ff8d3f4152525205dc /llvm/lib/LTO/LTO.cpp | |
parent | ec4be576554c8be1c0a47cb78d411c3f42ba69e9 (diff) | |
download | llvm-f7e52fbdb5a7af8ea0808e98458b497125a5eca1.zip llvm-f7e52fbdb5a7af8ea0808e98458b497125a5eca1.tar.gz llvm-f7e52fbdb5a7af8ea0808e98458b497125a5eca1.tar.bz2 |
Revert [ThinLTO] Optimize writeonly globals out
This reverts r365040 (git commit 5cacb914758c7f436b47c8362100f10cef14bbc4)
Speculatively reverting, since this appears to have broken check-lld on
Linux. Partial analysis in https://crbug.com/981168.
llvm-svn: 365097
Diffstat (limited to 'llvm/lib/LTO/LTO.cpp')
-rw-r--r-- | llvm/lib/LTO/LTO.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index 6450689..4ed1370 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -192,10 +192,8 @@ void llvm::computeLTOCacheKey( AddUnsigned(VI.isDSOLocal()); AddUsedCfiGlobal(VI.getGUID()); } - if (auto *GVS = dyn_cast<GlobalVarSummary>(GS)) { - AddUnsigned(GVS->maybeReadOnly()); - AddUnsigned(GVS->maybeWriteOnly()); - } + if (auto *GVS = dyn_cast<GlobalVarSummary>(GS)) + AddUnsigned(GVS->isReadOnly()); if (auto *FS = dyn_cast<FunctionSummary>(GS)) { for (auto &TT : FS->type_tests()) UsedTypeIds.insert(TT); @@ -373,9 +371,9 @@ void llvm::thinLTOResolvePrevailingInIndex( GUIDPreservedSymbols); } -static bool isWeakObjectWithRWAccess(GlobalValueSummary *GVS) { +static bool isWeakWriteableObject(GlobalValueSummary *GVS) { if (auto *VarSummary = dyn_cast<GlobalVarSummary>(GVS->getBaseObject())) - return !VarSummary->maybeReadOnly() && !VarSummary->maybeWriteOnly() && + return !VarSummary->isReadOnly() && (VarSummary->linkage() == GlobalValue::WeakODRLinkage || VarSummary->linkage() == GlobalValue::LinkOnceODRLinkage); return false; @@ -396,12 +394,11 @@ static void thinLTOInternalizeAndPromoteGUID( // We can't internalize available_externally globals because this // can break function pointer equality. S->linkage() != GlobalValue::AvailableExternallyLinkage && - // Functions and read-only variables with linkonce_odr and - // weak_odr linkage can be internalized. We can't internalize - // linkonce_odr and weak_odr variables which are both modified - // and read somewhere in the program because reads and writes - // will become inconsistent. - !isWeakObjectWithRWAccess(S.get())) + // Functions and read-only variables with linkonce_odr and weak_odr + // linkage can be internalized. We can't internalize linkonce_odr + // and weak_odr variables which are modified somewhere in the + // program because reads and writes will become inconsistent. + !isWeakWriteableObject(S.get())) S->setLinkage(GlobalValue::InternalLinkage); } } |