diff options
author | Dan Gohman <gohman@apple.com> | 2010-08-25 23:33:07 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-08-25 23:33:07 +0000 |
commit | 44f95335dd57dd76843d7e84537582ec08107508 (patch) | |
tree | b5c9758c25bc30ef1624290d6536047048e28bbf /tools/llvm-extract | |
parent | 1a68958d3d9233bfe512de8ea7137067ef660345 (diff) |
Convert llvm-extract to use lazy loading. This makes it substantially
faster on large modules.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112110 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-extract')
-rw-r--r-- | tools/llvm-extract/llvm-extract.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tools/llvm-extract/llvm-extract.cpp b/tools/llvm-extract/llvm-extract.cpp index 190ab2e6b1..b5c0bcf4f0 100644 --- a/tools/llvm-extract/llvm-extract.cpp +++ b/tools/llvm-extract/llvm-extract.cpp @@ -71,9 +71,10 @@ int main(int argc, char **argv) { llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. cl::ParseCommandLineOptions(argc, argv, "llvm extractor\n"); + // Use lazy loading, since we only care about selected global values. SMDiagnostic Err; std::auto_ptr<Module> M; - M.reset(ParseIRFile(InputFilename, Err, Context)); + M.reset(getLazyIRFileModule(InputFilename, Err, Context)); if (M.get() == 0) { Err.Print(argv[0], errs()); @@ -104,6 +105,18 @@ int main(int argc, char **argv) { GVs.push_back(GV); } + // Materialize requisite global values. + for (size_t i = 0, e = GVs.size(); i != e; ++i) { + GlobalValue *GV = GVs[i]; + if (GV->isMaterializable()) { + std::string ErrInfo; + if (GV->Materialize(&ErrInfo)) { + errs() << argv[0] << ": error reading input: " << ErrInfo << "\n"; + return 1; + } + } + } + // In addition to deleting all other functions, we also want to spiff it // up a little bit. Do this now. PassManager Passes; |