-int BugDriver::runPassesAsChild(const std::vector<const PassInfo*> &Passes) {
-
- std::ios::openmode io_mode = std::ios::out | std::ios::trunc |
- std::ios::binary;
- std::ofstream OutFile(ChildOutput.c_str(), io_mode);
- if (!OutFile.good()) {
- std::cerr << "Error opening bytecode file: " << ChildOutput << "\n";
- return 1;
- }
-
- PassManager PM;
- // Make sure that the appropriate target data is always used...
- PM.add(new TargetData("bugpoint", Program));
-
- for (unsigned i = 0, e = Passes.size(); i != e; ++i) {
- if (Passes[i]->getNormalCtor())
- PM.add(Passes[i]->getNormalCtor()());
- else
- std::cerr << "Cannot create pass yet: " << Passes[i]->getPassName()
- << "\n";
- }
- // Check that the module is well formed on completion of optimization
- PM.add(createVerifierPass());
-
- // Write bytecode out to disk as the last step...
- PM.add(new WriteBytecodePass(&OutFile));