Possible patch for miscompiled defer-pops

Per Bothner per@bothner.com
Mon Apr 30 00:24:00 GMT 2001

People have reported problems compiling Java code with -O2 - see
PR java/1412 and my message today ("please try this Java test program").
When I compiled the test program in 1412 with -da, the dumped rtl
looked wrong even starting with the earliest PropertiesTest.java.00.rtl
dump (i.e. before optimization passes).  It also looked like the
problem was not the loop itself, but the continue jump to the exit
label.  So I looked at the LABELED_BLOCK_EXPR case in expand_expr,
which Java uses for exitable-blocks.  It didn't seem obviously wrong
to me when compiled to some other code.  However, after some more
greping through the code, it looked like do_pending_stack_adjust
might be a reasonable thing to try.  And it seems to work!

However, I have no idea if this actually *is* the correct fix,
since I do not know the protocol for dealing with deferred
pops in the middle-end.  As this is a critical bug for Java, and
we need a solution before gcc 3.0, I'm hoping a back-end expert
will take a look.

2001-04-30  Per Bothner  <per@bothner.com>

	* expr.c (expand_expr):  When compiling LABELED_BLOCK_EXPR,
	call do_pending_stack_adjust before emiting label.

Index: expr.c
RCS file: /cvs/gcc/gcc/gcc/expr.c,v
retrieving revision
diff -u -p -r1.295.2.5 expr.c
--- expr.c	2001/04/14 03:32:47
+++ expr.c	2001/04/30 06:54:12
@@ -6495,6 +6495,7 @@ expand_expr (exp, target, tmode, modifie
       if (LABELED_BLOCK_BODY (exp))
 	expand_expr_stmt (LABELED_BLOCK_BODY (exp));
+      do_pending_stack_adjust ();
       emit_label (label_rtx (LABELED_BLOCK_LABEL (exp)));
       return const0_rtx;

	--Per Bothner
per@bothner.com   http://www.bothner.com/~per/

More information about the Java mailing list