llvm.org GIT mirror llvm / 38187d6
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31205 91177308-0d34-0410-b5e6-96231b3b80d8 Devang Patel 12 years ago
2 changed file(s) with 31 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
9090 NameToSymbolMap &,
9191 std::set &) = 0;
9292 virtual enum LTOStatus optimizeModules(const std::string &,
93 std::vector &,
94 std::string &) = 0;
93 std::vector &,
94 std::string &, bool,
95 const char *) = 0;
9596 virtual void getTargetTriple(const std::string &, std::string &) = 0;
9697 virtual void removeModule (const std::string &InputFilename) = 0;
9798 virtual ~LinkTimeOptimizer() = 0;
112113 std::set &references);
113114 enum LTOStatus optimizeModules(const std::string &OutputFilename,
114115 std::vector &exportList,
115 std::string &targetTriple);
116 void getTargetTriple(const std::string &InputFilename, std::string &targetTriple);
116 std::string &targetTriple, bool saveTemps,
117 const char *);
118 void getTargetTriple(const std::string &InputFilename,
119 std::string &targetTriple);
117120 void removeModule (const std::string &InputFilename);
118121
119122 // Constructors and destructors
128128 /// set corresponding target triplet string.
129129 void
130130 LTO::getTargetTriple(const std::string &InputFilename,
131 std::string &targetTriple)
131 std::string &targetTriple)
132132 {
133133 Module *m = getModule(InputFilename);
134134 if (m)
141141 /// Return LTO_READ_SUCCESS if there is no error.
142142 enum LTOStatus
143143 LTO::readLLVMObjectFile(const std::string &InputFilename,
144 NameToSymbolMap &symbols,
145 std::set &references)
144 NameToSymbolMap &symbols,
145 std::set &references)
146146 {
147147 Module *m = getModule(InputFilename);
148148 if (!m)
315315
316316 CodeGenPasses->add(new TargetData(*Target->getTargetData()));
317317 Target->addPassesToEmitFile(*CodeGenPasses, Out, TargetMachine::AssemblyFile,
318 true);
318 true);
319319
320320 // Run our queue of passes all at once now, efficiently.
321321 Passes.run(*M);
336336 /// Return appropriate LTOStatus.
337337 enum LTOStatus
338338 LTO::optimizeModules(const std::string &OutputFilename,
339 std::vector &exportList,
340 std::string &targetTriple)
339 std::vector &exportList,
340 std::string &targetTriple,
341 bool saveTemps,
342 const char *FinalOutputFilename)
341343 {
342344 if (modules.empty())
343345 return LTO_NO_WORK;
351353 if (theLinker.LinkModules(bigOne, modules[i], errMsg))
352354 return LTO_MODULE_MERGE_FAILURE;
353355
354 #if 0
355 // Enable this when -save-temps is used
356 std::ofstream Out("big.bc", io_mode);
357 WriteBytecodeToFile(bigOne, Out, true);
358 #endif
356 sys::Path FinalOutputPath(FinalOutputFilename);
357 FinalOutputPath.eraseSuffix();
358
359 if (saveTemps) {
360 std::string tempFileName(FinalOutputPath.c_str());
361 tempFileName += "0.bc";
362 std::ofstream Out(tempFileName.c_str(), io_mode);
363 WriteBytecodeToFile(bigOne, Out, true);
364 }
359365
360366 // Strip leading underscore because it was added to match names
361367 // seen by linker.
401407 tmpAsmFilePath.eraseFromDisk();
402408 TempDir.eraseFromDisk(true);
403409 return status;
410 }
411
412 if (saveTemps) {
413 std::string tempFileName(FinalOutputPath.c_str());
414 tempFileName += "1.bc";
415 std::ofstream Out(tempFileName.c_str(), io_mode);
416 WriteBytecodeToFile(bigOne, Out, true);
404417 }
405418
406419 targetTriple = bigOne->getTargetTriple();