From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26527 invoked by alias); 2 Dec 2003 20:21:35 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 26498 invoked from network); 2 Dec 2003 20:21:34 -0000 Received: from unknown (HELO hawaii.kealia.com) (209.3.10.89) by sources.redhat.com with SMTP; 2 Dec 2003 20:21:34 -0000 Received: by hawaii.kealia.com (Postfix, from userid 2049) id EB04DC6B2; Tue, 2 Dec 2003 12:21:33 -0800 (PST) To: Geoff Keating Cc: gcc mailing list Subject: Re: Should -fcross-jumping be part of -O1? References: <3FC0DCD0.9000106@coyotegulch.com> <20031123162248.GA336@atrey.karlin.mff.cuni.cz> <3FC0EC7E.7070800@coyotegulch.com> <20031123173321.GO15575@kam.mff.cuni.cz> <3FC0F7A6.4010103@coyotegulch.com> <20031123181903.GW15575@kam.mff.cuni.cz> <3FC11F13.2090708@coyotegulch.com> <877k1fmxr4.fsf@egil.codesourcery.com> From: David Carlton Date: Tue, 02 Dec 2003 20:36:00 -0000 In-Reply-To: (Geoff Keating's message of "02 Dec 2003 11:48:30 -0800") Message-ID: User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Rational FORTRAN, linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-12/txt/msg00190.txt.bz2 On 02 Dec 2003 11:48:30 -0800, Geoff Keating said: > David Carlton writes: >> This is obviously a very special case, but dead code elimination >> sometimes makes it difficult to write tests for GDB's test suite. And >> even when working on real programs I occasionally insert dead code as >> a place where I can set breakpoints. So, personally, I'd prefer that >> -O0 be pretty stupid. (Though I don't mind if it's not the default.) > I thought that the dead code elimination at -O0 is supposed to work > properly with GDB: it puts in a 'nop' that the breakpoint can target. > Is this not working? Not always. I went and dug up the original thread, and trimmed the resulting program a little bit. Compile the program after my signature (using gcc -g -O0; I've seen this on stock GCC 3.1 and on Red Hat's 3.2, though I haven't tried more recent GCC's), and run gdb on it, and do 'break main' and then 'run': it skips everything until the call to 'wack_struct_1'. And looking at the assembly code, 'main' is a lot shorter than I would wish. David Carlton carlton@kealia.com /* Check that GDB can correctly update a value, living in a register, in the target. This pretty much relies on the compiler taking heed of requests for values to be stored in registers. */ static char add_char (register char u, register char v) { return u + v; } static short add_short (register short u, register short v) { return u + v; } static int add_int (register int u, register int v) { return u + v; } static long add_long (register long u, register long v) { return u + v; } static float add_float (register float u, register float v) { return u + v; } static double add_double (register double u, register double v) { return u + v; } /* */ static char wack_char (register char u, register char v) { register char l = u; l = add_char (l, v); return l; } static short wack_short (register short u, register short v) { register short l = u; l = add_short (l, v); return l; } static int wack_int (register int u, register int v) { register int l = u; l = add_int (l, v); return l; } static long wack_long (register long u, register long v) { register long l = u; l = add_long (l, v); return l; } static float wack_float (register float u, register float v) { register float l = u; l = add_float (l, v); return l; } static double wack_double (register double u, register double v) { register double l = u; l = add_double (l, v); return l; } struct s_1 { short s[1]; } z_1, s_1; static struct s_1 add_struct_1 (struct s_1 s) { int i; for (i = 0; i < sizeof (s) / sizeof (s.s[0]); i++) { s.s[i] = s.s[i] + s.s[i]; } return s; } static struct s_1 wack_struct_1 (void) { int i; register struct s_1 u = z_1; for (i = 0; i < sizeof (s_1) / sizeof (s_1.s[0]); i++) { s_1.s[i] = i + 1; } u = add_struct_1 (u); return u; } int main () { /* These calls are for current frame test. */ wack_char (1, 2); wack_short (1, 2); wack_int (1, 2); wack_long (1, 2); wack_float (1, 2); wack_double (1, 2); /* These calls are for up frame. */ wack_char (1, 2); wack_short (1, 2); wack_int (1, 2); wack_long (1, 2); wack_float (1, 2); wack_double (1, 2); /* These calls are for current frame test. */ wack_struct_1 (); return 0; }