From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- gcc/testsuite/gcc.dg/struct/struct-reorg.exp | 75 ++++++++++++++++++++++ gcc/testsuite/gcc.dg/struct/w_prof_global_array.c | 30 +++++++++ gcc/testsuite/gcc.dg/struct/w_prof_global_var.c | 43 +++++++++++++ gcc/testsuite/gcc.dg/struct/w_prof_local_array.c | 38 +++++++++++ gcc/testsuite/gcc.dg/struct/w_prof_local_var.c | 41 ++++++++++++ .../gcc.dg/struct/w_prof_single_str_global.c | 33 ++++++++++ gcc/testsuite/gcc.dg/struct/w_prof_two_strs.c | 66 +++++++++++++++++++ gcc/testsuite/gcc.dg/struct/w_ratio_cold_str.c | 43 +++++++++++++ gcc/testsuite/gcc.dg/struct/wo_prof_array_field.c | 27 ++++++++ .../gcc.dg/struct/wo_prof_array_through_pointer.c | 39 +++++++++++ .../gcc.dg/struct/wo_prof_double_malloc.c | 30 +++++++++ gcc/testsuite/gcc.dg/struct/wo_prof_empty_str.c | 45 +++++++++++++ .../gcc.dg/struct/wo_prof_escape_arg_to_local.c | 44 +++++++++++++ .../gcc.dg/struct/wo_prof_escape_return.c | 31 +++++++++ .../gcc.dg/struct/wo_prof_escape_str_init.c | 33 ++++++++++ .../gcc.dg/struct/wo_prof_escape_substr_array.c | 34 ++++++++++ .../gcc.dg/struct/wo_prof_escape_substr_pointer.c | 49 ++++++++++++++ .../gcc.dg/struct/wo_prof_escape_substr_value.c | 46 +++++++++++++ gcc/testsuite/gcc.dg/struct/wo_prof_global_array.c | 33 ++++++++++ gcc/testsuite/gcc.dg/struct/wo_prof_global_var.c | 46 +++++++++++++ gcc/testsuite/gcc.dg/struct/wo_prof_local_array.c | 41 ++++++++++++ gcc/testsuite/gcc.dg/struct/wo_prof_local_var.c | 44 +++++++++++++ .../gcc.dg/struct/wo_prof_malloc_size_var.c | 48 ++++++++++++++ .../gcc.dg/struct/wo_prof_mult_field_peeling.c | 43 +++++++++++++ .../gcc.dg/struct/wo_prof_single_str_global.c | 35 ++++++++++ .../gcc.dg/struct/wo_prof_single_str_local.c | 35 ++++++++++ .../gcc.dg/struct/wo_prof_single_str_pointer.c | 40 ++++++++++++ gcc/testsuite/gcc.dg/struct/wo_prof_two_strs.c | 68 ++++++++++++++++++++ 28 files changed, 1180 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/struct/struct-reorg.exp create mode 100644 gcc/testsuite/gcc.dg/struct/w_prof_global_array.c create mode 100644 gcc/testsuite/gcc.dg/struct/w_prof_global_var.c create mode 100644 gcc/testsuite/gcc.dg/struct/w_prof_local_array.c create mode 100644 gcc/testsuite/gcc.dg/struct/w_prof_local_var.c create mode 100644 gcc/testsuite/gcc.dg/struct/w_prof_single_str_global.c create mode 100644 gcc/testsuite/gcc.dg/struct/w_prof_two_strs.c create mode 100644 gcc/testsuite/gcc.dg/struct/w_ratio_cold_str.c create mode 100644 gcc/testsuite/gcc.dg/struct/wo_prof_array_field.c create mode 100644 gcc/testsuite/gcc.dg/struct/wo_prof_array_through_pointer.c create mode 100644 gcc/testsuite/gcc.dg/struct/wo_prof_double_malloc.c create mode 100644 gcc/testsuite/gcc.dg/struct/wo_prof_empty_str.c create mode 100644 gcc/testsuite/gcc.dg/struct/wo_prof_escape_arg_to_local.c create mode 100644 gcc/testsuite/gcc.dg/struct/wo_prof_escape_return.c create mode 100644 gcc/testsuite/gcc.dg/struct/wo_prof_escape_str_init.c create mode 100644 gcc/testsuite/gcc.dg/struct/wo_prof_escape_substr_array.c create mode 100644 gcc/testsuite/gcc.dg/struct/wo_prof_escape_substr_pointer.c create mode 100644 gcc/testsuite/gcc.dg/struct/wo_prof_escape_substr_value.c create mode 100644 gcc/testsuite/gcc.dg/struct/wo_prof_global_array.c create mode 100644 gcc/testsuite/gcc.dg/struct/wo_prof_global_var.c create mode 100644 gcc/testsuite/gcc.dg/struct/wo_prof_local_array.c create mode 100644 gcc/testsuite/gcc.dg/struct/wo_prof_local_var.c create mode 100644 gcc/testsuite/gcc.dg/struct/wo_prof_malloc_size_var.c create mode 100644 gcc/testsuite/gcc.dg/struct/wo_prof_mult_field_peeling.c create mode 100644 gcc/testsuite/gcc.dg/struct/wo_prof_single_str_global.c create mode 100644 gcc/testsuite/gcc.dg/struct/wo_prof_single_str_local.c create mode 100644 gcc/testsuite/gcc.dg/struct/wo_prof_single_str_pointer.c create mode 100644 gcc/testsuite/gcc.dg/struct/wo_prof_two_strs.c (limited to 'gcc/testsuite/gcc.dg/struct') diff --git a/gcc/testsuite/gcc.dg/struct/struct-reorg.exp b/gcc/testsuite/gcc.dg/struct/struct-reorg.exp new file mode 100644 index 000000000..a18b11d15 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/struct-reorg.exp @@ -0,0 +1,75 @@ +# Copyright (C) 2007, 2008, 2009, 2010 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING3. If not see +# . + +# Test the functionality of programs compiled with profile-directed structure +# rearrangement using -fprofile-generate followed by -fprofile-use. + +load_lib gcc-dg.exp +load_lib target-supports.exp + +set STRUCT_REORG_CFLAGS "-O3 -fipa-struct-reorg -fdump-ipa-all -fwhole-program" + +# Initialize `dg'. +dg-init + +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/wo_prof_*.c]] "" $STRUCT_REORG_CFLAGS + +dg-final + +# Some targets don't support tree profiling. +if { ![check_profiling_available ""] } { + return +} + +# The procedures in profopt.exp need these parameters. +set tool gcc +set prof_ext "gcda" + +# Override the list defined in profopt.exp. +set PROFOPT_OPTIONS [list {}] + +if $tracelevel then { + strace $tracelevel +} + +# Load support procs. +load_lib profopt.exp + +# These are globals used by profopt-execute. The first is options +# needed to generate profile data, the second is options to use the +# profile data. +set common "-O3 -fwhole-program" +set profile_option [concat $common " -fprofile-generate"] +set feedback_option [concat $common " -fprofile-use -fipa-struct-reorg -fdump-ipa-all"] + +foreach src [lsort [glob -nocomplain $srcdir/$subdir/w_prof_*.c]] { + # If we're only testing specific files and this isn't one of them, skip it. + if ![runtest_file_p $runtests $src] then { + continue + } + profopt-execute $src +} + +set feedback_option [concat $feedback_option " --param struct-reorg-cold-struct-ratio=30"] + +foreach src [lsort [glob -nocomplain $srcdir/$subdir/w_ratio_*.c]] { + # If we're only testing specific files and this isn't one of them, skip it. + if ![runtest_file_p $runtests $src] then { + continue + } + profopt-execute $src +} diff --git a/gcc/testsuite/gcc.dg/struct/w_prof_global_array.c b/gcc/testsuite/gcc.dg/struct/w_prof_global_array.c new file mode 100644 index 000000000..ca3643e43 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/w_prof_global_array.c @@ -0,0 +1,30 @@ +#include +typedef struct +{ + int a; + float b; +}str_t; + +#define N 1000 +str_t A[N]; + +int +main () +{ + int i; + + for (i = 0; i < N; i++) + { + A[i].a = 0; + } + + for (i = 0; i < N; i++) + if (A[i].a != 0) + abort (); + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final-use { scan-ipa-dump "Number of structures to transform is 1" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final-use { cleanup-ipa-dump "*" } } */ diff --git a/gcc/testsuite/gcc.dg/struct/w_prof_global_var.c b/gcc/testsuite/gcc.dg/struct/w_prof_global_var.c new file mode 100644 index 000000000..baff45d91 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/w_prof_global_var.c @@ -0,0 +1,43 @@ +#include +typedef struct +{ + int a; + float b; +}str_t; + +#ifdef STACK_SIZE +#if STACK_SIZE > 8000 +#define N 1000 +#else +#define N (STACK_SIZE/8) +#endif +#else +#define N 1000 +#endif + +str_t *p; + +int +main () +{ + int i, sum; + + p = malloc (N * sizeof (str_t)); + if (p == NULL) + return 0; + for (i = 0; i < N; i++) + p[i].b = i; + + for (i = 0; i < N; i++) + p[i].a = p[i].b + 1; + + for (i = 0; i < N; i++) + if (p[i].a != p[i].b + 1) + abort (); + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final-use { scan-ipa-dump "Number of structures to transform is 1" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final-use { cleanup-ipa-dump "*" } } */ diff --git a/gcc/testsuite/gcc.dg/struct/w_prof_local_array.c b/gcc/testsuite/gcc.dg/struct/w_prof_local_array.c new file mode 100644 index 000000000..8953264fe --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/w_prof_local_array.c @@ -0,0 +1,38 @@ +#include +typedef struct +{ + int a; + float b; +}str_t; + +#ifdef STACK_SIZE +#if STACK_SIZE > 8000 +#define N 1000 +#else +#define N (STACK_SIZE/8) +#endif +#else +#define N 1000 +#endif + +int +main () +{ + int i; + str_t A[N]; + + for (i = 0; i < N; i++) + { + A[i].a = 0; + } + + for (i = 0; i < N; i++) + if (A[i].a != 0) + abort (); + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final-use { scan-ipa-dump "Number of structures to transform is 1" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final-use { cleanup-ipa-dump "*" } } */ diff --git a/gcc/testsuite/gcc.dg/struct/w_prof_local_var.c b/gcc/testsuite/gcc.dg/struct/w_prof_local_var.c new file mode 100644 index 000000000..9a23f8d53 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/w_prof_local_var.c @@ -0,0 +1,41 @@ +#include +typedef struct +{ + int a; + float b; +}str_t; + +#ifdef STACK_SIZE +#if STACK_SIZE > 8000 +#define N 1000 +#else +#define N (STACK_SIZE/8) +#endif +#else +#define N 1000 +#endif + +int +main () +{ + int i, sum; + + str_t * p = malloc (N * sizeof (str_t)); + if (p == NULL) + return 0; + for (i = 0; i < N; i++) + p[i].b = i; + + for (i = 0; i < N; i++) + p[i].a = p[i].b + 1; + + for (i = 0; i < N; i++) + if (p[i].a != p[i].b + 1) + abort (); + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final-use { scan-ipa-dump "Number of structures to transform is 1" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final-use { cleanup-ipa-dump "*" } } */ diff --git a/gcc/testsuite/gcc.dg/struct/w_prof_single_str_global.c b/gcc/testsuite/gcc.dg/struct/w_prof_single_str_global.c new file mode 100644 index 000000000..b02023991 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/w_prof_single_str_global.c @@ -0,0 +1,33 @@ +#include +typedef struct +{ + int a; + int b; +}str_t; + +#define N 3 + +str_t str; + +int +main () +{ + int i; + int res = 1<<(1< + +typedef struct +{ + int a; + float b; +}str_t1; + +typedef struct +{ + int c; + float d; +}str_t2; + +#ifdef STACK_SIZE +#if STACK_SIZE > 16000 +#define N 1000 +#else +#define N (STACK_SIZE/16) +#endif +#else +#define N 1000 +#endif + +str_t1 *p1; +str_t2 *p2; +int num; + +void +foo (void) +{ + int i; + + for (i=0; i < num; i++) + p2[i].c = 2; +} + +int +main () +{ + int i, r; + + r = rand (); + num = r > N ? N : r; + p1 = malloc (num * sizeof (str_t1)); + p2 = malloc (num * sizeof (str_t2)); + + if (p1 == NULL || p2 == NULL) + return 0; + + for (i = 0; i < num; i++) + p1[i].a = 1; + + foo (); + + for (i = 0; i < num; i++) + if (p1[i].a != 1 || p2[i].c != 2) + abort (); + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final-use { scan-ipa-dump "Number of structures to transform is 2" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final-use { cleanup-ipa-dump "*" } } */ + diff --git a/gcc/testsuite/gcc.dg/struct/w_ratio_cold_str.c b/gcc/testsuite/gcc.dg/struct/w_ratio_cold_str.c new file mode 100644 index 000000000..3c26e3be7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/w_ratio_cold_str.c @@ -0,0 +1,43 @@ +#include +typedef struct +{ + int a; + int b; +}str_t1; + +typedef struct +{ + float a; + float b; +}str_t2; + +#define N1 1000 +#define N2 100 +str_t1 A1[N1]; +str_t2 A2[N2]; + +int +main () +{ + int i; + + for (i = 0; i < N1; i++) + A1[i].a = 0; + + for (i = 0; i < N2; i++) + A2[i].a = 0; + + for (i = 0; i < N1; i++) + if (A1[i].a != 0) + abort (); + + for (i = 0; i < N2; i++) + if (A2[i].a != 0) + abort (); + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final-use { scan-ipa-dump "Number of structures to transform is 1" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final-use { cleanup-ipa-dump "*" } } */ diff --git a/gcc/testsuite/gcc.dg/struct/wo_prof_array_field.c b/gcc/testsuite/gcc.dg/struct/wo_prof_array_field.c new file mode 100644 index 000000000..5d5e37b4f --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/wo_prof_array_field.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-do run } */ + +#include +typedef struct basic +{ + int a; + int b[10]; +} type_struct; + +type_struct *str1; + +int main() +{ + int i; + + str1 = malloc (10 * sizeof (type_struct)); + + for (i=0; i<=9; i++) + str1[i].a = str1[i].b[0]; + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final { scan-ipa-dump "Number of structures to transform is 1" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final { cleanup-ipa-dump "*" } } */ diff --git a/gcc/testsuite/gcc.dg/struct/wo_prof_array_through_pointer.c b/gcc/testsuite/gcc.dg/struct/wo_prof_array_through_pointer.c new file mode 100644 index 000000000..efb68be8b --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/wo_prof_array_through_pointer.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-do run } */ + +#include +typedef struct +{ + int a; + float b; +}str_t; + +#ifdef STACK_SIZE +#if STACK_SIZE > 8000 +#define N 1000 +#else +#define N (STACK_SIZE/8) +#endif +#else +#define N 1000 +#endif + +int +main () +{ + int i; + str_t A[N]; + str_t *p = A; + + for (i = 0; i < N; i++) + p[i].a = 0; + + for (i = 0; i < N; i++) + if (p[i].a != 0) + abort (); + + return 0; +} + +/* { dg-final { scan-ipa-dump "Number of structures to transform is 1" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final { cleanup-ipa-dump "*" } } */ diff --git a/gcc/testsuite/gcc.dg/struct/wo_prof_double_malloc.c b/gcc/testsuite/gcc.dg/struct/wo_prof_double_malloc.c new file mode 100644 index 000000000..77226b449 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/wo_prof_double_malloc.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-do run } */ + +#include + +typedef struct test_struct +{ + int a; + int b; +} type_struct; + +typedef type_struct **struct_pointer2; + +struct_pointer2 str1; + +int main() +{ + int i, j; + + str1 = malloc (2 * sizeof (type_struct *)); + + for (i = 0; i <= 1; i++) + str1[i] = malloc (2 * sizeof (type_struct)); + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final { scan-ipa-dump "Number of structures to transform is 1" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final { cleanup-ipa-dump "*" } } */ diff --git a/gcc/testsuite/gcc.dg/struct/wo_prof_empty_str.c b/gcc/testsuite/gcc.dg/struct/wo_prof_empty_str.c new file mode 100644 index 000000000..09668face --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/wo_prof_empty_str.c @@ -0,0 +1,45 @@ +/* { dg-do run } */ + +#include + +struct S { int a; struct V *b; }; +typedef struct { int c; } T; +typedef struct { int d; int e; } U; + +void * +fn (void *x) +{ + return x; +} + +int +foo (struct S *s) +{ + T x; + + T y = *(T *)fn (&x); + return y.c; +} + +int +bar (struct S *s) +{ + U x; + + U y = *(U *)fn (&x); + return y.d + s->a; +} + +int +main () +{ + struct S s; + + foo(&s) + bar (&s); + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final { scan-ipa-dump "No structures to transform" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final { cleanup-ipa-dump "*" } } */ diff --git a/gcc/testsuite/gcc.dg/struct/wo_prof_escape_arg_to_local.c b/gcc/testsuite/gcc.dg/struct/wo_prof_escape_arg_to_local.c new file mode 100644 index 000000000..0116d8198 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/wo_prof_escape_arg_to_local.c @@ -0,0 +1,44 @@ +/* { dg-do run } */ + +#include +struct str +{ + int a; + float b; +}; + +#ifdef STACK_SIZE +#if STACK_SIZE > 8000 +#define N 1000 +#else +#define N (STACK_SIZE/8) +#endif +#else +#define N 1000 +#endif + +int +foo (struct str * p_str) +{ + static int sum = 0; + + sum = sum + p_str->a; + return sum; +} + +int +main () +{ + int i, sum; + struct str * p = malloc (N * sizeof (struct str)); + if (p == NULL) + return 0; + for (i = 0; i < N; i++) + sum = foo (p+i); + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final { scan-ipa-dump "is passed to local function...Excluded." "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final { cleanup-ipa-dump "*" } } */ diff --git a/gcc/testsuite/gcc.dg/struct/wo_prof_escape_return.c b/gcc/testsuite/gcc.dg/struct/wo_prof_escape_return.c new file mode 100644 index 000000000..21a6a7f3a --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/wo_prof_escape_return.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +#include + +struct A { + int d; +}; + +struct A a; + +struct A foo () +{ + a.d = 5; + return a; +} + +int +main () +{ + a.d = 0; + foo (); + + if (a.d != 5) + abort (); + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final { scan-ipa-dump "is return type of function...Excluded" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final { cleanup-ipa-dump "*" } } */ diff --git a/gcc/testsuite/gcc.dg/struct/wo_prof_escape_str_init.c b/gcc/testsuite/gcc.dg/struct/wo_prof_escape_str_init.c new file mode 100644 index 000000000..6da3420f6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/wo_prof_escape_str_init.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-do run } */ + +#include +typedef struct +{ + int a; + int b; +}str_t; + +#define N 2 + +str_t A[2] = {{1,1},{2,2}}; + +int +main () +{ + int i; + + for (i = 0; i < N; i++) + A[i].b = A[i].a; + + for (i = 0; i < N; i++) + if (A[i].b != A[i].a) + abort (); + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final { scan-ipa-dump "is initialized...Excluded" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final { cleanup-ipa-dump "*" } } */ + diff --git a/gcc/testsuite/gcc.dg/struct/wo_prof_escape_substr_array.c b/gcc/testsuite/gcc.dg/struct/wo_prof_escape_substr_array.c new file mode 100644 index 000000000..bd03ec42f --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/wo_prof_escape_substr_array.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-do run } */ + +#include +typedef struct +{ + int a; + float b; +}str_t; + +#define N 1000 + +typedef struct +{ + str_t A[N]; + int c; +}str_with_substr_t; + +str_with_substr_t a; + +int +main () +{ + int i; + + for (i = 0; i < N; i++) + a.A[i].b = 0; + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final { scan-ipa-dump "is a field in the structure" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final { cleanup-ipa-dump "*" } } */ diff --git a/gcc/testsuite/gcc.dg/struct/wo_prof_escape_substr_pointer.c b/gcc/testsuite/gcc.dg/struct/wo_prof_escape_substr_pointer.c new file mode 100644 index 000000000..59e0e4832 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/wo_prof_escape_substr_pointer.c @@ -0,0 +1,49 @@ +/* { dg-do compile } */ +/* { dg-do run } */ + +#include +typedef struct +{ + int a; + float b; +}str_t; + +#ifdef STACK_SIZE +#if STACK_SIZE > 16000 +#define N 1000 +#else +#define N (STACK_SIZE/16) +#endif +#else +#define N 1000 +#endif + +typedef struct +{ + str_t * sub_str; + int c; +}str_with_substr_t; + +int foo; + +int +main (void) +{ + int i; + str_with_substr_t A[N]; + str_t a[N]; + + for (i=0; i < N; i++) + A[i].sub_str = &(a[i]); + + for (i=0; i < N; i++) + A[i].sub_str->a = 5; + + foo = A[56].sub_str->a; + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final { scan-ipa-dump "is a field in the structure" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final { cleanup-ipa-dump "*" } } */ diff --git a/gcc/testsuite/gcc.dg/struct/wo_prof_escape_substr_value.c b/gcc/testsuite/gcc.dg/struct/wo_prof_escape_substr_value.c new file mode 100644 index 000000000..a6b32ddd6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/wo_prof_escape_substr_value.c @@ -0,0 +1,46 @@ +/* { dg-do compile } */ +/* { dg-do run } */ + +#include +typedef struct +{ + int a; + float b; +}str_t; + +#ifdef STACK_SIZE +#if STACK_SIZE > 8000 +#define N 1000 +#else +#define N (STACK_SIZE/8) +#endif +#else +#define N 1000 +#endif + + +typedef struct +{ + str_t sub_str; + int c; +}str_with_substr_t; + +int +main () +{ + int i; + str_with_substr_t A[N]; + + for (i = 0; i < N; i++) + A[i].sub_str.a = 5; + + for (i = 0; i < N; i++) + if (A[i].sub_str.a != 5) + abort (); + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final { scan-ipa-dump "is a field in the structure" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final { cleanup-ipa-dump "*" } } */ diff --git a/gcc/testsuite/gcc.dg/struct/wo_prof_global_array.c b/gcc/testsuite/gcc.dg/struct/wo_prof_global_array.c new file mode 100644 index 000000000..b61e26b12 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/wo_prof_global_array.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-do run } */ + +#include +typedef struct +{ + int a; + float b; +}str_t; + +#define N 1000 +str_t A[N]; + +int +main () +{ + int i; + + for (i = 0; i < N; i++) + { + A[i].a = 0; + } + + for (i = 0; i < N; i++) + if (A[i].a != 0) + abort (); + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final { scan-ipa-dump "Number of structures to transform is 1" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final { cleanup-ipa-dump "*" } } */ diff --git a/gcc/testsuite/gcc.dg/struct/wo_prof_global_var.c b/gcc/testsuite/gcc.dg/struct/wo_prof_global_var.c new file mode 100644 index 000000000..39351e072 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/wo_prof_global_var.c @@ -0,0 +1,46 @@ +/* { dg-do compile } */ +/* { dg-do run } */ + +#include +typedef struct +{ + int a; + float b; +}str_t; + +#ifdef STACK_SIZE +#if STACK_SIZE > 8000 +#define N 1000 +#else +#define N (STACK_SIZE/8) +#endif +#else +#define N 1000 +#endif + +str_t *p; + +int +main () +{ + int i, sum; + + p = malloc (N * sizeof (str_t)); + if (p == NULL) + return 0; + for (i = 0; i < N; i++) + p[i].b = i; + + for (i = 0; i < N; i++) + p[i].b = p[i].a + 1; + + for (i = 0; i < N; i++) + if (p[i].b != p[i].a + 1) + abort (); + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final { scan-ipa-dump "Number of structures to transform is 1" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final { cleanup-ipa-dump "*" } } */ diff --git a/gcc/testsuite/gcc.dg/struct/wo_prof_local_array.c b/gcc/testsuite/gcc.dg/struct/wo_prof_local_array.c new file mode 100644 index 000000000..18d5a7347 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/wo_prof_local_array.c @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* { dg-do run } */ + +#include +typedef struct +{ + int a; + float b; +}str_t; + +#ifdef STACK_SIZE +#if STACK_SIZE > 8000 +#define N 1000 +#else +#define N (STACK_SIZE/8) +#endif +#else +#define N 1000 +#endif + +int +main () +{ + int i; + str_t A[N]; + + for (i = 0; i < N; i++) + { + A[i].a = 0; + } + + for (i = 0; i < N; i++) + if (A[i].a != 0) + abort (); + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final { scan-ipa-dump "Number of structures to transform is 1" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final { cleanup-ipa-dump "*" } } */ diff --git a/gcc/testsuite/gcc.dg/struct/wo_prof_local_var.c b/gcc/testsuite/gcc.dg/struct/wo_prof_local_var.c new file mode 100644 index 000000000..26a9dbd73 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/wo_prof_local_var.c @@ -0,0 +1,44 @@ +/* { dg-do compile } */ +/* { dg-do run } */ + +#include +typedef struct +{ + int a; + float b; +}str_t; + +#ifdef STACK_SIZE +#if STACK_SIZE > 8000 +#define N 1000 +#else +#define N (STACK_SIZE/8) +#endif +#else +#define N 1000 +#endif + +int +main () +{ + int i, sum; + + str_t * p = malloc (N * sizeof (str_t)); + if (p == NULL) + return 0; + for (i = 0; i < N; i++) + p[i].b = i; + + for (i = 0; i < N; i++) + p[i].b = p[i].a + 1; + + for (i = 0; i < N; i++) + if (p[i].b != p[i].a + 1) + abort (); + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final { scan-ipa-dump "Number of structures to transform is 1" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final { cleanup-ipa-dump "*" } } */ diff --git a/gcc/testsuite/gcc.dg/struct/wo_prof_malloc_size_var.c b/gcc/testsuite/gcc.dg/struct/wo_prof_malloc_size_var.c new file mode 100644 index 000000000..6caadcf12 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/wo_prof_malloc_size_var.c @@ -0,0 +1,48 @@ +/* { dg-do compile } */ +/* { dg-do run } */ + +#include +typedef struct +{ + int a; + float b; +}str_t; + +#ifdef STACK_SIZE +#if STACK_SIZE > 8000 +#define N 1000 +#else +#define N (STACK_SIZE/8) +#endif +#else +#define N 1000 +#endif + +int +main () +{ + int i, num; + + num = rand(); + num = num > N ? N : num; + str_t * p = malloc (num * sizeof (str_t)); + + if (p == 0) + return 0; + + for (i = 0; i < num; i++) + p[i].b = i; + + for (i = 0; i < num; i++) + p[i].a = p[i].b + 1; + + for (i = 0; i < num; i++) + if (p[i].a != p[i].b + 1) + abort (); + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final { scan-ipa-dump "Number of structures to transform is 1" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final { cleanup-ipa-dump "*" } } */ diff --git a/gcc/testsuite/gcc.dg/struct/wo_prof_mult_field_peeling.c b/gcc/testsuite/gcc.dg/struct/wo_prof_mult_field_peeling.c new file mode 100644 index 000000000..8f116df4d --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/wo_prof_mult_field_peeling.c @@ -0,0 +1,43 @@ +/* { dg-do compile } */ +/* { dg-do run } */ + +#include +typedef struct +{ + int a; + float b; + int c; + float d; +}str_t; + +#ifdef STACK_SIZE +#if STACK_SIZE > 1600 +#define N 100 +#else +#define N (STACK_SIZE/16) +#endif +#else +#define N 100 +#endif + +int +main () +{ + int i; + str_t *p = malloc (N * sizeof (str_t)); + if (p == NULL) + return 0; + for (i = 0; i < N; i++) + p[i].a = 5; + + for (i = 0; i < N; i++) + if (p[i].a != 5) + abort (); + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* The structure str_t is erroneously peeled into 4 structures instead of 2. */ +/* { dg-final { scan-ipa-dump "the number of new types is 2" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final { cleanup-ipa-dump "*" } } */ diff --git a/gcc/testsuite/gcc.dg/struct/wo_prof_single_str_global.c b/gcc/testsuite/gcc.dg/struct/wo_prof_single_str_global.c new file mode 100644 index 000000000..812763d53 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/wo_prof_single_str_global.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-do run } */ + +#include +typedef struct +{ + int a; + int b; +}str_t; + +#define N 3 + +str_t str; + +int +main () +{ + int i; + int res = 1<<(1< +typedef struct +{ + int a; + int b; +}str_t; + +#define N 3 + +int +main () +{ + int i; + int res = 1<<(1< +typedef struct +{ + int a; + int *b; +}str_t; + +#define N 3 + +str_t *p; + +int +main () +{ + str_t str; + int i; + int res = 1 << (1 << N); + p = &str; + str.a = 2; + + p->b = &(p->a); + + for (i=0; i < N; i++) + p->a = *(p->b)*(*(p->b)); + + if (p->a != res) + abort (); + + /* POSIX ignores all but the 8 low-order bits, but other + environments may not. */ + return (p->a & 255); +} + +/*--------------------------------------------------------------------------*/ +/* The access &(p->a) is handled incorrectly in ipa-struct-reorg.c. */ +/* { dg-final { scan-ipa-dump "Number of structures to transform is 1" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final { cleanup-ipa-dump "*" } } */ diff --git a/gcc/testsuite/gcc.dg/struct/wo_prof_two_strs.c b/gcc/testsuite/gcc.dg/struct/wo_prof_two_strs.c new file mode 100644 index 000000000..92da94d29 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct/wo_prof_two_strs.c @@ -0,0 +1,68 @@ +/* { dg-do compile } */ +/* { dg-do run } */ + +#include + +typedef struct +{ + int a; + float b; +}str_t1; + +typedef struct +{ + int c; + float d; +}str_t2; + +#ifdef STACK_SIZE +#if STACK_SIZE > 16000 +#define N 1000 +#else +#define N (STACK_SIZE/16) +#endif +#else +#define N 1000 +#endif + +str_t1 *p1; +str_t2 *p2; +int num; + +void +foo (void) +{ + int i; + + for (i=0; i < num; i++) + p2[i].c = 2; +} + +int +main () +{ + int i, r; + + r = rand (); + num = r > N ? N : r; + p1 = malloc (num * sizeof (str_t1)); + p2 = malloc (num * sizeof (str_t2)); + + if (p1 == NULL || p2 == NULL) + return 0; + + for (i = 0; i < num; i++) + p1[i].a = 1; + + foo (); + + for (i = 0; i < num; i++) + if (p1[i].a != 1 || p2[i].c != 2) + abort (); + + return 0; +} + +/*--------------------------------------------------------------------------*/ +/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "ipa_struct_reorg" { xfail *-*-* } } } */ +/* { dg-final { cleanup-ipa-dump "*" } } */ -- cgit v1.2.3