[llvm] [ThinLTO] Replace `ErrorOr` with `Expected` (PR #80088)

Jan Svoboda via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 30 17:20:45 PST 2024


================
@@ -397,19 +397,22 @@ class ModuleCacheEntry {
   // Access the path to this entry in the cache.
   StringRef getEntryPath() { return EntryPath; }
 
-  // Try loading the buffer for this cache entry.
-  ErrorOr<std::unique_ptr<MemoryBuffer>> tryLoadingBuffer() {
-    if (EntryPath.empty())
-      return std::error_code();
+  /// Try loading the buffer for this cache entry.
+  ///
+  /// \returns The buffer on cache hit, null on cache miss, or an error when
+  /// unable to load the cache contents.
+  Expected<std::unique_ptr<MemoryBuffer>> tryLoadingBuffer() {
+    if (EntryPath.empty() || !sys::fs::exists(EntryPath))
----------------
jansvoboda11 wrote:

Yes, that's one aspect of this PR I'm not happy about. I think it's a time-of-check time-of-use bug, but something like this is necessary to be able to distinguish between cache miss and an actual error. Guarding this with a file lock might fix it, but I'd be interested in other ideas.

https://github.com/llvm/llvm-project/pull/80088


More information about the llvm-commits mailing list