Original Patch and summary by Philip Reames.
RewriteStatepointsForGC tries to rewrite a function in a manner where the optimizer can't end up using a pointer value after it might have been relocated by a safepoint. This pass checks the invariant that RSForGC is supposed to establish and that (if we constructed semantics correctly) later passes must preserve.
This has been a really useful diagnostic tool when initially developing the rewriting scheme and has found numerous bugs. Manuel recently pointed out that this had never gotten upstreamed. Given both Manuel and the Microsoft team are in the process of trying to ramp up both the amount of IR being fed through and the optimization passes run, it seems useful to have this available for them as well. Manuel in particular has already found and fixed a couple of relocation bugs the hard way.
In terms of placement and structure, I left this in the IR directory which is where we'd happened to drop it in our tree. I could see an argument that this should be in either Analysis or possibly Transform. I'm happy to move it if anyone has a preference.