# Minimal self-containing example of code transformation using generated functions?

**URL:** <https://discourse.julialang.org/t/minimal-self-containing-example-of-code-transformation-using-generated-functions/88535>\
**Category:** Internals & Design\
**Tags:** runtimegeneratedfunc\
**Created:** [October 10, 2022, 9:15pm UTC](https://discourse.julialang.org/t/minimal-self-containing-example-of-code-transformation-using-generated-functions/88535 "2022-10-10T21:15:09Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)\
**Post date:** [October 25, 2022, 4:58am UTC](https://discourse.julialang.org/t/minimal-self-containing-example-of-code-transformation-using-generated-functions/88535/3 "2022-10-25T04:58:29Z")

</div>

Unfortunately I’m not aware of any remotely accessible and self-contained example in the wild for this, but here are some possible leads. [Does overdubbing in generated function inserts inlined code - #7 by Tomas\_Pevny](https://discourse.julialang.org/t/does-overdubbing-in-generated-function-inserts-inlined-code/71868/7) has a self-contained snippet, but didn’t seem to work? [Cassette’s docs](https://julia.mit.edu/Cassette.jl/latest/overdub.html) shows how to create a valid CodeInfo output using its API but doesn’t go into details. The underlying code may thus be worth a read. Lastly, the genfuncs in [Zygote’s compiler](https://github.com/FluxML/Zygote.jl/blob/master/src/compiler/interface2.jl#L9-L59) show most of the steps required for ingesting a CodeInfo for a function argument and manipulating it to be compatible with the generated function signature, but you’ll have to read through some IRTools methods to know exactly what it’s doing under the hood and a lot of the AD-related stuff may be a distraction.

---

_[View the full topic](https://discourse.julialang.org/t/minimal-self-containing-example-of-code-transformation-using-generated-functions/88535)._
