[NewPM] Add option to prevent rerunning function pipeline on functions in CGSCC adaptor
authorArthur Eubanks <aeubanks@google.com>
Tue, 16 Nov 2021 20:58:13 +0000 (12:58 -0800)
committerArthur Eubanks <aeubanks@google.com>
Wed, 17 Nov 2021 17:06:46 +0000 (09:06 -0800)
commite3e25b51122573c12c30f25b1b3a1b556fca237b
treee0b420c7b7a32b8b8dab7de27a600bbb1783e0ed
parent2e7f12d5e9f998dcce62dd4a2e93a7a10dfc2515
[NewPM] Add option to prevent rerunning function pipeline on functions in CGSCC adaptor

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:
https://llvm-compile-time-tracker.com/compare.php?from=998dc4a5d3491d2ae8cbe742d2e13bc1b0cacc5f&to=5c27c913687d3d5559ef3ab42b5a3d513531d61c&stat=instructions

Reviewed By: asbirlea, nikic

Differential Revision: https://reviews.llvm.org/D113947
llvm/include/llvm/Analysis/CGSCCPassManager.h
llvm/include/llvm/Transforms/IPO/Inliner.h
llvm/lib/Analysis/CGSCCPassManager.cpp
llvm/lib/Passes/PassBuilderPipelines.cpp
llvm/lib/Passes/PassRegistry.def
llvm/lib/Transforms/IPO/Inliner.cpp
llvm/test/Other/no-rerun-function-simplification-pipeline.ll [new file with mode: 0644]