summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2018-02-05 17:17:51 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2018-02-05 17:17:51 +0000
commitb4edfb9af93c39f448ac649edff3be4d17263297 (patch)
treec25cddc1a2e1c106dd8d263626456c9b89dcd6c3 /llvm
parent2329fcd293e138924d96d4b2643dab7f3d60c3f3 (diff)
downloadbcm5719-llvm-b4edfb9af93c39f448ac649edff3be4d17263297.tar.gz
bcm5719-llvm-b4edfb9af93c39f448ac649edff3be4d17263297.zip
LTO: Include dso-local bit in ThinLTO cache key.
Differential Revision: https://reviews.llvm.org/D42713 llvm-svn: 324253
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/IR/ModuleSummaryIndex.h2
-rw-r--r--llvm/lib/IR/ModuleSummaryIndex.cpp9
-rw-r--r--llvm/lib/LTO/LTO.cpp4
-rw-r--r--llvm/lib/Transforms/Utils/FunctionImportUtils.cpp12
-rw-r--r--llvm/test/LTO/Resolution/X86/cache-dso-local.ll22
5 files changed, 38 insertions, 11 deletions
diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index a48571a8c5e..d75986b37fb 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -158,6 +158,8 @@ struct ValueInfo {
const GlobalValueSummaryMapTy::value_type *getRef() const {
return RefAndFlag.getPointer();
}
+
+ bool isDSOLocal() const;
};
template <> struct DenseMapInfo<ValueInfo> {
diff --git a/llvm/lib/IR/ModuleSummaryIndex.cpp b/llvm/lib/IR/ModuleSummaryIndex.cpp
index ce4c8cc3c80..ce74c00766f 100644
--- a/llvm/lib/IR/ModuleSummaryIndex.cpp
+++ b/llvm/lib/IR/ModuleSummaryIndex.cpp
@@ -17,6 +17,15 @@
#include "llvm/Support/Path.h"
using namespace llvm;
+bool ValueInfo::isDSOLocal() const {
+ // Need to check all summaries are local in case of hash collisions.
+ return getSummaryList().size() &&
+ llvm::all_of(getSummaryList(),
+ [](const std::unique_ptr<GlobalValueSummary> &Summary) {
+ return Summary->isDSOLocal();
+ });
+}
+
// Collect for the given module the list of function it defines
// (GUID -> Summary).
void ModuleSummaryIndex::collectDefinedFunctionsForModule(
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index a5bdeac4d9d..02d1c7506b3 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -177,8 +177,10 @@ static void computeCacheKey(
auto AddUsedThings = [&](GlobalValueSummary *GS) {
if (!GS) return;
- for (const ValueInfo &VI : GS->refs())
+ for (const ValueInfo &VI : GS->refs()) {
+ AddUnsigned(VI.isDSOLocal());
AddUsedCfiGlobal(VI.getGUID());
+ }
if (auto *FS = dyn_cast<FunctionSummary>(GS)) {
for (auto &TT : FS->type_tests())
UsedTypeIds.insert(TT);
diff --git a/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp b/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
index 6b5f593073b..bf6cce96f49 100644
--- a/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
+++ b/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
@@ -206,16 +206,8 @@ void FunctionImportGlobalProcessing::processGlobalForThinLTO(GlobalValue &GV) {
// definition.
if (GV.hasName()) {
ValueInfo VI = ImportIndex.getValueInfo(GV.getGUID());
- if (VI) {
- // Need to check all summaries are local in case of hash collisions.
- bool IsLocal = VI.getSummaryList().size() &&
- llvm::all_of(VI.getSummaryList(),
- [](const std::unique_ptr<GlobalValueSummary> &Summary) {
- return Summary->isDSOLocal();
- });
- if (IsLocal)
- GV.setDSOLocal(true);
- }
+ if (VI && VI.isDSOLocal())
+ GV.setDSOLocal(true);
}
bool DoPromote = false;
diff --git a/llvm/test/LTO/Resolution/X86/cache-dso-local.ll b/llvm/test/LTO/Resolution/X86/cache-dso-local.ll
new file mode 100644
index 00000000000..5e5b94cc94b
--- /dev/null
+++ b/llvm/test/LTO/Resolution/X86/cache-dso-local.ll
@@ -0,0 +1,22 @@
+; Tests whether the cache is sensitive to the dso-local bit on referenced
+; globals.
+; RUN: rm -rf %t.cache
+; RUN: opt -module-hash -module-summary -o %t.bc %s
+; RUN: llvm-lto2 run -o %t.o %t.bc -cache-dir %t.cache \
+; RUN: -r %t.bc,foo,px \
+; RUN: -r %t.bc,bar,px
+; RUN: llvm-lto2 run -o %t.o %t.bc -cache-dir %t.cache \
+; RUN: -r %t.bc,foo,plx \
+; RUN: -r %t.bc,bar,px
+; RUN: ls %t.cache | count 2
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define weak void @foo() {
+ ret void
+}
+
+define weak void()* @bar() {
+ ret void()* @foo
+}
OpenPOWER on IntegriCloud