[PATCH] D104465: [clang][deps] Prevent PCH validation failures by padding minimized files

Jan Svoboda via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 17 07:44:39 PDT 2021


jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, arphaman.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch fixes dependency scanning of a TU with prebuilt modular/PCH dependencies.

Such modules/PCH might have been built using non-minimized files, while dependency scanner does use the minimized versions of source files. Implicit build doesn't like the discrepancy in file sizes and errors out.

The issues is worked around by padding the minimized files with whitespace in such scenarios. This approach throws away one advantage of source minimization (the memory savings), but still keeps the benefits of faster preprocessing/lexing.

The padding solution comes with a 14% runtime regression compared to not padding the inputs. (I tested this by forcing padding and running `clang-scan-deps -j 20` on LLVM's `compile_commands.json` with modules disabled.) Interestingly, padding only with newlines (compared to spaces), the regression is 39%.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104465

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/test/ClangScanDeps/modules-pch.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104465.352725.patch
Type: text/x-patch
Size: 6322 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210617/5e9ac9ad/attachment.bin>


More information about the cfe-commits mailing list