This fix locks the "last use"-point for a pass as soon as the pass is determined to be "not preserved".
This prevents "last use" and "preservation" information from becoming inconsistent, i.e. a "last use" point beyond where the pass is no longer preserved. Since "last use" information is used to remove dead passes, this will make sure passes does not stay around when they are not preserved.
The LegacyPassManager has an algorithm that transitively calculates "last use", so a pass' last use point could otherwise be dragged along beyond non-preservation points, and thus stay alive for too long. For instance, two call graphs would exist at the same time, leading to various problems, especially value handle asserts.
This solves the following four llvm bugs:
26865 - Inliner crashes in ValueHandleBase::ValueIsDeleted
27050 - ArgumentPromotion crashing with "An asserting value handle still pointed to this value!"
27112 - Inliner crashing with "An asserting value handle still pointed to this value!"
27697 - Passmanager assertion failure in PassAnalysisSupport
Could these be better documented here?