[llvm] r324253 - LTO: Include dso-local bit in ThinLTO cache key.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 5 09:17:51 PST 2018
Author: pcc
Date: Mon Feb 5 09:17:51 2018
New Revision: 324253
URL: http://llvm.org/viewvc/llvm-project?rev=324253&view=rev
Log:
LTO: Include dso-local bit in ThinLTO cache key.
Differential Revision: https://reviews.llvm.org/D42713
Added:
llvm/trunk/test/LTO/Resolution/X86/cache-dso-local.ll
Modified:
llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
llvm/trunk/lib/IR/ModuleSummaryIndex.cpp
llvm/trunk/lib/LTO/LTO.cpp
llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp
Modified: llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h?rev=324253&r1=324252&r2=324253&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h (original)
+++ llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h Mon Feb 5 09:17:51 2018
@@ -158,6 +158,8 @@ struct ValueInfo {
const GlobalValueSummaryMapTy::value_type *getRef() const {
return RefAndFlag.getPointer();
}
+
+ bool isDSOLocal() const;
};
template <> struct DenseMapInfo<ValueInfo> {
Modified: llvm/trunk/lib/IR/ModuleSummaryIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/ModuleSummaryIndex.cpp?rev=324253&r1=324252&r2=324253&view=diff
==============================================================================
--- llvm/trunk/lib/IR/ModuleSummaryIndex.cpp (original)
+++ llvm/trunk/lib/IR/ModuleSummaryIndex.cpp Mon Feb 5 09:17:51 2018
@@ -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(
Modified: llvm/trunk/lib/LTO/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTO.cpp?rev=324253&r1=324252&r2=324253&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTO.cpp (original)
+++ llvm/trunk/lib/LTO/LTO.cpp Mon Feb 5 09:17:51 2018
@@ -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);
Modified: llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp?rev=324253&r1=324252&r2=324253&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp Mon Feb 5 09:17:51 2018
@@ -206,16 +206,8 @@ void FunctionImportGlobalProcessing::pro
// 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;
Added: llvm/trunk/test/LTO/Resolution/X86/cache-dso-local.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LTO/Resolution/X86/cache-dso-local.ll?rev=324253&view=auto
==============================================================================
--- llvm/trunk/test/LTO/Resolution/X86/cache-dso-local.ll (added)
+++ llvm/trunk/test/LTO/Resolution/X86/cache-dso-local.ll Mon Feb 5 09:17:51 2018
@@ -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
+}
More information about the llvm-commits
mailing list