summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-cat/llvm-cat.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2017-04-17 17:51:36 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2017-04-17 17:51:36 +0000
commita0f371a106f003bb6575bc8f19ab82121d8bc1c4 (patch)
tree7367ce107322299d35983d4e5a7fd4c98dff7709 /llvm/tools/llvm-cat/llvm-cat.cpp
parentdc77b2e960b6b6d4622c89ee8d324848ac6a0609 (diff)
downloadbcm5719-llvm-a0f371a106f003bb6575bc8f19ab82121d8bc1c4.tar.gz
bcm5719-llvm-a0f371a106f003bb6575bc8f19ab82121d8bc1c4.zip
Bitcode: Add a string table to the bitcode format.
Add a top-level STRTAB block containing a string table blob, and start storing strings for module codes FUNCTION, GLOBALVAR, ALIAS, IFUNC and COMDAT in the string table. This change allows us to share names between globals and comdats as well as between modules, and improves the efficiency of loading bitcode files by no longer using a bit encoding for symbol names. Once we start writing the irsymtab to the bitcode file we will also be able to share strings between it and the module. On my machine, link time for Chromium for Linux with ThinLTO decreases by about 7% for no-op incremental builds or about 1% for full builds. Total bitcode file size decreases by about 3%. As discussed on llvm-dev: http://lists.llvm.org/pipermail/llvm-dev/2017-April/111732.html Differential Revision: https://reviews.llvm.org/D31838 llvm-svn: 300464
Diffstat (limited to 'llvm/tools/llvm-cat/llvm-cat.cpp')
-rw-r--r--llvm/tools/llvm-cat/llvm-cat.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/tools/llvm-cat/llvm-cat.cpp b/llvm/tools/llvm-cat/llvm-cat.cpp
index 4d62099094b..8a21a6d07ca 100644
--- a/llvm/tools/llvm-cat/llvm-cat.cpp
+++ b/llvm/tools/llvm-cat/llvm-cat.cpp
@@ -44,11 +44,16 @@ int main(int argc, char **argv) {
std::unique_ptr<MemoryBuffer> MB = ExitOnErr(
errorOrToExpected(MemoryBuffer::getFileOrSTDIN(InputFilename)));
std::vector<BitcodeModule> Mods = ExitOnErr(getBitcodeModuleList(*MB));
- for (auto &BitcodeMod : Mods)
+ for (auto &BitcodeMod : Mods) {
Buffer.insert(Buffer.end(), BitcodeMod.getBuffer().begin(),
BitcodeMod.getBuffer().end());
+ Writer.copyStrtab(BitcodeMod.getStrtab());
+ }
}
} else {
+ // The string table does not own strings added to it, some of which are
+ // owned by the modules; keep them alive until we write the string table.
+ std::vector<std::unique_ptr<Module>> OwnedMods;
for (const auto &InputFilename : InputFilenames) {
SMDiagnostic Err;
std::unique_ptr<Module> M = parseIRFile(InputFilename, Err, Context);
@@ -57,7 +62,9 @@ int main(int argc, char **argv) {
return 1;
}
Writer.writeModule(M.get());
+ OwnedMods.push_back(std::move(M));
}
+ Writer.writeStrtab();
}
std::error_code EC;
OpenPOWER on IntegriCloud