This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix flatten-2.c testcase


On Fri, May 15, 2009 at 5:34 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> Hi,
> this testcase tests flattening of cycles in cgraph containing indirect
> function call. ?In main inliner we try to give precendece to
> non-indirect call, but early inliner don't know about the cycles. ?As
> discussed earlier, we don't make any promises here and I think it is
> perfectly resonable to inline indirect call and break cycle elsewhere as
> we do in case of cycles not containing any indirect edges.
>
> This patch updates testcase to disable early inlining and adds
> variant without the additional test that cycle is broken at indirect
> call as suggested by Richard.
>
> Regtested on x86_64-linux and comitted.

Note that I agree with Micha that we should inline the static functions here.
Thus I think your iteration scheme is sort-of broken - can't you simply only
consider new cgraph edges that appear during de-virtualization /
indirect->direct
call folding?

Richard.

> Honza
>
> ? ? ? ?* flatten-2.c: Disable early inlining; add comment.
> ? ? ? ?* flatten-3.c: New test based on flatten-2.c.
> Index: testsuite/gcc.dg/tree-ssa/flatten-2.c
> ===================================================================
> *** testsuite/gcc.dg/tree-ssa/flatten-2.c ? ? ? (revision 147391)
> --- testsuite/gcc.dg/tree-ssa/flatten-2.c ? ? ? (working copy)
> ***************
> *** 1,11 ****
> ?/* { dg-do compile } */
> ! /* { dg-options -O2 } */
>
> ?extern void do_something_usefull();
> ?/* Check that we finish compiling even if instructed to
> ? ? flatten a cyclic callgraph. ?Verify we correctly
> ? ? flatten with another function marked flatten in the
> ! ? ?callgraph. ?*/
>
> ?void __attribute__((flatten)) direct(void)
> ?{
> --- 1,16 ----
> ?/* { dg-do compile } */
> ! /* { dg-options "-O2 -fno-early-inlining" } */
>
> ?extern void do_something_usefull();
> ?/* Check that we finish compiling even if instructed to
> ? ? flatten a cyclic callgraph. ?Verify we correctly
> ? ? flatten with another function marked flatten in the
> ! ? ?callgraph.
> !
> ! ? ?Main inline is cureful about indirect calls giving
> ! ? ?precedence to breaking cycle at indirect call sites.
> ! ? ?Early inliner can't do similar analysis, so we need
> ! ? ?to disable it if we want cycles to be broken consistently. ?*/
>
> ?void __attribute__((flatten)) direct(void)
> ?{
> Index: testsuite/gcc.dg/tree-ssa/flatten-3.c
> ===================================================================
> *** testsuite/gcc.dg/tree-ssa/flatten-3.c ? ? ? (revision 0)
> --- testsuite/gcc.dg/tree-ssa/flatten-3.c ? ? ? (revision 0)
> ***************
> *** 0 ****
> --- 1,79 ----
> + /* { dg-do compile } */
> + /* { dg-options -O2 } */
> +
> + extern void do_something_usefull();
> + /* Check that we finish compiling even if instructed to
> + ? ?flatten a cyclic callgraph. ?Verify we correctly
> + ? ?flatten with another function marked flatten in the
> + ? ?callgraph. ?*/
> +
> + void __attribute__((flatten)) direct(void)
> + {
> + ? direct();
> + }
> +
> +
> + void __attribute__((flatten)) indirect(void);
> + static void indirect1(void)
> + {
> + ? indirect();
> + }
> + void __attribute__((flatten)) indirect(void)
> + {
> + ? indirect1();
> + }
> +
> +
> + void __attribute__((flatten)) doubleindirect(void);
> + static void doubleindirect2(void)
> + {
> + ? doubleindirect();
> + ? do_something_usefull ();
> + }
> + static void doubleindirect1(void)
> + {
> + ? doubleindirect2();
> + }
> + void __attribute__((flatten)) doubleindirect(void)
> + {
> + ? doubleindirect1();
> + }
> +
> +
> + static void subcycle1(void);
> + static void subcycle2(void)
> + {
> + ? subcycle1();
> + ? do_something_usefull ();
> + }
> + static void subcycle1(void)
> + {
> + ? subcycle2();
> + }
> + void __attribute__((flatten)) subcycle(void)
> + {
> + ? subcycle1();
> + }
> +
> +
> + static void doublesubcycle1(void);
> + static void doublesubcycle2(void);
> + static void doublesubcycle3(void)
> + {
> + ? doublesubcycle1();
> + ? do_something_usefull ();
> + }
> + static void doublesubcycle2(void)
> + {
> + ? doublesubcycle3();
> + }
> + static void doublesubcycle1(void)
> + {
> + ? doublesubcycle2();
> + }
> + void __attribute__((flatten)) doublesubcycle(void)
> + {
> + ? doublesubcycle1();
> + }
> +
> + /* { dg-final { scan-assembler "cycle\[123\]\[: \t\n\]" } } */
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]