Skip to content

nir/large_constants: De-duplicate constants

If a function has a constant and is called more than once, after inlining we may end up with different variables representing the same constant. This commit look into the data and de-duplicate them.

The first pass now will collect the constant data in a per variable buffer, then de-duplication happens (by sorting then linear walk), and the second pass will use the data in var->data.location.

One side-effect of the current implementation is that constants will be reordered. If this turns out to be a problem is something that can be fixed.

An alternative strategy considered was to perform this in a per-function basis and then merge the results, the problem is that we would have to fix up the offsets during the merge. Given the data we have, the current patch is good enough.

This MR is on top of !1061 (merged)

Edited by Caio Oliveira

Merge request reports