[llvm-commits] CVS: llvm/tools/lto/lto.cpp
Devang Patel
dpatel at apple.com
Thu Oct 26 13:46:37 PDT 2006
Changes in directory llvm/tools/lto:
lto.cpp updated: 1.24 -> 1.25
---
Log message:
Save temp. bc files when saveTemps flag is true. Use final output file
name supplied by linker to construct temp bc file names.
Remove tabs.
---
Diffs of the changes: (+24 -11)
lto.cpp | 35 ++++++++++++++++++++++++-----------
1 files changed, 24 insertions(+), 11 deletions(-)
Index: llvm/tools/lto/lto.cpp
diff -u llvm/tools/lto/lto.cpp:1.24 llvm/tools/lto/lto.cpp:1.25
--- llvm/tools/lto/lto.cpp:1.24 Wed Oct 25 13:10:07 2006
+++ llvm/tools/lto/lto.cpp Thu Oct 26 15:46:22 2006
@@ -129,7 +129,7 @@
/// set corresponding target triplet string.
void
LTO::getTargetTriple(const std::string &InputFilename,
- std::string &targetTriple)
+ std::string &targetTriple)
{
Module *m = getModule(InputFilename);
if (m)
@@ -142,8 +142,8 @@
/// Return LTO_READ_SUCCESS if there is no error.
enum LTOStatus
LTO::readLLVMObjectFile(const std::string &InputFilename,
- NameToSymbolMap &symbols,
- std::set<std::string> &references)
+ NameToSymbolMap &symbols,
+ std::set<std::string> &references)
{
Module *m = getModule(InputFilename);
if (!m)
@@ -316,7 +316,7 @@
CodeGenPasses->add(new TargetData(*Target->getTargetData()));
Target->addPassesToEmitFile(*CodeGenPasses, Out, TargetMachine::AssemblyFile,
- true);
+ true);
// Run our queue of passes all at once now, efficiently.
Passes.run(*M);
@@ -337,8 +337,10 @@
/// Return appropriate LTOStatus.
enum LTOStatus
LTO::optimizeModules(const std::string &OutputFilename,
- std::vector<const char *> &exportList,
- std::string &targetTriple)
+ std::vector<const char *> &exportList,
+ std::string &targetTriple,
+ bool saveTemps,
+ const char *FinalOutputFilename)
{
if (modules.empty())
return LTO_NO_WORK;
@@ -352,11 +354,15 @@
if (theLinker.LinkModules(bigOne, modules[i], errMsg))
return LTO_MODULE_MERGE_FAILURE;
-#if 0
- // Enable this when -save-temps is used
- std::ofstream Out("big.bc", io_mode);
- WriteBytecodeToFile(bigOne, Out, true);
-#endif
+ sys::Path FinalOutputPath(FinalOutputFilename);
+ FinalOutputPath.eraseSuffix();
+
+ if (saveTemps) {
+ std::string tempFileName(FinalOutputPath.c_str());
+ tempFileName += "0.bc";
+ std::ofstream Out(tempFileName.c_str(), io_mode);
+ WriteBytecodeToFile(bigOne, Out, true);
+ }
// Strip leading underscore because it was added to match names
// seen by linker.
@@ -404,6 +410,13 @@
return status;
}
+ if (saveTemps) {
+ std::string tempFileName(FinalOutputPath.c_str());
+ tempFileName += "1.bc";
+ std::ofstream Out(tempFileName.c_str(), io_mode);
+ WriteBytecodeToFile(bigOne, Out, true);
+ }
+
targetTriple = bigOne->getTargetTriple();
// Run GCC to assemble and link the program into native code.
More information about the llvm-commits
mailing list