[tree-ssa libmudflap] alloca fix, new tests

Frank Ch. Eigler fche@redhat.com
Mon Sep 30 08:13:00 GMT 2002


Hi -

The following patch adds some more tests and a fix to the libmudflap
alloca emulation code.  The new tests exercise bitfield instrumentation,
and builtin alloca calls, both of which have a problem (with pending fixes).


+2002-09-30  Frank Ch. Eigler  <fche@redhat.com>
+
+	* test/pass21-frag.c, pass22-frag.c: New tests: alloca, bitfields.
+	* Makefile.am, Makefile.in: Run new tests.
+	* mf-hooks.c (alloca): Correct stack direction logic.

Index: Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/Attic/Makefile.am,v
retrieving revision 1.1.2.12
diff -u -w -s -r1.1.2.12 Makefile.am
--- Makefile.am	20 Sep 2002 17:53:24 -0000	1.1.2.12
+++ Makefile.am	30 Sep 2002 15:08:04 -0000
@@ -16,7 +16,8 @@
  test/pass1.x test/pass2.x test/pass3.x test/pass4.x test/pass5.x \
  test/pass6.x test/pass7.x test/pass8.x test/pass9.x test/pass10.x \
  test/pass11.x test/pass12.x test/pass13.x test/pass14.x test/pass15.x \
- test/pass16.x test/pass17.x test/pass18.x test/pass19.x test/pass20.x
+ test/pass16.x test/pass17.x test/pass18.x test/pass19.x test/pass20.x \
+ test/pass21.x test/pass22.x
 
 test/%.c: test/%-frag.c test/mf-driver.c
 	@mkdir -p test

Index: mf-hooks.c
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/Attic/mf-hooks.c,v
retrieving revision 1.1.2.15
diff -u -r1.1.2.15 mf-hooks.c
--- mf-hooks.c	16 Sep 2002 14:49:57 -0000	1.1.2.15
+++ mf-hooks.c	30 Sep 2002 15:11:55 -0000
@@ -309,9 +309,9 @@
 
   /* Free any previously alloca'd blocks that belong to deeper-nested functions,
      which must therefore have exited by now.  */
-#define INNER_THAN < /* for x86 */
+#define DEEPER_THAN < /* for x86 */
   while (alloca_history &&
-	 ((uintptr_t) stack INNER_THAN (uintptr_t) alloca_history->stack))
+	 ((uintptr_t) alloca_history->stack DEEPER_THAN (uintptr_t) stack))
     {
       struct alloca_tracking *next = alloca_history->next;
       CALL_WRAP (free, alloca_history->ptr);
Index: test/pass21-frag.c
===================================================================
RCS file: test/pass21-frag.c
diff -N test/pass21-frag.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ test/pass21-frag.c	30 Sep 2002 15:08:04 -0000
@@ -0,0 +1,5 @@
+char *boo, *foo;
+boo = alloca (100);
+boo[99] = 'a';
+foo = __builtin_alloca (200);
+foo[44] = 'b';
Index: test/pass22-frag.c
===================================================================
RCS file: test/pass22-frag.c
diff -N test/pass22-frag.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ test/pass22-frag.c	30 Sep 2002 15:08:04 -0000
@@ -0,0 +1,16 @@
+struct foo {
+  unsigned base:8;
+  unsigned flag1:1;
+  unsigned flag2:3;
+  unsigned flag3:4;
+  char nothing[0];
+};
+
+#define offsetof(TYPE, MEMBER)	((size_t) &((TYPE *) 0)->MEMBER)
+
+struct foo* f = (void *) malloc (offsetof (struct foo, nothing));
+f->base = 1;
+f->flag1 = 1;
+free (f);
+
+



More information about the Gcc-patches mailing list