Using addPassesToEmitWholeFile is not a good idea here.

Use FunctionPassManager to do the job.

llvm-svn: 30160
This commit is contained in:
Devang Patel 2006-09-07 21:41:11 +00:00
parent ce2c1eb154
commit 5606dd8a45
1 changed files with 14 additions and 1 deletions

View File

@ -282,11 +282,24 @@ static enum LTOStatus lto_optimize(Module *M, std::ostream &Out,
// Make sure everything is still good. // Make sure everything is still good.
Passes.add(createVerifierPass()); Passes.add(createVerifierPass());
Target.addPassesToEmitWholeFile(Passes, Out, TargetMachine::AssemblyFile, true); FunctionPassManager *CodeGenPasses =
new FunctionPassManager(new ExistingModuleProvider(M));
CodeGenPasses->add(new TargetData(*Target.getTargetData()));
Target.addPassesToEmitFile(*CodeGenPasses, Out, TargetMachine::AssemblyFile,
true);
// Run our queue of passes all at once now, efficiently. // Run our queue of passes all at once now, efficiently.
Passes.run(*M); Passes.run(*M);
// Run the code generator, if present.
CodeGenPasses->doInitialization();
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) {
if (!I->isExternal())
CodeGenPasses->run(*I);
}
CodeGenPasses->doFinalization();
return LTO_OPT_SUCCESS; return LTO_OPT_SUCCESS;
} }