From 84db1406e6d9b6d68bf45612348a8094b25e708b Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Fri, 25 Nov 2016 08:18:26 +0000 Subject: [PATCH] Add run tests for recent sibcall patches gcc/testsuite/ * gcc.dg/tree-ssa/tailcall-7-run.c: New test. * gcc.dg/tree-ssa/tailcall-8-run.c: Likewise. From-SVN: r242861 --- gcc/testsuite/ChangeLog | 5 ++ .../gcc.dg/tree-ssa/tailcall-7-run.c | 72 ++++++++++++++++ .../gcc.dg/tree-ssa/tailcall-8-run.c | 86 +++++++++++++++++++ 3 files changed, 163 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/tailcall-7-run.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/tailcall-8-run.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e18397f2a4c..159b14d9670 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-11-25 Richard Sandiford + + * gcc.dg/tree-ssa/tailcall-7-run.c: New test. + * gcc.dg/tree-ssa/tailcall-8-run.c: Likewise. + 2016-11-25 Richard Sandiford * gcc.dg/tree-ssa/tailcall-8.c: New test. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/tailcall-7-run.c b/gcc/testsuite/gcc.dg/tree-ssa/tailcall-7-run.c new file mode 100644 index 00000000000..d18ff9d8914 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/tailcall-7-run.c @@ -0,0 +1,72 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-additional-sources "tailcall-7.c" } */ + +struct s { int x; }; +extern struct s global; + +void g1 (void); +void g2 (void); +void g3 (struct s *); +struct s g4 (struct s); +struct s g5 (void); +struct s g6 (void); +struct s g7 (void); +struct s g8 (struct s *); +int g9 (struct s); +int g10 (int); + +struct s last; +struct s tmp; + +struct s +f (int i) +{ + struct s ret; + ret.x = i + 100; + last = ret; + return ret; +} + +void +callit (void (*fn) (void)) +{ + fn (); +} + +int +test (int last_val, int global_val, int tmp_val) +{ + return last.x == last_val && global.x == global_val && tmp.x == tmp_val; +} + +int +main (void) +{ + global.x = 200; + tmp.x = 300; + g1 (); + if (!test (101, 200, 300)) + __builtin_abort (); + g2 (); + if (!test (102, 102, 300)) + __builtin_abort (); + g3 (&tmp); + if (!test (103, 102, 103)) + __builtin_abort (); + if (g4 (tmp).x != 104 || !test (104, 102, 103)) + __builtin_abort (); + if (g5 ().x != 105 || !test (105, 102, 103)) + __builtin_abort (); + if (g6 ().x != 106 || !test (106, 102, 103)) + __builtin_abort (); + if (g7 ().x != 107 || !test (107, 107, 103)) + __builtin_abort (); + if (g8 (&tmp).x != 108 || !test (108, 107, 108)) + __builtin_abort (); + if (g9 (tmp) != 9 || !test (109, 107, 108)) + __builtin_abort (); + if (g10 (10) != 10 || !test (110, 107, 108)) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/tailcall-8-run.c b/gcc/testsuite/gcc.dg/tree-ssa/tailcall-8-run.c new file mode 100644 index 00000000000..f8929093846 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/tailcall-8-run.c @@ -0,0 +1,86 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-additional-sources "tailcall-8.c" } */ + +struct s { int x; }; + +int expected; +struct s *last_ptr; +struct s tmp; + +void +start (int val, struct s *initial_last_ptr) +{ + expected = val; + tmp.x = val; + last_ptr = initial_last_ptr; +} + +void +f_direct (struct s param) +{ + if (param.x != expected) + __builtin_abort (); +} + +void +f_indirect (struct s *ptr) +{ + if (ptr->x != expected) + __builtin_abort (); + last_ptr = ptr; + ptr->x += 100; +} + +void +f_void (void) +{ + if (last_ptr->x != expected + 100) + __builtin_abort (); +} + + +void g1 (struct s); +void g2 (struct s *); +void g3 (struct s *); +void g4 (struct s *); +void g5 (struct s); +void g6 (struct s); +void g7 (struct s); +void g8 (struct s *); +void g9 (struct s *); + +int +main (void) +{ + struct s g6_s = { 106 }; + + start (1, 0); + g1 (tmp); + + start (2, 0); + g2 (&tmp); + + start (3, 0); + g3 (&tmp); + + start (4, 0); + g4 (&tmp); + + start (5, 0); + g5 (tmp); + + start (6, &g6_s); + g6 (tmp); + + start (7, 0); + g7 (tmp); + + start (8, 0); + g8 (&tmp); + + start (9, 0); + g9 (&tmp); + + return 0; +} -- 2.30.2