Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 25572
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Alan Modra <amodra@gmail.com>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Anton Blanchard <anton@samba.org>
Add CC:
CC:
Remove selected CCs
Build:
Patch URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 25572 depends on: Show dependency tree
Show dependency graph
Bug 25572 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2005-12-28 05:18 Opened: 2005-12-27 00:16
We found this problem when building a ppc64 Linux kernel. It turns out r30 was
not preserved in a function that was using a local TOC. The compiler used was:

gcc version 4.0.3 20051201 (prerelease) (Debian 4.0.2-5)

Although it seems to reproduce on older toolchains too (eg 3.4).

pinskia cut the original test case down to:

/* Compile with -m64 -O2 -mminimal-toc */
int per_cpu__kstat;

int *f()
{
  int *__ptr;
  asm volatile(";%0":"=g"(__ptr):"0"(&per_cpu__kstat));
  return __ptr;
}

/*
.f:
        ld 30,.LCTOC0@toc(2)
        ld 9,.LC0-.LCTOC1(30)
        mr 3,9
#APP
        ;3
#NO_APP

*/

------- Comment #1 From Andrew Pinski 2005-12-27 00:18 -------
Confirmed, not a regression.

------- Comment #2 From Alan Modra 2005-12-28 03:03 -------
Happens at -O0 too.  At -O0, r30 is used for the first time when reload decides
that the asm_operands in the following needs reloading.  regs_ever_live[30]
isn't set.

(insn 8 6 10 3 (set (mem/c/i:DI (plus:DI (reg/f:DI 113 sfp)
                (const_int 48 [0x30])) [0 __ptr+0 S8 A128])
        (asm_operands/v:DI (";%0") ("=g") 0 [
                (symbol_ref:DI ("per_cpu__kstat") <var_decl 0x80003499a0
per_cpu__kstat>)
            ]
             [
                (asm_input:DI ("0"))
            ] ("/src/tmp/pr25572.c") 7)) -1 (nil)
    (nil))

------- Comment #3 From Alan Modra 2005-12-28 04:52 -------
Adding
  if (no_new_pseudos)
    regs_ever_live[TOC_REGISTER] = 1;
to rs6000.c:create_TOC_reference fixes this problem.  There seems to be
precedent for such chicanery: eg. rs6000_got_register and a number of places in
i386.c setting regs_ever_live[PIC_OFFSET_TABLE_REGNUM].

------- Comment #4 From Alan Modra 2005-12-29 01:10 -------
Subject: Bug 25572

Author: amodra
Date: Thu Dec 29 01:10:05 2005
New Revision: 109133

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109133
Log:
        PR target/25572
        * config/rs6000/rs6000.c (create_TOC_reference): Set regs_ever_live.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/rs6000/rs6000.c

------- Comment #5 From Alan Modra 2005-12-29 01:14 -------
Subject: Bug 25572

Author: amodra
Date: Thu Dec 29 01:14:18 2005
New Revision: 109134

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109134
Log:
        PR target/25572
        * config/rs6000/rs6000.c (create_TOC_reference): Set regs_ever_live.


Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/config/rs6000/rs6000.c

------- Comment #6 From Alan Modra 2005-12-29 01:20 -------
Subject: Bug 25572

Author: amodra
Date: Thu Dec 29 01:20:15 2005
New Revision: 109135

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109135
Log:
        PR target/25572
        * config/rs6000/rs6000.c (create_TOC_reference): Set regs_ever_live.


Modified:
    branches/gcc-4_0-branch/gcc/ChangeLog
    branches/gcc-4_0-branch/gcc/config/rs6000/rs6000.c

------- Comment #7 From Alan Modra 2005-12-29 01:29 -------
Subject: Bug 25572

Author: amodra
Date: Thu Dec 29 01:29:18 2005
New Revision: 109136

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109136
Log:
        PR target/25572
        * config/rs6000/rs6000.c (create_TOC_reference): Set regs_ever_live.


Modified:
    branches/gcc-3_4-branch/gcc/ChangeLog
    branches/gcc-3_4-branch/gcc/config/rs6000/rs6000.c

------- Comment #8 From Alan Modra 2005-12-29 01:29 -------
Fixed

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug