This is an archive of the discontinued LLVM Phabricator instance.

[clang][deps] Set -disable-free for module compilations
ClosedPublic

Authored by benlangmuir on Jun 7 2022, 10:13 AM.

Details

Summary

The command-line arguments for module builds are cc1 commands, so they do not implicitly set -disable-free like a driver invocation, and Tooling will disable it for the scanning instance itself. Set -disable-free explicitly so that separate invocations for building modules will not pay for freeing memory unnecessarily.

Diff Detail

Event Timeline

benlangmuir created this revision.Jun 7 2022, 10:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 7 2022, 10:13 AM
benlangmuir requested review of this revision.Jun 7 2022, 10:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 7 2022, 10:13 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Attempt to fix Windows path issue in test.

jansvoboda11 added inline comments.Jun 8 2022, 12:59 AM
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
338

I see the driver is adding -disable-free conditionally:

if (!C.isForDiagnostics())
  CmdArgs.push_back("-disable-free");

Does that change anything for this patch?

338

If this is always true for our purposes, is there a reason for passing this argument into DependencyScanningAction instead of just hard-coding it there?

benlangmuir added inline comments.Jun 8 2022, 10:31 AM
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
338

C.isForDiagnostics() is only true in Driver::generateCompilationDiagnostics, which didn't seem relevant to this tool.

If this is always true for our purposes, is there a reason for passing this argument into DependencyScanningAction instead of just hard-coding it there?

My thinking here was that making this an explicit option forces us to think about it if we add another way to trigger dependency scanning that doesn't use a driver invocation directly - for example, in our downstream branch experimental/cas/main, we have another path through this code that starts from a cc1 command-line, in which case I would think we should not add -disable-free unless the original command-line set it, since it's explicit in cc1. Obviously we don't need to bend over backwards to accommodate out-of-tree code here, but it seemed like a good indication this should be explicit, since it's easy to do that. WDYT?

jansvoboda11 accepted this revision.Jun 8 2022, 10:37 AM

LGTM!

clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
338

That makes sense, thanks!

This revision is now accepted and ready to land.Jun 8 2022, 10:37 AM
This revision was landed with ongoing or failed builds.Jun 8 2022, 11:11 AM
This revision was automatically updated to reflect the committed changes.