Hi everyone,
This is my first real contribution to LLVM, so please be gentle!
For context, we are writing a JIT that will require LLVM's stackmap facility in order to reconstruct the native stack when deoptimising from specialised JITted code back into generic AOT-compiled code.
During my experimentation with stackmaps, I've identified a few problems that I hope to be able to fix. This diff makes a start at addressing the first of these issues, namely: https://github.com/llvm/llvm-project/issues/21657
In short, passing illegally-typed live variable operands to llvm.experimental.stackmap (at -O1 or above) will make LLVM crash by an assertion failure. The issue is that stackmap operands are emitted directly to target nodes in the selection DAG, which means their operands don't get legalised.
The diff below introduces a (non-target) stackmap DAG node, so that the stackmap node and its operands can take part in regular legalisations.
Although ninja check passes, I don't expect this to be ready to be merged just yet because:
- I only legalise integer operands and constant operands for now. I expect more needs to be done to legalise floats (and are there any other types that require legalisation?)
- GC statepoints and patchpoints have the same problem as stackmaps and will require the same treatment.
- There are a couple of questions, marked in the diff with XXX. I'd appreciate it if someone could comment on those points.
So although incomplete, I'm raising this now to check that I'm headed in the right direction. Any and all feedback would be much appreciated (even if you just say "yes, this looks correct/on-track", that's useful).
(The diff is formatted with git clang-format version 11, as found on Debian. Hope that's OK)
Nit: could you have it in single line as cases above (if it fits in 80 chars)?