See any sub-issue in https://github.com/llvm/llvm-project/issues/157287 on how to do the refactor.