<div dir="auto"><div>I added details onto <a href="https://reviews.llvm.org/D87966">https://reviews.llvm.org/D87966</a>.<br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 9, 2020, 3:19 PM Jordan Rupprecht via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Author: Jordan Rupprecht<br>
Date: 2020-10-09T14:36:20-07:00<br>
New Revision: 9b5b3050237db3642ed7ab1bdb3ffa2202511b99<br>
<br>
URL: <a href="https://github.com/llvm/llvm-project/commit/9b5b3050237db3642ed7ab1bdb3ffa2202511b99" rel="noreferrer noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/9b5b3050237db3642ed7ab1bdb3ffa2202511b99</a><br>
DIFF: <a href="https://github.com/llvm/llvm-project/commit/9b5b3050237db3642ed7ab1bdb3ffa2202511b99.diff" rel="noreferrer noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/9b5b3050237db3642ed7ab1bdb3ffa2202511b99.diff</a><br>
<br>
LOG: Temporarily revert "[ThinLTO] Re-order modules for optimal multi-threaded processing"<br>
<br>
This reverts commit 6537004913f3009d896bc30856698e7d22199ba7. This is causing test failures internally, and while a few of the cases turned out to be bad user code (relying on a specific order of static initialization across translation units), some cases are less clear. Temporarily reverting for now, and Teresa is going to follow up with more details.<br>
<br>
Added: <br>
<br>
<br>
Modified: <br>
llvm/include/llvm/LTO/LTO.h<br>
llvm/lib/LTO/LTO.cpp<br>
llvm/lib/LTO/ThinLTOCodeGenerator.cpp<br>
<br>
Removed: <br>
<br>
<br>
<br>
################################################################################<br>
diff --git a/llvm/include/llvm/LTO/LTO.h b/llvm/include/llvm/LTO/LTO.h<br>
index a47f0cc0c3c0..93456c0ae7ae 100644<br>
--- a/llvm/include/llvm/LTO/LTO.h<br>
+++ b/llvm/include/llvm/LTO/LTO.h<br>
@@ -91,10 +91,6 @@ setupLLVMOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename,<br>
Expected<std::unique_ptr<ToolOutputFile>><br>
setupStatsFile(StringRef StatsFilename);<br>
<br>
-/// Produces a container ordering for optimal multi-threaded processing. Returns<br>
-/// ordered indices to elements in the input array.<br>
-std::vector<int> generateModulesOrdering(ArrayRef<BitcodeModule *> R);<br>
-<br>
class LTO;<br>
struct SymbolResolution;<br>
class ThinBackendProc;<br>
<br>
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp<br>
index 4fbb3ad5bb4a..6230216aa446 100644<br>
--- a/llvm/lib/LTO/LTO.cpp<br>
+++ b/llvm/lib/LTO/LTO.cpp<br>
@@ -1443,21 +1443,15 @@ Error LTO::runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache,<br>
auto &ModuleMap =<br>
ThinLTO.ModulesToCompile ? *ThinLTO.ModulesToCompile : ThinLTO.ModuleMap;<br>
<br>
- std::vector<BitcodeModule *> ModulesVec;<br>
- ModulesVec.reserve(ModuleMap.size());<br>
- for (auto &Mod : ModuleMap)<br>
- ModulesVec.push_back(&Mod.second);<br>
- std::vector<int> ModulesOrdering = generateModulesOrdering(ModulesVec);<br>
-<br>
// Tasks 0 through ParallelCodeGenParallelismLevel-1 are reserved for combined<br>
// module and parallel code generation partitions.<br>
- for (auto IndexCount : ModulesOrdering) {<br>
- auto &Mod = *(ModuleMap.begin() + IndexCount);<br>
- if (Error E = BackendProc->start(<br>
- RegularLTO.ParallelCodeGenParallelismLevel + IndexCount, Mod.second,<br>
- ImportLists[Mod.first], ExportLists[Mod.first],<br>
- ResolvedODR[Mod.first], ThinLTO.ModuleMap))<br>
+ unsigned Task = RegularLTO.ParallelCodeGenParallelismLevel;<br>
+ for (auto &Mod : ModuleMap) {<br>
+ if (Error E = BackendProc->start(Task, Mod.second, ImportLists[Mod.first],<br>
+ ExportLists[Mod.first],<br>
+ ResolvedODR[Mod.first], ThinLTO.ModuleMap))<br>
return E;<br>
+ ++Task;<br>
}<br>
<br>
return BackendProc->wait();<br>
@@ -1501,18 +1495,3 @@ lto::setupStatsFile(StringRef StatsFilename) {<br>
StatsFile->keep();<br>
return std::move(StatsFile);<br>
}<br>
-<br>
-// Compute the ordering we will process the inputs: the rough heuristic here<br>
-// is to sort them per size so that the largest module get schedule as soon as<br>
-// possible. This is purely a compile-time optimization.<br>
-std::vector<int> lto::generateModulesOrdering(ArrayRef<BitcodeModule *> R) {<br>
- std::vector<int> ModulesOrdering;<br>
- ModulesOrdering.resize(R.size());<br>
- std::iota(ModulesOrdering.begin(), ModulesOrdering.end(), 0);<br>
- llvm::sort(ModulesOrdering, [&](int LeftIndex, int RightIndex) {<br>
- auto LSize = R[LeftIndex]->getBuffer().size();<br>
- auto RSize = R[RightIndex]->getBuffer().size();<br>
- return LSize > RSize;<br>
- });<br>
- return ModulesOrdering;<br>
-}<br>
<br>
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp<br>
index 3f71487951c8..14dae848b362 100644<br>
--- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp<br>
+++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp<br>
@@ -1054,11 +1054,19 @@ void ThinLTOCodeGenerator::run() {<br>
ModuleToDefinedGVSummaries[ModuleIdentifier];<br>
}<br>
<br>
- std::vector<BitcodeModule *> ModulesVec;<br>
- ModulesVec.reserve(Modules.size());<br>
- for (auto &Mod : Modules)<br>
- ModulesVec.push_back(&Mod->getSingleBitcodeModule());<br>
- std::vector<int> ModulesOrdering = lto::generateModulesOrdering(ModulesVec);<br>
+ // Compute the ordering we will process the inputs: the rough heuristic here<br>
+ // is to sort them per size so that the largest module get schedule as soon as<br>
+ // possible. This is purely a compile-time optimization.<br>
+ std::vector<int> ModulesOrdering;<br>
+ ModulesOrdering.resize(Modules.size());<br>
+ std::iota(ModulesOrdering.begin(), ModulesOrdering.end(), 0);<br>
+ llvm::sort(ModulesOrdering, [&](int LeftIndex, int RightIndex) {<br>
+ auto LSize =<br>
+ Modules[LeftIndex]->getSingleBitcodeModule().getBuffer().size();<br>
+ auto RSize =<br>
+ Modules[RightIndex]->getSingleBitcodeModule().getBuffer().size();<br>
+ return LSize > RSize;<br>
+ });<br>
<br>
// Parallel optimizer + codegen<br>
{<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" rel="noreferrer">llvm-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div></div>