diff options
author | Quentin Carbonneaux <quentin@c9x.me> | 2022-12-18 17:35:19 +0100 |
---|---|---|
committer | Quentin Carbonneaux <quentin@c9x.me> | 2022-12-25 16:37:33 +0100 |
commit | 5e9726946dcb9248dbd34ded1bdd4f7af8dc2d31 (patch) | |
tree | 9842f9837784911e386357af18b08a2ca1b69896 /copy.c | |
parent | c5cd65261e05029889450ca27050785504164853 (diff) | |
download | roux-5e9726946dcb9248dbd34ded1bdd4f7af8dc2d31.tar.gz |
new UNDEF Ref
Crashing loads of uninitialized memory proved to be a problem when implementing unions using qbe. This patch introduces a new UNDEF Ref to represent data that is known to be uninitialized. Optimization passes can make use of it to eliminate some code. In the last compilation stages, UNDEF is treated as the constant 0xdeaddead.
Diffstat (limited to 'copy.c')
-rw-r--r-- | copy.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/copy.c b/copy.c index 1f9e1f3..77a8f06 100644 --- a/copy.c +++ b/copy.c @@ -125,7 +125,7 @@ subst(Ref *pr, Ref *cpy) *pr = copyof(*pr, cpy); } -/* requires use and rpo, breaks use */ +/* requires use and dom, breaks use */ void copy(Fn *fn) { @@ -155,12 +155,16 @@ copy(Fn *fn) for (a=0; a<p->narg; a++) if (p->blk[a]->id < n) { r1 = copyof(p->arg[a], cpy); - if (req(r, R) || req(r1, r)) + if (req(r, R) || req(r, UNDEF)) + r = r1; + if (req(r1, r) || req(r1, UNDEF)) eq++; - r = r1; } assert(!req(r, R)); - if (eq == p->narg) + if (rtype(r) == RTmp + && !dom(fn->rpo[fn->tmp[r.val].bid], b)) + cpy[p->to.val] = p->to; + else if (eq == p->narg) cpy[p->to.val] = r; else { cpy[p->to.val] = p->to; |