I have a program that I wrote that uses LLVM 3.5 as a JIT compiler, which I am trying to upgrade to use MCJIT in LLVM 3.7. This basically works for me, but I'm struggling to reproduce one debugging function implemented with LLVM 3.5.
I would like to see the host machine code (for example, x86, x64 or ARM, not the LLVM IR) generated by the JIT process; in debug builds I log this when my program is running. With LLVM 3.5, I was able to do this by calling ExecutionEngine :: runJITOnFunction () to populate the llvm :: MachineCodeInfo object, which gave me the starting address and size of the generated code. Then I could parse this code.
I can not find the equivalent in MCJIT. I can get the start address of the function (e.g. via getPointerToFunction ()), but not the size.
I have seen disassemble the memory , but besides the fact that the answers do not have so many details, it looks like it's more about how to parse a sequence of bytes. I know how to do this, my question is: how can I get a sequence of bytes in the first place?
If this helps to make it more specific, please reformulate this question as follows: "How can I extend the Kaleidoscope JIT example to show the machine code (x86, ARM, etc.) that it produces, and not just LLVM IR? "
Thanks.
source
share