Bug 42564 - unrecognizable insn with -O -fPIC
Summary: unrecognizable insn with -O -fPIC
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.4.3
: P3 normal
Target Milestone: 4.3.5
Assignee: Eric Botcazou
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2009-12-31 10:19 UTC by Debian GCC Maintainers
Modified: 2010-02-01 19:03 UTC (History)
4 users (show)

See Also:
Host:
Target: sparc*-linux-gnu
Build:
Known to work:
Known to fail: 4.1.2 4.3.4 4.4.2 4.5.0
Last reconfirmed: 2010-01-02 17:33:26


Attachments
preprocessed source (19.25 KB, application/x-gzip)
2009-12-31 10:20 UTC, Debian GCC Maintainers
Details
Reduced testcase. (115 bytes, text/plain)
2010-01-02 22:26 UTC, Eric Botcazou
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Debian GCC Maintainers 2009-12-31 10:19:53 UTC
seen with current branches and trunk when building libcap-ng on sparc/sparc64. the file builds without -fPIC or with -O0.

  Matthias

$ gcc-4.4 -c -O2 -fPIC cap-ng.i 
cap-ng.c: In function 'init':
cap-ng.c:154: error: unrecognizable insn:
(insn 18 17 19 4 cap-ng.c:139 (set (reg:SI 117)
        (lo_sum:SI (reg:SI 117)
            (unspec:SI [
                    (symbol_ref:SI ("m") [flags 0x1a] <var_decl 0xf7bafad0 m>)
                ] 0))) -1 (nil))
cap-ng.c:154: internal compiler error: in extract_insn, at recog.c:2048
Please submit a full bug report,
with preprocessed source if appropriate.
Comment 1 Debian GCC Maintainers 2009-12-31 10:20:25 UTC
Created attachment 19429 [details]
preprocessed source
Comment 2 Eric Botcazou 2009-12-31 17:36:56 UTC
I cannot reproduce with a cross, neither on mainline nor 4.4 branch.  Could you post the command line passed to cc1?  Do you have relevant local patches?
Comment 3 Jakub Jelinek 2009-12-31 20:43:21 UTC
I couldn't reproduce this either.
Comment 4 Debian GCC Maintainers 2010-01-01 11:06:27 UTC
the sparc64-linux compiler from the trunk is configured with

         --with-pkgversion='Debian 20091228-2'
         --with-bugurl='file:///usr/share/doc/gcc-snapshot/README.Bugs'
         --enable-languages=c,c++,java,fortran,objc,obj-c++
         --prefix=/usr/lib/gcc-snapshot
         --enable-shared
         --with-system-zlib
         --disable-nls
         --enable-clocale=gnu
         --enable-libstdcxx-debug
         --enable-plugin
         --disable-browser-plugin
         --enable-java-awt=gtk
         --enable-gtk-cairo
         --with-java-home=//usr/lib/jvm/java-1.5.0-gcj-4.5-snap/jre
         --enable-java-home
         --with-jvm-root-dir=//usr/lib/jvm/java-1.5.0-gcj-4.5-snap
         --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.5-snap
         --with-arch-directory=sparc64
         --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
         --enable-objc-gc
         --disable-multilib
         --with-long-double-128
         --disable-werror
         --build=sparc64-linux-gnu
         --host=sparc64-linux-gnu
         --target=sparc64-linux-gnu

COLLECT_GCC_OPTIONS='-v' '-c' '-fPIC' '-O2' '-mcpu=v9'
 /usr/lib/gcc-snapshot/libexec/gcc/sparc64-linux-gnu/4.5.0/cc1 -fpreprocessed cap-ng.i -quiet -dumpbase cap-ng.i -mcpu=v9 -auxbase cap-ng -O2 -version -fPIC -o /tmp/ccGcfzUk.s

patches applied are:

pr40521-revert-workaround:
  Revert the dwarf2cfi_asm workaround, obsoleted by PR debug/40521.

gcc-ice-hack:
  Retry the build on an ice, save the calling options and preprocessed
  source when the ice is reproducible.

gcc-ice-apport:
  Report an ICE to apport (if apport is available
  and the environment variable GCC_NOAPPORT is not set)

plus two build patches for libjava and gcc/config/arm.

started a build without the pr40521-revert-workaround
Comment 5 Debian GCC Maintainers 2010-01-02 10:42:19 UTC
not applying the pr40521-revert-workaround patch shows the ICE as well.
Comment 6 Eric Botcazou 2010-01-02 17:33:26 UTC
I can reproduce on native (and with a cross by stealing the native auto-host.h).
Comment 7 Eric Botcazou 2010-01-02 22:26:47 UTC
Created attachment 19451 [details]
Reduced testcase.

Requires TLS support.
Comment 8 Eric Botcazou 2010-01-02 23:00:30 UTC
The root of the problem is plus_constant wrapping up a TLS symbol in a CONST:

(const:DI (plus:DI (symbol_ref:DI ("m") [flags 0x1a] <var_decl m>)
        (const_int 4 [0x4])))

what the SPARC back-end doesn't like.  So something like this works:

Index: explow.c
===================================================================
--- explow.c    (revision 155516)
+++ explow.c    (working copy)
@@ -137,7 +137,8 @@ plus_constant (rtx x, HOST_WIDE_INT c)

     case SYMBOL_REF:
     case LABEL_REF:
