diff options
author | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-06-09 11:24:45 +0200 |
---|---|---|
committer | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-06-09 12:59:52 +0200 |
commit | 7e87749b70a6955808682689962112b33ebb422b (patch) | |
tree | 2d7115b0411de72806458f7156ca71aacc4249a3 /gcc/testsuite | |
parent | 8417ba15c91443e5bfca945c3cf412523d2c1e0c (diff) |
Fixes escape analysis tests
Diffstat (limited to 'gcc/testsuite')
13 files changed, 85 insertions, 68 deletions
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 index 9d096b3747f..b7f1b3c051f 100644 --- 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 @@ -1,5 +1,5 @@ /* { dg-do link } */ -/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ +/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-escape-analysis" } */ struct astruct_s { _Bool a; _Bool b; _Bool c;}; struct astruct_s astruct; 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 index 94cd66d8ef7..511543307ce 100644 --- 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 @@ -1,5 +1,5 @@ /* { dg-do link } */ -/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ +/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-escape-analysis" } */ #include <stddef.h> 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 index 3cacc4a3838..c2cfeb313c9 100644 --- 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 @@ -1,5 +1,5 @@ /* { dg-do link } */ -/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ +/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-escape-analysis" } */ #include <stddef.h> 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 index 2feb88a1a60..652f8576ecd 100644 --- 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 @@ -1,5 +1,5 @@ /* { dg-do link } */ -/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ +/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-escape-analysis" } */ #include <stddef.h> 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 index 7b40c7701bf..5f952afe739 100644 --- 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 @@ -1,5 +1,5 @@ /* { dg-do link } */ -/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ +/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-escape-analysis" } */ #include <stddef.h> @@ -15,6 +15,17 @@ 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" } } */ +// We have a complete type, probably from record_parameter +/* { dg-final { scan-wpa-ipa-dump "collected: record astruct_s .boolean_type a.boolean_type b.boolean_type c.." "type-escape-analysis" } } */ +// Now we have an incomplete struct +/* { dg-final { scan-wpa-ipa-dump "collected: record astruct_s .." "type-escape-analysis" } } */ +// This is the pointer... +/* { dg-final { scan-wpa-ipa-dump "collected: record astruct_s ..." "type-escape-analysis" } } */ +// We are missing the array parameter +// But it seems that the array parameter is passed as a pointer, which makes sense... +// array_parameter (struct astruct_s * a) +// { +// <bb 2> : +// return; +// +// } 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 index 32a77195322..29071ccce29 100644 --- 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 @@ -1,5 +1,5 @@ /* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ +/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-escape-analysis" } */ /* { dg-require-effective-target lto } */ @@ -17,7 +17,10 @@ int main() } -/* { 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" } } */ +/* { dg-final { scan-wpa-ipa-dump "collected: record astruct_s .boolean_type a;boolean_type b;boolean_type c;." "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump "collected: record bstruct_s .boolean_type a;boolean_type b;boolean_type c;." "type-escape-analysis" } } */ +// Do we find the externally visible struct? +// This says that record astruct_s is escaping because the reason g (global is visible) is set to true... +/* { dg-final { scan-wpa-ipa-dump " record astruct_s .boolean_type a.boolean_type b.boolean_type c.. reason: g=1 p=0 r=0 c=0 v=0 u=0" "type-escape-analysis" } } */ +// This says that record bstruct_s is not escaping +/* { dg-final { scan-wpa-ipa-dump " record bstruct_s .boolean_type a.boolean_type b.boolean_type c.. reason: g=0 p=0 r=0 c=0 v=0 u=0" "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 index 2e7024ab907..56344f78faf 100644 --- 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 @@ -1,5 +1,5 @@ /* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ +/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-escape-analysis" } */ #include <stddef.h> @@ -14,8 +14,16 @@ int main() bstruct.b = 0; } +// This test is pretty much the same as the previous one. +// The reason for this is because initially the previous +// test tested the escaping of variables and this one of +// types. Since, we are now not checking variables escaping +// these two tests have merged. -/* { 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" } } */ +/* { dg-final { scan-wpa-ipa-dump "collected: record astruct_s .boolean_type a;boolean_type b;boolean_type c;." "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump "collected: record bstruct_s .boolean_type a;boolean_type b;boolean_type c;." "type-escape-analysis" } } */ +// Do we find the externally visible struct? +// This says that record astruct_s is escaping because the reason g (global is visible) is set to true... +/* { dg-final { scan-wpa-ipa-dump " record astruct_s .boolean_type a.boolean_type b.boolean_type c.. reason: g=1 p=0 r=0 c=0 v=0 u=0" "type-escape-analysis" } } */ +// This says that record bstruct_s is not escaping +/* { dg-final { scan-wpa-ipa-dump " record bstruct_s .boolean_type a.boolean_type b.boolean_type c.. reason: g=0 p=0 r=0 c=0 v=0 u=0" "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 index d1842987735..5c0443c217c 100644 --- 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 @@ -1,5 +1,5 @@ /* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ +/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-escape-analysis" } */ /* { dg-require-effective-target lto } */ @@ -15,13 +15,10 @@ void non_escaping(struct bstruct_s dstruct) {} int main() { - astruct.a = 0; - bstruct.b = 0; + escaping(astruct); + non_escaping(bstruct); } -/* { 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" } } */ +/* { dg-final { scan-wpa-ipa-dump " record astruct_s .boolean_type a;boolean_type b;boolean_type c;. reason: g=0 p=1 r=0 c=0 v=0 u=0" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump " record bstruct_s .boolean_type a;boolean_type b;boolean_type c;. reason: g=0 p=0 r=0 c=0 v=0 u=0" "type-escape-analysis" } } */ 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 deleted file mode 100644 index 79809249942..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-ea-09-parameter-type-escapes-0.c +++ /dev/null @@ -1,24 +0,0 @@ -/* { 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 index f2c5f307f01..e1be6c2bfbd 100644 --- 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 @@ -1,5 +1,5 @@ /* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ +/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-escape-analysis" } */ #include <stddef.h> @@ -9,16 +9,17 @@ 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) {} +struct astruct_s __attribute__((externally_visible)) escaping() { struct astruct_s a; return a; } +struct bstruct_s non_escaping() {} int main() { - astruct.a = 0; - bstruct.b = 0; + astruct = escaping(); + bstruct = non_escaping(); } -/* { 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" } } */ +// This says that astruct_s escapes because it is returning from an externally visible function +/* { dg-final { scan-wpa-ipa-dump " record astruct_s .boolean_type a;boolean_type b;boolean_type c;. reason: g=0 p=0 r=1 c=0 v=0 u=0" "type-escape-analysis" } } */ +// This says that bstruct_s does not escape +/* { dg-final { scan-wpa-ipa-dump " record bstruct_s .boolean_type a;boolean_type b;boolean_type c;. reason: g=0 p=0 r=0 c=0 v=0 u=0" "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 index 596f220a72c..d79b1574ce4 100644 --- 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 @@ -20,4 +20,13 @@ int main() } -/* { dg-final { scan-wpa-ipa-dump "record" "structure-reorg" } } */ +// The type +/* { dg-final { scan-wpa-ipa-dump " record bstruct_s .boolean_type a;boolean_type b;boolean_type c;. reason: g=0 p=0 r=0 c=1 v=0 u=0" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump " record astruct_s .boolean_type a;boolean_type b;boolean_type c;. reason: g=0 p=0 r=0 c=1 v=0 u=0" "type-escape-analysis" } } */ +// The pointer +/* { dg-final { scan-wpa-ipa-dump " record bstruct_s .boolean_type a;boolean_type b;boolean_type c;.. reason: g=0 p=0 r=0 c=1 v=0 u=0" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump " record astruct_s .boolean_type a;boolean_type b;boolean_type c;.. reason: g=0 p=0 r=0 c=1 v=0 u=0" "type-escape-analysis" } } */ + +// But there are incomplete types... should does be marked as escaping as well here? +// No, because at the moment, how we compute it is with the fixed point and at that moment, we get rid of reasons. +// So, at the moment, it is sufficient to say that only a fraction of equivalent types escape. 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 index 1f298b1415b..5a9be3021e0 100644 --- 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 @@ -1,5 +1,5 @@ /* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ +/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-cast-analysis" } */ #include <stddef.h> @@ -20,8 +20,8 @@ int main() } -/* { 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" } } */ +/* { dg-final { scan-wpa-ipa-dump "void_type. reason: g=0 p=0 r=0 c=1 v=0 u=0" "type-escape-analysis" } } */ +// base type +/* { dg-final { scan-wpa-ipa-dump " record astruct_s .boolean_type a;boolean_type b;boolean_type c;. reason: g=0 p=0 r=0 c=1 v=0 u=0" "type-escape-analysis" } } */ +// pointer +/* { dg-final { scan-wpa-ipa-dump " record astruct_s .boolean_type a;boolean_type b;boolean_type c;.. reason: g=0 p=0 r=0 c=1 v=0 u=0" "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 index aa3e97b5444..fb3e0e9d17d 100644 --- 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 @@ -1,5 +1,5 @@ /* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ +/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-escape-analysis" } */ #include <stddef.h> #include <stdio.h> @@ -7,9 +7,21 @@ int main(int argc, char** argv) { char *filename = "helloworld.txt"; - FILE* f = fopen(filename); + FILE* f = fopen(filename, "r"); fclose(f); } -/* { dg-final { scan-wpa-ipa-dump "type FILE is escaping true" "type-escape-analysis" } } */ +// This is the incomplete type p=0 because it is memoized and it is an optimization. +// However, I will also match a 1 +/* { dg-final { scan-wpa-ipa-dump " record _IO_FILE .. reason: g=0 p=. r=1 c=0 v=0 u=0" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump " record _IO_FILE ... reason: g=0 p=. r=1 c=0 v=0 u=0" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump " record _IO_wide_data .. reason: g=0 p=. r=1 c=0 v=0 u=0" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump " record _IO_wide_data ... reason: g=0 p=. r=1 c=0 v=0 u=0" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump " record _IO_codecvt .. reason: g=0 p=. r=1 c=0 v=0 u=0" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump " record _IO_codecvt ... reason: g=0 p=. r=1 c=0 v=0 u=0" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump "void_type. reason: g=0 p=. r=1 c=0 v=0 u=0" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump " record _IO_marker .. reason: g=0 p=. r=1 c=0 v=0 u=0" "type-escape-analysis" } } */ +/* { dg-final { scan-wpa-ipa-dump " record _IO_marker ... reason: g=0 p=. r=1 c=0 v=0 u=0" "type-escape-analysis" } } */ +// This is the complete type... but I have condensed it to match .* +/* { dg-final { scan-wpa-ipa-dump " record FILE .* reason: g=0 p=. r=1 c=0 v=0 u=0" "type-escape-analysis" } } */ |