Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===- Caching.h - LLVM Link Time Optimizer Configuration -----------------===// |
| 2 | // |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 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 |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 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 | #include <string> |
| 19 | |
| 20 | namespace llvm { |
| 21 | namespace lto { |
| 22 | |
| 23 | /// This type defines the callback to add a pre-existing native object file |
| 24 | /// (e.g. in a cache). |
| 25 | /// |
| 26 | /// Buffer callbacks must be thread safe. |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 27 | using AddBufferFn = |
| 28 | std::function<void(unsigned Task, std::unique_ptr<MemoryBuffer> MB)>; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 29 | |
| 30 | /// Create a local file system cache which uses the given cache directory and |
| 31 | /// file callback. This function also creates the cache directory if it does not |
| 32 | /// already exist. |
| 33 | Expected<NativeObjectCache> localCache(StringRef CacheDirectoryPath, |
| 34 | AddBufferFn AddBuffer); |
| 35 | |
| 36 | } // namespace lto |
| 37 | } // namespace llvm |
| 38 | |
| 39 | #endif |