diff options
author | Bill Wendling <isanbard@gmail.com> | 2007-02-08 01:41:07 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2007-02-08 01:41:07 +0000 |
commit | 546d0fbd9718ea5ad422faaeffea939fe7312408 (patch) | |
tree | 180ff06f13f6c2b7bd71cce182457a6b0212b62f /tools/lto | |
parent | eb1ac3385096dd6f45a1548f3492f21648f55b4c (diff) | |
download | external_llvm-546d0fbd9718ea5ad422faaeffea939fe7312408.zip external_llvm-546d0fbd9718ea5ad422faaeffea939fe7312408.tar.gz external_llvm-546d0fbd9718ea5ad422faaeffea939fe7312408.tar.bz2 |
The new version of how to add passes to emit files. We explicitly call a
function to add the file writers between calls to add the passes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34035 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lto')
-rw-r--r-- | tools/lto/lto.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp index d7dec3f..816b1d8 100644 --- a/tools/lto/lto.cpp +++ b/tools/lto/lto.cpp @@ -27,6 +27,7 @@ #include "llvm/System/Signals.h" #include "llvm/Analysis/Passes.h" #include "llvm/Analysis/Verifier.h" +#include "llvm/CodeGen/FileWriters.h" #include "llvm/Target/SubtargetFeature.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" @@ -308,8 +309,31 @@ LTO::optimize(Module *M, std::ostream &Out, new FunctionPassManager(new ExistingModuleProvider(M)); CodeGenPasses->add(new TargetData(*Target->getTargetData())); - Target->addPassesToEmitFile(*CodeGenPasses, Out, TargetMachine::AssemblyFile, - true); + + MachineCodeEmitter *MCE = 0; + + switch (Target->addPassesToEmitFile(*CodeGenPasses, Out, + TargetMachine::AssemblyFile, true)) { + default: + assert(0 && "Invalid file model!"); + return LTO_UNKNOWN; + case FileModel::Error: + // FIXME: Error... + return LTO_UNKNOWN; + case FileModel::AsmFile: + break; + case FileModel::MachOFile: + MCE = AddMachOWriter(*CodeGenPasses, Out, *Target); + break; + case FileModel::ElfFile: + MCE = AddELFWriter(*CodeGenPasses, Out, *Target); + break; + } + + if (Target->addPassesToEmitFileFinish(*CodeGenPasses, MCE, true)) { + // FIXME: Error... + return LTO_UNKNOWN; + } // Run our queue of passes all at once now, efficiently. Passes.run(*M); |