Bug 592 - [ARM/Thumb] Poor choice of PIC register
: [ARM/Thumb] Poor choice of PIC register
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: target
: 2.96
: P3 normal
: 4.2.0
Assigned To: Richard Earnshaw
:
: missed-optimization
: 11135
:
  Show dependency treegraph
 
Reported: 2000-10-02 20:26 UTC by iant
Modified: 2006-01-17 20:32 UTC (History)
2 users (show)

See Also:
Host:
Target: arm-*-*,thumb-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-12-23 00:07:42


Attachments
ian.c (157 bytes, text/plain)
2003-05-21 15:17 UTC, iant
Details

Note You need to log in before you can comment on or make changes to this bug.
Description iant 2000-10-02 20:26:00 UTC
{~home}: /tools/arm/ecos/H-i686-pc-linux-gnu/bin/thumb-elf-gcc -v --save-temps
-c -fpic -o ian.o ../src/ian.c
Reading specs from
/tools/arm/ecos/H-i686-pc-linux-gnu/lib/gcc-lib/thumb-elf/2.96/specs
gcc version 2.96 20000313 (experimental)
 /tools/arm/ecos/H-i686-pc-linux-gnu/lib/gcc-lib/thumb-elf/2.96/cpp -lang-c -v
-D__GNUC__=2 -D__GNUC_MINOR__=96 -D__GNUC_PATCHLEVEL__=0 -Dthumb -Dthumbelf
-D__thumb -D__thumb__ -D__thumbelf__ -D__thumb -D__thumb -D__thumbelf
-Acpu(arm) -Amachine(arm) -D__CHAR_UNSIGNED__ -D__ARMEL__ -D__THUMBEL__
../src/ian.c ian.i
GNU CPP version 2.96 20000313 (experimental) (cpplib)
 (Thumb/elf)
ignoring nonexistent directory
`/tools/arm/ecos/H-i686-pc-linux-gnu/thumb-elf/sys-include'
#include "..." search starts here:
#include <...> search starts here:
 /tools/arm/ecos/H-i686-pc-linux-gnu/lib/gcc-lib/thumb-elf/2.96/include
 /tools/arm/ecos/H-i686-pc-linux-gnu/thumb-elf/include
End of search list.
 /tools/arm/ecos/H-i686-pc-linux-gnu/lib/gcc-lib/thumb-elf/2.96/cc1 ian.i
-quiet -dumpbase ian.c -version -fpic -o ian.s
GNU C version 2.96 20000313 (experimental) (thumb-elf) compiled by GNU C
version 2.7.2.3.
../src/ian.c: In function `MyFunction':
../src/ian.c:9: Insn does not satisfy its constraints:
(insn 34 29 22 (set (reg:SI 10 sl)
        (mem:SI (label_ref 38) 0)) 1 {*movsi_insn} (nil)
    (nil))
../src/ian.c:9: Internal compiler error in `insn_default_length', at
insn-attrtab.c:164
Please submit a full bug report.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.

Release:
2.96 20000313 (experimental)

Environment:
Sparc 2 running Solaris 2.6

How-To-Repeat:
use the gnu for arm compiler (target thumb-elf) (redhat/cygnus) and compile
ian.c with the -fpic flag:

thumb-elf-gcc -v --save-temps -c -fpic -o ian.o ../src/ian.c
Comment 1 iant 2000-10-02 20:26:00 UTC
Fix:
take out the -fpic flag, or modify the source somehow...
Comment 2 Richard Earnshaw 2000-11-01 02:44:07 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: This is specific to the ARM back-end only (and only in thumb mode)
    The compiler is continuing to use r10 as the PIC base register, 
    even for thumb (which is a bad choice) -- the compiler needs to be
    reworked to use a different PIC base register in Thumb mode.
Comment 3 Richard Earnshaw 2000-11-01 10:44:08 UTC
From: rearnsha@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org, iant@palmchip.com, nobody@gcc.gnu.org
Cc:  
Subject: Re: target/592
Date: 1 Nov 2000 10:44:08 -0000

 Synopsis: gcc for arm (thumb mode) Insn bug with -fpic flag
 
 State-Changed-From-To: open->analyzed
 State-Changed-By: rearnsha
 State-Changed-When: Wed Nov  1 02:44:07 2000
 State-Changed-Why:
     This is specific to the ARM back-end only (and only in thumb mode)
     The compiler is continuing to use r10 as the PIC base register, 
     even for thumb (which is a bad choice) -- the compiler needs to be
     reworked to use a different PIC base register in Thumb mode.
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=592&database=gcc
Comment 4 Philip Blundell 2002-01-22 03:05:37 UTC
Responsible-Changed-From-To: unassigned->pb
Responsible-Changed-Why: .
Comment 5 Richard Earnshaw 2002-04-23 08:44:20 UTC
Responsible-Changed-From-To: pb->rearnsha
Responsible-Changed-Why: .
Comment 6 Richard Earnshaw 2002-04-23 08:44:20 UTC
State-Changed-From-To: analyzed->suspended
State-Changed-Why: Having given this some consideration, I'm no-longer convinced that
    fixing a lo reigster is a good idea: it would unduly pessimize
    other code and might lead to situations where we would run
    out of registers.
    The best solution would be to make the PIC register a pseudo,
    but apparently there are other issues that prevent this.
    
    I believe the orignal problem that provoked this report has now
    been resolved.
Comment 7 Richard Earnshaw 2006-01-17 20:22:25 UTC
Subject: Bug 592

Author: rearnsha
Date: Tue Jan 17 20:22:19 2006
New Revision: 109839

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109839
Log:
    PR target/592
    PR middle-end/11135
    * arm.h (struct machine_function): Add pic_reg.
    * arm.c (arm_pic_register): Make unsigned.
    (arm_override_options): Only set arm_pic_register if
    TARGET_SINGLE_PIC_BASE.
    (use_return_insn): Only test for a pic register if it is fixed.
    (arm_compute_save_reg0_reg12_mask): Likewise.
    (thumb_compute_save_reg_mask): Likewise.
    (legitimate_pic_operand): Factor out some known invariants.
    (legitimize_pic_address): If we don't have a fixed pic register,
    then set up a pseudo in the function entry sequence.  Handle the
    pic base being in a pseudo.
    (arm_load_pic_register): Handle the pic register being in a pseudo.
    (arm_expand_prologue): Only set up the pic register if it is fixed.
    (thumb_expand_prologue): Likewise.
    * arm.md (pic_load_addr_based): Handle the pic base being a pseudo.
    (pic_load_addr_based_insn): Likewise.
    (builtin_setjmp_receiver): Don't restore the pic base if it isn't
    fixed.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/arm/arm.c
    trunk/gcc/config/arm/arm.h
    trunk/gcc/config/arm/arm.md
Comment 8 Richard Earnshaw 2006-01-17 20:32:36 UTC
Fixed