From: Michael Matz Date: Sun, 10 May 2009 18:40:16 +0000 (+0000) Subject: re PR target/40031 (ARM broken with addresses in PHIs with -fPIC) X-Git-Tag: releases/gcc-4.5.0~5808 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=af618949a430bf38b27a7e897dae4413a78ca8dc;p=thirdparty%2Fgcc.git re PR target/40031 (ARM broken with addresses in PHIs with -fPIC) 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. From-SVN: r147350 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6c0177b65554..4c6540a8ae04 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2009-05-10 Michael Matz + + PR target/40031 + * config/arm/arm.c (require_pic_register): Emit on entry edge, + not at entry of function. + 2009-05-10 Richard Guenther PR tree-optimization/40081 diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 926476090812..1d9b42658438 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -3596,7 +3596,11 @@ require_pic_register (void) seq = get_insns (); end_sequence (); - emit_insn_after (seq, entry_of_function ()); + /* We can be called during expansion of PHI nodes, where + we can't yet emit instructions directly in the final + insn stream. Queue the insns on the entry edge, they will + be committed after everything else is expanded. */ + insert_insn_on_edge (seq, single_succ_edge (ENTRY_BLOCK_PTR)); } } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 017cbf4cfd07..e0e92ce27dc4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-05-10 Michael Matz + + PR target/40031 + * gcc.dg/pr40031.c: New test. + 2009-05-10 Paul Thomas PR fortran/40018 diff --git a/gcc/testsuite/gcc.dg/pr40031.c b/gcc/testsuite/gcc.dg/pr40031.c new file mode 100644 index 000000000000..f6f1f65a7eeb --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr40031.c @@ -0,0 +1,9 @@ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O2 -fPIC" } */ +double c; +double d; +double *f(int a) +{ + if(a) return &c; + return &d; +}