mehdi_amini added a comment. I don't have time to page-in the LegacyPassManager infrastructure, but I know @chandlerc has been reviewing stuff in this area recently, maybe he can have a look. https://reviews.llvm.org/D21468