From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6059 invoked by alias); 23 Apr 2002 02:46:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 6034 invoked by uid 71); 23 Apr 2002 02:46:01 -0000 Resent-Date: 23 Apr 2002 02:46:01 -0000 Resent-Message-ID: <20020423024601.6033.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, Alan Modra Received:(qmail 3143 invoked from network); 23 Apr 2002 02:40:02 -0000 Received: from unknown (HELO mta04ps.bigpond.com) (144.135.25.136) by sources.redhat.com with SMTP; 23 Apr 2002 02:40:02 -0000 Received: from bubble.local ([144.135.25.87]) by mta04ps.bigpond.com (Netscape Messaging Server 4.15) with SMTP id GV022N00.DRK for ; Tue, 23 Apr 2002 12:39:59 +1000 Received: from CPE-144-136-176-14.sa.bigpond.net.au ([144.136.176.14]) by psmam07.mailsvc.email.bigpond.com(MailRouter V3.0j 125/29391); 23 Apr 2002 12:39:59 Received: (qmail 9173 invoked by uid 179); 23 Apr 2002 02:39:59 -0000 Message-Id:<20020423023959.GT31160@bubble.sa.bigpond.net.au> Date: Mon, 22 Apr 2002 19:46:00 -0000 From: Alan Modra To: gcc-gnats@gcc.gnu.org References:<20020422141515.GM31160@bubble.sa.bigpond.net.au> Subject: target/6413: PROFILE_HOOK label_no X-SW-Source: 2002-04/txt/msg01141.txt.bz2 List-Id: >Number: 6413 >Category: target >Synopsis: PROFILE_HOOK label_no >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Mon Apr 22 19:46:00 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Alan Modra >Release: 3.1 20020417 (prerelease) >Organization: IBM >Environment: pa, rs6000 AIX_ABI, sparc targets. >Description: There's an underlying problem with PROFILE_HOOK and it's label_no arg: Inline function rtl generated by PROFILE_HOOK will use the value of profile_label_no when the inline function is defined. For static inline functions, profile_label_no is not incremented, thus a deferred out-of-line expansion typically uses the wrong profile counter label. On pa, it's even worse as the label_no is used to access a local label at the start of the function with a pc-rel offset from the _mcount call. Using the wrong label can generate assembly code that overflows ldo insns. >How-To-Repeat: Attached testcase. Debug session for pa shows the problem. Note how profile_label_no is stuck on 1 for the profile_hook calls on the static inline functions, and increments on the profile_function calls. Breakpoint 4, hppa_profile_hook (label_no=0) at /src/gcc-ppc64-31/gcc/config/pa/pa.c:3535 2: profile_label_no = 0 1: cfun->name = 0x82e1088 "foo" (gdb) c Continuing. Breakpoint 6, profile_function (file=0x4001a500) at /src/gcc-ppc64-31/gcc/final.c:1602 2: profile_label_no = 0 1: cfun->name = 0x82e1088 "foo" (gdb) bt #0 profile_function (file=0x4001a500) at /src/gcc-ppc64-31/gcc/final.c:1602 #1 0x080d9e7b in final_start_function (first=0x4001a500, file=0x82da748, optimize=2) at /src/gcc-ppc64-31/gcc/final.c:1531 #2 0x0817773e in rest_of_compilation (decl=0x40185b60) at /src/gcc-ppc64-31/gcc/toplev.c:3480 #3 0x08059592 in c_expand_body (fndecl=0x40185b60, nested_p=0, can_defer_p=1) at /src/gcc-ppc64-31/gcc/c-decl.c:7122 #4 0x08059357 in finish_function (nested=0, can_defer_p=1073849600) at /src/gcc-ppc64-31/gcc/c-decl.c:6989 #5 0x08049eb7 in yyparse_1 () at c-parse.y:386 #6 0x08176204 in compile_file () at /src/gcc-ppc64-31/gcc/toplev.c:2120 #7 0x0817a8f9 in do_compile () at /src/gcc-ppc64-31/gcc/toplev.c:5202 #8 0x0817a95b in toplev_main (argc=1073849600, argv=0x0) at /src/gcc-ppc64-31/gcc/toplev.c:5234 #9 0x0807fafb in main (argc=1073849600, argv=0x4001a500) at /src/gcc-ppc64-31/gcc/main.c:35 #10 0x4003ea8e in __libc_start_main (main=0x807fae0
, argc=40, argv=0xbffff1c4, init=0x8049054 <_init>, fini=0x8213170 <_fini>, rtld_fini=0x4000aa20 <_dl_fini>, stack_end=0xbffff1bc) at ../sysdeps/generic/libc-start.c:92 (gdb) c Continuing. Breakpoint 4, hppa_profile_hook (label_no=1) at /src/gcc-ppc64-31/gcc/config/pa/pa.c:3535 2: profile_label_no = 1 1: cfun->name = 0x82e107f "f0" (gdb) Continuing. Breakpoint 4, hppa_profile_hook (label_no=1) at /src/gcc-ppc64-31/gcc/config/pa/pa.c:3535 2: profile_label_no = 1 1: cfun->name = 0x82e1082 "f1" (gdb) Continuing. Breakpoint 4, hppa_profile_hook (label_no=1) at /src/gcc-ppc64-31/gcc/config/pa/pa.c:3535 2: profile_label_no = 1 1: cfun->name = 0x82e1085 "f2" (gdb) Continuing. Breakpoint 6, profile_function (file=0x4001a600) at /src/gcc-ppc64-31/gcc/final.c:1602 2: profile_label_no = 1 1: cfun->name = 0x82e107f "f0" (gdb) Continuing. Breakpoint 6, profile_function (file=0x4001a700) at /src/gcc-ppc64-31/gcc/final.c:1602 2: profile_label_no = 2 1: cfun->name = 0x82e1082 "f1" (gdb) Continuing. Breakpoint 6, profile_function (file=0x4001a800) at /src/gcc-ppc64-31/gcc/final.c:1602 2: profile_label_no = 3 1: cfun->name = 0x82e1085 "f2" (gdb) bt #0 profile_function (file=0x4001a800) at /src/gcc-ppc64-31/gcc/final.c:1602 #1 0x080d9e7b in final_start_function (first=0x4001a800, file=0x82da748, optimize=2) at /src/gcc-ppc64-31/gcc/final.c:1531 #2 0x0817773e in rest_of_compilation (decl=0x401859a0) at /src/gcc-ppc64-31/gcc/toplev.c:3480 #3 0x0811c701 in output_inline_function (fndecl=0x401859a0) at /src/gcc-ppc64-31/gcc/integrate.c:3004 #4 0x08175e97 in wrapup_global_declarations (vec=0x82e9cd0, len=0) at /src/gcc-ppc64-31/gcc/toplev.c:1975 #5 0x0817627b in compile_file () at /src/gcc-ppc64-31/gcc/toplev.c:2152 #6 0x0817a8f9 in do_compile () at /src/gcc-ppc64-31/gcc/toplev.c:5202 #7 0x0817a95b in toplev_main (argc=1073850368, argv=0x0) at /src/gcc-ppc64-31/gcc/toplev.c:5234 #8 0x0807fafb in main (argc=1073850368, argv=0x4001a800) at /src/gcc-ppc64-31/gcc/main.c:35 #9 0x4003ea8e in __libc_start_main (main=0x807fae0
, argc=40, argv=0xbffff1c4, init=0x8049054 <_init>, fini=0x8213170 <_fini>, rtld_fini=0x4000aa20 <_dl_fini>, stack_end=0xbffff1bc) at ../sysdeps/generic/libc-start.c:92 (gdb) c Continuing. Program exited normally. >Fix: Increment a function counter in expand_function_start, save in cfun, and use that value in profile_function. --HG+GLK89HZ1zG0kk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="inline.c" static inline int f0 (void) { return 0; } static inline int f1 (void) { return 1; } static inline int f2 (void) { return 2; } int foo (void) { /* Take the address of inline functions here to force them to be emitted out of line. */ return (int) &f0 + (int) &f1 + (int) &f2; } --HG+GLK89HZ1zG0kk-- >Release-Note: >Audit-Trail: >Unformatted: --HG+GLK89HZ1zG0kk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline