diff options
| author | Sean Silva <chisophugis@gmail.com> | 2016-03-09 20:01:08 +0000 |
|---|---|---|
| committer | Sean Silva <chisophugis@gmail.com> | 2016-03-09 20:01:08 +0000 |
| commit | 35ef3d95eb76a7b2272a1eb1ef8d060a2ddfc2be (patch) | |
| tree | d32a63e4c55c68636eccae1d2d7c3a19f4383846 /lld/ELF/SymbolTable.cpp | |
| parent | 669aaccb8940ffefae74cc03aca373e917147657 (diff) | |
| download | bcm5719-llvm-35ef3d95eb76a7b2272a1eb1ef8d060a2ddfc2be.tar.gz bcm5719-llvm-35ef3d95eb76a7b2272a1eb1ef8d060a2ddfc2be.zip | |
[lto] Add beginning of -save-temps option.
Summary:
This is useful for debugging issues with LTO.
The option follows the analogous option in ld64 and the gold plugin (per
Rafael's suggestion).
For starters, this only dumps the combined bitcode file.
In a future patch I will add dumping for the .o file.
The naming of the output follows ld64's convention which is slightly more
consistent IMO (consistent `.lto.<extension>` for all the files).
Reviewers: rafael, ruiu
Subscribers: joker.eph, Bigcheese, llvm-commits
Differential Revision: http://reviews.llvm.org/D18006
llvm-svn: 263055
Diffstat (limited to 'lld/ELF/SymbolTable.cpp')
| -rw-r--r-- | lld/ELF/SymbolTable.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index 8e8d77f117f..0f3f02b870d 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -147,6 +147,13 @@ static void addBitcodeFile(IRMover &Mover, BitcodeFile &F, Mover.move(std::move(M), Keep, [](GlobalValue &, IRMover::ValueAdder) {}); } +static void saveBCFile(std::string Path, Module &M) { + std::error_code EC; + raw_fd_ostream OS(Path, EC, sys::fs::OpenFlags::F_None); + check(EC); + WriteBitcodeToFile(&M, OS, /* ShouldPreserveUseListOrder */ true); +} + // Merge all the bitcode files we have seen, codegen the result and return // the resulting ObjectFile. template <class ELFT> @@ -156,6 +163,8 @@ ObjectFile<ELFT> *SymbolTable<ELFT>::createCombinedLtoObject() { IRMover Mover(Combined); for (const std::unique_ptr<BitcodeFile> &F : BitcodeFiles) addBitcodeFile(Mover, *F, Context); + if (Config->SaveTemps) + saveBCFile(Config->OutputFile.str() + ".lto.bc", Combined); std::unique_ptr<InputFile> F = codegen(Combined); ObjectFiles.emplace_back(cast<ObjectFile<ELFT>>(F.release())); return &*ObjectFiles.back(); |

