# ANN: Mixtape.jl -- a static overlay and optimization tool

**URL:** https://discourse.julialang.org/t/ann-mixtape-jl-a-static-overlay-and-optimization-tool/58979
**Category:** Package Announcements
**Created:** [April 10, 2021, 1:39pm UTC](https://discourse.julialang.org/t/ann-mixtape-jl-a-static-overlay-and-optimization-tool/58979 "2021-04-10T13:39:20Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![McCoy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mccoy/32/13833_2.png) [@McCoy](https://discourse.julialang.org/u/McCoy)
#### Post date: [April 10, 2021, 1:39pm UTC](https://discourse.julialang.org/t/ann-mixtape-jl-a-static-overlay-and-optimization-tool/58979/1 "2021-04-10T13:39:20Z")

</div>

Hi all – I’d like to present a small experimental compiler package I’ve been working on with the help of `AbstractInterpreter` and `GPUCompiler` (as well as the sick, twisted minds of @vchuravy and @Roger-luo).

> **[GitHub - JuliaCompilerPlugins/Mixtape.jl: A static method overlay and...](https://github.com/JuliaCompilerPlugins/Mixtape.jl)**
>
> A static method overlay and optimization tool with configurable code generation and execution. - GitHub - JuliaCompilerPlugins/Mixtape.jl: A static method overlay and optimization tool with configu...

If you’d like to use this package, I recommend that you don’t add it from the registry for now – and instead just follow the top `pkg` lines of the repository.

Here’s the value proposition:

`Mixtape.jl` is a static method overlay and optimization tool which operates during Julia type inference. It allows you to (precisely) insert semantic-intruding changes to lowered code (e.g. replace `CodeInfo` , pre-optimize `CodeInfo` , and create other forms of static analysis tools on uninferred `CodeInfo` ) _before optimization_ . It also allows you to customize the optimization pipeline – allowing users to write semantic-preserving passes on [Core.Compiler.IRCode](https://github.com/JuliaLang/julia/blob/master/base/compiler/ssair/ir.jl) which operate _after inference_ .

> **Note** : `Mixtape.jl` manages its own code cache and execution engine through [LLVM.jl](https://github.com/maleadt/LLVM.jl) and [GPUCompiler.jl](https://github.com/JuliaGPU/GPUCompiler.jl) – so it is less part of Julia’s native pipeline, and closer to a separate compiler pipeline. In the future, parts of `Mixtape.jl` may be integrated into the compiler.

In many respects, it is similar to [Cassette.jl](https://github.com/JuliaLabs/Cassette.jl) – _but it is completely static_ .

> **Note** : the architecture for this package can be found in many other places. The interested reader might look at [KernelCompiler.jl](https://github.com/vchuravy/KernelCompiler.jl), [Enzyme.jl](https://github.com/wsmoses/Enzyme.jl), [the Julia frontend to brutus](https://github.com/JuliaLabs/brutus/blob/master/Brutus/src/Brutus.jl), and the [compiler interface in GPUCompiler.jl](https://github.com/JuliaGPU/GPUCompiler.jl/blob/master/src/interface.jl) to understand this a bit better.
> 
> When in doubt, don’t be afraid of [typeinfer.jl](https://github.com/JuliaLang/julia/blob/master/base/compiler/typeinfer.jl) and [Julia’s SSA form IR](https://github.com/JuliaLang/julia/tree/master/base/compiler/ssair)!

Here’s a list of pros and cons:

A few upsides!

1. Completely static – does not rely on recursive pollution of the call stack (see: [the overdub issue](https://julia.mit.edu/Cassette.jl/stable/overdub.html)).
2. Transforms operate pre-type inference – all semantic-intruding changes happen before type inference runs on the lowered method body.
3. `Mixtape.jl` manages its own code cache – and doesn’t interact with the native runtime system (see above).

A few downsides…

1. `Mixtape.jl` uses a custom execution engine through `GPUCompiler.jl` – code which causes `GPUCompiler.jl` to fail will also cause `Mixtape.jl` to fail. In practice, this means you can’t use the pipeline on dispatch tuples with `Union{As...}` or `Any` – you must specify a non-dynamic type.
