public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ubizjak at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/60973] New: Invalid propagation of a tail call in copyrename2 pass Date: Sat, 26 Apr 2014 08:27:00 -0000 [thread overview] Message-ID: <bug-60973-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60973 Bug ID: 60973 Summary: Invalid propagation of a tail call in copyrename2 pass Product: gcc Version: 4.10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: ubizjak at gmail dot com This problem can be illustrated with a target, that doesn't define TARGET_ASM_CAN_OUTPUT_MI_THUNK, such as h8300-elf. Compiling g++.dg/ipa/imm-devirt-2.C using -O2 with a crosscompiler to h8300-elf, we get in _.037t.inline_param2: virtual int C::_ZThn10_N1C3fooEi(int) (struct C * const this, int i) { int retval___0; <bb 2>: this_2 = this_1(D) + 65526; retval___0_5 = C::foo (this_2, i_4(D)); [tail call] return retval___0_5; } and int main(int, char**) (int argc, char * * argv) { struct C c; int _3; int _6; <bb 2>: C::C (&c); _3 = get_input (); _6 = C::_ZThn10_N1C3fooEi (&c.D.1912.D.1895, _3); if (_6 != 4) goto <bb 3>; else goto <bb 4>; <bb 3>: abort (); <bb 4>: c ={v} {CLOBBER}; return 0; } However, copyrename2 pass propagates tail call annotation to the call site, resulting in _.054t.copyrename2: int main(int, char**) (int argc, char * * argv) { int retval___0; int D.2161; struct C * const this; struct C c; int _3; int _6; <bb 2>: C::C (&c); _3 = get_input (); this_7 = &c.D.1912.D.1895 + 65526; retval___0_8 = C::foo (this_7, _3); [tail call] <<< here! _9 = retval___0_8; _6 = _9; if (_6 != 4) goto <bb 3>; else goto <bb 4>; <bb 3>: abort (); <bb 4>: c ={v} {CLOBBER}; return 0; } On a target that support sibcalls, RTL expansion ends after tail call, so _.170r.expand ends with: ... (call_insn/u/j 15 14 16 2 (set (reg:SI 3 r3) (call (mem:SI (symbol_ref:SI ("_ZN1C3fooEi") [flags 0x3] <function_decl 0x7fe46eeab200 foo>) [0 foo S4 A32]) (const_int 0 [0]))) -1 (expr_list:REG_EH_REGION (const_int 0 [0]) (nil)) (expr_list:SI (use (reg:SI 4 r4)) (expr_list:SI (use (reg:SI 3 r3)) (nil)))) ;; succ: EXIT [100.0%] (ABNORMAL,SIBCALL) (barrier 16 15 0) The tail call is valid only in _ZThn16_N1C3fooEi (a.k.a non-virtual thunk to C::foo(int)) and should not be propagated as a tail call to its call site.
next reply other threads:[~2014-04-26 8:27 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-04-26 8:27 ubizjak at gmail dot com [this message] 2014-04-28 9:49 ` [Bug ipa/60973] Invalid propagation of a tail call in devirt pass rguenth at gcc dot gnu.org 2014-05-06 11:28 ` hubicka at gcc dot gnu.org 2014-05-07 18:10 ` ubizjak at gmail dot com 2014-05-09 10:56 ` rguenth at gcc dot gnu.org 2014-05-09 14:27 ` hubicka at ucw dot cz 2014-05-13 7:57 ` rguenth at gcc dot gnu.org 2014-05-13 11:05 ` rguenth at gcc dot gnu.org 2014-05-13 11:06 ` rguenth at gcc dot gnu.org 2014-05-13 11:06 ` rguenth at gcc dot gnu.org
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=bug-60973-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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).