[compiler-rt] [clang] [libc] [libcxx] [lld] [clang-tools-extra] [llvm] [flang] [ELF] --save-temps --lto-emit-asm: derive ELF/asm file names from bitcode file names (PR #78835)
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 23 09:44:22 PST 2024
================
@@ -352,32 +357,49 @@ std::vector<InputFile *> BitcodeCompiler::compile() {
pruneCache(config->thinLTOCacheDir, config->thinLTOCachePolicy, files);
if (!config->ltoObjPath.empty()) {
- saveBuffer(buf[0], config->ltoObjPath);
+ saveBuffer(buf[0].second, config->ltoObjPath);
for (unsigned i = 1; i != maxTasks; ++i)
- saveBuffer(buf[i], config->ltoObjPath + Twine(i));
- }
-
- if (config->saveTempsArgs.contains("prelink")) {
- if (!buf[0].empty())
- saveBuffer(buf[0], config->outputFile + ".lto.o");
- for (unsigned i = 1; i != maxTasks; ++i)
- saveBuffer(buf[i], config->outputFile + Twine(i) + ".lto.o");
- }
-
- if (config->ltoEmitAsm) {
- saveBuffer(buf[0], config->outputFile);
- for (unsigned i = 1; i != maxTasks; ++i)
- saveBuffer(buf[i], config->outputFile + Twine(i));
- return {};
+ saveBuffer(buf[i].second, config->ltoObjPath + Twine(i));
}
+ bool savePrelink = config->saveTempsArgs.contains("prelink");
std::vector<InputFile *> ret;
- for (unsigned i = 0; i != maxTasks; ++i)
- if (!buf[i].empty())
- ret.push_back(createObjFile(MemoryBufferRef(buf[i], "lto.tmp")));
+ const char *ext = config->ltoEmitAsm ? ".s" : ".o";
+ for (unsigned i = 0; i != maxTasks; ++i) {
+ StringRef bitcodeFilePath;
+ StringRef objBuf;
+ if (files[i]) {
----------------
MaskRay wrote:
Clarified the comment a bit
https://github.com/llvm/llvm-project/pull/78835
More information about the cfe-commits
mailing list