[PATCH] D154191: [LTO] Replace llvm::writeFileAtomically with llvm::writeToOutput API.
Steven Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 30 09:32:15 PDT 2023
steven_wu accepted this revision.
steven_wu added a comment.
This revision is now accepted and ready to land.
This is generally fine. I don't see any error that should fall into `consumeError` condition that won't just error out anyway (like out of disk space, etc.) and I don't see those are special cased for code before switching to `writeFileAtomically`.
================
Comment at: llvm/lib/LTO/ThinLTOCodeGenerator.cpp:419
- // Write to a temporary to avoid race condition
- SmallString<128> TempFilename;
- SmallString<128> CachePath(EntryPath);
- llvm::sys::path::remove_filename(CachePath);
- sys::path::append(TempFilename, CachePath, "Thin-%%%%%%.tmp.o");
-
- if (auto Err = handleErrors(
- llvm::writeFileAtomically(TempFilename, EntryPath,
- OutputBuffer.getBuffer()),
- [](const llvm::AtomicFileWriteError &E) {
- std::string ErrorMsgBuffer;
- llvm::raw_string_ostream S(ErrorMsgBuffer);
- E.log(S);
-
- if (E.Error ==
- llvm::atomic_write_error::failed_to_create_uniq_file) {
- errs() << "Error: " << ErrorMsgBuffer << "\n";
- report_fatal_error("ThinLTO: Can't get a temporary file");
- }
- })) {
- // FIXME
- consumeError(std::move(Err));
- }
+ if (auto Err = handleErrors(llvm::writeToOutput(
+ EntryPath, [&OutputBuffer](llvm::raw_ostream &OS) -> llvm::Error {
----------------
Nit: Since now we don't care about what kind of error returns, this `handleErrors` with no error handle does nothing. Just do:
```
auto Err = llvm::writeToOutput()
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154191/new/
https://reviews.llvm.org/D154191
More information about the cfe-commits
mailing list