Idea: polymorphic baseline codegen

Perhaps a more feasible variant of this, one we have oft discussed but never implemented, would be to analyze the MIR of fns and determine to what extent it relies on its type parameters.

To start, we might look for things that do not not rely at all on any particulars of the type. Something like the len method of a Vec (or even Vec iterators) might fit the bill (particularly since we know that Vec<T> requires T: Sized). In those cases, we can collapse monomorphizations.

Once we have the base case working, we can probably extend. I imagine there are many functions that only care about the size/alignment of their type parameters.

We’ve had some PRs take a stab at this, but it’d be good to figure out a planned impl strategy beforehand, I think, since most of those ran aground before really getting started.

11 Likes