This was originally done as an IR->IR transform, to get something working quickly. This was never the correct layer and it was obviously wrong when export tables were generated further down in the back end.
This change moves import table generation to the same place as export table generation. We now record things that need import tables at the point where we generate the load and then emit them at the end.
A few tests are updated because the later expansion changes the order in which import tables are emitted or the register used for the loads.
Aside from the aesthetic improvements, this comes with the following benefits:
We now generate a shorter auipcc+clc sequence, rather than auipcc+cincoffset+clc for import tables.
The later expansion means that we have more opportunities to convert safe calls into direct calls.
The later expansion means that we can now emit library calls for runtime functions inserted late in the pipeline. In particular, this means that things like 64-bit integer division can now work.
This was originally done as an IR->IR transform, to get something working quickly. This was never the correct layer and it was obviously wrong when export tables were generated further down in the back end.
This change moves import table generation to the same place as export table generation. We now record things that need import tables at the point where we generate the load and then emit them at the end.
A few tests are updated because the later expansion changes the order in which import tables are emitted or the register used for the loads.
Aside from the aesthetic improvements, this comes with the following benefits: