llvm.org GIT mirror llvm / 44f9533
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 Dan Gohman 10 years ago
1 changed file(s) with 14 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
7070 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
7171 cl::ParseCommandLineOptions(argc, argv, "llvm extractor\n");
7272
73 // Use lazy loading, since we only care about selected global values.
7374 SMDiagnostic Err;
7475 std::auto_ptr M;
75 M.reset(ParseIRFile(InputFilename, Err, Context));
76 M.reset(getLazyIRFileModule(InputFilename, Err, Context));
7677
7778 if (M.get() == 0) {
7879 Err.Print(argv[0], errs());
101102 return 1;
102103 }
103104 GVs.push_back(GV);
105 }
106
107 // Materialize requisite global values.
108 for (size_t i = 0, e = GVs.size(); i != e; ++i) {
109 GlobalValue *GV = GVs[i];
110 if (GV->isMaterializable()) {
111 std::string ErrInfo;
112 if (GV->Materialize(&ErrInfo)) {
113 errs() << argv[0] << ": error reading input: " << ErrInfo << "\n";
114 return 1;
115 }
116 }
104117 }
105118
106119 // In addition to deleting all other functions, we also want to spiff it