From af618949a430bf38b27a7e897dae4413a78ca8dc Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Sun, 10 May 2009 18:40:16 +0000 Subject: [PATCH] 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 --- gcc/ChangeLog | 6 ++++++ gcc/config/arm/arm.c | 6 +++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr40031.c | 9 +++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr40031.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6c0177b..4c6540a 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 9264760..1d9b426 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 017cbf4..e0e92ce 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 0000000..f6f1f65 --- /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; +} -- 2.7.4