Commit graph

18 commits

Author SHA1 Message Date
Quentin Carbonneaux
bd7a73d0ea fix bug in alias analysis
The handling of phi was incorrect
and we would sometimes miss escapes.
We now handle phis at the very end
of the pass to make sure the defs
for their arguments have all been
processed.
2024-03-07 16:40:51 +01:00
Quentin Carbonneaux
26c1c30b7d new blit instruction 2022-12-14 23:18:26 +01:00
Quentin Carbonneaux
c5ea06c136 treat retc as non-escaping
We may well treat all rets as
non-escaping since stack slots
are destroyed upon funcion
return.
2022-12-12 22:36:34 +01:00
Quentin Carbonneaux
cbee74bdb4 use a new struct for symbols
Symbols are a useful abstraction
that occurs in both Con and Alias.
In this patch they get their own
struct. This new struct packages
a symbol name and a type; the type
tells us where the symbol name
must be interpreted (currently, in
gobal memory or in thread-local
storage).

The refactor fixed a bug in
addcon(), proving the value of
packaging symbol names with their
type.
2022-11-22 21:56:21 +01:00
Quentin Carbonneaux
f5007126f3 export getalias()
We will be using it in the new
coalesce() pass.
2022-11-20 22:13:44 +01:00
Quentin Carbonneaux
a70aa044de make multiple calls to fillalias() possible
The asserts (a->type == ABot) made it
impossible to run fillalias() multiple
times. We now reset the Alias.type field
of all temps before starting.

Getting rid of the asserts would have
been another option.
2022-11-20 22:09:12 +01:00
Quentin Carbonneaux
45ab1e5aa3 stored bytes in Alias information
Stack slots may have padding
bytes, and if we want to have
precise liveness information
it's important that we are able
to tell them apart.

This patch extends fillalias()
to remember for every slot
what bytes were ever assigned.
In case the slot address does
not escape we know that only
these bytes matter.

To save space, we only store
this information if the slot
size is less than or equal to
NBit.

The Alias struct was reworked
a bit to save some space. I am
still not very satisfied with
its layout though.
2022-11-20 21:47:11 +01:00
Quentin Carbonneaux
7200606195 argc does not leak its address argument 2022-11-20 21:44:25 +01:00
Quentin Carbonneaux
1f696fed0d make Alias.base an int
We had the invariant that it'd
always be a temporary.
2022-11-20 21:44:25 +01:00
Quentin Carbonneaux
4e90b4210e "rel" fields become "reloc" 2022-10-08 21:48:47 +02:00
Quentin Carbonneaux
2e38c86af6 do not drop relocation kind in alias analysis 2022-10-08 21:48:47 +02:00
Quentin Carbonneaux
cde5f95591 mark phi arguments as escaping
Thanks to Michael Forney for spotting this
oversight and providing the test case.

Note: because esc() leaves ABot unchanged,
the assertion "a->type == ABot" on line 122
remains valid.
2019-02-18 13:56:03 +01:00
Quentin Carbonneaux
a3a1451c5f intern symbol names
Symbols in the source file are still limited in
length because the rest of the code assumes that
strings always fit in NString bytes.

Regardless, there is already a benefit because
comparing/copying symbol names does not require
using strcmp()/strcpy() anymore.
2017-05-17 10:05:28 -04:00
Quentin Carbonneaux
19801b9253 simplify slot logic in alias analysis
The previous code was buggy.  It would put a stack
pointer on the heap when handling "add $foo, 42".
The new code is more straightforward and hopefully
more correct.  Only temporaries with a "stack"
alias class will have a slot pointer.
2017-04-10 09:19:40 -04:00
Quentin Carbonneaux
a35dc8c495 fix pretty bad bug in alias analysis
When a temporary marked local is escaping,
the whole slot must be marked as such.  To
solve this, Alias now holds a pointer to
the alias information of the slot.  For
simplicity of the code, this pointer is
always valid and fetching ->type out of it
is meaningful.
2017-02-24 12:00:38 -05:00
Quentin Carbonneaux
0689986187 propagate aliasing information through copies 2017-02-23 11:19:11 -05:00
Quentin Carbonneaux
7e1c1f9f77 use uint for block ids 2017-02-06 14:36:27 -05:00
Quentin Carbonneaux
8fdea1dd52 implement a simple alias analysis 2016-12-12 22:17:03 -05:00