[llvm] r285871 - [ThinLTO] Handle distributed backend case when doing renaming
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 2 18:07:16 PDT 2016
Author: tejohnson
Date: Wed Nov 2 20:07:16 2016
New Revision: 285871
URL: http://llvm.org/viewvc/llvm-project?rev=285871&view=rev
Log:
[ThinLTO] Handle distributed backend case when doing renaming
Summary:
The recent change I made to consult the summary when deciding whether to
rename (to handle inline asm) in r285513 broke the distributed build
case. In a distributed backend we will only have a portion of the
combined index, specifically for imported modules we only have the
summaries for any imported definitions. When renaming on import we were
asserting because no summary entry was found for a local reference being
linked in (def wasn't imported).
We only need to consult the summary for a renaming decision for the
exporting module. For imports, we would have prevented importing any
references to NoRename values already.
Reviewers: mehdi_amini
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D26250
Added:
llvm/trunk/test/ThinLTO/X86/Inputs/distributed_import.ll
llvm/trunk/test/ThinLTO/X86/distributed_import.ll
Modified:
llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp
Modified: llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp?rev=285871&r1=285870&r2=285871&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp Wed Nov 2 20:07:16 2016
@@ -67,10 +67,25 @@ bool FunctionImportGlobalProcessing::sho
if (GVar && GVar->isConstant() && GVar->hasGlobalUnnamedAddr())
return false;
- auto *Summary = ImportIndex.getGlobalValueSummary(SGV->getGUID());
- assert(Summary && "Missing summary for global value");
- if (Summary->noRename())
- return false;
+ // If we are exporting, we need to see whether this value is marked
+ // as NoRename in the summary. If we are importing, we may not have
+ // a summary in the distributed backend case (only summaries for values
+ // importes as defs, not references, are included in the index passed
+ // to the distributed backends).
+ auto Summaries = ImportIndex.findGlobalValueSummaryList(SGV->getGUID());
+ if (Summaries == ImportIndex.end())
+ // Assert that this is an import - we should always have access to the
+ // summary when exporting.
+ assert(isPerformingImport() &&
+ "Missing summary for global value when exporting");
+ else {
+ assert(Summaries->second.size() == 1 && "Local has more than one summary");
+ if (Summaries->second.front()->noRename()) {
+ assert((isModuleExporting() || !GlobalsToImport->count(SGV)) &&
+ "Imported a non-renamable local value");
+ return false;
+ }
+ }
// Eventually we only need to promote functions in the exporting module that
// are referenced by a potentially exported function (i.e. one that is in the
Added: llvm/trunk/test/ThinLTO/X86/Inputs/distributed_import.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ThinLTO/X86/Inputs/distributed_import.ll?rev=285871&view=auto
==============================================================================
--- llvm/trunk/test/ThinLTO/X86/Inputs/distributed_import.ll (added)
+++ llvm/trunk/test/ThinLTO/X86/Inputs/distributed_import.ll Wed Nov 2 20:07:16 2016
@@ -0,0 +1,6 @@
+ at G = internal global i32 7
+define i32 @g() {
+entry:
+ %0 = load i32, i32* @G
+ ret i32 %0
+}
Added: llvm/trunk/test/ThinLTO/X86/distributed_import.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ThinLTO/X86/distributed_import.ll?rev=285871&view=auto
==============================================================================
--- llvm/trunk/test/ThinLTO/X86/distributed_import.ll (added)
+++ llvm/trunk/test/ThinLTO/X86/distributed_import.ll Wed Nov 2 20:07:16 2016
@@ -0,0 +1,20 @@
+; RUN: opt -module-summary %s -o %t1.bc
+; RUN: opt -module-summary %p/Inputs/distributed_import.ll -o %t2.bc
+
+; RUN: llvm-lto2 %t1.bc %t2.bc -o %t.o -save-temps \
+; RUN: -thinlto-distributed-indexes \
+; RUN: -r=%t1.bc,g, \
+; RUN: -r=%t1.bc,f,px \
+; RUN: -r=%t2.bc,g,px
+; RUN: opt -function-import -summary-file %t1.bc.thinlto.bc %t1.bc -o %t1.out
+; RUN: opt -function-import -summary-file %t2.bc.thinlto.bc %t2.bc -o %t2.out
+; RUN: llvm-dis -o - %t2.out | FileCheck %s
+; CHECK: @G.llvm.0
+
+declare i32 @g(...)
+
+define void @f() {
+entry:
+ call i32 (...) @g()
+ ret void
+}
More information about the llvm-commits
mailing list