lplewa wrote: Re-land of #222677 + #224622, which were reverted together in #224703. This commit is the two originals combined; the fix for the AMDGPU record-replay regression that motivated the revert is kept as a separate follow-up commit. https://github.com/llvm/llvm-project/pull/224930