Page MenuHomePhabricator

[NewPM] Add option to prevent rerunning function pipeline on functions in CGSCC adaptor

Authored by aeubanks on Nov 15 2021, 3:15 PM.



In a CGSCC pass manager, we may visit the same function multiple times
due to SCC mutations. In the inliner pipeline, this results in running
the function simplification pipeline on a function multiple times even
if it hasn't been changed since the last function simplification
pipeline run.

We use a newly introduced analysis to keep track of whether or not a
function has changed since the last time the function simplification
pipeline has run on it. If we see this analysis available for a function
in a CGSCCToFunctionPassAdaptor, we skip running the function passes on
the function. The analysis is queried at the end of the function passes
so that it's available after the first time the function simplification
pipeline runs on a function. This is a per-adaptor option so it doesn't
apply to every adaptor.

The goal of this is to improve compile times. However, currently we
can't turn this on by default at least for the higher optimization
levels since the function simplification pipeline is not robust enough
to be idempotent in many cases, resulting in performance regressions if
we stop running the function simplification pipeline on a function
multiple times. We may be able to turn this on for -O1 in the near
future, but turning this on for higher optimization levels would require
more investment in the function simplification pipeline.

Heavily inspired by D98103.

Example compile time improvements with flag turned on:

Diff Detail

Event Timeline

aeubanks created this revision.Nov 15 2021, 3:15 PM
aeubanks requested review of this revision.Nov 15 2021, 3:15 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 15 2021, 3:15 PM
nikic accepted this revision.Nov 16 2021, 12:16 PM



Why is this include needed?


The layering here isn't great, in that the analysis is created and checked in the CGSCC pass manager, while the invalidation has to happen explicitly in the pipeline. Unfortunately I don't have a great suggestion on how to do this better, as we have the DevirtSCC pass wrapper sitting in between.

This revision is now accepted and ready to land.Nov 16 2021, 12:16 PM
aeubanks updated this revision to Diff 387764.Nov 16 2021, 2:20 PM

remove unnecessary include

asbirlea accepted this revision.Nov 16 2021, 2:57 PM

Thank you for this work!

This revision was landed with ongoing or failed builds.Nov 17 2021, 9:07 AM
This revision was automatically updated to reflect the committed changes.