Using addPassesToEmitWholeFile is not a good idea here.

Use FunctionPassManager to do the job.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30160 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2006-09-07 21:41:11 +00:00
parent 76ed7b1cf5
commit 998051a221

View File

@ -282,11 +282,24 @@ static enum LTOStatus lto_optimize(Module *M, std::ostream &Out,
// Make sure everything is still good.
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.
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;
}