This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

bounds checking for egcs


Hello,

Richard Jones and I want to make our bounds-checking code patch available
to egcs. The latest patch for egcs-1.1a can be found at:

"http://web.inter.NL.net/hcc/Haj.Ten.Brugge/bounds-checking-egcs-1.1a-1.00.tar.gz"

At this location also the patch for gcc-2.8.1 and egcs-1.0.3a is present. I
had some small problems with including this patch into egcs. I had to disable
some code to let bounds checking work correctly.

The first problem was that deconstructors are not called on exit of a
function in all places where a function could return. To fix this I made
the following patch:

diff -rup egcs-1.1a.org/gcc/jump.c egcs-1.1a/gcc/jump.c
--- egcs-1.1a.org/gcc/jump.c    Tue Jul 21 06:03:40 1998
+++ egcs-1.1a/gcc/jump.c        Sun Sep  6 13:41:44 1998
@@ -2460,7 +2460,7 @@ duplicate_loop_exit_test (loop_start)
              || NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_CONT)
            return 0;

-         if (optimize < 2
+         if ((bounds_checking_enabled || optimize < 2) /* FIXME */
              && (NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_BEG
                  || NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_END))
            /* If we were to duplicate this code, we would not move
diff -rup egcs-1.1a.org/gcc/stmt.c egcs-1.1a/gcc/stmt.c
--- egcs-1.1a.org/gcc/stmt.c    Mon Jul 13 23:21:01 1998
+++ egcs-1.1a/gcc/stmt.c        Sun Sep  6 13:41:33 1998
@@ -1968,7 +1969,7 @@ expand_end_loop ()
        {
          if (GET_CODE (insn) == NOTE)
            {
-             if (optimize < 2
+             if ((bounds_checking_enabled || optimize < 2) /* FIXME */
                  && (NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_BEG
                      || NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_END))
                /* The code that actually moves the exit test will

I also had some problem with loop optimizing code. Some registers are moved
when they should not have been moved. The patch for this is:

diff -rup egcs-1.1a.org/gcc/loop.c egcs-1.1a/gcc/loop.c
--- egcs-1.1a.org/gcc/loop.c    Sat Aug 15 01:32:19 1998
+++ egcs-1.1a/gcc/loop.c        Sun Sep  6 13:41:52 1998
@@ -793,6 +793,11 @@ scan_loop (loop_start, end, nregs, unrol
                 before it is set just like a user-variable).
             (3) the set is guaranteed to be executed once the loop starts,
                 and the reg is not used until after that.  */
+         else if (bounds_checking_enabled      /* FIXME */
+                  && (loop_reg_used_before_p (set, p, loop_start,
+                                              scan_start, end)
+                      || !reg_in_basic_block_p (p, SET_DEST (set))))
+               ;
          else if (! ((! maybe_never
                       && ! loop_reg_used_before_p (set, p, loop_start,
                                                    scan_start, end))

I can not find anything wrong with our bounds-checking patch. I did not
have to make these patches for egcs-1.0.3a and gcc-2.8.1. So they are
probably needed because something changed that should be fixed when using
bounds checking.
All the patches above are include in bounds-checking-egcs-1.1a-1.00.tar.gz

I tested the patches with the gcc.c-torture tests. Some tests failed
because they did illegal things. Some are accessing arrays outside valid
boundary and some others do illegal pointer arithmetic. I could not find
any serious problem with these tests.
I tested the egcs-1.1a patch only on redhat version 5.0 on a i686 platform.
I will do some more testing on other platforms next week but I don't expect
any serious problems.
I am using the bounds-checking patches since 1995 on various platforms.
See also the file 'egcs/gcc/bounds/MACHINES'.

	Herman.

-- 
-------------------------------------------------------------------------
Herman ten Brugge			Email:	Haj.Ten.Brugge@net.HCC.nl
Richard Jones				Email:  rjones@orchestream.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]