diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6c0177b6555..4c6540a8ae0 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 92647609081..1d9b4265843 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 017cbf4cfd0..e0e92ce27dc 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 00000000000..f6f1f65a7ee --- /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; +}