Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Unified Diff: llvm/tools/lto/LTOCodeGenerator.cpp

Issue 10808021: Change LLVM bitcode linking to use tree reduction to scale better (Closed)
Patch Set: Different version (change way gold-plugin uses interface, rather than hack the scoped pointers) Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « llvm/tools/lto/LTOCodeGenerator.h ('k') | llvm/tools/lto/lto.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: llvm/tools/lto/LTOCodeGenerator.cpp
===================================================================
--- a/llvm/tools/lto/LTOCodeGenerator.cpp
+++ b/llvm/tools/lto/LTOCodeGenerator.cpp
@@ -101,6 +101,54 @@
return ret;
}
+
+// @LOCALMOD-BEGIN
+bool LTOCodeGenerator::gatherModule(LTOModule* mod) {
robertm 2012/08/01 14:02:31 gather is no a very specific term. Maybe add a com
jvoung (off chromium) 2012/08/01 17:11:01 renamed to gatherModuleForLink(), but yeah, not su
+ _gatheredModules.push_back(mod);
+}
+
+bool LTOCodeGenerator::linkGatheredModulesAndDispose(std::string& errMsg) {
+ // We gather the asm undefs earlier than addModule() does,
robertm 2012/08/01 14:02:31 since the llvm folks did not seem to have commente
jvoung (off chromium) 2012/08/01 17:11:01 Added some comments. Hopefully this is a constant
+ // since we delete the modules earlier.
+ for (unsigned i = 0, ei = _gatheredModules.size(); i != ei; ++i) {
+ const std::vector<const char*> &undefs =
+ _gatheredModules[i]->getAsmUndefinedRefs();
+ for (int j = 0, ej = undefs.size(); j != ej; ++j) {
+ _asmUndefinedRefs[undefs[j]] = 1;
+ }
+ }
+
+ // Tree-reduce the mods, re-using the incoming mods as scratch
+ // intermediate results. Module i is linked with (i + stride), with i as
+ // the dest. Eventually the Module with the content of all other modules
+ // will be Module 0.
robertm 2012/08/01 14:02:31 not sure whether this adds all that much: After th
jvoung (off chromium) 2012/08/01 17:11:01 Done.
+ unsigned stride = 1;
+ unsigned len = _gatheredModules.size();
+ while (stride < len) {
robertm 2012/08/01 14:02:31 why not use a for loop here as well
jvoung (off chromium) 2012/08/01 17:11:01 Done.
+ for (unsigned i = 0; i + stride < len; i = i + (stride * 2)) {
+ if (Linker::LinkModules(_gatheredModules[i]->getLLVVMModule(),
+ _gatheredModules[i+stride]->getLLVVMModule(),
+ Linker::DestroySource, &errMsg)) {
+ errs() << "LinkModules " << i << " w/ " << i + stride << " failed...\n";
+ // We leak the memory in this case...
+ return true;
+ }
+ delete _gatheredModules[i+stride];
+ }
+ stride = stride * 2;
+ }
+
+ // Finally, link Node 0 with the Dest and delete Node 0.
+ if (_linker.LinkInModule(_gatheredModules[0]->getLLVVMModule(), &errMsg)) {
+ errs() << "LinkModules Dst w/ _gatheredModules[0] failed...\n";
+ return true;
+ }
+ delete _gatheredModules[0];
+
+ return false;
+}
+// @LOCALMOD-END
+
bool LTOCodeGenerator::setDebugInfo(lto_debug_model debug,
std::string& errMsg) {
switch (debug) {
« no previous file with comments | « llvm/tools/lto/LTOCodeGenerator.h ('k') | llvm/tools/lto/lto.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698