Bug 29122 - ICE with -ipa-cp and -m64 (tail calls)
Summary: ICE with -ipa-cp and -m64 (tail calls)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2006-09-18 09:21 UTC by revital eres
Modified: 2006-11-26 18:15 UTC (History)
6 users (show)

See Also:
Host:
Target: powerpc64-linux
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-09-19 03:12:51


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description revital eres 2006-09-18 09:21:32 UTC
gcc -O3 test.c --ipa-cp  -m64

test.c:
========================================================

#include <stdio.h>

int
bar (int b, int c)
{
  printf ("%d %d\n", b, c);
}

int
foo (int a)
{
  if (a++ > 0)
    bar (a, 3);

  foo (7);
}

int
main ()
{
  foo (7);
  return 0;
}



========================================================

test.c: In function âfooâ:
test.c:16: error: unrecognizable insn:
(call_insn/j 31 30 32 5 (parallel [
            (set (reg:DI 3 3)
                (call (mem:SI (symbol_ref:DI ("T.10")) [0 S4 A8])
                    (const_int 64 [0x40])))
            (use (const_int 0 [0x0]))
            (use (reg:SI 126))
            (return)
        ]) -1 (nil)
    (expr_list:REG_EH_REGION (const_int 0 [0x0])
        (nil))
    (expr_list:REG_DEP_TRUE (use (reg:DI 3 3))
        (nil)))
Comment 1 razya 2006-09-18 10:09:18 UTC
The ICE is due to a call to a versioned function that IPCP triggered.
The call instruction is corrupted.
Comment 2 Andrew Pinski 2006-09-19 03:12:51 UTC
Here is a reduced testcase:
int
bar (int b, int c)
{
  return 0;
}
int
main ()
{
  bar (8, 4);
  return bar (7, 4);
}

-----
This is due to tail calls.
> The call instruction is corrupted.
No, it is not, it is correct.  Just the function looks like it is not set to be right.  Anyways I think the Function decl is messed up to begin with.
With -O1, we get an indirect function call which is just wrong.
.main:
        mflr 0
        std 0,16(1)
        stdu 1,-112(1)
        li 3,7
        li 4,4
        ld 9,.LC0@toc(2)
        ld 0,0(9)
        mtctr 0
        std 2,40(1)
        ld 2,8(9)
        ld 11,16(9)
        bctrl
        ld 2,40(1)
        addi 1,1,112
        ld 0,16(1)
        mtlr 0
        blr
.LC0:
        .tc T.0[TC],T.0
        .section        ".text"


I might bet this might have an issue on ppc-aix also even not in 64bit mode because that is a TOC based ABI also.
Comment 3 razya 2006-10-12 11:44:34 UTC
(In reply to comment #0)
> gcc -O3 test.c --ipa-cp  -m64
> test.c:
> ========================================================
> #include <stdio.h>
> int
> bar (int b, int c)
> {
>   printf ("%d %d\n", b, c);
> }
> int
> foo (int a)
> {
>   if (a++ > 0)
>     bar (a, 3);
>   foo (7);
> }
> int
> main ()
> {
>   foo (7);
>   return 0;
> }
> ========================================================
> test.c: In function âfooâ:
> test.c:16: error: unrecognizable insn:
> (call_insn/j 31 30 32 5 (parallel [
>             (set (reg:DI 3 3)
>                 (call (mem:SI (symbol_ref:DI ("T.10")) [0 S4 A8])
>                     (const_int 64 [0x40])))
>             (use (const_int 0 [0x0]))
>             (use (reg:SI 126))
>             (return)
>         ]) -1 (nil)
>     (expr_list:REG_EH_REGION (const_int 0 [0x0])
>         (nil))
>     (expr_list:REG_DEP_TRUE (use (reg:DI 3 3))
>         (nil)))

I would like to be assigned to this PR.
Razya 
Comment 4 razya 2006-10-31 11:36:38 UTC
Subject: Bug 29122

Author: razya
Date: Tue Oct 31 11:36:28 2006
New Revision: 118227

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118227
Log:
2006-10-31  Razya Ladklesky  <razya@il.ibm.com>

            * tree-inline.c (remap_decls): remap all TYPE_DECLs.
            PR tree-optimization/29122
            * tree-inline.c (tree_function_versioning): Update DECL_ASSEMBLER_NAME
              for the new version.  Assign NULL to DECL_RTL of the new version.


Modified:
    branches/ipa-branch/gcc/ChangeLog.ipa
    branches/ipa-branch/gcc/tree-inline.c

Comment 5 razya 2006-10-31 12:08:22 UTC
(In reply to comment #4)
> Subject: Bug 29122
> Author: razya
> Date: Tue Oct 31 11:36:28 2006
> New Revision: 118227
> URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118227
> Log:
> 2006-10-31  Razya Ladklesky  <razya@il.ibm.com>
>             * tree-inline.c (remap_decls): remap all TYPE_DECLs.
>             PR tree-optimization/29122
>             * tree-inline.c (tree_function_versioning): Update
> DECL_ASSEMBLER_NAME
>               for the new version.  Assign NULL to DECL_RTL of the new version.
> Modified:
>     branches/ipa-branch/gcc/ChangeLog.ipa
>     branches/ipa-branch/gcc/tree-inline.c

(In reply to comment #4)
> Subject: Bug 29122
> Author: razya
> Date: Tue Oct 31 11:36:28 2006
> New Revision: 118227
> URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118227
> Log:
> 2006-10-31  Razya Ladklesky  <razya@il.ibm.com>
>             * tree-inline.c (remap_decls): remap all TYPE_DECLs.
>             PR tree-optimization/29122
>             * tree-inline.c (tree_function_versioning): Update
> DECL_ASSEMBLER_NAME
>               for the new version.  Assign NULL to DECL_RTL of the new version.
> Modified:
>     branches/ipa-branch/gcc/ChangeLog.ipa
>     branches/ipa-branch/gcc/tree-inline.c

This was committed only on ipa branch (witth Hubicka's consent). This fix was submitted for GCC4.3 and possibly for GCC4.2 
http://gcc.gnu.org/ml/gcc-patches/2006-10/msg01457.html
Comment 6 patchapp@dberlin.org 2006-10-31 12:19:06 UTC
Subject: Bug number PR29122

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-10/msg01457.html
Comment 7 patchapp@dberlin.org 2006-11-06 11:40:24 UTC
Subject: Bug number PR29122

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-11/msg00305.html
Comment 8 patchapp@dberlin.org 2006-11-16 11:50:21 UTC
Subject: Bug number PR29122

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-11/msg01140.html
Comment 9 razya 2006-11-26 10:00:30 UTC
Subject: Bug 29122

Author: razya
Date: Sun Nov 26 10:00:18 2006
New Revision: 119220

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=119220
Log:
2006-11-26  Razya Ladklesky  <razya@il.ibm.com>

        PR tree-optimization/29122
        * tree-inline.c (tree_function_versioning): Update DECL_ASSEMBLER_NAME
        for the new version.  Assign NULL to DECL_RTL of the new version.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-inline.c

Comment 10 Andrew Pinski 2006-11-26 18:15:37 UTC
Fixed.