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 /util.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 'util.c')
-rw-r--r-- | util.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/util.c b/util.c index 8432b5a..8997f6c 100644 --- a/util.c +++ b/util.c @@ -361,7 +361,7 @@ newcon(Con *c0, Fn *fn) Con *c1; int i; - for (i=0; i<fn->ncon; i++) { + for (i=1; i<fn->ncon; i++) { c1 = &fn->con[i]; if (c0->type == c1->type && symeq(c0->sym, c1->sym) @@ -378,8 +378,9 @@ getcon(int64_t val, Fn *fn) { int c; - for (c=0; c<fn->ncon; c++) - if (fn->con[c].type == CBits && fn->con[c].bits.i == val) + for (c=1; c<fn->ncon; c++) + if (fn->con[c].type == CBits + && fn->con[c].bits.i == val) return CON(c); vgrow(&fn->con, ++fn->ncon); fn->con[c] = (Con){.type = CBits, .bits.i = val}; |