diff options
author | Tobias Edler von Koch <tobias@codeaurora.org> | 2015-11-20 00:13:05 +0000 |
---|---|---|
committer | Tobias Edler von Koch <tobias@codeaurora.org> | 2015-11-20 00:13:05 +0000 |
commit | cbf870d3b1118dfe60236acbcc31878e14df72d6 (patch) | |
tree | b7e564483a6d81126891d907dd2478d5bc27930d /tools/llvm-lto | |
parent | 5b01c014963f0b4f79aeda48eebad3cc587dba13 (diff) |
[LTO] Add options to llvm-lto to select output format and dump merged module
This introduces two new options:
- "llvm-lto -save-merged-module -o outfile" dumps the LTO Module to
outfile.merged.bc prior to CodeGen and after LTO optimizations have been run.
- "llvm-lto -filetype=asm -o outfile" makes llvm-lto emit assembly instead of
object code in outfile.
Both are intended for use in lit tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253624 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-lto')
-rw-r--r-- | tools/llvm-lto/llvm-lto.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/llvm-lto/llvm-lto.cpp b/tools/llvm-lto/llvm-lto.cpp index cdf91f9e377..aac82d31a36 100644 --- a/tools/llvm-lto/llvm-lto.cpp +++ b/tools/llvm-lto/llvm-lto.cpp @@ -64,6 +64,10 @@ static cl::opt<bool> ThinLTO("thinlto", cl::init(false), cl::desc("Only write combined global index for ThinLTO backends")); +static cl::opt<bool> +SaveModuleFile("save-merged-module", cl::init(false), + cl::desc("Write merged LTO module to file before CodeGen")); + static cl::list<std::string> InputFilenames(cl::Positional, cl::OneOrMore, cl::desc("<input bitcode files>")); @@ -343,6 +347,9 @@ int main(int argc, char **argv) { if (!attrs.empty()) CodeGen.setAttr(attrs.c_str()); + if (FileType.getNumOccurrences()) + CodeGen.setFileType(FileType); + if (!OutputFilename.empty()) { if (!CodeGen.optimize(DisableVerify, DisableInline, DisableGVNLoadPRE, DisableLTOVectorization)) { @@ -351,6 +358,17 @@ int main(int argc, char **argv) { return 1; } + if (SaveModuleFile) { + std::string ModuleFilename = OutputFilename; + ModuleFilename += ".merged.bc"; + std::string ErrMsg; + + if (!CodeGen.writeMergedModules(ModuleFilename.c_str())) { + errs() << argv[0] << ": writing merged module failed.\n"; + return 1; + } + } + std::list<tool_output_file> OSs; std::vector<raw_pwrite_stream *> OSPtrs; for (unsigned I = 0; I != Parallelism; ++I) { @@ -381,6 +399,11 @@ int main(int argc, char **argv) { return 1; } + if (SaveModuleFile) { + errs() << argv[0] << ": -save-merged-module must be specified with -o\n"; + return 1; + } + const char *OutputName = nullptr; if (!CodeGen.compile_to_file(&OutputName, DisableVerify, DisableInline, DisableGVNLoadPRE, DisableLTOVectorization)) { |