-      all_constant = 1;
+      if (CONSTANT_ADDRESS_P (x))
+       all_constant = 1;
       break;

     case PLUS:

but I presume other back-ends may not necessarily like it.
Comment 9 Eric Botcazou 2010-01-05 22:29:33 UTC
Subject: Bug 42564

Author: ebotcazou
Date: Tue Jan  5 22:29:18 2010
New Revision: 155662

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155662
Log:
	PR target/42564
	* config/sparc/sparc.h (SPARC_SYMBOL_REF_TLS_P): Delete.
	* config/sparc/sparc-protos.h (legitimize_pic_address): Likewise.
	(legitimize_tls_address): Likewise.
	(sparc_tls_referenced_p): Likewise.
	* config/sparc/sparc.c (sparc_expand_move): Use legitimize_tls_address
	and adjust calls to legitimize_pic_address.
	(legitimate_constant_p) Use sparc_tls_referenced_p.
	(legitimate_pic_operand_p): Likewise.
	(sparc_legitimate_address_p): Do not use SPARC_SYMBOL_REF_TLS_P.
	(sparc_tls_symbol_ref_1): Delete.
	(sparc_tls_referenced_p): Make static, recognize specific patterns.
	(legitimize_tls_address): Make static, handle CONST patterns.
	(legitimize_pic_address): Make static, remove unused parameter and
	adjust recursive calls.
	(sparc_legitimize_address): Make static, use sparc_tls_referenced_p
	and adjust call to legitimize_pic_address.
	(sparc_output_mi_thunk): Likewise.

Added:
    trunk/gcc/testsuite/gcc.dg/tls/opt-15.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/sparc/sparc-protos.h
    trunk/gcc/config/sparc/sparc.c
    trunk/gcc/config/sparc/sparc.h
    trunk/gcc/testsuite/ChangeLog

Comment 10 Eric Botcazou 2010-01-05 22:32:37 UTC
Subject: Bug 42564

Author: ebotcazou
Date: Tue Jan  5 22:32:25 2010
New Revision: 155663

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155663
Log:
	PR target/42564
	* config/sparc/sparc.h (SPARC_SYMBOL_REF_TLS_P): Delete.
	* config/sparc/sparc-protos.h (legitimize_pic_address): Likewise.
	(legitimize_tls_address): Likewise.
	(sparc_tls_referenced_p): Likewise.
	* config/sparc/sparc.c (sparc_expand_move): Use legitimize_tls_address
	and adjust calls to legitimize_pic_address.
	(legitimate_constant_p) Use sparc_tls_referenced_p.
	(legitimate_pic_operand_p): Likewise.
	(sparc_legitimate_address_p): Do not use SPARC_SYMBOL_REF_TLS_P.
	(sparc_tls_symbol_ref_1): Delete.
	(sparc_tls_referenced_p): Make static, recognize specific patterns.
	(legitimize_tls_address): Make static, handle CONST patterns.
	(legitimize_pic_address): Make static, remove unused parameter and
	adjust recursive calls.
	(sparc_legitimize_address): Make static, use sparc_tls_referenced_p
	and adjust call to legitimize_pic_address.
	(sparc_output_mi_thunk): Likewise.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/tls/opt-15.c
Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/config/sparc/sparc-protos.h
    branches/gcc-4_4-branch/gcc/config/sparc/sparc.c
    branches/gcc-4_4-branch/gcc/config/sparc/sparc.h
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog

Comment 11 Eric Botcazou 2010-01-05 22:34:14 UTC
Subject: Bug 42564

Author: ebotcazou
Date: Tue Jan  5 22:34:01 2010
New Revision: 155664

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155664
Log:
	PR target/42564
	* config/sparc/sparc.h (SPARC_SYMBOL_REF_TLS_P): Delete.
	* config/sparc/sparc-protos.h (legitimize_pic_address): Likewise.
	(legitimize_tls_address): Likewise.
	(sparc_tls_referenced_p): Likewise.
	* config/sparc/sparc.c (sparc_expand_move): Use legitimize_tls_address
	and adjust calls to legitimize_pic_address.
	(legitimate_constant_p) Use sparc_tls_referenced_p.
	(legitimate_pic_operand_p): Likewise.
	(sparc_legitimate_address_p): Do not use SPARC_SYMBOL_REF_TLS_P.
	(sparc_tls_symbol_ref_1): Delete.
	(sparc_tls_referenced_p): Make static, recognize specific patterns.
	(legitimize_tls_address): Make static, handle CONST patterns.
	(legitimize_pic_address): Make static, remove unused parameter and
	adjust recursive calls.
	(sparc_legitimize_address): Make static, use sparc_tls_referenced_p
	and adjust call to legitimize_pic_address.
	(sparc_output_mi_thunk): Likewise.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gcc.dg/tls/opt-15.c
Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/config/sparc/sparc-protos.h
    branches/gcc-4_3-branch/gcc/config/sparc/sparc.c
    branches/gcc-4_3-branch/gcc/config/sparc/sparc.h
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

Comment 12 Eric Botcazou 2010-01-05 22:43:04 UTC
On all active branches.