Where can I learn how to read the output of `@code_llvm`?

Together with the LLVM LangRef, you can just run @code_llvm of various Julia functions and try to decode how it maps to the functions definition (or output of @code_typed). For each instruction you generate that you don’t understand, read the description for it in the LangRef (sounds obvious, but you learn a lot by doing this).

You could also try out the LLVM.jl examples in LLVM.jl/examples at master · maleadt/LLVM.jl · GitHub to get a feel for what kind of LLVM code you can generate and what it does.

I also like to read the LLVM codegen tests in LLVM’s repository (at test/CodeGen) when I’m working on LLVM-based compilers just to see what kind of code patterns one could see in the wild.

3 Likes