[PATCH] D69327: [Clang][ThinLTO] Add a cache for compile phase output.

Yuanfang Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 23 00:56:24 PDT 2019


ychen created this revision.
ychen added reviewers: mehdi_amini, pcc, tejohnson.
Herald added subscribers: llvm-commits, cfe-commits, dang, dexonsmith, steven_wu, aheejin, hiraditya, inglorion.
Herald added projects: clang, LLVM.

Currently the link phase has a object file cache whereas the compile phase always
perform optimizations (most likely happen for large source files and O2 <https://reviews.llvm.org/owners/package/2/> or above)
which could potentially waste time optimizing a file that finally hit the object file cache.
For example, with Intel W-2133 and 64GB memory, compile X86ISelLowering.cpp with -flto=thin -O3
takes about 40s (takes about 10s with caching implemented by this patch).
The patch makes sure bitcodes that hit LTO cache also skip IR optimizations.

Add a driver/cc1 flag (-fthinlto-cache-dir, default off) to cache the minimized or regular ThinLTO bitcode file.
The caching is only trigger if the input is large than `-fthinlto-cache-min-filesize=`. Default minimum is 1024 IR instructions.
Cache pruning (`-fthinlto-cache-policy=`) shares the implementation with `lld --thinlto-cache-policy`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69327

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/thin_link_bitcode.c
  llvm/include/llvm/LTO/Caching.h
  llvm/lib/LTO/Caching.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69327.226098.patch
Type: text/x-patch
Size: 22533 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191023/7df18844/attachment.bin>


More information about the llvm-commits mailing list