[llvm] c45bb32 - [ThinLTO] Disable "Always import constants" due to compile time issues

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 30 10:13:03 PST 2020


Author: Teresa Johnson
Date: 2020-01-30T10:12:48-08:00
New Revision: c45bb326a681570b88dd315299c10c2242c143a9

URL: https://github.com/llvm/llvm-project/commit/c45bb326a681570b88dd315299c10c2242c143a9
DIFF: https://github.com/llvm/llvm-project/commit/c45bb326a681570b88dd315299c10c2242c143a9.diff

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

Summary:
Disable the always importing of constants introduced in D70404 by
default under a new internal option, since it is causing order of
magnitude compile time regressions during the thin link. Will continue
investigating why the regressions occur.

Reviewers: evgeny777, wmi

Subscribers: mehdi_amini, inglorion, hiraditya, steven_wu, dexonsmith, arphaman, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73724

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/ModuleSummaryIndex.cpp b/llvm/lib/IR/ModuleSummaryIndex.cpp
index 301df9a9d493..0a43e17c358c 100644
--- a/llvm/lib/IR/ModuleSummaryIndex.cpp
+++ b/llvm/lib/IR/ModuleSummaryIndex.cpp
@@ -31,6 +31,12 @@ static cl::opt<bool> PropagateAttrs("propagate-attrs", cl::init(true),
                                     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 @@ bool ModuleSummaryIndex::canImportGlobalVar(GlobalValueSummary *S,
     // 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());
 

diff  --git a/llvm/test/ThinLTO/X86/import-constant.ll b/llvm/test/ThinLTO/X86/import-constant.ll
index 6902359e4738..162bc3d28b7e 100644
--- a/llvm/test/ThinLTO/X86/import-constant.ll
+++ b/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 \

diff  --git a/llvm/test/ThinLTO/X86/referenced_by_constant.ll b/llvm/test/ThinLTO/X86/referenced_by_constant.ll
index 4c5e757907f4..e097cd5161f0 100644
--- a/llvm/test/ThinLTO/X86/referenced_by_constant.ll
+++ b/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()


        


More information about the llvm-commits mailing list