[PATCH] D42713: LTO: Include dso-local bit in ThinLTO cache key.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 5 09:19:46 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL324253: LTO: Include dso-local bit in ThinLTO cache key. (authored by pcc, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D42713?vs=132238&id=132849#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42713

Files:
  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
  llvm/trunk/test/LTO/Resolution/X86/cache-dso-local.ll


Index: llvm/trunk/test/LTO/Resolution/X86/cache-dso-local.ll
===================================================================
--- llvm/trunk/test/LTO/Resolution/X86/cache-dso-local.ll
+++ llvm/trunk/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
+}
Index: llvm/trunk/lib/IR/ModuleSummaryIndex.cpp
===================================================================
--- llvm/trunk/lib/IR/ModuleSummaryIndex.cpp
+++ llvm/trunk/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(
Index: llvm/trunk/lib/LTO/LTO.cpp
===================================================================
--- llvm/trunk/lib/LTO/LTO.cpp
+++ llvm/trunk/lib/LTO/LTO.cpp
@@ -177,8 +177,10 @@
 
   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);
Index: llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp
+++ llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp
@@ -206,16 +206,8 @@
   // 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;
Index: llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
===================================================================
--- llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
+++ llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
@@ -158,6 +158,8 @@
   const GlobalValueSummaryMapTy::value_type *getRef() const {
     return RefAndFlag.getPointer();
   }
+
+  bool isDSOLocal() const;
 };
 
 template <> struct DenseMapInfo<ValueInfo> {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42713.132849.patch
Type: text/x-patch
Size: 3548 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180205/fa3e4437/attachment.bin>


More information about the llvm-commits mailing list