1 //===- Caching.h - LLVM Link Time Optimizer Configuration -----------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file defines the localCache function, which allows clients to add a 10 // filesystem cache to ThinLTO. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_LTO_CACHING_H 15 #define LLVM_LTO_CACHING_H 16 17 #include "llvm/LTO/LTO.h" 18 19 namespace llvm { 20 namespace lto { 21 22 /// This type defines the callback to add a pre-existing native object file 23 /// (e.g. in a cache). 24 /// 25 /// Buffer callbacks must be thread safe. 26 using AddBufferFn = 27 std::function<void(unsigned Task, std::unique_ptr<MemoryBuffer> MB)>; 28 29 /// Create a local file system cache which uses the given cache directory and 30 /// file callback. This function also creates the cache directory if it does not 31 /// already exist. 32 Expected<NativeObjectCache> localCache(StringRef CacheDirectoryPath, 33 AddBufferFn AddBuffer); 34 35 } // namespace lto 36 } // namespace llvm 37 38 #endif 39