From: Kyrylo Tkachov Date: Fri, 2 Dec 2016 12:22:54 +0000 (+0000) Subject: [ree] PR rtl-optimization/78038: Handle global register dataflow definitions in ree X-Git-Tag: releases/gcc-5.5.0~668 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d11c8f105634b09a3363ee612599a7ed36044108;p=thirdparty%2Fgcc.git [ree] PR rtl-optimization/78038: Handle global register dataflow definitions in ree 2016-12-02 Kyrylo Tkachov Backport from mainline 2016-10-21 Kyrylo Tkachov PR rtl-optimization/78038 * ree.c (get_defs): Return NULL if a defining insn for REG cannot be deduced to set REG through the RTL structure. (make_defs_and_copies_lists): Return false on a failing get_defs call. * gcc.target/aarch64/pr78038.c: New test. From-SVN: r243175 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3e86e38aadc9..382004e3e253 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2016-12-02 Kyrylo Tkachov + + Backport from mainline + 2016-10-21 Kyrylo Tkachov + + PR rtl-optimization/78038 + * ree.c (get_defs): Return NULL if a defining insn for REG cannot + be deduced to set REG through the RTL structure. + (make_defs_and_copies_lists): Return false on a failing get_defs call. + 2016-12-02 Andreas Krebbel Backport from mainline diff --git a/gcc/ree.c b/gcc/ree.c index 48765b6aaabb..69dfe90af154 100644 --- a/gcc/ree.c +++ b/gcc/ree.c @@ -529,6 +529,14 @@ get_defs (rtx_insn *insn, rtx reg, vec *dest) return NULL; if (DF_REF_INSN_INFO (ref_link->ref) == NULL) return NULL; + /* As global regs are assumed to be defined at each function call + dataflow can report a call_insn as being a definition of REG. + But we can't do anything with that in this pass so proceed only + if the instruction really sets REG in a way that can be deduced + from the RTL structure. */ + if (global_regs[REGNO (reg)] + && !set_of (reg, DF_REF_INSN (ref_link->ref))) + return NULL; } if (dest) @@ -627,7 +635,7 @@ make_defs_and_copies_lists (rtx_insn *extend_insn, const_rtx set_pat, /* Initialize the work list. */ if (!get_defs (extend_insn, src_reg, &state->work_list)) - gcc_unreachable (); + return false; is_insn_visited = XCNEWVEC (bool, max_insn_uid); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cb846e6d9b93..ab1f24dbca59 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2016-12-02 Kyrylo Tkachov + + Backport from mainline + 2016-10-21 Kyrylo Tkachov + + PR rtl-optimization/78038 + * gcc.target/aarch64/pr78038.c: New test. + 2016-12-02 Andreas Krebbel Backport from mainline diff --git a/gcc/testsuite/gcc.target/aarch64/pr78038.c b/gcc/testsuite/gcc.target/aarch64/pr78038.c new file mode 100644 index 000000000000..76d97d3b0ad4 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr78038.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +/* PR rtl-optimization/78038. + Make sure ree can gracefully handle extensions of the global + variable register after a call. */ + +typedef void (*test_fptr_t) (void); +void +test_f (void) +{ +} +test_fptr_t test_fptr = test_f; + +struct test2_s +{ + int f; +}; + +register struct test2_s *g __asm__("x28"); + +void +do_something () +{ + test_fptr (); + struct test2_s *p1 = 0; + *p1 = *g; +}