summaryrefslogtreecommitdiffstats
path: root/llvm/lib/LTO
diff options
context:
space:
mode:
authorEugene Leviant <eleviant@accesssoftek.com>2019-07-03 14:14:52 +0000
committerEugene Leviant <eleviant@accesssoftek.com>2019-07-03 14:14:52 +0000
commit5cacb914758c7f436b47c8362100f10cef14bbc4 (patch)
tree7943a7bea3ec5bce87302e137c8ce0b4b643e2ac /llvm/lib/LTO
parent250015bacf7f255abcfb646fb8b6b56ce8be7e01 (diff)
downloadbcm5719-llvm-5cacb914758c7f436b47c8362100f10cef14bbc4.tar.gz
bcm5719-llvm-5cacb914758c7f436b47c8362100f10cef14bbc4.zip
[ThinLTO] Optimize writeonly globals out
Differential revision: https://reviews.llvm.org/D63444 llvm-svn: 365040
Diffstat (limited to 'llvm/lib/LTO')
-rw-r--r--llvm/lib/LTO/LTO.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index 4ed13701aa9..64506890956 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -192,8 +192,10 @@ void llvm::computeLTOCacheKey(
AddUnsigned(VI.isDSOLocal());
AddUsedCfiGlobal(VI.getGUID());
}
- if (auto *GVS = dyn_cast<GlobalVarSummary>(GS))
- AddUnsigned(GVS->isReadOnly());
+ if (auto *GVS = dyn_cast<GlobalVarSummary>(GS)) {
+ AddUnsigned(GVS->maybeReadOnly());
+ AddUnsigned(GVS->maybeWriteOnly());
+ }
if (auto *FS = dyn_cast<FunctionSummary>(GS)) {
for (auto &TT : FS->type_tests())
UsedTypeIds.insert(TT);
@@ -371,9 +373,9 @@ void llvm::thinLTOResolvePrevailingInIndex(
GUIDPreservedSymbols);
}
-static bool isWeakWriteableObject(GlobalValueSummary *GVS) {
+static bool isWeakObjectWithRWAccess(GlobalValueSummary *GVS) {
if (auto *VarSummary = dyn_cast<GlobalVarSummary>(GVS->getBaseObject()))
- return !VarSummary->isReadOnly() &&
+ return !VarSummary->maybeReadOnly() && !VarSummary->maybeWriteOnly() &&
(VarSummary->linkage() == GlobalValue::WeakODRLinkage ||
VarSummary->linkage() == GlobalValue::LinkOnceODRLinkage);
return false;
@@ -394,11 +396,12 @@ 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 modified somewhere in the
- // program because reads and writes will become inconsistent.
- !isWeakWriteableObject(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 both modified
+ // and read somewhere in the program because reads and writes
+ // will become inconsistent.
+ !isWeakObjectWithRWAccess(S.get()))
S->setLinkage(GlobalValue::InternalLinkage);
}
}
OpenPOWER on IntegriCloud