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..