Commit graph

20 commits

Author SHA1 Message Date
Quentin Carbonneaux
43967b6306 use assert for ssa invariants in fold/copy 2016-04-19 11:07:54 -04:00
Quentin Carbonneaux
f5c4f9b76f rename only live phi arguments in fold
AFL found that.
2016-04-19 10:53:35 -04:00
Quentin Carbonneaux
47a0556a16 compute dead phi args correctly in fold
The code computing if "the" edge of a phi
argument is live or dead was wrong. AFL
found that.
2016-04-17 21:01:49 -04:00
Quentin Carbonneaux
4be9d2b559 cosmetic modification in fold 2016-04-12 14:51:50 -04:00
Quentin Carbonneaux
eb3a5b4457 simplify latmerge() 2016-04-12 14:51:50 -04:00
Quentin Carbonneaux
861bb7c534 the lattice merge has to be used in update() 2016-04-12 14:51:50 -04:00
Quentin Carbonneaux
e562f219cf oops, dumb bug in folding 2016-04-12 14:51:50 -04:00
Quentin Carbonneaux
b58fdfec9d diagnose some undefined uses 2016-04-12 10:24:00 -04:00
Quentin Carbonneaux
3a3c88532c this can be false
I think I should check for Top when rewriting.
Because for sure, we don't want to replace some
temporary by Top, first, I can't represent it,
and second, it'd mean that it is a temporary
used undefined.

The example that triggered the assertion was like
that:

@b0
  jnz 1, @b1, @b3
@b1
  %x =w phi @b0 10, @b2 %x1
  jnz %x, @b2, @b3
@b2
  %x1 =w sub %x, 1
  jmp @b1
@b3
  %x2 =w phi @b1 %x, @b0 42

So SCCP optimistically assumes %x is 10 when it goes
through @b1, then at the branch, @b1->@b3 is left for
dead.  After that, @b2 is processed and the flow
worklist is empty.  Now uses are processed, %x2 will
get processed regardless if its block is dead or not
(it is at that time), then all the back-edges are dead
so the phi is set to the lattice merge of tops only.
BOOM!

This leads to the question, should phis of dead blocks
be processed?  I'll check that later.
2016-04-09 22:22:44 -04:00
Quentin Carbonneaux
d8770d112b fix wrong assertion in fold 2016-04-09 14:31:42 -04:00
Quentin Carbonneaux
71e6fa0b30 oops, forgot to patch phi arguments 2016-04-09 14:31:23 -04:00
Quentin Carbonneaux
a8fc696052 more debug tweaks in fold 2016-04-09 14:22:25 -04:00
Quentin Carbonneaux
1e0f18e908 add a proper block deletion routine 2016-04-09 14:21:56 -04:00
Quentin Carbonneaux
081360df6a nicer debug info 2016-04-09 09:38:20 -04:00
Quentin Carbonneaux
717524d4a3 quickly hack fold rewriting 2016-04-09 09:32:22 -04:00
Quentin Carbonneaux
554ba694ab use cast in czero() 2016-04-07 20:31:33 -04:00
Quentin Carbonneaux
9294295bb5 inline latmerge() (cross fingers) 2016-04-07 14:48:21 -04:00
Quentin Carbonneaux
03083f653d adjustments in sccp 2016-04-07 14:43:02 -04:00
Quentin Carbonneaux
ebcc123e4d add boring folding code 2016-04-07 13:21:15 -04:00
Quentin Carbonneaux
45f3493777 start work on constant propagation 2016-04-06 20:59:07 -04:00