Caching.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. #ifndef LLVM_LTO_CACHING_H
  14. #define LLVM_LTO_CACHING_H
  15. #include "llvm/LTO/LTO.h"
  16. namespace llvm {
  17. namespace lto {
  18. /// This type defines the callback to add a pre-existing native object file
  19. /// (e.g. in a cache).
  20. ///
  21. /// Buffer callbacks must be thread safe.
  22. using AddBufferFn =
  23. std::function<void(unsigned Task, std::unique_ptr<MemoryBuffer> MB)>;
  24. /// Create a local file system cache which uses the given cache directory and
  25. /// file callback. This function also creates the cache directory if it does not
  26. /// already exist.
  27. Expected<NativeObjectCache> localCache(StringRef CacheDirectoryPath,
  28. AddBufferFn AddBuffer);
  29. } // namespace lto
  30. } // namespace llvm
  31. #endif