https://github.com/QuarticCat requested changes to this pull request. I'm uncertain about memory ordering choices. Other parts look good to me. https://github.com/llvm/llvm-project/pull/94156