Bug 12739 - [3.4 Regression] gcj emits dead bytecode
Summary: [3.4 Regression] gcj emits dead bytecode
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 3.4.0
Assignee: Jeff Sturm
URL:
Keywords: missed-optimization, patch
Depends on:
Blocks:
 
Reported: 2003-10-23 03:26 UTC by Jeff Sturm
Modified: 2004-01-17 04:22 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-10-27 18:05:55


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Sturm 2003-10-23 03:26:25 UTC
For the test case:

class T {
  int t() { try { return 0; } finally { } }
}

Compare the bytecode created with 3.2.2:

Method name:"t" Signature: 6=()int
Attribute "Code", length:26, max_stack:1, max_locals:1, code_length:2
  0: iconst_0
  1: ireturn

vs. current CVS:

Method name:"t" Signature: 6=()int
Attribute "Code", length:48, max_stack:2, max_locals:4, code_length:16
  0: iconst_0
  1: istore_1
  2: jsr 13
  5: iload_1
  6: ireturn
  7: astore_3
  8: jsr 13
 11: aload_3
 12: athrow
 13: astore_2
 14: ret 2
Exceptions (count: 1):
  start: 0, end: 7, handler: 7, type: 0 /* finally */

Probably caused by:

2003-09-03  Jeff Sturm  <jsturm@one-point.com>
        * parse.y: Include cgraph.h.
        (block): Don't special-case empty block production.
Comment 1 Jeff Sturm 2003-10-23 03:28:29 UTC
Forgot to mention: this is a 3.4 regression, though we are no worse off than
javac (which doesn't strip the useless try/finally).
Comment 2 Andrew Pinski 2003-10-23 03:33:42 UTC
Forgot to mention I can confirm this on the mainline (20031022).
Comment 4 GCC Commits 2003-11-18 03:42:33 UTC
Subject: Bug 12739

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	jsturm@gcc.gnu.org	2003-11-18 03:42:30

Modified files:
	gcc/java       : ChangeLog java-tree.h parse.y 

Log message:
	Fix PR java/12739.
	* java-tree.h (BLOCK_EMPTY_P): Define.
	* parse.y (java_complete_lhs): Check for empty blocks
	in TRY_FINALLY_EXPR case.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/ChangeLog.diff?cvsroot=gcc&r1=1.1293&r2=1.1294
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/java-tree.h.diff?cvsroot=gcc&r1=1.187&r2=1.188
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/parse.y.diff?cvsroot=gcc&r1=1.455&r2=1.456

Comment 5 Jeff Sturm 2003-11-18 03:53:38 UTC
Patch applied.