summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/FunctionImport.cpp
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2018-07-10 20:06:04 +0000
committerTeresa Johnson <tejohnson@google.com>2018-07-10 20:06:04 +0000
commitc0320ef47b16272464900df8a7c5a4cb3d1f20c9 (patch)
tree9f9ec44ab6b4567fc2d834ed8e686a0602d84cc7 /llvm/lib/Transforms/IPO/FunctionImport.cpp
parentfb302d0198e3bab1ee9b044a6d0b7f361f4d437c (diff)
downloadbcm5719-llvm-c0320ef47b16272464900df8a7c5a4cb3d1f20c9.tar.gz
bcm5719-llvm-c0320ef47b16272464900df8a7c5a4cb3d1f20c9.zip
[ThinLTO] Use std::map to get determistic imports files
Summary: I noticed that the .imports files emitted for distributed ThinLTO backends do not have consistent ordering. This is because StringMap iteration order is not guaranteed to be deterministic. Since we already have a std::map with this information, used when emitting the individual index files (ModuleToSummariesForIndex), use it for the imports files as well. This issue is likely causing some unnecessary rebuilds of the ThinLTO backends in our distributed build system as the imports files are inputs to those backends. Reviewers: pcc, steven_wu, mehdi_amini Subscribers: mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D48783 llvm-svn: 336721
Diffstat (limited to 'llvm/lib/Transforms/IPO/FunctionImport.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/FunctionImport.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp
index 38f4d981952..c2907937e70 100644
--- a/llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -707,15 +707,19 @@ void llvm::gatherImportedSummariesForModule(
}
/// Emit the files \p ModulePath will import from into \p OutputFilename.
-std::error_code
-llvm::EmitImportsFiles(StringRef ModulePath, StringRef OutputFilename,
- const FunctionImporter::ImportMapTy &ModuleImports) {
+std::error_code llvm::EmitImportsFiles(
+ StringRef ModulePath, StringRef OutputFilename,
+ const std::map<std::string, GVSummaryMapTy> &ModuleToSummariesForIndex) {
std::error_code EC;
raw_fd_ostream ImportsOS(OutputFilename, EC, sys::fs::OpenFlags::F_None);
if (EC)
return EC;
- for (auto &ILI : ModuleImports)
- ImportsOS << ILI.first() << "\n";
+ for (auto &ILI : ModuleToSummariesForIndex)
+ // The ModuleToSummariesForIndex map includes an entry for the current
+ // Module (needed for writing out the index files). We don't want to
+ // include it in the imports file, however, so filter it out.
+ if (ILI.first != ModulePath)
+ ImportsOS << ILI.first << "\n";
return std::error_code();
}
OpenPOWER on IntegriCloud