This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
exceptions and cross jump optimization
- To: egcs-bugs at cygnus dot com
- Subject: exceptions and cross jump optimization
- From: ulrich dot kunitz at db dot com
- Date: Mon, 1 Jun 1998 18:15:44 +0100
Following programm gives different output if compiled with -O0 or -O1.
/* cross jump optimization bug */
#include <stdio.h>
#include <string.h>
class A {
public:
virtual void throw_exception();
void xxx(char * sz);
};
void A::throw_exception() { throw 1; }
void A::xxx(char * sz) {
if (strcmp(sz, "xxx") == 0) {
try {
throw_exception();
return;
}
catch (int n) { }
}
else {
throw_exception();
return;
}
}
int main(void) {
A a;
int fOk = 1;
try {
a.xxx("xxx");
}
catch (int n) {
fOk = 0;
}
printf(fOk != 0 ? "Ok\n" : "Wrong\n");
}
Following patch proves that this is cross jump optimization problem:
--- gcc/jump.c.orig Sun May 31 22:18:18 1998
+++ gcc/jump.c Mon Jun 1 02:11:30 1998
@@ -148,6 +148,8 @@
int max_uid = 0;
rtx last_insn;
+ /* Following code line switches cross jump optimization off. */
+ cross_jump = 0;
cross_jump_death_matters = (cross_jump == 2);
I've been discussing the problem with Martin Loewis
(martin@mira.isdn.cs.tu-berlin.de).
He didn't like to use in_same_eh_region() in find_cross_jump() because the
function
returns always false in the first optimizer passes. Jump cross
optimizations isn't done in
that passes, so maybe it isn't such a bad idea.
Ciao, Uli Kunitz