[PATCH] D73724: [ThinLTO] Disable "Always import constants" due to compile time issues

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 30 10:20:31 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGc45bb326a681: [ThinLTO] Disable "Always import constants" due to compile time issues (authored by tejohnson).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73724/new/

https://reviews.llvm.org/D73724

Files:
  llvm/lib/IR/ModuleSummaryIndex.cpp
  llvm/test/ThinLTO/X86/import-constant.ll
  llvm/test/ThinLTO/X86/referenced_by_constant.ll


Index: llvm/test/ThinLTO/X86/referenced_by_constant.ll
===================================================================
--- llvm/test/ThinLTO/X86/referenced_by_constant.ll
+++ llvm/test/ThinLTO/X86/referenced_by_constant.ll
@@ -7,14 +7,14 @@
 ; referenced constant objects. There is stll a room for improvement: we
 ; can make a local copy of someglobal and someglobal2 because they are both
 ; 'unnamed_addr' constants. This should eventually be done as well.
-; RUN: llvm-lto -thinlto-action=import %t.bc -thinlto-index=%t3.bc -o - | llvm-dis -o -   | FileCheck %s --check-prefix=IMPORT
+; RUN: llvm-lto -thinlto-action=import -import-constants-with-refs %t.bc -thinlto-index=%t3.bc -o - | llvm-dis -o -   | FileCheck %s --check-prefix=IMPORT
 ; IMPORT: @someglobal.llvm.0 = available_externally hidden unnamed_addr constant i8* bitcast (void ()* @referencedbyglobal to i8*)
 ; IMPORT: @someglobal2.llvm.0 = available_externally hidden unnamed_addr constant i8* bitcast (void ()* @localreferencedbyglobal.llvm.0 to i8*)
 ; IMPORT: define available_externally void @bar()
 
 ; Check the export side: we currently only export bar(), which causes
 ; @someglobal and @someglobal2 to be promoted (see above).
-; RUN: llvm-lto -thinlto-action=promote %t2.bc -thinlto-index=%t3.bc -o - | llvm-dis -o -   | FileCheck %s --check-prefix=EXPORT
+; RUN: llvm-lto -thinlto-action=promote -import-constants-with-refs %t2.bc -thinlto-index=%t3.bc -o - | llvm-dis -o -   | FileCheck %s --check-prefix=EXPORT
 ; EXPORT: @someglobal.llvm.0 = hidden unnamed_addr constant
 ; EXPORT: @someglobal2.llvm.0 = hidden unnamed_addr constant
 ; EXPORT: define void @referencedbyglobal()
Index: llvm/test/ThinLTO/X86/import-constant.ll
===================================================================
--- llvm/test/ThinLTO/X86/import-constant.ll
+++ llvm/test/ThinLTO/X86/import-constant.ll
@@ -4,6 +4,7 @@
 ; RUN: opt -thinlto-bc %s -o %t1.bc
 ; RUN: opt -thinlto-bc %p/Inputs/import-constant.ll -o %t2.bc
 ; RUN: llvm-lto2 run -save-temps %t1.bc %t2.bc -o %t-out \
+; RUN:    -import-constants-with-refs \
 ; RUN:    -r=%t1.bc,main,plx \
 ; RUN:    -r=%t1.bc,_Z6getObjv,l \
 ; RUN:    -r=%t2.bc,_Z6getObjv,pl \
Index: llvm/lib/IR/ModuleSummaryIndex.cpp
===================================================================
--- llvm/lib/IR/ModuleSummaryIndex.cpp
+++ llvm/lib/IR/ModuleSummaryIndex.cpp
@@ -31,6 +31,12 @@
                                     cl::Hidden,
                                     cl::desc("Propagate attributes in index"));
 
+// FIXME: Enable again when thin link compile time regressions understood and
+// addressed
+static cl::opt<bool> ImportConstantsWithRefs(
+    "import-constants-with-refs", cl::init(false), cl::Hidden,
+    cl::desc("Import constant global variables with references"));
+
 FunctionSummary FunctionSummary::ExternalNode =
     FunctionSummary::makeDummyFunctionSummary({});
 
@@ -221,8 +227,8 @@
     // c) Link error (external declaration with internal definition).
     // However we do not promote objects referenced by writeonly GV
     // initializer by means of converting it to 'zeroinitializer'
-    return !GVS->isConstant() && !isReadOnly(GVS) && !isWriteOnly(GVS) &&
-           GVS->refs().size();
+    return !(ImportConstantsWithRefs && GVS->isConstant()) &&
+           !isReadOnly(GVS) && !isWriteOnly(GVS) && GVS->refs().size();
   };
   auto *GVS = cast<GlobalVarSummary>(S->getBaseObject());
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73724.241502.patch
Type: text/x-patch
Size: 3446 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200130/e3d5ba5c/attachment.bin>


More information about the llvm-commits mailing list