Why does julia have slots, rather than go full SSA?

More a question of history.
though, it seems like going full SSA would remove some sources of within function type-instability.
Since it would be impossible to assign different types to same variable, since you actually only assign once

2 Likes

Do you know about Julia SSA-form IR · The Julia Language?

I think the question is more like. Why don’t we lower directly to SSA instead of slots then SSA.

2 Likes

I think it basically started as “add type annotations to lowered AST.”

2 Likes

yes, that talks about why we lower to (near) SSA.
But it is an impure SSA, as it has slots.
My question is why don’t we go all the way?

We eliminate slots before going to the optimizer. When we added the SSA form IR, there was some talk of doing inference on the SSA form as well, but there was some concern around inference precision. We should probably revisit this at some point.

1 Like

Ah cool.
Is there a way to view the IR at that state?

There isn’t a builtin way to see the IR post-ssa-conversion, but before the rest of the optimizer pipeline, but you can put a Core.Main.Base.display(ir) here: julia/optimize.jl at a2912e2148b23601316b2b3135e223d9b3dd1c16 · JuliaLang/julia · GitHub and then just do @code_typed gcd(10, 20) or something.

5 Likes