diff options
author | Michael Forney <mforney@mforney.org> | 2019-07-02 20:32:09 -0700 |
---|---|---|
committer | Quentin Carbonneaux <quentin@c9x.me> | 2021-11-10 23:08:53 +0100 |
commit | 6838496e5c990339755577eb16b949fe2f47790e (patch) | |
tree | 91e13641873c6133b0540916ea1fd9f1fd5ee9ad /fold.c | |
parent | ae8803cbe655f64a2ef1739c8dfc5c12af99bdfb (diff) | |
download | roux-6838496e5c990339755577eb16b949fe2f47790e.tar.gz |
fold: Don't fold invalid addition/subtraction rather than failing
This may happen in a branch QBE doesn't realize is unreachable, for example (simplified from real code found in ncurses) data $str = { b "abcdef", b 0 } function l $f(w %x) { @start %.1 =w ceqw %x, 0 jnz %.1, @logic_join, @logic_right @logic_right %p =l call $strchr(l $str, w %x) %.2 =w ceql %p, 0 @logic_join %.3 =w phi @start %.1, @logic_right %.2 jnz %.3, @fail, @return @fail ret 0 @return %.4 =l sub %p, $str ret %.4 }
Diffstat (limited to 'fold.c')
-rw-r--r-- | fold.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/fold.c b/fold.c index 2081a72..5c09469 100644 --- a/fold.c +++ b/fold.c @@ -343,7 +343,7 @@ foldint(Con *res, int op, int w, Con *cl, Con *cr) if (op == Oadd) { if (cl->type == CAddr) { if (cr->type == CAddr) - err("undefined addition (addr + addr)"); + return 1; lab = cl->label; typ = CAddr; } @@ -358,10 +358,10 @@ foldint(Con *res, int op, int w, Con *cl, Con *cr) lab = cl->label; typ = CAddr; } else if (cl->label != cr->label) - err("undefined substraction (addr1 - addr2)"); + return 1; } else if (cr->type == CAddr) - err("undefined substraction (num - addr)"); + return 1; } else if (cl->type == CAddr || cr->type == CAddr) { if (Ocmpl <= op && op <= Ocmpl1) |