From bef3c57babac2e7ff368cb226a962644575c22e0 Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Wed, 28 Jan 2009 08:58:07 +0100 Subject: [PATCH] re PR target/38988 (Cannot build crtstuff.c with -mcmodel=large -fPIC -O2) PR target/38988 * config/i386/i386.md (set_rip_rex64): Wrap operand 1 in label_ref. (set_got_offset_rex64): Ditto. From-SVN: r143720 --- gcc/ChangeLog | 9 ++++++++- gcc/config/i386/i386.md | 6 ++++-- gcc/testsuite/gcc.target/i386/pr38988.c | 24 ++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr38988.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ad51b27b671..5300a8627bc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2009-01-28 Uros Bizjak + + PR target/38988 + * config/i386/i386.md (set_rip_rex64): Wrap operand 1 in label_ref. + (set_got_offset_rex64): Ditto. + 2009-01-27 H.J. Lu PR target/38941 @@ -511,7 +517,8 @@ used to index the memory access. Do not pass loop_p. Fix comment. Stop recursion on tcc_constant or tcc_declaration. (expand_scalar_variables_stmt): Pass to expand_scalar_variables_expr - the gimple_stmt_iterator where it inserts new code. Do not pass loop_p. + the gimple_stmt_iterator where it inserts new code. + Do not pass loop_p. (copy_bb_and_scalar_dependences): Do not pass loop_p. (translate_clast): Update call to copy_bb_and_scalar_dependences. diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 6543cf5ec57..89a3b17607b 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -15299,7 +15299,7 @@ (define_insn "set_rip_rex64" [(set (match_operand:DI 0 "register_operand" "=r") - (unspec:DI [(match_operand:DI 1 "" "")] UNSPEC_SET_RIP))] + (unspec:DI [(label_ref (match_operand 1 "" ""))] UNSPEC_SET_RIP))] "TARGET_64BIT" "lea{q}\t{%l1(%%rip), %0|%0, %l1[rip]}" [(set_attr "type" "lea") @@ -15307,7 +15307,9 @@ (define_insn "set_got_offset_rex64" [(set (match_operand:DI 0 "register_operand" "=r") - (unspec:DI [(match_operand:DI 1 "" "")] UNSPEC_SET_GOT_OFFSET))] + (unspec:DI + [(label_ref (match_operand 1 "" ""))] + UNSPEC_SET_GOT_OFFSET))] "TARGET_64BIT" "movabs{q}\t{$_GLOBAL_OFFSET_TABLE_-%l1, %0|%0, OFFSET FLAT:_GLOBAL_OFFSET_TABLE_-%l1}" [(set_attr "type" "imov") diff --git a/gcc/testsuite/gcc.target/i386/pr38988.c b/gcc/testsuite/gcc.target/i386/pr38988.c new file mode 100644 index 00000000000..8e2c8eaa67b --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr38988.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-require-effective-target fpic } */ +/* { dg-options "-O2 -fpic -mcmodel=large" } */ + +typedef long unsigned int size_t; +typedef void (*func_ptr) (void); + +static func_ptr __DTOR_LIST__[1] = { (func_ptr) (-1) }; + +void +__do_global_dtors_aux (void) +{ + extern func_ptr __DTOR_END__[]; + size_t dtor_idx = 0; + const size_t max_idx = __DTOR_END__ - __DTOR_LIST__ - 1; + func_ptr f; + + while (dtor_idx < max_idx) + { + f = __DTOR_LIST__[++dtor_idx]; + f (); + } +} -- 2.30.2