15#ifndef LLVM_SUPPORT_CACHING_H
16#define LLVM_SUPPORT_CACHING_H
33 std::string OSPath =
"")
41 Twine(
"CacheStream already committed."));
44 "CacheStream already aborted.");
59 "CacheStream already committed.");
68 std::unique_ptr<raw_pwrite_stream>
OS;
79using AddStreamFn = std::function<Expected<std::unique_ptr<CachedFileStream>>(
107 : CacheFunction(
std::
move(CacheFn)), CacheDirectoryPath(DirectoryPath) {}
116 return CacheDirectoryPath;
118 bool isValid()
const {
return static_cast<bool>(CacheFunction); }
122 std::string CacheDirectoryPath;
129 std::unique_ptr<MemoryBuffer> MB)>;
140 const Twine &CacheNameRef,
const Twine &TempFilePrefixRef,
141 const Twine &CacheDirectoryPathRef,
143 std::unique_ptr<MemoryBuffer> MB) {},
144 bool CacheFileRename =
false);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
CachedFileStream(std::unique_ptr< raw_pwrite_stream > OS, std::string OSPath="")
virtual Error abort()
Must be called if the file was not committed before its destroyed (for example if some writes didn't ...
std::string ObjectPathName
virtual ~CachedFileStream()
std::unique_ptr< raw_pwrite_stream > OS
virtual Error commit(std::unique_ptr< MemoryBuffer > MemBuf)
virtual Error commit()
Must be called after the writes to OS have been completed successfully but before the CachedFileStrea...
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
This is an optimization pass for GlobalISel generic memory operations.
std::error_code make_error_code(BitcodeError E)
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
std::function< Expected< AddStreamFn >( unsigned Task, StringRef Key, const Twine &ModuleName)> FileCacheFunction
This is a callable that manages file caching operations.
std::function< void(unsigned Task, const Twine &ModuleName, std::unique_ptr< MemoryBuffer > MB)> AddBufferFn
This type defines the callback to add a pre-existing file (e.g.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI Expected< FileCache > localCache(const Twine &CacheNameRef, const Twine &TempFilePrefixRef, const Twine &CacheDirectoryPathRef, AddBufferFn AddBuffer=[](size_t Task, const Twine &ModuleName, std::unique_ptr< MemoryBuffer > MB) {}, bool CacheFileRename=false)
Create a local file system cache which uses the given cache name, temporary file prefix,...
std::function< Expected< std::unique_ptr< CachedFileStream > >( unsigned Task, const Twine &ModuleName)> AddStreamFn
This type defines the callback to add a file that is generated on the fly.
Implement std::hash so that hash_code can be used in STL containers.
Expected< AddStreamFn > operator()(unsigned Task, StringRef Key, const Twine &ModuleName)
const std::string & getCacheDirectoryPath() const
FileCache(FileCacheFunction CacheFn, const std::string &DirectoryPath)