https://github.com/simonpcook requested changes to this pull request. I tried integrating this into a LLVM build locally, and there are a couple of issues that need fixing which I've commented on the appropriate lines. https://github.com/llvm/llvm-project/pull/77884