In some compiler passes like SampleProfileLoaderPass, we want to know which LTO/ThinLTO phase the pass is in. Currently the phase is represented in enum class PassBuilder::ThinLTOPhase, so it is only available in PassBuilder and it also cannot represent phase in full LTO. The patch extends it to include LTO phases and move it from PassBuilder.h to Pass.h, then it is much easier for PassBuilder to communiate with each pass about current LTO phase.
Thanks for refactoring. We had internal change to add IsFullLTOPreLink alongside with IsThinLTOPreLink for a few places. And we always wanted clean it up too. :)
nit: name it LTOPhase? There's similar change in https://reviews.llvm.org/D69732.
And perhaps FullLTOPreLink and FullLTOPostLink too though I noticed there's PrepareForLTO and PrepareForThinLTO.. Not sure if LTO is always used to refer FullLTO..
LTO traditionally refers to FullLTO, so using LTO can be confusing.
I suggest make it even clearer:
Thanks, I use ThinOrFullLTOPhase for the enum class name and change LTOPreLink/LTOPostLink to FullLTOPreLink/FullLTOPostLink.
Thanks for the refactoring!
BTW, looks like there is a use of ThinLTOPhase::None to be replaced in polly/lib/Support/RegisterPasses.cpp. Otherwise, LGTM.