diff options
author | Devang Patel <dpatel@apple.com> | 2006-09-07 21:41:11 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2006-09-07 21:41:11 +0000 |
commit | 998051a2211a5f86b38941de0aca241b34895e1e (patch) | |
tree | 964ea5cd6ea05fd26430e884b500c539b554866b /tools/lto | |
parent | 76ed7b1cf5d3f70b28753d4f0f39a7a4cc956a64 (diff) | |
download | external_llvm-998051a2211a5f86b38941de0aca241b34895e1e.zip external_llvm-998051a2211a5f86b38941de0aca241b34895e1e.tar.gz external_llvm-998051a2211a5f86b38941de0aca241b34895e1e.tar.bz2 |
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
Diffstat (limited to 'tools/lto')
-rw-r--r-- | tools/lto/lto.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp index fedd4ae..05114b7 100644 --- a/tools/lto/lto.cpp +++ b/tools/lto/lto.cpp @@ -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; } |