public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Alan Modra <amodra@bigpond.net.au> To: gcc-gnats@gcc.gnu.org Subject: target/6413: PROFILE_HOOK label_no Date: Mon, 22 Apr 2002 19:46:00 -0000 [thread overview] Message-ID: <20020423023959.GT31160@bubble.sa.bigpond.net.au> (raw) In-Reply-To: <20020422141515.GM31160@bubble.sa.bigpond.net.au> >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 <amodra@bigpond.net.au> >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 <main>, 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 <main>, 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
parent reply other threads:[~2002-04-23 2:46 UTC|newest] Thread overview: expand[flat|nested] mbox.gz Atom feed [parent not found: <20020422141515.GM31160@bubble.sa.bigpond.net.au>]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20020423023959.GT31160@bubble.sa.bigpond.net.au \ --to=amodra@bigpond.net.au \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).