-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Right now, we are allocating stack space for every named variable that is assigned a value - the amount of space allocated and the type is determined by the RHS expression.
But in some cases, we might have named variables which only act as references for another named variable.
Something like:
i = map.lookup(0)
j = iAnd throughout the program, we do not encounter a situation where the value of j diverges from that of i.
In this case, we don't need to do the allocation twice.
We need a reference_guess pass which takes in the symbol table and creates sets of named vars within it (all the vars within a set don't diverge their value from others), and each named var within a set is a reference to the same stack space. We can then allocate stack space for each set.
I am unsure if llc will optimize such cases or not (need to check that against the generated BPF bytecode). But if it does not, then this is something worth implementing at a later stage.