Skip to content

Add a reference_guess pass #53

@r41k0u

Description

@r41k0u

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 = i

And 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestwishlistStuff we want but there are more important things

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions