Advice on using @code_warntype

I get the general idea behind @code_warntype but LLVM is new to me. Right now, I might try @code_warntype on a one-liner, but with larger functions … I get lost. I use the Julia REPL, and I figure that I just look for things that are colored yellow or red to warn me of bad program design?

Is it just the sort of thing that I will pick up after a while, or should I try to learn some LLVM IR?

It depends on what level of the compilation process you’re interested in. @code_warntype is really good for type level help, but almost nothing of that is still visible once you hit LLVM. Conversely, the kinds of vectorization details you may be able to see in LLVM IR, are often not visible on the type level directly.

For getting a feel about type stable design, I think there isn’t a good substitute for practice, as well as checking with JET.jl and/or Cthulhu.jl.

Thanks again!

Also bear in mind that @code_ assumes all arguments are specialized on, which is not always true (issue #32834). It is mentioned in the Performance Tips but it is easy to miss for a long time.

1 Like

You may find Cthulhu much easier to interpret than @code_warntype.

Great package name, Cthulu, the slow descent into madness! :grin:

1 Like