Open BruceForstall opened 9 months ago
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch See info in area-owners.md if you want to be subscribed.
Author: | BruceForstall |
---|---|
Assignees: | - |
Labels: | `area-CodeGen-coreclr` |
Milestone: | - |
This will certainly be very useful to have for debugging purpose. I wanted to do something similar to associate Interval/RefPositions to the assembly code to track the register allocation to the generated code. There are lot of other examples where annotating the code would help:
Should be fairly simple to do this once comment is attached to GenTree nodes. Before genCodeForTreeNode()
, save the lastIns
emitted and once the method is done, all the instrDesc
generated can be attached to the comment of that GenTree node. We can also find out number of instructions generated and can include that in comment (e.g. Comment (5 instructions)) or along that line.
It's possible there will be multiple types of comments, e.g.:
There are many patterns of RyuJIT codegen where something interesting is known about the code when generating it, and that interesting information would be valuable if displayed as a comment on the generated code.
The JIT already generates some comments on generated code, e.g., for handles and strings:
One example of additional comments that could be added is around PInvoke handling. For example, the JIT could add:
Other examples might be when generating explicit null checks, prolog/epilog actions, locals zeroing, etc.
To implement this, we would want a mechanism to associate an arbitrary comment text (or perhaps even multiple?) with any GenTree node. When generating a GenTree node or node tree to a set of instructions (instrDesc), the set of comments would need to be associated with the generated instructions, and then output during disassembly. Perhaps these associations should be done using side tables which could be DEBUG only, or perhaps easily enabled for non-DEBUG builds if that was determined to be useful.
Comments?
@dotnet/jit-contrib