Discussion:
Question about dce
Peter Kuschnerus
2014-04-07 17:03:42 UTC
Permalink
Hi,

I am reading the code of dce in module regs.c

This code scans the trees for assign to temps
and if that temp is not used further,
that assign is deleted.

My question is now:
Is it thue that this operation is only done on temps
and not on local variable and not on local struct.


Regards
Peter Kuschnerus
Anders Magnusson
2014-04-07 17:41:15 UTC
Permalink
Hi Peter,
Post by Peter Kuschnerus
Hi,
I am reading the code of dce in module regs.c
This code scans the trees for assign to temps
and if that temp is not used further,
that assign is deleted.
Is it thue that this operation is only done on temps
and not on local variable and not on local struct.
all automatic variables not declared volatile are called TEMPs internally.
This means that all autos are subject to dce. Exceptions are targets
where some autos
must be handled special, for example long double on amd64 (which uses
the x87
floating point stack machine).char

Currently all structs are stored in memory, which includes automatic
structs.
This means that no structs are eliminated, and not assignments to their
values either.

Example:

int x()
{
int f; // will be removed
char *c = "burkmat"; // will be removed
struct proc p; // will not be removed

f = *c; // will be removed
p.pid = 72; // will not be removed
}

-- Ragge
Peter Kuschnerus
2014-04-08 07:39:43 UTC
Permalink
Post by Anders Magnusson
This means that no structs are eliminated, and not assignments to their
values either.
But then the only assignmentoperaion this dce is subject on
is ASSIGN and not STASG.

But in subroutine deldead line 1361
and subroutine unionize line 1503
there is written
if (asgop(o) ....

IMHO that should be better written as
if (o == ASSIGN ....


Regards
Peter Kuschnerus
Anders Magnusson
2014-04-08 12:42:18 UTC
Permalink
Post by Peter Kuschnerus
Post by Anders Magnusson
This means that no structs are eliminated, and not assignments to their
values either.
But then the only assignmentoperaion this dce is subject on
is ASSIGN and not STASG.
Right now, yes, but I plan to extend it to structs as well, just haven't
implemented it.
This will solve a bunch of other problems when it gets done.

-- Ragge
Peter Kuschnerus
2014-04-09 07:30:47 UTC
Permalink
Post by Anders Magnusson
Right now, yes, but I plan to extend it to structs as well, just haven't
implemented it.
This will solve a bunch of other problems when it gets done.
The reason I am discussing dce is,
I had some unexpected implication with dce:

In module match.c at line 758: #ifdef mach_pdp11
A special feature for arch pdp11.
It allows to use STASG with pointer instead of oreg.
I found this feature also useful for me.

I changed that #ifdef and used this feature.
The table entry for STASG I changed accordingly.
And in clocal a handling of STASG in the same way as in pdp11 is done.

Then this worked well.
I liked this feature, because it fits well to my arch.
I would suggest to make this feature usable for any arch
by changing this #ifdef to a value that may be defined in macdefs.h


But when I apply dce to this feature, it seems to be confused.
Because while p->n_op is STASG, then p->n_left->n_op is TEMP.
The STASG is eliminated by dce erroneously.

I solved this tentatively in module regs.c in function deldead
by changing
if (asgop(p->n_op) ...
to
if (p->n->op == ASSIGN ...
so dce works only on ASSIGN and not on STASG.

I assume that this isue is also in arch pdp11.


I would suggest to consider this also when dce is extended.


Regards
Peter Kuschnerus

Loading...