The Legacy Partial Inlining pass has an ownership issue related to the OptimizationRemarkEmitter objects it creates. The call back used to create an ORE caches the allocated object in a unique_ptr in the runOnModule function, and returns a reference to that object. In the case we find a multi-region outline candidate that fails to get inlined into any of its users we end up with a dangling reference. This occurs because we get a reference to an ORE in unswitchFunction which gets destructed when tryPartialInline calls the callback to create other ORE objects. After we fail to inline in the multi-region case, we continue on with the single-region case which tries to emit a remark with the now deleted emitter.
I've reverted back to creating the OREs directly rather they trying to get them as an analysis pass.