diff options
author | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-06-17 12:40:33 +0200 |
---|---|---|
committer | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-06-17 13:10:06 +0200 |
commit | c91c8ab11faa895584fdb3776acf45f02011c7b4 (patch) | |
tree | f752801fbb59b51422db5fa66834013d6d0c251b /gcc/testsuite | |
parent | 7bb28ab761e556581a6ecd4cb59c7bf903b8f4fc (diff) |
can deal with arrays
Diffstat (limited to 'gcc/testsuite')
13 files changed, 150 insertions, 124 deletions
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-05-field-reads-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-05-field-reads-0.c new file mode 100644 index 00000000000..18e8fe0a596 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-05-field-reads-0.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ + +int +main () +{ + struct astruct_s + { + _Bool a; + _Bool b; + _Bool c; + }; + struct astruct_s astruct; + _Bool a = astruct.a; + _Bool c = astruct.c; + return 0; +} + +/* { dg-final { scan-ipa-dump "replacing field a 0 with a 0" "type-escape-analysis" } } */ +/* { dg-final { scan-ipa-dump "replacing field c 16 with a 8" "type-escape-analysis" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-05-rewrite-local-decl-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-05-rewrite-local-decl-0.c new file mode 100644 index 00000000000..13aa56ed9ee --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-05-rewrite-local-decl-0.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ +/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ + +#include <stdio.h> + +int +main () +{ + struct astruct_s + { + _Bool a; + _Bool b; + _Bool c; + }; + struct astruct_s astruct; + printf("%d %d\n", astruct.a, astruct.c); + return 0; +} + +// This is different from previous because here we are replacing a local declaration +/* { dg-final { scan-ipa-dump "replacing field a 0 with a 0" "type-escape-analysis" } } */ +/* { dg-final { scan-ipa-dump "replacing field c 16 with c 8" "type-escape-analysis" } } */ + diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-06-field-writes-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-06-field-writes-0.c new file mode 100644 index 00000000000..41396bfe4d3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-06-field-writes-0.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ + +#include <stdio.h> + +int +main () +{ + struct astruct_s + { + _Bool a; + _Bool b; + _Bool c; + }; + struct astruct_s astruct; + astruct.c = 0; + printf("%d %d\n", astruct.a, astruct.c); + return 0; +} + +/* { dg-final { scan-ipa-dump "replacing field a 0 with a 0" "type-escape-analysis" } } */ +// There's two... mmm.. not sure how to convey this here to the test +/* { dg-final { scan-ipa-dump "replacing field c 16 with c 8" "type-escape-analysis" } } */ +/* { dg-final { scan-ipa-dump "replacing field c 16 with c 8" "type-escape-analysis" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-07-delete-first-field-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-07-delete-first-field-0.c new file mode 100644 index 00000000000..a9c40ba0eda --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-07-delete-first-field-0.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ +/* { dg-options "-w -flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ + +#include <assert.h> +#include <stdio.h> + +int +main () +{ + struct astruct_s + { + _Bool b; + _Bool a; + _Bool c; + _Bool d; + }; + struct astruct_s astruct; + + printf("%d %d %d\n", astruct.a, astruct.c, astruct.d); + _Bool *a_ptr = &astruct.a; + struct astruct_s *s_ptr = &astruct; + assert(a_ptr == s_ptr); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-08-modify-double-struct-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-08-modify-double-struct-0.c new file mode 100644 index 00000000000..0706c7b22ea --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-08-modify-double-struct-0.c @@ -0,0 +1,30 @@ +/* { dg-do run } */ +/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ + +#include <assert.h> +int +main () +{ + struct inner_s + { + _Bool a; + _Bool b; + _Bool c; + _Bool d; + }; + struct astruct_s + { + struct inner_s a; + struct inner_s b; + struct inner_s c; + struct inner_s d; + }; + struct astruct_s astruct; + struct inner_s *a_ptr = &(astruct.a); + struct inner_s *c_ptr = &(astruct.c); + struct inner_s *d_ptr = &(astruct.d); + struct inner_s *c_ptr_2 = a_ptr + 1; + struct inner_s *a_ptr_2 = d_ptr - 2; + assert(c_ptr_2 == c_ptr); + assert(a_ptr == a_ptr_2); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-09-modify-int-struct-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-09-modify-int-struct-0.c new file mode 100644 index 00000000000..e5e80860034 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-09-modify-int-struct-0.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ +/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ + +#include <assert.h> + +int +main () +{ + struct astruct_s + { + int a; + int b; + int c; + int d; + }; + struct astruct_s astruct; + int *a = &(astruct.a); + int *c = &(astruct.c); + int *d = &(astruct.d); + assert (c - 1 == a); + assert (a + 2 == d); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-10-array-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-10-array-0.c index af0c175515a..8e828b8c6ed 100644 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-10-array-0.c +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-10-array-0.c @@ -1,5 +1,8 @@ /* { dg-do run } */ -/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=b -fipa-typelist-struct=astruct_s" } */ +/* { dg-options " -flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ + +#include <assert.h> +#include <stdio.h> int main () @@ -11,6 +14,10 @@ main () _Bool c; }; struct astruct_s a; + printf("%d %d\n", a.a, a.c); struct astruct_s b[2]; a = b[0]; + _Bool *a_ptr = &a.a; + _Bool *c_ptr = &a.c; + assert(a_ptr + 1 == c_ptr); } diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-5-field-reads-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-5-field-reads-0.c deleted file mode 100644 index 3e37a780774..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-5-field-reads-0.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=b -fipa-typelist-struct=astruct_s" } */ - -int -main () -{ - struct astruct_s - { - _Bool a; - _Bool b; - _Bool c; - }; - struct astruct_s astruct; - _Bool c = astruct.c; - return 0; -} - -/* "rewrite,field_offset,c,1" "typelist" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-5-rewrite-local-decl-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-5-rewrite-local-decl-0.c deleted file mode 100644 index 07d6ea35e0f..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-5-rewrite-local-decl-0.c +++ /dev/null @@ -1,15 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=b -fipa-typelist-struct=astruct_s" } */ - -int -main () -{ - struct astruct_s - { - _Bool a; - _Bool b; - _Bool c; - }; - struct astruct_s astruct; - return 0; -} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-6-field-writes-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-6-field-writes-0.c deleted file mode 100644 index c7092516692..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-6-field-writes-0.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=b -fipa-typelist-struct=astruct_s" } */ - -int -main () -{ - struct astruct_s - { - _Bool a; - _Bool b; - _Bool c; - }; - struct astruct_s astruct; - astruct.c = 0; - return 0; -} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-7-delete-first-field-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-7-delete-first-field-0.c deleted file mode 100644 index b0fdc15d63e..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-7-delete-first-field-0.c +++ /dev/null @@ -1,23 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=b -fipa-typelist-struct=astruct_s" } */ - -#include <assert.h> - -int -main () -{ - struct astruct_s - { - _Bool b; - _Bool a; - _Bool c; - _Bool d; - }; - struct astruct_s astruct; - - _Bool *a_ptr = &astruct.a; - struct astruct_s *astruct_ptr = &astruct; - _Bool test = (_Bool *) astruct_ptr == a_ptr; - char compile_test[test ? 1 : -1]; - assert (test); -} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-8-modify-double-struct-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-8-modify-double-struct-0.c deleted file mode 100644 index 83c508ee24e..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-8-modify-double-struct-0.c +++ /dev/null @@ -1,33 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=b -fipa-typelist-struct=astruct_s" } */ - -#include <assert.h> -int -main () -{ - struct inner_s - { - _Bool a; - _Bool b; - _Bool c; - _Bool d; - }; - struct astruct_s - { - struct inner_s a; - struct inner_s b; - struct inner_s c; - struct inner_s d; - }; - struct astruct_s astruct; - struct inner_s a = astruct.a; - struct inner_s c = astruct.c; - struct inner_s d = astruct.d; - _Bool *pa = (_Bool *) &(astruct.a); - _Bool *pc = (_Bool *) &(astruct.c); - _Bool *pd = (_Bool *) &(astruct.d); - _Bool *c_1 = pa + 4; - _Bool *d_1 = pa + 8; - assert (pc == c_1); - assert (pd == d_1); -} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-9-modify-int-struct-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-9-modify-int-struct-0.c deleted file mode 100644 index be51f9e06e9..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-9-modify-int-struct-0.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=b -fipa-typelist-struct=astruct_s" } */ - -int -main () -{ - struct astruct_s - { - int a; - int b; - int c; - int d; - }; - struct astruct_s astruct; - int a = astruct.a; - int c = astruct.c; - int d = astruct.d; -} |