https://github.com/paperchalice commented:
In general I think we should handle pipeline construction and {start,stop}-{before,after} separately, i.e. construct pipeline firstly then remove unwanted passes, but it is off-topic.
https://github.com/llvm/llvm-project/pull/200631