Why does rustc implement SSA?

I saw that rustc transforms MIR to SSA form in rust/compiler/rustc_mir_transform/src/ssa.rs at master · rust-lang/rust · GitHub.

But why does rustc implement SSA algorithm when LLVM can do it?

1 Like

Notice that's in the mir transform library.

It's there because there are optimizations on MIR that we want to do where the best way to implement it is to compute SSA-like information, for the same reason that LLVM uses SSA form.

The TL/DR of the whole thing is that if Rust can optimize stuff in the generic form of methods, then LLVM doesn't need to optimize that in every monomorphization, which ends up saving compilation time.

13 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.