Skip to content

File tree

7 files changed

+13
-40
lines changed

7 files changed

+13
-40
lines changed

lldb/source/Core/DataFileCache.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,6 @@ bool DataFileCache::SetCachedData(llvm::StringRef key,
132132
if (file_or_err) {
133133
llvm::CachedFileStream *cfs = file_or_err->get();
134134
cfs->OS->write((const char *)data.data(), data.size());
135-
if (llvm::Error err = cfs->commit()) {
136-
Log *log = GetLog(LLDBLog::Modules);
137-
LLDB_LOG_ERROR(log, std::move(err),
138-
"failed to commit to the cache for key: {0}");
139-
}
140135
return true;
141136
} else {
142137
Log *log = GetLog(LLDBLog::Modules);

llvm/include/llvm/Support/Caching.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class CachedFileStream {
3030
CachedFileStream(std::unique_ptr<raw_pwrite_stream> OS,
3131
std::string OSPath = "")
3232
: OS(std::move(OS)), ObjectPathName(OSPath) {}
33-
virtual Error commit() { return Error::success(); }
3433
std::unique_ptr<raw_pwrite_stream> OS;
3534
std::string ObjectPathName;
3635
virtual ~CachedFileStream() = default;

llvm/lib/Debuginfod/Debuginfod.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ class StreamedHTTPResponseHandler : public HTTPResponseHandler {
188188
public:
189189
StreamedHTTPResponseHandler(CreateStreamFn CreateStream, HTTPClient &Client)
190190
: CreateStream(CreateStream), Client(Client) {}
191-
Error commit();
192191
virtual ~StreamedHTTPResponseHandler() = default;
193192

194193
Error handleBodyChunk(StringRef BodyChunk) override;
@@ -211,12 +210,6 @@ Error StreamedHTTPResponseHandler::handleBodyChunk(StringRef BodyChunk) {
211210
return Error::success();
212211
}
213212

214-
Error StreamedHTTPResponseHandler::commit() {
215-
if (FileStream)
216-
return FileStream->commit();
217-
return Error::success();
218-
}
219-
220213
// An over-accepting simplification of the HTTP RFC 7230 spec.
221214
static bool isHeader(StringRef S) {
222215
StringRef Name;
@@ -305,8 +298,6 @@ Expected<std::string> getCachedOrDownloadArtifact(
305298
Error Err = Client.perform(Request, Handler);
306299
if (Err)
307300
return std::move(Err);
308-
if (Err = Handler.commit())
309-
return std::move(Err);
310301

311302
unsigned Code = Client.responseCode();
312303
if (Code && Code != 200)

llvm/lib/LTO/LTOBackend.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,6 @@ static void codegen(const Config &Conf, TargetMachine *TM,
421421

422422
if (DwoOut)
423423
DwoOut->keep();
424-
425-
if (Error Err = Stream->commit())
426-
report_fatal_error(std::move(Err));
427424
}
428425

429426
static void splitCodeGen(const Config &C, TargetMachine *TM,

llvm/lib/Support/Caching.cpp

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,9 @@ Expected<FileCache> llvm::localCache(const Twine &CacheNameRef,
8989
AddBuffer(std::move(AddBuffer)), TempFile(std::move(TempFile)),
9090
ModuleName(ModuleName), Task(Task) {}
9191

92-
Error commit() override {
93-
if (Committed)
94-
return Error::success();
95-
Committed = true;
92+
~CacheStream() {
93+
// TODO: Manually commit rather than using non-trivial destructor,
94+
// allowing to replace report_fatal_errors with a return Error.
9695

9796
// Make sure the stream is closed before committing it.
9897
OS.reset();
@@ -102,12 +101,10 @@ Expected<FileCache> llvm::localCache(const Twine &CacheNameRef,
102101
MemoryBuffer::getOpenFile(
103102
sys::fs::convertFDToNativeFile(TempFile.FD), ObjectPathName,
104103
/*FileSize=*/-1, /*RequiresNullTerminator=*/false);
105-
if (!MBOrErr) {
106-
std::error_code EC = MBOrErr.getError();
107-
return createStringError(EC, Twine("Failed to open new cache file ") +
108-
TempFile.TmpName + ": " +
109-
EC.message() + "\n");
110-
}
104+
if (!MBOrErr)
105+
report_fatal_error(Twine("Failed to open new cache file ") +
106+
TempFile.TmpName + ": " +
107+
MBOrErr.getError().message() + "\n");
111108

112109
// On POSIX systems, this will atomically replace the destination if
113110
// it already exists. We try to emulate this on Windows, but this may
@@ -122,10 +119,7 @@ Expected<FileCache> llvm::localCache(const Twine &CacheNameRef,
122119
E = handleErrors(std::move(E), [&](const ECError &E) -> Error {
123120
std::error_code EC = E.convertToErrorCode();
124121
if (EC != errc::permission_denied)
125-
return createStringError(
126-
EC, Twine("Failed to rename temporary file ") +
127-
TempFile.TmpName + " to " + ObjectPathName + ": " +
128-
EC.message() + "\n");
122+
return errorCodeToError(EC);
129123

130124
auto MBCopy = MemoryBuffer::getMemBufferCopy((*MBOrErr)->getBuffer(),
131125
ObjectPathName);
@@ -138,10 +132,11 @@ Expected<FileCache> llvm::localCache(const Twine &CacheNameRef,
138132
});
139133

140134
if (E)
141-
return E;
135+
report_fatal_error(Twine("Failed to rename temporary file ") +
136+
TempFile.TmpName + " to " + ObjectPathName + ": " +
137+
toString(std::move(E)) + "\n");
142138

143139
AddBuffer(Task, ModuleName, std::move(*MBOrErr));
144-
return Error::success();
145140
}
146141

147142
~CacheStream() {

llvm/tools/gold/gold-plugin.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,9 +1101,7 @@ static std::vector<std::pair<SmallString<128>, bool>> runLTO() {
11011101

11021102
auto AddBuffer = [&](size_t Task, const Twine &moduleName,
11031103
std::unique_ptr<MemoryBuffer> MB) {
1104-
auto Stream = *AddStream(Task, ModuleName);
1105-
Stream->OS << MB->getBuffer();
1106-
check(Stream->commit(), "Failed to commit cache");
1104+
*AddStream(Task, moduleName)->OS << MB->getBuffer();
11071105
};
11081106

11091107
FileCache Cache;

llvm/tools/llvm-lto2/llvm-lto2.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,7 @@ static int run(int argc, char **argv) {
447447

448448
auto AddBuffer = [&](size_t Task, const Twine &ModuleName,
449449
std::unique_ptr<MemoryBuffer> MB) {
450-
auto Stream = AddStream(Task, ModuleName);
451-
*Stream->OS << MB->getBuffer();
452-
check(Stream->commit(), "Failed to commit cache");
450+
*AddStream(Task, ModuleName)->OS << MB->getBuffer();
453451
};
454452

455453
FileCache Cache;

0 commit comments

Comments
 (0)