Bug 40031 - [4.5 Regression] ARM broken with addresses in PHIs with -fPIC
Summary: [4.5 Regression] ARM broken with addresses in PHIs with -fPIC
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.5.0
: P3 blocker
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
URL:
Keywords: build, ice-on-valid-code
: 40053 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-05-05 19:13 UTC by Andrew Pinski
Modified: 2009-05-10 18:41 UTC (History)
3 users (show)

See Also:
Host:
Target: arm-eabi
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-05-06 10:59:43


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2009-05-05 19:13:36 UTC
Testcase:
double c;
double d;
double *f(int a)
{
  if(a) return &c;
  return &d;
}
Comment 1 Richard Biener 2009-05-06 08:28:19 UTC
What's the ICE?
Comment 2 Ramana Radhakrishnan 2009-05-06 08:46:30 UTC
Can't replicate this with a stage2 or stage3 compiler with O2, O3, Os -fPIC {-mthumb} with r147121. 

However while bootstrapping the above mentioned revision, I get a segfault as in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39929#c12 but with . 

ramana@gcc55:~/build-20090505/armv5tel-unknown-linux-gnueabi/libstdc++-v3/libsupc++\[01;32mramana@gcc55[01;34m ~/build-20090505/armv5tel-unknown-linux-gnueabi/libstdc++-v3/libsupc++ $[00m [Kgdb --args  /home/ramana/build-20090505/./gcc/cc1 -quiet -v -I.. -I/home/ramana/trunk/libstdc++-v3/../libiberty -I/home/ramana/trunk/libstdc++-v3/../include -I/home/ramana/build-20090505/armv5tel-unknown-linux-gnueabi/libstdc++-v3/include/armv5tel-unknown-linux-gnueabi -I/home/ramana/build-20090505/armv5tel-unknown-linux-gnuea 
bi/libstdc++-v3/include -I/home/ramana/trunk/libstdc++-v3/libsupc++ -iprefix /home/ramana/build-20090505/gcc/../lib/gcc/armv5tel-unknown-linux-gnueabi/4.5.0/ -isystem /home/ramana/build-20090505/./gcc/include -isystem /home/ramana/build-20090505/./gcc/include-fixed -DHAVE_CONFIG_H -DIN_GLIBCPP_V3 -DPIC -isystem /usr/local/armv5tel-unknown-linux-gnueabi/include -isystem /usr/local/armv5tel-unknown-linux-gnueabi/sys-include cp-demangle.c -quiet -dumpbase cp-demangle.c -auxbase-strip cp-demangle.o -g -O2 -Wno-error -version -fPIC -o /tmp/ccIO2OGk.s


(gdb) r

Starting program: /home/ramana/build-20090505/gcc/cc1 -quiet -v -I.. -I/home/ramana/trunk/libstdc++-v3/../libiberty -I/home/ramana/trunk/libstdc++-v3/../include -I/home/ramana/build-20090505/armv5tel-unknown-linux-gnueabi/libstdc++-v3/include/armv5tel-unknown-linux-gnueabi -I/home/ramana/build-20090505/armv5tel-unknown-linux-gnueabi/libstdc++-v3/include -I/home/ramana/trunk/libstdc++-v3/libsupc++ -iprefix /home/ramana/build-20090505/gcc/../lib/gcc/armv5tel-unknown-linux-gnueabi/4.5.0/ -isystem /home/ramana/build-20090505/./gcc/include -isystem /home/ramana/build-20090505/./gcc/include-fixed -DHAVE_CONFIG_H -DIN_GLIBCPP_V3 -DPIC -isystem /usr/local/armv5tel-unknown-linux-gnueabi/include -isystem /usr/local/armv5tel-unknown-linux-gnueabi/sys-include cp-demangle.c -quiet -dumpbase cp-demangle.c -auxbase-strip cp-demangle.o -g -O2 -Wno-error -version -fPIC -o /tmp/ccIO2OGk.s

GNU C (GCC) version 4.5.0 20090505 (experimental) [trunk revision 147121] (armv5tel-unknown-linux-gnueabi)

	compiled by GNU C version 4.5.0 20090505 (experimental) [trunk revision 147121], GMP version 4.2.4, MPFR version 2.3.2.

GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096


Program received signal SIGSEGV, Segmentation fault.
emit_insn_after_1 (first=0x403790f0, after=0x40588f50, bb=0xa5a5a5a5) at ../../trunk/gcc/emit-rtl.c:4129
4129	      if (BB_END (bb) == after)
(gdb) bt
#0  emit_insn_after_1 (first=0x403790f0, after=0x40588f50, bb=0xa5a5a5a5) at ../../trunk/gcc/emit-rtl.c:4129
#1  0x0053cc60 in legitimize_pic_address (orig=0x40595b80, mode=<value optimized out>, reg=0x0) at ../../trunk/gcc/config/arm/arm.c:3600
#2  0x00602060 in gen_movsi (operand0=0x0, operand1=<value optimized out>) at ../../trunk/gcc/config/arm/arm.md:4966
#3  0x001e72c0 in emit_move_insn_1 (x=0x40706d38, y=0x40595b80) at ../../trunk/gcc/expr.c:3337
#4  0x001e756c in emit_move_insn (x=0x40706d38, y=0x40595b80) at ../../trunk/gcc/expr.c:3425
#5  0x001c3a60 in force_reg (mode=SImode, x=0x40595b80) at ../../trunk/gcc/explow.c:663
#6  0x001c4a90 in use_anchored_address (x=0x403d8350) at ../../trunk/gcc/explow.c:583
#7  0x001dd558 in expand_expr_real_1 (exp=0x404a8b40, target=<value optimized out>, tmode=<value optimized out>, modifier=<value optimized out>, alt_rtl=0x0) at ../../trunk/gcc/expr.c:7329
#8  0x001e6110 in expand_expr_real (exp=0x404a8b40, target=0x40588f50, tmode=VOIDmode, modifier=EXPAND_WRITE, alt_rtl=0x0) at ../../trunk/gcc/expr.c:7114
#9  0x001ea070 in expand_expr_addr_expr_1 (exp=0x404a8b40, target=0x0, tmode=SImode, modifier=EXPAND_NORMAL) at ../../trunk/gcc/expr.h:539
#10 0x001e9e14 in expand_expr_addr_expr_1 (exp=0x405fb690, target=0x40706630, tmode=SImode, modifier=EXPAND_NORMAL) at ../../trunk/gcc/expr.c:6838
#11 0x001db5d4 in expand_expr_real_1 (exp=0x405c1fc0, target=0x40706630, tmode=<value optimized out>, modifier=<value optimized out>, alt_rtl=0x0) at ../../trunk/gcc/expr.c:6897
#12 0x001e6110 in expand_expr_real (exp=0x405c1fc0, target=0x40588f50, tmode=VOIDmode, modifier=EXPAND_WRITE, alt_rtl=0x0) at ../../trunk/gcc/expr.c:7114
#13 0x0072be90 in eliminate_phi (e=0x405fb900, g=0xa39f08) at ../../trunk/gcc/expr.h:539
#14 0x0072cb6c in expand_phi_nodes (sa=<value optimized out>) at ../../trunk/gcc/tree-outof-ssa.c:777
#15 0x006b4800 in gimple_expand_cfg () at ../../trunk/gcc/cfgexpand.c:2506
#16 0x002fcdf0 in execute_one_pass (pass=0x95dcfc) at ../../trunk/gcc/passes.c:1291
#17 0x002fd07c in execute_pass_list (pass=0x95dcfc) at ../../trunk/gcc/passes.c:1340
#18 0x003fa1e0 in tree_rest_of_compilation (fndecl=0x403cc580) at ../../trunk/gcc/tree-optimize.c:394
#19 0x0054e584 in cgraph_expand_function (node=0x4047cf00) at ../../trunk/gcc/cgraphunit.c:1051
#20 0x0055059c in cgraph_optimize () at ../../trunk/gcc/cgraphunit.c:1110
#21 0x0008ba4c in c_write_global_declarations () at ../../trunk/gcc/c-decl.c:8364
#22 0x003a7384 in toplev_main (argc=1073882620, argv=0x400cf804) at ../../trunk/gcc/toplev.c:990
#23 0x400e0e2c in __libc_start_main () from /lib/libc.so.6
#24 0x0007a428 in _start ()



Comment 3 Ramana Radhakrishnan 2009-05-06 10:59:43 UTC
(In reply to comment #1)
> What's the ICE?
> 

With a cross arm-linux-gnueabi version r147153, I get a segfault with the following backtrace for this particular testcase. 

#0  0x082112b1 in emit_insn_after_1 (first=0xb7c352d0, after=0xb7c324b0, bb=0xb7c324d4) at /home/ramrad01/sourcearea/trunk/gcc/emit-rtl.c:4129
#1  0x0821214c in emit_insn_after (pattern=0x0, after=0xb7c324b0) at /home/ramrad01/sourcearea/trunk/gcc/emit-rtl.c:4335
#2  0x085eb5b7 in legitimize_pic_address (orig=0xb7c41c08, mode=SImode, reg=0x0) at /home/ramrad01/sourcearea/trunk/gcc/config/arm/arm.c:3599
#3  0x086b2ead in gen_movsi (operand0=0x0, operand1=0xb7c41c08) at /home/ramrad01/sourcearea/trunk/gcc/config/arm/arm.md:4966
#4  0x0824ad24 in emit_move_insn_1 (x=0xb7c39ce0, y=0xb7c41c08) at /home/ramrad01/sourcearea/trunk/gcc/expr.c:3337
#5  0x0824b012 in emit_move_insn (x=0xb7c39ce0, y=0xb7c41c08) at /home/ramrad01/sourcearea/trunk/gcc/expr.c:3425
#6  0x087d1923 in expand_phi_nodes (sa=0x8acb174) at /home/ramrad01/sourcearea/trunk/gcc/tree-outof-ssa.c:211
#7  0x08754d77 in gimple_expand_cfg () at /home/ramrad01/sourcearea/trunk/gcc/cfgexpand.c:2506
#8  0x08381d8d in execute_one_pass (pass=0x8a2f720) at /home/ramrad01/sourcearea/trunk/gcc/passes.c:1291
#9  0x0838200c in execute_pass_list (pass=0x8a2f720) at /home/ramrad01/sourcearea/trunk/gcc/passes.c:1340
#10 0x0848a6c0 in tree_rest_of_compilation (fndecl=0xb7c34680) at /home/ramrad01/sourcearea/trunk/gcc/tree-optimize.c:394
#11 0x085fd902 in cgraph_expand_function (node=0xb7bb8a00) at /home/ramrad01/sourcearea/trunk/gcc/cgraphunit.c:1051
#12 0x085ff7cf in cgraph_optimize () at /home/ramrad01/sourcearea/trunk/gcc/cgraphunit.c:1110
#13 0x080cec7b in c_write_global_declarations () at /home/ramrad01/sourcearea/trunk/gcc/c-decl.c:8364
#14 0x084334a6 in toplev_main (argc=20, argv=0xbf806e84) at /home/ramrad01/sourcearea/trunk/gcc/toplev.c:990
#15 0x08152f82 in main (argc=Cannot access memory at address 0x0
) at /home/ramrad01/sourcearea/trunk/gcc/main.c:35

Comment 4 Ramana Radhakrishnan 2009-05-07 08:10:40 UTC
*** Bug 40053 has been marked as a duplicate of this bug. ***
Comment 5 Laurent GUERBY 2009-05-10 09:28:27 UTC
For the record at rev 147290 even with c++ disabled the bootstrap failed on libmudflap:

libtool: compile:  /home/guerby/build/./gcc/xgcc -B/home/guerby/build/./gcc/ -B/n/50/guerby/install-trunk-147290/armv5tel-unknown-linux-gnueabi/bin/ -B/n/50/guerby/install-trunk-147290/armv5tel-unknown-linux-gnueabi/lib/ -isystem /n/50/guerby/install-trunk-147290/armv5tel-unknown-linux-gnueabi/include -isystem /n/50/guerby/install-trunk-147290/armv5tel-unknown-linux-gnueabi/sys-include -DHAVE_CONFIG_H -I. -I../../../trunk/libmudflap -I. -Wall -ffunction-sections -fdata-sections -g -O2 -MT mf-runtime.lo -MD -MP -MF .deps/mf-runtime.Tpo -c ../../../trunk/libmudflap/mf-runtime.c  -fPIC -DPIC -o .libs/mf-runtime.o
../../../trunk/libmudflap/mf-runtime.c: In function '__mf_describe_object':
../../../trunk/libmudflap/mf-runtime.c:1725: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
make[4]: *** [mf-runtime.lo] Error 1
make[4]: Leaving directory `/home/guerby/build/armv5tel-unknown-linux-gnueabi/libmudflap'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/guerby/build/armv5tel-unknown-linux-gnueabi/libmudflap'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/guerby/build/armv5tel-unknown-linux-gnueabi/libmudflap'
make[1]: *** [all-target-libmudflap] Error 2
make[1]: Leaving directory `/home/guerby/build'
make: *** [bootstrap] Error 2
Comment 6 Michael Matz 2009-05-10 18:17:50 UTC
I haven't yet committed the patch that Ramana tested.  Have you applied it
manually?  Otherwise the breakage is expected.
Comment 7 Laurent GUERBY 2009-05-10 18:23:52 UTC
I confirm I didn't apply your patch on the build that failed libmudflap.
Comment 8 Michael Matz 2009-05-10 18:40:35 UTC
Subject: Bug 40031

Author: matz
Date: Sun May 10 18:40:16 2009
New Revision: 147350

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=147350
Log:
        PR target/40031
        * config/arm/arm.c (require_pic_register): Emit on entry
        edge, not at entry of function.
testsuite/
        * gcc.dg/pr40031.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr40031.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/arm/arm.c
    trunk/gcc/testsuite/ChangeLog

Comment 9 Michael Matz 2009-05-10 18:41:46 UTC
Now I have, hence fixed.