https://github.com/david-arm approved this pull request. LGTM! Thanks for spending so much time addressing all the comments. The approach seems reasonable and safe to me, but please wait a day or so in case @nikic has any comments. https://github.com/llvm/llvm-project/pull/139943