ack/util
George Koehler f26259caac Check AAR earlier to prevent LOI/STI unknown size.
In ego, the CS phase may convert a LAR/SAR to AAR LOI/STI so it can
optimize multiple occurrences of AAR of the same array element.  This
conversion should not happen if it would LOI/STI a large or unknown
size.

cs_profit.c okay_lines() checked the size of each occurrence of AAR
except the first.  If the first AAR was the implicit AAR in a LAR/SAR,
then the conversion happened without checking the size.  For unknown
size, this made a bad LOI -1 or STI -1.  Fix by checking the size
earlier: if a LAR/SAR has a bad size, then don't enter it as an AAR.

This Modula-2 code showed the bug.  Given M.def:

    DEFINITION MODULE M;
    TYPE S = SET OF [0..95];
    PROCEDURE F(a: ARRAY OF S; i, j: INTEGER);
    END M.

and M.mod:

    (*$R-*) IMPLEMENTATION MODULE M;
    FROM SYSTEM IMPORT ADDRESS, ADR;
    PROCEDURE G(s: S; p, q: ADDRESS; t: S); BEGIN
      s := s; p := p; q := q; t := t;
    END G;
    PROCEDURE F(a: ARRAY OF S; i, j: INTEGER); BEGIN
      G(a[i + j], ADR(a[i + j]), ADR(a[i + j]), a[i + j])
    END F;
    END M.

then the bug caused an error:

    $ ack -mlinuxppc -O3 -c.e M.mod
    /tmp/Ack_b357d.g, line 57: Argument range error

The bug had put LOI -1 in the code, then em_decode got an error
because -1 is out of range for LOI.

Procedure F has 4 occurrences of `a[i + j]`.  The size of `a[i + j]`
is 96 bits, or 12 bytes, but the EM code hides the size in an array
descriptor, so the size is unknown to CS.  The pragma `(*$R-*)`
disables a range check on `i + j` so CS can work.  EM uses AAR for the
2 `ADR(a[i + j])` and LAR for the other 2 `a[i + j]`.  EM pushes the
arguments to G in reverse order, so the last `a[i + j]` in Modula-2 is
the first LAR in EM.

CS found 4 occurrences of AAR.  The first AAR was an implicit AAR in
LAR.  Because of the bug, CS converted this LAR 4 to AAR 4 LOI -1.
2018-03-02 16:06:21 -05:00
..
ack strcmp, strncmp are in <string.h> 2017-11-14 17:35:35 -05:00
amisc Rename RELOLIS to RELOPPC_LIS. 2017-10-18 15:39:31 -04:00
arch Stop using mktemp() --- on Haiku, it always generates the same filenames, 2017-08-06 13:22:05 +02:00
ass Distributions are a pain --- let's not bother any more. Instead, we just tag 2016-09-02 23:00:38 +02:00
build Run all tests, even the ones which fail, and emit a test summary right at the 2016-12-01 23:03:30 +01:00
byacc Stop using mktemp() --- on Haiku, it always generates the same filenames, 2017-08-06 13:22:05 +02:00
ceg Distributions are a pain --- let's not bother any more. Instead, we just tag 2016-09-02 23:00:38 +02:00
cgg Distributions are a pain --- let's not bother any more. Instead, we just tag 2016-09-02 23:00:38 +02:00
cmisc Check each format string in tabgen.c 2017-11-13 20:59:03 -05:00
cpp Distributions are a pain --- let's not bother any more. Instead, we just tag 2016-09-02 23:00:38 +02:00
ego Check AAR earlier to prevent LOI/STI unknown size. 2018-03-02 16:06:21 -05:00
flex Stop using mktemp() --- on Haiku, it always generates the same filenames, 2017-08-06 13:22:05 +02:00
grind Distributions are a pain --- let's not bother any more. Instead, we just tag 2016-09-02 23:00:38 +02:00
int Distributions are a pain --- let's not bother any more. Instead, we just tag 2016-09-02 23:00:38 +02:00
led Delete old "assert.h" files; use libc <assert.h>. 2017-11-09 22:22:13 -05:00
LLgen Merge pull request #69 from kernigh/kernigh-stdc 2017-11-19 12:00:40 +01:00
make Distributions are a pain --- let's not bother any more. Instead, we just tag 2016-09-02 23:00:38 +02:00
mcgg Restore an assignment deleted in commit 789f79b. 2017-11-07 23:52:52 -05:00
misc Use <stdarg.h> in util/misc/convert.c 2017-12-06 17:09:12 -05:00
ncgg strcmp, strncmp are in <string.h> 2017-11-14 17:35:35 -05:00
opt Delete old "assert.h" files; use libc <assert.h>. 2017-11-09 22:22:13 -05:00
shf Distributions are a pain --- let's not bother any more. Instead, we just tag 2016-09-02 23:00:38 +02:00
topgen strcmp, strncmp are in <string.h> 2017-11-14 17:35:35 -05:00