This is an archive of the discontinued LLVM Phabricator instance.

[NewPM] Add PipelineTuningOption to eagerly invalidate analyses
ClosedPublic

Authored by aeubanks on Oct 11 2021, 1:21 PM.

Details

Summary

This trades off more compile time for less peak memory usage. Right now
it invalidates all function analyses after a module->function or
cgscc->function adaptor.

https://llvm-compile-time-tracker.com/compare.php?from=1fb24fe85a19ae71b00875ff6c96ef1831dcf7e3&to=cb28ddb063c87f0d5df89812ab2de9a69dd276db&stat=instructions
https://llvm-compile-time-tracker.com/compare.php?from=1fb24fe85a19ae71b00875ff6c96ef1831dcf7e3&to=cb28ddb063c87f0d5df89812ab2de9a69dd276db&stat=max-rss

For now this is just experimental.

See comments on why this may affect optimizations.

Diff Detail

Event Timeline

aeubanks created this revision.Oct 11 2021, 1:21 PM
aeubanks retitled this revision from invalidate more to [NewPM] Add PipelineTuningOption to eagerly invalidate analyses.Oct 18 2021, 10:18 AM
aeubanks edited the summary of this revision. (Show Details)
aeubanks edited the summary of this revision. (Show Details)Oct 18 2021, 10:19 AM
aeubanks edited reviewers, added: asbirlea, nikic; removed: ctetreau.
aeubanks published this revision for review.Oct 18 2021, 10:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 18 2021, 10:19 AM
This revision is now accepted and ready to land.Oct 18 2021, 10:30 AM
aeubanks edited the summary of this revision. (Show Details)Oct 18 2021, 10:32 AM
nikic added inline comments.Oct 18 2021, 10:58 AM
llvm/include/llvm/Passes/PassBuilder.h
80 ↗(On Diff #380459)

I think this could be more precise about what "invalidate more analyses" means. From the implementation, my understanding is that analyses will be invalidated after a function pass manager finishes processing a function.

Makes me wonder if we shouldn't be handling this in the Function to CGSCC/Module pass manager adaptors.

nikic added inline comments.Oct 18 2021, 10:59 AM
llvm/tools/opt/NewPMDriver.cpp
155 ↗(On Diff #380459)

Can we please move this option from opt into LLVM? I'd like it to be testable via -mllvm equivalents without explicit frontend support.

aeubanks updated this revision to Diff 380499.Oct 18 2021, 12:49 PM

make this affect all cgscc/module->function adaptors
just to simplify this change, now the flag isn't in PTO, it's just a global cl flag

aeubanks edited the summary of this revision. (Show Details)Oct 18 2021, 12:49 PM
This revision was landed with ongoing or failed builds.Oct 18 2021, 1:20 PM
This revision was automatically updated to reflect the committed changes.

Here are the results for this change with rust's compile-time tracking infrastructure:

Compile-time: https://perf.rust-lang.org/compare.html?start=5dab47dcd8267b8769421b46532414ec36d625e3&end=cfe9eecdf01985dff182ce388fe843987d1da888 (disable the filtering to see fairly consistent minor impact)
Max-rss: https://perf.rust-lang.org/compare.html?start=5dab47dcd8267b8769421b46532414ec36d625e3&end=cfe9eecdf01985dff182ce388fe843987d1da888&stat=max-rss

This looks like a pretty good tradeoff to me.

Here are the results for this change with rust's compile-time tracking infrastructure:

Compile-time: https://perf.rust-lang.org/compare.html?start=5dab47dcd8267b8769421b46532414ec36d625e3&end=cfe9eecdf01985dff182ce388fe843987d1da888 (disable the filtering to see fairly consistent minor impact)
Max-rss: https://perf.rust-lang.org/compare.html?start=5dab47dcd8267b8769421b46532414ec36d625e3&end=cfe9eecdf01985dff182ce388fe843987d1da888&stat=max-rss

This looks like a pretty good tradeoff to me.

interesting, it doesn't match the Clang numbers