diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/ipa')
81 files changed, 1765 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-00-simple-read-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-00-simple-read-0.c new file mode 100644 index 00000000000..88f96ea3be4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-00-simple-read-0.c @@ -0,0 +1,19 @@ +/* { dg-do link } */ +/* { dg-options "-flto -fipa-hello-world -fdump-ipa-hello-world" } */ + +#include <stdio.h> + +struct astruct_s { _Bool a; _Bool b; _Bool c;}; +struct astruct_s astruct; + + +int +main () +{ + printf("%d\n", astruct.a); + printf("%d\n", astruct.a); +} + +/* { dg-final { scan-wpa-ipa-dump "collected,astruct_s" "hello-world" } } */ +/* { dg-final { scan-wpa-ipa-dump "astruct_s.a read 1" "hello-world" } } */ +/* { dg-final { scan-wpa-ipa-dump "astruct_s.a read 2" "hello-world" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-01-simple-write-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-01-simple-write-0.c new file mode 100644 index 00000000000..6e7b3236294 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-01-simple-write-0.c @@ -0,0 +1,19 @@ +/* { dg-do link } */ +/* { dg-options "-flto -fipa-hello-world -fdump-ipa-hello-world" } */ + +#include <stdio.h> + +struct astruct_s { _Bool a; _Bool b; _Bool c;}; +struct astruct_s astruct; + + +int +main () +{ + astruct.a++; + astruct.a = 3; +} + +/* { dg-final { scan-wpa-ipa-dump "collected,astruct_s" "hello-world" } } */ +/* { dg-final { scan-wpa-ipa-dump "astruct_s.a write 1" "hello-world" } } */ +/* { dg-final { scan-wpa-ipa-dump "astruct_s.a write 2" "hello-world" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-02-pointer-read-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-02-pointer-read-0.c new file mode 100644 index 00000000000..1b6755565ff --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-02-pointer-read-0.c @@ -0,0 +1,19 @@ +/* { dg-do link } */ +/* { dg-options "-flto -fipa-hello-world -fdump-ipa-hello-world" } */ + +#include <stdio.h> + +struct astruct_s { _Bool a; _Bool b; _Bool c;}; +struct astruct_s *astruct = NULL; + + +int +main () +{ + printf("%d\n", astruct->a); + printf("%d\n", astruct->a); +} + +/* { dg-final { scan-wpa-ipa-dump "collected,astruct_s" "hello-world" } } */ +/* { dg-final { scan-wpa-ipa-dump "astruct_s.a read 1" "hello-world" } } */ +/* { dg-final { scan-wpa-ipa-dump "astruct_s.a read 2" "hello-world" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-03-pointer-write-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-03-pointer-write-0.c new file mode 100644 index 00000000000..68e2f40a12a --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-03-pointer-write-0.c @@ -0,0 +1,19 @@ +/* { dg-do link } */ +/* { dg-options "-flto -fipa-hello-world -fdump-ipa-hello-world" } */ + +#include <stdio.h> + +struct astruct_s { _Bool a; _Bool b; _Bool c;}; +struct astruct_s *astruct; + + +int +main () +{ + astruct->a++; + astruct->a = 3; +} + +/* { dg-final { scan-wpa-ipa-dump "collected,astruct_s" "hello-world" } } */ +/* { dg-final { scan-wpa-ipa-dump "astruct_s.a write 1" "hello-world" } } */ +/* { dg-final { scan-wpa-ipa-dump "astruct_s.a write 2" "hello-world" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-04-gimple-cond-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-04-gimple-cond-0.c new file mode 100644 index 00000000000..0dd152a2783 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-04-gimple-cond-0.c @@ -0,0 +1,19 @@ +/* { dg-do link } */ +/* { dg-options "-flto -fipa-hello-world -fdump-ipa-hello-world" } */ + +#include <stdio.h> + +struct astruct_s { _Bool a; _Bool b; _Bool c;}; +struct astruct_s astruct; + + +int +main () +{ + if (astruct.a) { + puts("hello world"); + } +} + +/* { dg-final { scan-wpa-ipa-dump "collected,astruct_s" "hello-world" } } */ +/* { dg-final { scan-wpa-ipa-dump "astruct_s.a read 1" "hello-world" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-ea-00-collect-global-record-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-ea-00-collect-global-record-0.c new file mode 100644 index 00000000000..f9c4af5d6cf --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-ea-00-collect-global-record-0.c @@ -0,0 +1,13 @@ +/* { dg-do link } */ +/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ + +struct astruct_s { _Bool a; _Bool b; _Bool c;}; +struct astruct_s astruct; + +int +main () +{ + astruct.a = 0; +} + +/* { dg-final { scan-ipa-dump "collected,astruct_s" "type-escape-analysis" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-ea-01-collect-global-pointers-to-record-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-ea-01-collect-global-pointers-to-record-0.c new file mode 100644 index 00000000000..e1147844f18 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-ea-01-collect-global-pointers-to-record-0.c @@ -0,0 +1,16 @@ +/* { dg-do link } */ +/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ + +#include <stddef.h> + +struct astruct_s { _Bool a; _Bool b; _Bool c;}; +struct astruct_s *astruct; + +int +main () +{ + astruct = NULL; +} + +/* { dg-final { scan-ipa-dump "collected,astruct_s" "type-escape-analysis" } } */ +/* { dg-final { scan-ipa-dump "collected,astruct_s*" "type-escape-analysis" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-ea-02-collect-global-array-to-record-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-ea-02-collect-global-array-to-record-0.c new file mode 100644 index 00000000000..aed61d4ef69 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-ea-02-collect-global-array-to-record-0.c @@ -0,0 +1,16 @@ +/* { dg-do link } */ +/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ + +#include <stddef.h> + +struct astruct_s { _Bool a; _Bool b; _Bool c;}; +struct astruct_s astruct[2]; + +int +main () +{ + struct astruct_s another = astruct[0]; +} + +/* { dg-final { scan-ipa-dump "collected,astruct_s" "type-escape-analysis" } } */ +/* { dg-final { scan-ipa-dump "collected,astruct_s[]" "type-escape-analysis" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-ea-03-collect-nested-record-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-ea-03-collect-nested-record-0.c new file mode 100644 index 00000000000..e300b0b598a --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-ea-03-collect-nested-record-0.c @@ -0,0 +1,20 @@ +/* { dg-do link } */ +/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ + +#include <stddef.h> + +struct astruct_s { _Bool a; _Bool b; _Bool c;}; +struct astruct_s astruct[2]; +struct outer_struct { _Bool d; struct astruct_s a; }; +struct outer_struct bstruct; + +int +main () +{ + bstruct.d = 0; + struct astruct_s another = astruct[0]; +} + +/* { dg-final { scan-ipa-dump "collected,astruct_s" "type-escape-analysis" } } */ +/* { dg-final { scan-ipa-dump "collected,outer_struct" "type-escape-analysis" } } */ +/* { dg-final { scan-ipa-dump "collected,astruct_s[]" "type-escape-analysis" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-ea-04-collect-parameters-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-ea-04-collect-parameters-0.c new file mode 100644 index 00000000000..7b40c7701bf --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-ea-04-collect-parameters-0.c @@ -0,0 +1,20 @@ +/* { dg-do link } */ +/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ + +#include <stddef.h> + +struct astruct_s { _Bool a; _Bool b; _Bool c;}; + +void record_parameter(struct astruct_s a) {} +void pointer_parameter(struct astruct_s *a) {} +void array_parameter(struct astruct_s a[]) {} + + +int +main () +{ +} + +/* { dg-final { scan-ipa-dump "collected,astruct_s" "type-escape-analysis" } } */ +/* { dg-final { scan-ipa-dump "collected,astruct_s*" "type-escape-analysis" } } */ +/* { dg-final { scan-ipa-dump "collected,astruct_s[]" "type-escape-analysis" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-ea-05-global-escapes-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-ea-05-global-escapes-0.c new file mode 100644 index 00000000000..32a77195322 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-ea-05-global-escapes-0.c @@ -0,0 +1,23 @@ +/* { dg-do link } */ +/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ +/* { dg-require-effective-target lto } */ + + +#include <stddef.h> + +struct astruct_s { _Bool a; _Bool b; _Bool c;}; +__attribute__((externally_visible)) struct astruct_s astruct; // This should escape +struct bstruct_s { _Bool a; _Bool b; _Bool c;}; +struct bstruct_s bstruct; // This should not escape + +int main() +{ + astruct.a = 0; + bstruct.b = 0; +} + + +/* { dg-final { scan-wpa-ipa-dump "collected,astruct_s" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump "variable bstruct is escaping false" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump "collected,bstruct_s" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump "variable astruct is escaping true" "type-escape-analysis" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-ea-06-global-type-escapes-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-ea-06-global-type-escapes-0.c new file mode 100644 index 00000000000..2e7024ab907 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-ea-06-global-type-escapes-0.c @@ -0,0 +1,21 @@ +/* { dg-do link } */ +/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ + +#include <stddef.h> + +struct astruct_s { _Bool a; _Bool b; _Bool c;}; +__attribute__((externally_visible)) struct astruct_s astruct; // This should escape +struct bstruct_s { _Bool a; _Bool b; _Bool c;}; +struct bstruct_s bstruct; // This should not escape + +int main() +{ + astruct.a = 0; + bstruct.b = 0; +} + + +/* { dg-final { scan-wpa-ipa-dump "collected,astruct_s" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump "type astruct_s is escaping true" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump "collected,bstruct_s" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump "type bstruct_s is escaping false" "type-escape-analysis" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-ea-08-parameter-escapes-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-ea-08-parameter-escapes-0.c new file mode 100644 index 00000000000..d1842987735 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-ea-08-parameter-escapes-0.c @@ -0,0 +1,27 @@ +/* { dg-do link } */ +/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ +/* { dg-require-effective-target lto } */ + + +#include <stddef.h> + +struct astruct_s { _Bool a; _Bool b; _Bool c;}; +struct astruct_s astruct; // This should not escape +struct bstruct_s { _Bool a; _Bool b; _Bool c;}; +struct bstruct_s bstruct; // This should not escape + +__attribute__((externally_visible)) void escaping(struct astruct_s cstruct) {} +void non_escaping(struct bstruct_s dstruct) {} + +int main() +{ + astruct.a = 0; + bstruct.b = 0; +} + + +/* { dg-final { scan-wpa-ipa-dump "collected,astruct_s" "hello-world" } } */ +/* { dg-final { scan-wpa-ipa-dump "variable bstruct is escaping false" "hello-world" } } */ +/* { dg-final { scan-wpa-ipa-dump "collected,bstruct_s" "hello-world" } } */ +/* { dg-final { scan-wpa-ipa-dump "parameter type astruct_s is escaping true" "hello-world" } } */ +/* { dg-final { scan-wpa-ipa-dump "parameter type bstruct_s is escaping false" "hello-world" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-ea-09-parameter-type-escapes-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-ea-09-parameter-type-escapes-0.c new file mode 100644 index 00000000000..79809249942 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-ea-09-parameter-type-escapes-0.c @@ -0,0 +1,24 @@ +/* { dg-do link } */ +/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ + +#include <stddef.h> + +struct astruct_s { _Bool a; _Bool b; _Bool c;}; +struct astruct_s astruct; // This should not escape +struct bstruct_s { _Bool a; _Bool b; _Bool c;}; +struct bstruct_s bstruct; // This should not escape + +// This will make astruct_s escape +__attribute__((externally_visible)) void escaping(struct astruct_s cstruct) {} +void non_escaping(struct bstruct_s dstruct) {} + +int main() +{ + astruct.a = 0; + bstruct.b = 0; +} + + +/* { dg-final { scan-wpa-ipa-dump "collected,astruct_s" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump "collected,bstruct_s" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump "type bstruct_s is escaping false" "type-escape-analysis" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-ea-10-return-type-escapes-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-ea-10-return-type-escapes-0.c new file mode 100644 index 00000000000..f2c5f307f01 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-ea-10-return-type-escapes-0.c @@ -0,0 +1,24 @@ +/* { dg-do link } */ +/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ + +#include <stddef.h> + +struct astruct_s { _Bool a; _Bool b; _Bool c;}; +struct astruct_s astruct; // This should not escape +struct bstruct_s { _Bool a; _Bool b; _Bool c;}; +struct bstruct_s bstruct; // This should not escape + +// This will make astruct_s escape +__attribute__((externally_visible)) struct astruct_s escaping() { struct astruct_s a; return a; } +void non_escaping(struct bstruct_s dstruct) {} + +int main() +{ + astruct.a = 0; + bstruct.b = 0; +} + + +/* { dg-final { scan-wpa-ipa-dump "collected,astruct_s" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump "collected,bstruct_s" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump "type bstruct_s is escaping false" "type-escape-analysis" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-ea-11-cast-to-void-ptr-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-ea-11-cast-to-void-ptr-0.c new file mode 100644 index 00000000000..5ef153eb5f9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-ea-11-cast-to-void-ptr-0.c @@ -0,0 +1,26 @@ +/* { dg-do link } */ +/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ + +#include <stddef.h> + +struct astruct_s { _Bool a; _Bool b; _Bool c;}; +struct astruct_s astruct; // This should not escape +struct bstruct_s { _Bool a; _Bool b; _Bool c;}; +struct bstruct_s bstruct; // This should not escape + +void casting_to_void (struct astruct_s *s) +{ + void *nullify_non_escape = s; +} + +int main() +{ + astruct.a = 0; + bstruct.b = 0; +} + + +/* { dg-final { scan-wpa-ipa-dump "collected,astruct_s" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump "type astruct_s\\\* is escaping true" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump "collected,bstruct_s" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump "type bstruct_s is escaping false" "type-escape-analysis" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-ea-12-cast-to-void-ptr-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-ea-12-cast-to-void-ptr-0.c new file mode 100644 index 00000000000..1f298b1415b --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-ea-12-cast-to-void-ptr-0.c @@ -0,0 +1,27 @@ +/* { dg-do link } */ +/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ + +#include <stddef.h> + +struct astruct_s { _Bool a; _Bool b; _Bool c;}; +struct astruct_s astruct; // This should not escape +struct bstruct_s { _Bool a; _Bool b; _Bool c;}; +struct bstruct_s bstruct; // This should not escape + +void casting_to_void (struct astruct_s *s) +{ + void *nullify_non_escape = s; +} + +int main() +{ + astruct.a = 0; + bstruct.b = 0; +} + + +/* { dg-final { scan-wpa-ipa-dump "collected,astruct_s" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump "type astruct_s\\\* is escaping true" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump "type astruct_s is escaping true" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump "collected,bstruct_s" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump "type bstruct_s is escaping false" "type-escape-analysis" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-ea-13-calling-printf-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-ea-13-calling-printf-0.c new file mode 100644 index 00000000000..aa3e97b5444 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-ea-13-calling-printf-0.c @@ -0,0 +1,15 @@ +/* { dg-do link } */ +/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ + +#include <stddef.h> +#include <stdio.h> + +int main(int argc, char** argv) +{ + char *filename = "helloworld.txt"; + FILE* f = fopen(filename); + fclose(f); +} + + +/* { dg-final { scan-wpa-ipa-dump "type FILE is escaping true" "type-escape-analysis" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-0-runs-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-0-runs-0.c new file mode 100644 index 00000000000..22185badeab --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-0-runs-0.c @@ -0,0 +1,11 @@ +/* { 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" } */ + +// Dummy test to find out if +// our optimization is registered + +int +main () +{ + return 0; +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-1-prints-structs-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-1-prints-structs-0.c new file mode 100644 index 00000000000..07d6ea35e0f --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-1-prints-structs-0.c @@ -0,0 +1,15 @@ +/* { 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-10-array-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-10-array-0.c new file mode 100644 index 00000000000..af0c175515a --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-10-array-0.c @@ -0,0 +1,16 @@ +/* { 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 a; + struct astruct_s b[2]; + a = b[0]; +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-11-rewrites-minus-expr-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-11-rewrites-minus-expr-0.c new file mode 100644 index 00000000000..448db9759ef --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-11-rewrites-minus-expr-0.c @@ -0,0 +1,22 @@ +/* { 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> +#include <stddef.h> + +int +main () +{ + struct astruct_s + { + _Bool a; + _Bool b; + _Bool c; + }; + struct astruct_s astruct; + _Bool *c_ptr = &(astruct.c); + _Bool *a_ptr = &(astruct.a); + ptrdiff_t diff = c_ptr - a_ptr; + assert (diff == 1); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-12-delete-last-field-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-12-delete-last-field-0.c new file mode 100644 index 00000000000..dd14c66f600 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-12-delete-last-field-0.c @@ -0,0 +1,23 @@ +/* { 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 a; + _Bool c; + _Bool b; + }; + struct astruct_s b[2]; + _Bool *first_of_second = &(b[1].a); + _Bool *c_0 = &(b[0].c); + _Bool *a_1 = &(b[1].a); + _Bool *a_1_from_c_0 = c_0 + 1; + _Bool test = a_1_from_c_0 == a_1; + char compile_test[test ? 1 : -1]; + assert (test); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-13-modify-size-four-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-13-modify-size-four-0.c new file mode 100644 index 00000000000..df1b546906c --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-13-modify-size-four-0.c @@ -0,0 +1,25 @@ +/* { 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> +#include <stddef.h> + +int +main () +{ + struct astruct_s + { + _Bool a; + _Bool b; + _Bool c; + _Bool d; + }; + struct astruct_s astruct; + _Bool *a = &(astruct.a); + _Bool *c = &(astruct.c); + _Bool *d = &(astruct.d); + ptrdiff_t diff_1 = c - a; + ptrdiff_t diff_2 = d - a; + assert (diff_1 == 1); + assert (diff_2 == 2); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-14-rewrite-plus-expr-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-14-rewrite-plus-expr-0.c new file mode 100644 index 00000000000..e458b14c820 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-14-rewrite-plus-expr-0.c @@ -0,0 +1,22 @@ +/* { 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> +#include <stddef.h> + +int +main () +{ + struct astruct_s + { + _Bool a; + _Bool b; + _Bool c; + }; + struct astruct_s astruct; + int d = astruct.c + 1; + _Bool *a = &(astruct.a); + _Bool *c = a + 1; + assert (*c == 1); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-15-rewrite-mult-expr-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-15-rewrite-mult-expr-0.c new file mode 100644 index 00000000000..2f7ab7d8927 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-15-rewrite-mult-expr-0.c @@ -0,0 +1,22 @@ +/* { 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 <stddef.h> +#include <assert.h> + +int +main () +{ + struct astruct_s + { + _Bool a; + _Bool b; + _Bool c; + }; + struct astruct_s astruct; + int d = astruct.c * 2; + _Bool *a = &(astruct.a); + _Bool *c = a + 1; + assert (*c == 0); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-16-rewrite-field-reads-ptr-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-16-rewrite-field-reads-ptr-0.c new file mode 100644 index 00000000000..3c4b7b08dd1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-16-rewrite-field-reads-ptr-0.c @@ -0,0 +1,24 @@ +/* { 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> +#include <stddef.h> + +int +main () +{ + struct astruct_s + { + _Bool a; + _Bool b; + _Bool c; + }; + struct astruct_s astruct; + astruct.c = 1; + struct astruct_s *astruct_p = &astruct; + _Bool c = astruct_p->c; + _Bool *a = &(astruct.a); + _Bool *c_ptr = a + 1; + assert (*c_ptr == c); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-17-rewrite-field-write-ptr-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-17-rewrite-field-write-ptr-0.c new file mode 100644 index 00000000000..f297eea6aa0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-17-rewrite-field-write-ptr-0.c @@ -0,0 +1,22 @@ +/* { 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 a; + _Bool b; + _Bool c; + }; + struct astruct_s astruct; + struct astruct_s *astruct_p = &astruct; + astruct_p->c = 1; + _Bool *a = &(astruct.a); + _Bool *c = a + 1; + assert (*c == 1); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-18-field-writes-deref-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-18-field-writes-deref-0.c new file mode 100644 index 00000000000..bc204f4017f --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-18-field-writes-deref-0.c @@ -0,0 +1,22 @@ +/* { 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 e; + _Bool a; + _Bool b; + _Bool c; + _Bool d; + }; + struct astruct_s astruct; + _Bool *c_ptr = &astruct.c; + c_ptr--; + *c_ptr = 1; + _Bool *e_ptr = &astruct.e; + e_ptr++; + return *e_ptr - 1; +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-19-middle-pointer-equal-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-19-middle-pointer-equal-0.c new file mode 100644 index 00000000000..10f850bb801 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-19-middle-pointer-equal-0.c @@ -0,0 +1,24 @@ +/* { 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 a; + _Bool b; + _Bool c; + _Bool d; + }; + struct astruct_s astruct; + _Bool *a = &astruct.a; + _Bool *d = &astruct.d; + _Bool *c_from_a = a + 1; + _Bool *c_from_d = d - 1; + _Bool test = c_from_a == c_from_d; + char compile_test[test ? 1 : -1]; + assert (test); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-2-modifies-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-2-modifies-0.c new file mode 100644 index 00000000000..e32e18af2f4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-2-modifies-0.c @@ -0,0 +1,17 @@ +/* { 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; +} + +/* "modifying,astruct_s" "typelist" */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-20-array-offset-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-20-array-offset-0.c new file mode 100644 index 00000000000..f93b642586e --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-20-array-offset-0.c @@ -0,0 +1,23 @@ +/* { 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 a; + _Bool b; + _Bool c; + }; + struct astruct_s b[2]; + _Bool *first_of_second = &(b[1].a); + _Bool *a_ptr = &(b[0].a); + _Bool *c_from_a = ++a_ptr; + _Bool *c_from_array = --first_of_second; + _Bool test = c_from_a == c_from_array; + assert (test); + char compile_test[test ? 1 : -1]; +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-21-rewrites-clobber-type-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-21-rewrites-clobber-type-0.c new file mode 100644 index 00000000000..080d8509c26 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-21-rewrites-clobber-type-0.c @@ -0,0 +1,17 @@ +/* { 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; +} + +// CLOBBERS :( diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-22-rewrites-addr-expr-read-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-22-rewrites-addr-expr-read-0.c new file mode 100644 index 00000000000..68c75427640 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-22-rewrites-addr-expr-read-0.c @@ -0,0 +1,21 @@ +/* { 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 a; + _Bool b; + _Bool c; + }; + struct astruct_s astruct; + _Bool *a = &astruct.a; + _Bool *c = &astruct.c; + _Bool *c_1 = a + 1; + assert (c_1 == c); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-23-array-cast-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-23-array-cast-0.c new file mode 100644 index 00000000000..c86bce1f885 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-23-array-cast-0.c @@ -0,0 +1,28 @@ +/* { 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> +#include <stdio.h> +#include <stddef.h> + +int +main () +{ + struct astruct_s + { + _Bool a; + _Bool b; + _Bool c; + }; + struct astruct_s a[2]; + struct bstruct_s + { + _Bool a; + _Bool c; + }; + struct astruct_s *a_0 = &(a[0]); + struct astruct_s *a_1 = a_0 + 1; + struct bstruct_s *b_0 = (struct bstruct_s *) a_0; + struct bstruct_s *b_1 = b_0 + 1; + assert ((struct bstruct_s *) a_1 == b_1); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-24-array-cast-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-24-array-cast-0.c new file mode 100644 index 00000000000..f42acd18d93 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-24-array-cast-0.c @@ -0,0 +1,31 @@ +/* { 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> +#include <stdio.h> +#include <stddef.h> + +int +main () +{ + struct astruct_s + { + _Bool a; + _Bool b; + _Bool c; + _Bool d; + }; + struct astruct_s a[2]; + struct bstruct_s + { + _Bool a; + _Bool c; + _Bool d; + }; + + struct astruct_s *a_0 = &(a[0]); + struct astruct_s *a_1 = a_0 + 1; + struct bstruct_s *b_0 = (struct bstruct_s *) a_0; + struct bstruct_s *b_1 = b_0 + 1; + assert ((struct bstruct_s *) a_1 == b_1); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-25-array-cast-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-25-array-cast-0.c new file mode 100644 index 00000000000..ef4c1c10772 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-25-array-cast-0.c @@ -0,0 +1,31 @@ +/* { 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> +#include <stdio.h> +#include <stddef.h> + +int +main () +{ + struct astruct_s + { + _Bool a; + _Bool b; + _Bool c; + _Bool d; + }; + struct astruct_s a[2]; + struct bstruct_s + { + _Bool a; + _Bool c; + _Bool d; + }; + + struct astruct_s *a_0 = &(a[1]); + struct astruct_s *a_1 = a_0 - 1; + struct bstruct_s *b_0 = (struct bstruct_s *) a_0; + struct bstruct_s *b_1 = b_0 - 1; + assert ((struct bstruct_s *) a_1 == b_1); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-26-array-cast-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-26-array-cast-0.c new file mode 100644 index 00000000000..7ec3c82a916 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-26-array-cast-0.c @@ -0,0 +1,31 @@ +/* { 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> +#include <stdio.h> +#include <stddef.h> + +int +main (int argc, char **argv) +{ + struct astruct_s + { + _Bool a; + _Bool b; + _Bool c; + _Bool d; + }; + struct astruct_s a[2]; + struct bstruct_s + { + _Bool a; + _Bool c; + _Bool d; + }; + + struct astruct_s *a_0 = &(a[0]); + struct astruct_s *a_1 = a_0 + argc; + struct bstruct_s *b_0 = (struct bstruct_s *) a_0; + struct bstruct_s *b_1 = b_0 + argc; + assert ((struct bstruct_s *) a_1 == b_1); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-27-array-cast-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-27-array-cast-0.c new file mode 100644 index 00000000000..b3c8f739ef3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-27-array-cast-0.c @@ -0,0 +1,20 @@ +/* { 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> +#include <stdio.h> +#include <stddef.h> + +int +main (int argc, char **argv) +{ + struct astruct_s + { + _Bool a; + _Bool b; + _Bool c; + _Bool d; + }; + struct astruct_s a[2][2]; + struct astruct_s b = a[argc][argc]; +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-28-array-cast-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-28-array-cast-0.c new file mode 100644 index 00000000000..aba8eefe3dc --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-28-array-cast-0.c @@ -0,0 +1,31 @@ +/* { 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> +#include <stdio.h> +#include <stddef.h> + +int +main () +{ + struct astruct_s + { + _Bool a; + _Bool b; + _Bool c; + _Bool d; + }; + struct astruct_s a[3]; + struct bstruct_s + { + _Bool a; + _Bool c; + _Bool d; + }; + + struct astruct_s *a_0 = &(a[0]); + struct astruct_s *a_1 = a_0 + 2; + struct bstruct_s *b_0 = (struct bstruct_s *) a_0; + struct bstruct_s *b_1 = b_0 + 2; + assert ((struct bstruct_s *) a_1 == b_1); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-29-heterogeneous-struct.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-29-heterogeneous-struct.c new file mode 100644 index 00000000000..43a74ce963c --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-29-heterogeneous-struct.c @@ -0,0 +1,22 @@ +/* { 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> +#include <stdio.h> +#include <stddef.h> + +int +main () +{ + struct astruct_s + { + int a; + _Bool b; + int c; + }; + struct astruct_s astruct; + int *a = &(astruct.a); + int *c = &(astruct.c); + ptrdiff_t d = c - a; + assert (d == 1); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-3-new-offsets-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-3-new-offsets-0.c new file mode 100644 index 00000000000..07d6ea35e0f --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-3-new-offsets-0.c @@ -0,0 +1,15 @@ +/* { 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-30-heterogenous-struct-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-30-heterogenous-struct-0.c new file mode 100644 index 00000000000..49436d8bb87 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-30-heterogenous-struct-0.c @@ -0,0 +1,26 @@ +/* { 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> +#include <stdio.h> +#include <stddef.h> + +int +main () +{ + // unmodified { a = 1, b = 4; c = 5; d = 8; e = 12 + // modified { a = 1, c = 2; d = 4, e = 8 + struct astruct_s + { + _Bool a; + int b; + _Bool c; + int d; + _Bool e; + }; + struct astruct_s astruct; + _Bool *a = &(astruct.a); + _Bool *e = &(astruct.e); + ptrdiff_t diff = e - a; + assert (diff == 8); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-31-heterogenous-struct-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-31-heterogenous-struct-0.c new file mode 100644 index 00000000000..4f9853af425 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-31-heterogenous-struct-0.c @@ -0,0 +1,28 @@ +/* { 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> +#include <stdio.h> +#include <stddef.h> + +int +main () +{ + // unmodified a = 0, d = 1; e = 2; f = 3; b = 4; c = 8 + // modified a = 0, d = 1, e = 2, f = 3, c = 4; + struct astruct_s + { + _Bool a; + _Bool d; + _Bool e; + _Bool f; + _Bool b; + int c; + }; + struct astruct_s astruct; + struct astruct_s *p = &astruct; + _Bool *a = &(p->a); + _Bool *c = (_Bool *) &(p->c); + ptrdiff_t d = c - a; + assert (d == 4); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-32-pointer-indirection-level-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-32-pointer-indirection-level-0.c new file mode 100644 index 00000000000..687ef04ac77 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-32-pointer-indirection-level-0.c @@ -0,0 +1,23 @@ +/* { 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 a; + _Bool b; + _Bool c; + }; + struct astruct_s astruct; + struct astruct_s *p0 = &astruct; + struct astruct_s **p1 = &p0; + _Bool *a_ptr_0 = (_Bool *) p0; + _Bool *c_ptr_0 = a_ptr_0 + 1; + _Bool **a_ptr_1 = (_Bool **) p1; + _Bool *c_ptr_1 = (_Bool *) ((*a_ptr_1) + 1); + assert (c_ptr_0 == c_ptr_1); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-33-nested-struct-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-33-nested-struct-0.c new file mode 100644 index 00000000000..ca942339efe --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-33-nested-struct-0.c @@ -0,0 +1,42 @@ +/* { 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 a; + _Bool b; + _Bool c; + _Bool d; + }; + struct outerstruct_s + { + struct astruct_s a; + struct astruct_s b; + struct astruct_s c; + struct astruct_s d; + }; + struct outerstruct_s outerstruct; + _Bool *outer_a = (_Bool *) &outerstruct.a; + _Bool *outer_b = (_Bool *) &outerstruct.b; + _Bool *outer_c = (_Bool *) &outerstruct.c; + _Bool *outer_d = (_Bool *) &outerstruct.d; + _Bool *outer_b_1 = outer_a + 3; + _Bool *outer_c_1 = outer_a + 6; + _Bool *outer_d_1 = outer_a + 9; + assert (outer_b == outer_b_1); + assert (outer_c == outer_c_1); + assert (outer_d == outer_d_1); +} + +/* " offset,astruct_s.reorg,a,0" "typelist" } } */ +/* " offset,astruct_s.reorg,c,1" "typelist" } } */ +/* " offset,astruct_s.reorg,d,2" "typelist" } } */ +/* " offset,outerstruct_s.reorg,a,0" "typelist" } } */ +/* " offset,outerstruct_s.reorg,b,3" "typelist" } } */ +/* " offset,outerstruct_s.reorg,c,6" "typelist" } } */ +/* " offset,outerstruct_s.reorg,d,9" "typelist" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-33-pointer-indirection-level-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-33-pointer-indirection-level-0.c new file mode 100644 index 00000000000..0fc5f0f9e46 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-33-pointer-indirection-level-0.c @@ -0,0 +1,24 @@ +/* { 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 a; + _Bool b; + _Bool c; + _Bool d; + }; + struct astruct_s astruct; + struct astruct_s *p0 = &astruct; + struct astruct_s **p1 = &p0; + _Bool *a_ptr = &(astruct.a); + _Bool *c_ptr = a_ptr + 1; + _Bool *a_ptr_2 = &((*p1)->a); + _Bool *c_ptr_2 = a_ptr_2 + 1; + assert (c_ptr == c_ptr_2); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-34-array-cast-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-34-array-cast-0.c new file mode 100644 index 00000000000..5ae01feb7bc --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-34-array-cast-0.c @@ -0,0 +1,21 @@ +/* { 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> +#include <stdio.h> +#include <stddef.h> + +int +main (int argc, char **argv) +{ + struct astruct_s + { + _Bool a; + _Bool b; + _Bool c; + _Bool d; + }; + struct astruct_s a[2][2]; + + struct astruct_s b = a[argc][argc]; +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-35-array-cast-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-35-array-cast-0.c new file mode 100644 index 00000000000..ea4d49258a2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-35-array-cast-0.c @@ -0,0 +1,38 @@ +/* { 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> +#include <stdio.h> +#include <stddef.h> + +int +main (int argc, char **argv) +{ + struct astruct_s + { + _Bool a; + _Bool b; + _Bool c; + _Bool d; + }; + struct astruct_s a[2][2]; + struct bstruct_s + { + _Bool a; + _Bool c; + _Bool d; + }; + struct bstruct_s *b_ptr = (struct bstruct_s *) &a; + // a[0][0] = b_ptr + 0 + 0; + // a[0][1] = b_ptr + 0 + sizeof(astruct_s) + // a[1][0] = b_ptr + 2*sizeof(astruct_s) + 0; + // a[1][1] = b_ptr + 2*sizeof(astruct_s) + sizeof(astruct_s); + // as a function of argc + // a[argc][argc] = b_ptr + 2*sizeof(astruct_s)* argc + sizeof(astruct_s)*argc + // TODO: Can't put size of astruct_s because + // we don't change sizeof yet... + int size = sizeof (struct bstruct_s); + struct bstruct_s *b_ptr_2 = b_ptr + 2 * argc + argc; + struct bstruct_s *b = (struct bstruct_s *) &(a[argc][argc]); + assert (b_ptr_2 == b); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-36-arguments-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-36-arguments-0.c new file mode 100644 index 00000000000..2b2e70a0b16 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-36-arguments-0.c @@ -0,0 +1,37 @@ +/* { 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> +#include <stdio.h> +#include <stddef.h> + +struct astruct_s +{ + _Bool a; + _Bool b; + _Bool c; + _Bool d; +}; + +// PASS BY VALUE +_Bool +foo (struct astruct_s astruct) +{ + _Bool *a = &astruct.a; + assert (!*a); + _Bool *c = a + 1; + assert (*c); + _Bool *d = a + 2; + assert (*d); + return *c; +} + +int +main (int argc, char **argv) +{ + struct astruct_s astruct; + astruct.a = 0; + astruct.c = argc; + astruct.d = 1; + foo (astruct); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-37-arguments-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-37-arguments-0.c new file mode 100644 index 00000000000..b8a3a01ba0a --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-37-arguments-0.c @@ -0,0 +1,37 @@ +/* { 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> +#include <stdio.h> +#include <stddef.h> + +struct astruct_s +{ + _Bool a; + _Bool b; + _Bool c; + _Bool d; +}; + +// PASS BY REFERENCE +_Bool +foo (struct astruct_s *astruct) +{ + _Bool *a = (_Bool *) &(astruct->a); + assert (!*a); + _Bool *c = a + 1; + assert (*c); + _Bool *d = a + 2; + assert (*d); + return *c; +} + +int +main (int argc, char **argv) +{ + struct astruct_s astruct; + astruct.a = 0; + astruct.c = argc; + astruct.d = 1; + foo (&astruct); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-38-return-values-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-38-return-values-0.c new file mode 100644 index 00000000000..0df611a7d7b --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-38-return-values-0.c @@ -0,0 +1,38 @@ +/* { 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> +#include <stdio.h> +#include <stddef.h> + +struct astruct_s +{ + _Bool a; + _Bool b; + _Bool c; + _Bool d; +}; + +// RETURN BY VALUE +struct astruct_s +foo (_Bool c) +{ + struct astruct_s astruct; + astruct.a = 0; + astruct.c = c; + astruct.d = 1; + return astruct; +} + +int +main (int argc, char **argv) +{ + struct astruct_s astruct; + astruct = foo (argc); + _Bool *a = &(astruct.a); + assert (!*a); + _Bool *c = a + 1; + assert (*c == argc); + _Bool *d = a + 2; + assert (*d); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-39-typedef-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-39-typedef-0.c new file mode 100644 index 00000000000..c8f0569e932 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-39-typedef-0.c @@ -0,0 +1,15 @@ +/* { 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 () +{ + typedef struct astruct_s + { + _Bool a; + _Bool b; + _Bool c; + } astruct_s; + astruct_s astruct; + return 0; +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-4-layout-compile-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-4-layout-compile-0.c new file mode 100644 index 00000000000..d933f3a5e85 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-4-layout-compile-0.c @@ -0,0 +1,22 @@ +/* { 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 <stddef.h> + +int +main (int argc, char **argv) +{ + struct astruct_s + { + int a; + int b; + int c; + }; + struct astruct_s astruct; + int *c = &astruct.c; + int *a = &astruct.a; + ptrdiff_t d = c - a; + char ch[d == 1 ? 1 : -1]; +} + +/* "Executing structreorg" "typelist" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-40-typedef-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-40-typedef-0.c new file mode 100644 index 00000000000..d1f752ff005 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-40-typedef-0.c @@ -0,0 +1,16 @@ +/* { 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; + }; + typedef struct astruct_s astruct_s; + astruct_s astruct; + return 0; +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-41-deref-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-41-deref-0.c new file mode 100644 index 00000000000..a0c8d4a1f3e --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-41-deref-0.c @@ -0,0 +1,18 @@ +/* { 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; + struct astruct_s *t, copy; + t = &astruct; + copy = *t; + return 0; +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-42-mem-ref-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-42-mem-ref-0.c new file mode 100644 index 00000000000..5cc493d2f3f --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-42-mem-ref-0.c @@ -0,0 +1,29 @@ +/* { dg-do link } */ +/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=nextout -fipa-typelist-struct=arc" } */ + +#include <stdlib.h> + +typedef struct arc arc_t; +typedef struct arc *arc_p; + +struct arc +{ + int id; + long cost; + void *tail, *head; + short ident; + arc_p nextout, nextin; + long flow; + long org_cost; +}; + +int +main () +{ + int num_threads = 10; + arc_p *deleted_arcs; + register arc_t *arcnew = (arc_t*) malloc (num_threads * sizeof (arc_p)); + deleted_arcs = (arc_p *) malloc (num_threads * num_threads * sizeof (arc_p)); + deleted_arcs[num_threads - 1][num_threads - 1] = arcnew[0]; + return 0; +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-43-args-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-43-args-0.c new file mode 100644 index 00000000000..a3890b404a7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-43-args-0.c @@ -0,0 +1,30 @@ +/* { dg-do run } */ +/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=nextout -fipa-typelist-struct=arc" } */ + +#include <stdlib.h> + +struct astruct_s +{ + _Bool a; + _Bool b; + _Bool c; +}; +struct wrapper_s +{ + struct astruct_s *a; +}; + +void +foo (struct wrapper_s *wrapper){}; +void +bar (struct wrapper_s *wrapper) +{ + foo (wrapper); +}; + +int +main () +{ + struct wrapper_s a_wrapper; + bar (&a_wrapper); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-44-cond-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-44-cond-0.c new file mode 100644 index 00000000000..749dad5995e --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-44-cond-0.c @@ -0,0 +1,14 @@ +/* { dg-do link } */ +/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=nextout -fipa-typelist-struct=arc" } */ + +struct a +{ + struct arc *b; +} c (struct a *d) +{ + while (d) + ; +} +void +main () +{} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-45-phis-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-45-phis-0.c new file mode 100644 index 00000000000..c490c17de6b --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-45-phis-0.c @@ -0,0 +1,14 @@ +/* { dg-do link } */ +/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=nextout -fipa-typelist-struct=arc" } */ + +struct a +{ + struct arc *b; +} c (struct a *d, struct a *e) +{ + while (e) + d = d; +} +int +main () +{} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-46-static-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-46-static-0.c new file mode 100644 index 00000000000..f0befcd814c --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-46-static-0.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ +/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=nextout -fipa-typelist-struct=arc -o ipa-structreorg-46-static-0.exe " } */ + +#include <assert.h> +#include <stddef.h> + +struct arc +{ + _Bool a; + _Bool nextout; + _Bool c; +}; + +struct arc an_arc; + +int +main () +{ + _Bool *a = &(an_arc.a); + _Bool *c = &(an_arc.c); + ptrdiff_t diff = c - a; + assert (diff == 1); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-47-constructor-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-47-constructor-0.c new file mode 100644 index 00000000000..28d18a54957 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-47-constructor-0.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=nextout -fipa-typelist-struct=arc -o ipa-structreorg-46-static-0.exe " } */ + +#include <assert.h> +#include <stddef.h> + +int +main () +{ + struct arc + { + _Bool a; + _Bool nextout; + _Bool c; + }; + struct arc an_arc; + struct another + { + _Bool a; + struct arc d; + _Bool c; + }; + struct another an_another = {0, {0, 1}, 1}; +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-48-function-ptr-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-48-function-ptr-0.c new file mode 100644 index 00000000000..2e55ad41d34 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-48-function-ptr-0.c @@ -0,0 +1,38 @@ +/* { dg-do run } */ +/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=nextout -fipa-typelist-struct=arc " } */ + +#include <assert.h> +#include <stddef.h> + +struct arc +{ + _Bool a; + _Bool nextout; + _Bool c; +}; + +_Bool +returnLast (struct arc anArc) +{ + return anArc.c; +} + +_Bool +returnLast2 (struct arc anArc) +{ + _Bool *ptr = &(anArc.a); + ptr = ptr + 1; + return *ptr; +} + +int +main (int argc, char **argv) +{ + _Bool (*func1) (struct arc); + func1 = &returnLast; + _Bool (*func2) (struct arc); + func2 = &returnLast2; + struct arc anArc; + anArc.c = argc; + assert (func1 (anArc) == func2 (anArc)); +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-49-array-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-49-array-0.c new file mode 100644 index 00000000000..6f4fb557d16 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-49-array-0.c @@ -0,0 +1,48 @@ +/* { dg-do run } */ +/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=nextout,nextin -fipa-typelist-struct=astruct_s " } */ + +#include <assert.h> +#include <stddef.h> + +int +main (int argc, char **argv) +{ + struct astruct_s + { + int id; + long cost; + void *tail; + void *head; + void *nextin; + void *nextout; + short ident; + long flow; + long org_cost; + }; + struct cstruct_s + { + int id; + long cost; + void *tail; + void *head; + short ident; + long flow; + long org_cost; + }; + struct bstruct_s + { + struct astruct_s *basic_arc; + }; + long num = argc; + struct astruct_s array[100]; + struct astruct_s *old_arcs = array; + struct bstruct_s b; + struct bstruct_s *c = &b; + c->basic_arc = array + num; + c->basic_arc->cost = num; + struct cstruct_s *other = ((struct cstruct_s *) (array)) + num; + size_t off = c->basic_arc - old_arcs; + size_t off2 = other - (struct cstruct_s *) old_arcs; + assert ((struct cstruct_s *) c->basic_arc == other); + assert (c->basic_arc->cost == other->cost); +} 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 new file mode 100644 index 00000000000..3e37a780774 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-5-field-reads-0.c @@ -0,0 +1,18 @@ +/* { 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 new file mode 100644 index 00000000000..07d6ea35e0f --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-5-rewrite-local-decl-0.c @@ -0,0 +1,15 @@ +/* { 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-50-field-write-delete-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-50-field-write-delete-0.c new file mode 100644 index 00000000000..a504400aaad --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-50-field-write-delete-0.c @@ -0,0 +1,15 @@ +/* { dg-do run } */ +/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=delete_me -fipa-typelist-struct=astruct_s " } */ + +#include <assert.h> +#include <stddef.h> +#include <stdbool.h> + +int +main (int argc, char **argv) +{ +struct astruct_s { _Bool a; _Bool delete_me; _Bool c;}; +struct astruct_s astruct; +astruct.delete_me = false; +return 0; +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-51-creduce-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-51-creduce-0.c new file mode 100644 index 00000000000..d03f511078a --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-51-creduce-0.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-w -flto -flto-partition=none -fipa-dead-field-eliminate" } */ + +struct { +} main() { +} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-52-creduce-1.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-52-creduce-1.c new file mode 100644 index 00000000000..6a9994f3e46 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-52-creduce-1.c @@ -0,0 +1,11 @@ +/* { dg-do run } */ +/* { dg-options "-w -flto -flto-partition=none -fipa-dead-field-eliminate" } */ + +#include <stdint.h> +union a { + int16_t b +} c() { + union a d; + -d.b; +} +main() {} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-53-csmith-2.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-53-csmith-2.c new file mode 100644 index 00000000000..df33fb7aeb7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-53-csmith-2.c @@ -0,0 +1,5 @@ +/* { dg-do run } */ +/* { dg-options "-w -flto -flto-partition=none -fipa-dead-field-eliminate" } */ +struct { +} a; +main() {} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-54-csmith-3.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-54-csmith-3.c new file mode 100644 index 00000000000..f49627eeeba --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-54-csmith-3.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-options "-w -flto -flto-partition=none -fipa-dead-field-eliminate" } */ + +#include <stdint.h> +//TODO: So, our analysis says that we are deleting a field "a". +//And that the field "a" is contained in struct "b". +//However, we are doing is_interesting_struct("c") == yes +//is_interesting_field("a") == yes +//and so we delete field a from struct c. +struct { + uint64_t a +} b[]; +struct { + unsigned : 5; + unsigned a +} c; +d() { + uint16_t e = b; + int8_t f = c.a; +} +main() {} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-55-csmith-4.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-55-csmith-4.c new file mode 100644 index 00000000000..e745c6aa8fb --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-55-csmith-4.c @@ -0,0 +1,10 @@ +/* { dg-do run } */ +/* { dg-options "-w -flto -flto-partition=none -fipa-dead-field-eliminate" } */ + +#include <stdint.h> +union a { + int8_t b +} c() { + union a d = {4073709551608}; +} +main() {} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-56-csmith-5.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-56-csmith-5.c new file mode 100644 index 00000000000..27da3daa29d --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-56-csmith-5.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-options "-w -flto -flto-partition=none -fipa-dead-field-eliminate" } */ + +#include <stdint.h> +struct a { + int8_t b +}; +struct c { + struct a d +} e[]; + +/* Analysis failed because e[2].d was considered not read + * we were only looking at e[2].d.b which is considered read. + * So we need to recurse + */ +f() { g(e[2].d.b, 0); } + +void g(int8_t a, int8_t b) { a + b ;} +main() {} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-57-csmith-6.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-57-csmith-6.c new file mode 100644 index 00000000000..9827d228e31 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-57-csmith-6.c @@ -0,0 +1,6 @@ +/* { dg-do run } */ +/* { dg-options "-w -flto -flto-partition=none -fipa-dead-field-eliminate" } */ + +struct a {}; +b(struct a c) {} +main() {} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-58-csmith-7.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-58-csmith-7.c new file mode 100644 index 00000000000..3edc8a44499 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-58-csmith-7.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-options "-w -flto -flto-partition=none -fipa-dead-field-eliminate" } */ + +#include <stdint.h> +struct a { + int32_t b +} c; +d() { + for (;; c.b = 0) + ; +} +main() {} diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-59-csmith-8.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-59-csmith-8.c new file mode 100644 index 00000000000..050e3177fb1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-59-csmith-8.c @@ -0,0 +1,10 @@ +/* { dg-do run } */ +/* { dg-options "-w -flto -flto-partition=none -fipa-dead-field-eliminate" } */ + +struct a { + signed b +}; +struct { + struct a b +} volatile c; +main() { c.b.b; } 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 new file mode 100644 index 00000000000..c7092516692 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-6-field-writes-0.c @@ -0,0 +1,16 @@ +/* { 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-60-csmith-9.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-60-csmith-9.c new file mode 100644 index 00000000000..b1001a6286c --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-60-csmith-9.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-w -flto -flto-partition=none -fipa-dead-field-eliminate" } */ + +#include <stdint.h> + +void foo(uint64_t a, uint64_t b) +{ a + b; } + +struct a { + uint64_t b; + uint8_t c +} d() { + // I think the problem here is with the const attribute... + const struct a e; + foo(0, e.b); + return e; +} + + +main() {} 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 new file mode 100644 index 00000000000..b0fdc15d63e --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-7-delete-first-field-0.c @@ -0,0 +1,23 @@ +/* { 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 new file mode 100644 index 00000000000..83c508ee24e --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-8-modify-double-struct-0.c @@ -0,0 +1,33 @@ +/* { 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 new file mode 100644 index 00000000000..be51f9e06e9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-9-modify-int-struct-0.c @@ -0,0 +1,18 @@ +/* { 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; +} |