This is an archive of the discontinued LLVM Phabricator instance.

[clang][deps] Allow switching between lazily/eagerly loaded PCMs
ClosedPublic

Authored by jansvoboda11 on Aug 17 2022, 1:11 PM.

Details

Summary

This patch introduces new option -eager-load-pcm to clang-scan-deps, which controls whether the resulting command-lines will load PCM files eagerly (at the start of compilation) or lazily (when handling import directive). This patch also switches the default from eager to lazy.

To reduce the potential for churn in LIT tests in the future, this patch also removes redundant checks of command-line arguments and introduces new test modules-dep-args.c as a substitute.

Diff Detail

Event Timeline

jansvoboda11 created this revision.Aug 17 2022, 1:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 17 2022, 1:11 PM
jansvoboda11 requested review of this revision.Aug 17 2022, 1:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 17 2022, 1:11 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
benlangmuir added inline comments.Aug 17 2022, 4:02 PM
clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
50

Since you're changing the default to lazy loading, please mention that in the commit message.

clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
104

Nit: How about adding an accessor to the DependencyScanningWorker instead of duplicating this state here? I find it easier to understand the tool when it has no state of its own and just wraps a worker.

clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
71

I think we need to include this new state in getModuleContextHash. Here's my suggestion:

  • In makeInvocationForModuleBuildWithoutOutputs you can add the module map paths if EagerLoadModules is false. Those are all inputs, so it should be fine to do immediately, which will also include them in the context hash for free.
  • In getModuleContextHash hash just the EagerLoadModules bit. It's a bit subtle whether this is actually needed or not since adding the module map paths will also change the hash, but I think it's safer to include it since in the future we could e.g. drop duplicate module map paths, and then the difference in flags might only be the spelling of fmodule-file options, which are not hashed.

Stop duplicating worker state, fix context hash computation.

jansvoboda11 edited the summary of this revision. (Show Details)Aug 18 2022, 5:05 PM
benlangmuir accepted this revision.Aug 19 2022, 8:59 AM

Thanks, LGTM

This revision is now accepted and ready to land.Aug 19 2022, 8:59 AM