From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2700 invoked by alias); 3 Apr 2004 14:17:34 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 2693 invoked from network); 3 Apr 2004 14:17:33 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 3 Apr 2004 14:17:33 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i33EHXjj025902 for ; Sat, 3 Apr 2004 09:17:33 -0500 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i33EHWj00531; Sat, 3 Apr 2004 09:17:32 -0500 Received: from localhost.localdomain (vpn50-1.rdu.redhat.com [172.16.50.1]) by pobox.corp.redhat.com (8.12.8/8.12.8) with ESMTP id i33EHWnM009388; Sat, 3 Apr 2004 09:17:32 -0500 Received: from saguaro (saguaro.lan [192.168.64.2]) by localhost.localdomain (8.12.10/8.12.10) with SMTP id i33EHQOR022884; Sat, 3 Apr 2004 07:17:26 -0700 Date: Sat, 03 Apr 2004 14:17:00 -0000 From: Kevin Buettner To: Jim Blandy Cc: gdb-patches@sources.redhat.com, Joel Brobecker Subject: Re: [RFA] Fix small problems in rs6000-tdep.c:skip_prologue() Message-Id: <20040403071726.60159025@saguaro> In-Reply-To: References: <20040402183637.GC871@gnat.com> Organization: Red Hat Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-SW-Source: 2004-04/txt/msg00094.txt.bz2 On 02 Apr 2004 16:14:16 -0500 Jim Blandy wrote: > Joel Brobecker writes: > > > The second problem is with the following instruction: "stw r0,28(r31)". > > The prologue analyzer tags this instruction as being part of the > > prologue, but this is incorrect, I believe. According to the PPC > > ABI document I have, only r3 to r10 are used for parameter passing: > > > > For PowerPC, up to eight words are passed in general purpose > > registers, loaded sequentially into general purpose registers r3 > > through r10. > > > > Unfortunately, skip_prologue() detects the "stw Rx, NUM(R31)" sequence, > > but forgot to check the register number. Here, it's the scratch register > > zero, so the instruction should not be considered part of the prologue > > either. > > Here's a prologue I saw recently where an 'stX r0, NUM(r31)' really is > part of the prologue: > > .align 2 > .globl arg_passing_test2 > .type arg_passing_test2, @function > arg_passing_test2: > .LFB107: > .loc 1 62 0 > stwu 1,-64(1) > .LCFI11: > stw 31,60(1) > .LCFI12: > mr 31,1 > .LCFI13: > mr 0,3 > evstdd 4,16(31) > stw 5,24(31) > stw 7,32(31) > stw 8,36(31) > stw 9,40(31) > stb 0,8(31) > lwz 11,0(1) > lwz 31,-4(11) > mr 1,11 > blr > .LFE107: > .size arg_passing_test2, .-arg_passing_test2 > > In this case, the stX 0,N(31) is spilling an argument, even though r0 > is not an argument register. ('evstdd' is an E500 instruction that > is definitely an argument spill.) Do you have any idea why the compiler chose to arrange the code this way? Why couldn't it have just done "stb 3, 8(31)" and ommitted the "mr 0, 3" altogether? > Clearly, both your function and mine need to go into the test suite... > > What if we did something like this? It'd need to be combined with the > rest of your change, I'm just sketching: > > *** rs6000-tdep.c.~1.191.~ 2004-03-29 16:45:15.000000000 -0500 > --- rs6000-tdep.c 2004-04-02 16:11:26.000000000 -0500 > *************** > *** 441,446 **** > --- 441,447 ---- > int minimal_toc_loaded = 0; > int prev_insn_was_prologue_insn = 1; > int num_skip_non_prologue_insns = 0; > + int r0_contains_argument = 0; > const struct bfd_arch_info *arch_info = gdbarch_bfd_arch_info (current_gdbarch); > struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); > > *************** > *** 509,519 **** > --- 510,524 ---- > ones. */ > if (lr_reg < 0) > lr_reg = (op & 0x03e00000); > + if (lr_reg == 0) > + r0_contains_argument = 0; This special casing of r0 bothers me. In your example above, what's to prevent the compiler from using some other scratch register, e.g. r11 or r12? If it starts doing so, do we add more state variables to record this fact? Kevin