diff options
author | Gary Oblock <gary@amperecomputing.com> | 2020-09-10 13:48:29 -0700 |
---|---|---|
committer | Gary Oblock <gary@amperecomputing.com> | 2020-09-10 13:48:29 -0700 |
commit | cc9febff9eac9376c43dcf1366b4b29133f08fff (patch) | |
tree | a12fddf4c9e77ceb7818861f338e13cfd7a608f9 | |
parent | 8c6206b7b46585281439c7dcef3c7f3874fe43df (diff) | |
parent | 57ddf0b6961359c785b79ade4df9156037cc1393 (diff) |
Merge branch 'common/ipa-str-reorg-v2' of git.theobroma-systems.com:ampere-computing/gcc-experimental into common/ipa-str-reorg-v2
82 files changed, 231 insertions, 1868 deletions
diff --git a/gcc/ipa-type-escape-analysis.c b/gcc/ipa-type-escape-analysis.c index 45875f74443..d573dd71f49 100644 --- a/gcc/ipa-type-escape-analysis.c +++ b/gcc/ipa-type-escape-analysis.c @@ -80,7 +80,7 @@ public: : simple_ipa_opt_pass(pass_data_ipa_type_escape_analysis, ctx) {} - virtual bool gate(function*) { return in_lto_p && flag_ipa_type_escape_analysis && flag_profile_use; } + virtual bool gate(function*) { return false; } virtual unsigned execute (function*) { return iphw_execute(); } }; } // anon namespace 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 deleted file mode 100644 index 390f73a6cc3..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-00-simple-read-0.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-access-analysis " } */ - -#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); -} - -// This means a read. -/* { dg-final { scan-wpa-ipa-dump "astruct_s.a = 0x0001" "type-escape-analysis" } } */ 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 deleted file mode 100644 index d809ed31df8..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-01-simple-write-0.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-access-analysis " } */ - -#include <stdio.h> - -struct astruct_s { _Bool a; _Bool b; _Bool c;}; -struct astruct_s astruct; - - -int -main () -{ - astruct.a++; - astruct.a = 3; -} - -// This means that this is only a write and not a read. -/* { dg-final { scan-wpa-ipa-dump "astruct_s.a = 0x0003" "type-escape-analysis" } } */ 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 deleted file mode 100644 index 59f7707e5af..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-02-pointer-read-0.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-access-analysis " } */ - -#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); -} - -// So, even if we have a pointer COMPONENT_REF counter still works... -/* { dg-final { scan-wpa-ipa-dump "astruct_s.a = 0x0001" "type-escape-analysis" } } */ 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 deleted file mode 100644 index 17ad02529ee..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-03-pointer-write-0.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-access-analysis " } */ - -#include <stdio.h> - -struct astruct_s { _Bool a; _Bool b; _Bool c;}; -struct astruct_s *astruct; - - -int -main () -{ - astruct->a++; - astruct->a = 3; -} - -// This says that only writes are happening even if astruct is a pointer -/* { dg-final { scan-wpa-ipa-dump "astruct_s.a = 0x0003" "type-escape-analysis" } } */ 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 deleted file mode 100644 index a80bda39730..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-04-gimple-cond-0.c +++ /dev/null @@ -1,19 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-access-analysis " } */ - -#include <stdio.h> - -struct astruct_s { _Bool a; _Bool b; _Bool c;}; -struct astruct_s astruct; - - -int -main () -{ - if (astruct.a) { - puts("hello world"); - } -} - -// This says that astruct_s.a is read in a conditional -/* { dg-final { scan-wpa-ipa-dump "astruct_s.a = 0x0001" "type-escape-analysis" } } */ 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 deleted file mode 100644 index b7f1b3c051f..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-ea-00-collect-global-record-0.c +++ /dev/null @@ -1,15 +0,0 @@ -/* { dg-do link } */ -/* { 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; - -int -main () -{ - astruct.a = 0; -} - -// Please note that braces and semicollons are replaced with dots in order -// to parse correctly -/* { dg-final { scan-ipa-dump "collected: record astruct_s .boolean_type a.boolean_type b.boolean_type c.." "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 deleted file mode 100644 index 511543307ce..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-ea-01-collect-global-pointers-to-record-0.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-escape-analysis" } */ - -#include <stddef.h> - -struct astruct_s { _Bool a; _Bool b; _Bool c;}; -struct astruct_s *astruct; - -int -main () -{ - astruct = NULL; -} - -// This is for the structure -/* { dg-final { scan-ipa-dump "collected: record astruct_s .boolean_type a.boolean_type b.boolean_type c.." "type-escape-analysis" } } */ -// This one has an extra dot to mark the * for the pointer -/* { dg-final { scan-ipa-dump "collected: record astruct_s .boolean_type a.boolean_type b.boolean_type c..." "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 deleted file mode 100644 index c2cfeb313c9..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-ea-02-collect-global-array-to-record-0.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-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]; -} - -// This one is for the structure -/* { dg-final { scan-ipa-dump "collected: record astruct_s .boolean_type a.boolean_type b.boolean_type c.." "type-escape-analysis" } } */ -// This one is for the array. That's why it has two dots at the end -/* { dg-final { scan-ipa-dump "collected: record astruct_s .boolean_type a.boolean_type b.boolean_type c...." "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 deleted file mode 100644 index 652f8576ecd..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-ea-03-collect-nested-record-0.c +++ /dev/null @@ -1,17 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-escape-analysis" } */ - -#include <stddef.h> - -struct astruct_s { _Bool a; _Bool b; _Bool c;}; -struct outer_struct { _Bool d; struct astruct_s a; }; -struct outer_struct bstruct; - -int -main () -{ - bstruct.d = 0; -} - -// We only care about collecting the inner struct for this test -/* { dg-final { scan-ipa-dump "collected: record astruct_s .boolean_type a.boolean_type b.boolean_type c.." "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 deleted file mode 100644 index 5f952afe739..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-ea-04-collect-parameters-0.c +++ /dev/null @@ -1,31 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-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 () -{ -} - -// 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 deleted file mode 100644 index 29071ccce29..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-ea-05-global-escapes-0.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-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: 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 deleted file mode 100644 index 56344f78faf..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-ea-06-global-type-escapes-0.c +++ /dev/null @@ -1,29 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-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; -} - -// 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: 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 deleted file mode 100644 index 5c0443c217c..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-ea-08-parameter-escapes-0.c +++ /dev/null @@ -1,24 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-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() -{ - escaping(astruct); - non_escaping(bstruct); -} - - -/* { 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-10-return-type-escapes-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-ea-10-return-type-escapes-0.c deleted file mode 100644 index e1be6c2bfbd..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-ea-10-return-type-escapes-0.c +++ /dev/null @@ -1,25 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-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 -struct astruct_s __attribute__((externally_visible)) escaping() { struct astruct_s a; return a; } -struct bstruct_s non_escaping() {} - -int main() -{ - astruct = escaping(); - bstruct = non_escaping(); -} - - -// 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 deleted file mode 100644 index ec503593742..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-ea-11-cast-to-void-ptr-0.c +++ /dev/null @@ -1,31 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-escape-analysis" } */ - -#include <stddef.h> - -struct astruct_s { _Bool a; _Bool b; _Bool c;}; -struct bstruct_s { _Bool a; _Bool b; _Bool c; _Bool d;}; - -struct bstruct_s *casting_to_void (struct astruct_s *s) -{ - return (struct bstruct_s *)(s); -} - -int main() -{ - struct astruct_s astruct; - struct bstruct_s bstruct; - casting_to_void(&astruct); -} - - -// The type -/* { dg-final { scan-wpa-ipa-dump " record bstruct_s .boolean_type a;boolean_type b;boolean_type c;boolean d;. reason: g=0 p=0 r=0 c=1 v=0 u=0 i=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;boolean d.. reason: g=0 p=0 r=0 c=1 v=0 u=0 i=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 deleted file mode 100644 index 5a9be3021e0..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-ea-12-cast-to-void-ptr-0.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-cast-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 "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 deleted file mode 100644 index fb3e0e9d17d..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-ea-13-calling-printf-0.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-escape-analysis" } */ - -#include <stddef.h> -#include <stdio.h> - -int main(int argc, char** argv) -{ - char *filename = "helloworld.txt"; - FILE* f = fopen(filename, "r"); - fclose(f); -} - - -// 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" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-ea-14-volatile-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-ea-14-volatile-0.c deleted file mode 100644 index b620185bfad..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-ea-14-volatile-0.c +++ /dev/null @@ -1,14 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-escape-analysis" } */ - -#include <stddef.h> -#include <stdio.h> - -int main(int argc, char** argv) -{ - struct astruct_s { _Bool a; _Bool b; _Bool c; }; - volatile struct astruct_s astruct; -} - -// This says that astruct_s has a volatile -/* { 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=0 v=1 u=0" "type-escape-analysis" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-ea-15-union-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-ea-15-union-0.c deleted file mode 100644 index 11777b0bc70..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-ea-15-union-0.c +++ /dev/null @@ -1,15 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-escape-analysis" } */ - -#include <stddef.h> -#include <stdio.h> - -int main(int argc, char** argv) -{ - struct astruct_s { _Bool a; _Bool b; _Bool c; }; - union outer { struct astruct_s a ; double b ;}; - union outer an_outer; -} - -// This says that astruct_s is inside a union -/* { 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=0 v=0 u=1" "type-escape-analysis" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-ea-16-parameter-cast-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-ea-16-parameter-cast-0.c deleted file mode 100644 index 623a8c0af00..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-ea-16-parameter-cast-0.c +++ /dev/null @@ -1,20 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-cast-analysis -Wno-incompatible-pointer-types" } */ - -#include <stddef.h> -#include <stdio.h> - -struct astruct_s { _Bool a; _Bool b; _Bool c; }; -struct bstruct_s { _Bool a; _Bool b; _Bool c; }; -void foo(struct bstruct_s *s) { }; - -int main(int argc, char** argv) -{ - struct astruct_s astruct; - foo(&astruct); -} - -// This says that astruct_s is casted -/* { 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" } } */ -// This says that the pointer is casted -/* { 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-17-malloc-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-ea-17-malloc-0.c deleted file mode 100644 index 94e96701f96..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-ea-17-malloc-0.c +++ /dev/null @@ -1,17 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-cast-analysis -Wno-incompatible-pointer-types" } */ - -#include <stddef.h> -#include <stdio.h> -#include <stdlib.h> - -struct astruct_s { _Bool a; _Bool b; _Bool c; }; - -int main(int argc, char** argv) -{ - struct astruct_s *a = malloc(sizeof(struct astruct_s)); -} - -// This says that astruct_s is not casted -/* { 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=0 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=0 v=0 u=0" "type-escape-analysis" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-03-new-type-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-03-new-type-0.c deleted file mode 100644 index c79bc41e1f8..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-03-new-type-0.c +++ /dev/null @@ -1,17 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-access-analysis " } */ - -#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.c); -} - -/* { dg-final { scan-ipa-dump " record astruct_s .boolean_type a;boolean_type b;boolean_type c;. .. record astruct_s .boolean_type a;boolean_type c;." "type-escape-analysis" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-04-heterogeneous-struct-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-04-heterogeneous-struct-0.c deleted file mode 100644 index 166fbccfbcd..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-04-heterogeneous-struct-0.c +++ /dev/null @@ -1,17 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-access-analysis " } */ - -#include <stdio.h> - -struct astruct_s { float a; _Bool b; int c;}; -struct astruct_s astruct; - - -int -main () -{ - printf("%d\n", astruct.a); - printf("%d\n", astruct.c); -} - -/* { dg-final { scan-ipa-dump " record astruct_s .real_type a.boolean_type b.integer_type c.. .. record astruct_s .real_type a.integer_type c.." "type-escape-analysis" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-04-layout-compile-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-04-layout-compile-0.c deleted file mode 100644 index d53d4ee4bed..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-04-layout-compile-0.c +++ /dev/null @@ -1,22 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ - -#include <stddef.h> -#include <assert.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; - assert(d == 1); -} - 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 deleted file mode 100644 index 18e8fe0a596..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-05-field-reads-0.c +++ /dev/null @@ -1,20 +0,0 @@ -/* { 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-nested-struct-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-05-nested-struct-0.c deleted file mode 100644 index b0959c209f3..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-05-nested-struct-0.c +++ /dev/null @@ -1,21 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-access-analysis " } */ - -#include <stdio.h> - -struct astruct_s { float a; _Bool b; int c;}; -struct ostruct_s { struct astruct_s a; float b; float c; }; -struct ostruct_s ostruct; - - -int -main () -{ - printf("%d\n", ostruct.b); - printf("%d\n", ostruct.c); - printf("%f\n", ostruct.a.a); - printf("%d\n", ostruct.a.c); -} - -/* { dg-final { scan-ipa-dump " record astruct_s .real_type a;boolean_type b;integer_type c;. -> record astruct_s .real_type a;integer_type c;." "type-escape-analysis" } } */ -/* { dg-final { scan-ipa-dump " record ostruct_s . record astruct_s .real_type a;boolean_type b;integer_type c;. a;real_type b;real_type c;. -> record ostruct_s . record astruct_s .real_type a;integer_type c;. a;real_type b;real_type c;." "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 deleted file mode 100644 index 13aa56ed9ee..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-05-rewrite-local-decl-0.c +++ /dev/null @@ -1,23 +0,0 @@ -/* { 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 deleted file mode 100644 index 41396bfe4d3..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-06-field-writes-0.c +++ /dev/null @@ -1,24 +0,0 @@ -/* { 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-06-pointer-struct-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-06-pointer-struct-0.c deleted file mode 100644 index dceab124b4b..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-06-pointer-struct-0.c +++ /dev/null @@ -1,22 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-access-analysis " } */ - -#include <stdio.h> - -struct astruct_s { float a; _Bool b; int c;}; -struct ostruct_s { struct astruct_s *a; float b; float c; }; -struct ostruct_s ostruct; - - -int -main () -{ - printf("%d\n", ostruct.b); - printf("%d\n", ostruct.c); - printf("%f\n", ostruct.a->a); - printf("%d\n", ostruct.a->c); -} - -/* { dg-final { scan-ipa-dump " record astruct_s ... -> record astruct_s ..." "type-escape-analysis" } } */ -/* { dg-final { scan-ipa-dump " record ostruct_s . record astruct_s ... a;real_type b;real_type c;. -> record ostruct_s . record astruct_s ... a;real_type b;real_type c;." "type-escape-analysis" } } */ -/* { dg-final { scan-ipa-dump " record astruct_s .real_type a;boolean_type b;integer_type c.. -> record astruct_s .real_type a;integer_type c.." "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 deleted file mode 100644 index a9c40ba0eda..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-07-delete-first-field-0.c +++ /dev/null @@ -1,23 +0,0 @@ -/* { 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 deleted file mode 100644 index e94699adbd6..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-08-modify-double-struct-0.c +++ /dev/null @@ -1,33 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#include <assert.h> -#include <stdio.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; - printf("%d %d %d\n", &astruct.a, &astruct.c, &astruct.d); - struct inner_s *a_ptr = &(astruct.a); - struct inner_s *c_ptr = &(astruct.c); - struct inner_s *d_ptr = &(astruct.d); - printf("%d %d %d %d\n", a_ptr->a, a_ptr->b, a_ptr->c, a_ptr->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 deleted file mode 100644 index e5e80860034..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-09-modify-int-struct-0.c +++ /dev/null @@ -1,22 +0,0 @@ -/* { 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-1-prints-structs-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-1-prints-structs-0.c deleted file mode 100644 index 1f6078e842d..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-1-prints-structs-0.c +++ /dev/null @@ -1,19 +0,0 @@ -/* { 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; - return 0; -} - -/* { dg-final { scan-ipa-dump "astruct_s.a may be deleted" "type-escape-analysis" } } */ -/* { dg-final { scan-ipa-dump "astruct_s.b may be deleted" "type-escape-analysis" } } */ -/* { dg-final { scan-ipa-dump "astruct_s.c may be deleted" "type-escape-analysis" } } */ 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 deleted file mode 100644 index 8e828b8c6ed..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-10-array-0.c +++ /dev/null @@ -1,23 +0,0 @@ -/* { dg-do run } */ -/* { dg-options " -flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ - -#include <assert.h> -#include <stdio.h> - -int -main () -{ - struct astruct_s - { - _Bool a; - _Bool b; - _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-11-rewrites-minus-expr-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-11-rewrites-minus-expr-0.c deleted file mode 100644 index 2501da43b64..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-11-rewrites-minus-expr-0.c +++ /dev/null @@ -1,22 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ - -#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 deleted file mode 100644 index 5183e632228..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-12-delete-last-field-0.c +++ /dev/null @@ -1,23 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ - -#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 deleted file mode 100644 index 911e9cba242..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-13-modify-size-four-0.c +++ /dev/null @@ -1,25 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ - -#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 deleted file mode 100644 index f752d36c22f..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-14-rewrite-plus-expr-0.c +++ /dev/null @@ -1,25 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ - -#include <assert.h> -#include <stddef.h> - -int -main () -{ - struct astruct_s - { - _Bool a; - _Bool b; - _Bool c; - }; - struct astruct_s astruct; - astruct.a = 1; - astruct.c = 1; - int d = astruct.a + astruct.c; - assert(d == 2); - _Bool *a = &(astruct.a); - _Bool *c = &(astruct.c); - assert(a + 1 == c); - 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 deleted file mode 100644 index 63182416316..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-15-rewrite-mult-expr-0.c +++ /dev/null @@ -1,25 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ - -#include <stddef.h> -#include <assert.h> - -int -main () -{ - struct astruct_s - { - _Bool a; - _Bool b; - _Bool c; - }; - struct astruct_s astruct; - astruct.a = 1; - astruct.c = 1; - int d = astruct.a * astruct.c; - assert(d == 1); - _Bool *a = &(astruct.a); - _Bool *c = &(astruct.c); - assert (a + 1 == c); - 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 deleted file mode 100644 index 21a0a5c202c..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-16-rewrite-field-reads-ptr-0.c +++ /dev/null @@ -1,24 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ - -#include <assert.h> -#include <stddef.h> -#include <stdio.h> - -int -main () -{ - struct astruct_s - { - _Bool a; - _Bool b; - _Bool c; - }; - struct astruct_s astruct; - struct astruct_s *astruct_p = &astruct; - printf("%d %d\n", astruct_p->a, astruct_p->c); - _Bool *a = &(astruct.a); - _Bool *c = &(astruct.c); - assert (a + 1 == 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 deleted file mode 100644 index 22dd58f46c5..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-17-rewrite-field-write-ptr-0.c +++ /dev/null @@ -1,23 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ - -#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_ptr = &(astruct.c); - _Bool *c = a + 1; - assert (*c == *c_ptr); - 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 deleted file mode 100644 index f395f721ba8..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-18-field-writes-deref-0.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ - -#include <assert.h> - -int -main () -{ - struct astruct_s - { - _Bool a; - _Bool b; - _Bool c; - _Bool d; - }; - struct astruct_s astruct; - _Bool *c_ptr = &astruct.c; - *c_ptr = 1; - _Bool *a_ptr = &astruct.a; - _Bool *d_ptr = &astruct.d; - a_ptr++; - d_ptr--; - assert(*a_ptr == 1); - assert(*d_ptr == 1); - return 0; -} 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 deleted file mode 100644 index c537788eef4..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-19-middle-pointer-equal-0.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ - -#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 = &astruct.c; - _Bool *c_from_a = a + 1; - _Bool *c_from_d = d - 1; - assert(c == c_from_a); - assert(c == c_from_d); - assert(c_from_a == c_from_d); - return 0; -} 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 deleted file mode 100644 index 1a2ba2030a3..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-2-modifies-0.c +++ /dev/null @@ -1,19 +0,0 @@ -/* { 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; - astruct.a = astruct.c; - astruct.c = astruct.a; - return 0; -} - -/* { dg-final { scan-ipa-dump "astruct_s.b may be deleted" "type-escape-analysis" } } */ 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 deleted file mode 100644 index d9f0ac13b55..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-20-array-offset-0.c +++ /dev/null @@ -1,24 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#include <assert.h> - -int -main () -{ - struct astruct_s - { - _Bool a; - _Bool b; - _Bool c; - }; - struct astruct_s b[2]; - _Bool *a_0_ptr = &(b[0].a); - _Bool *c_0_ptr = &(b[0].c); - _Bool *a_1_ptr = &(b[1].a); - - _Bool *c_0_ptr_from_a_0_ptr = a_0_ptr + 1; - _Bool *c_0_ptr_from_a_1_ptr = a_1_ptr - 1; - assert(c_0_ptr_from_a_0_ptr == c_0_ptr); - assert(c_0_ptr_from_a_1_ptr == c_0_ptr); -} 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 deleted file mode 100644 index 869d2b622e0..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-22-rewrites-addr-expr-read-0.c +++ /dev/null @@ -1,23 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#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; - _Bool *a_1 = c - 1; - assert (c_1 == c); - assert (a_1 == a); - 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 deleted file mode 100644 index a4b1c516fb1..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-23-array-cast-0.c +++ /dev/null @@ -1,31 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#include <assert.h> -#include <stdio.h> -#include <stddef.h> -#include <stdio.h> - -int -main () -{ - struct astruct_s - { - _Bool a; - _Bool b; - _Bool c; - }; - struct astruct_s a[2]; - struct astruct_s *a_0 = &(a[0]); - struct astruct_s *a_1 = &(a[1]); - struct astruct_s *a_1_from_a_0 = a_0 + 1; - printf("%d %d\n", a_0->a, a_0->c); - // old new - // 0 a a - // 1 b c - // 2 c a - // 3 a c - // 4 b a - // 5 c c - assert(a_1 == a_1_from_a_0); -} 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 deleted file mode 100644 index bf867b6cd43..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-25-array-cast-0.c +++ /dev/null @@ -1,31 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */ - -#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_1 = &(a[1]); - struct astruct_s *a_0 = a_1 - 1; - struct bstruct_s *b_1 = (struct bstruct_s *) a_1; - struct bstruct_s *b_0 = b_1 - 1; - assert ((struct bstruct_s *) a_0 != b_0); -} 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 deleted file mode 100644 index 37ac48a701c..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-26-array-cast-0.c +++ /dev/null @@ -1,25 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#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 astruct_s *a_0 = &(a[0]); - struct astruct_s *a_1 = a_0 + argc; - ptrdiff_t d = a_1 - a_0; - printf("%d %d %d\n", a_0->a, a_0->c, a_0->d); - printf("%d\n", d); - -} 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 deleted file mode 100644 index b761cb95004..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-27-array-cast-0.c +++ /dev/null @@ -1,21 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#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]; - printf("%d %d %d\n", b.a, b.c, b.d); -} 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 deleted file mode 100644 index ee86abde434..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-29-heterogeneous-struct.c +++ /dev/null @@ -1,22 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#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-30-heterogenous-struct-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-30-heterogenous-struct-0.c deleted file mode 100644 index 27993f0d08c..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-30-heterogenous-struct-0.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#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); - printf("%d %d\n", astruct.c, astruct.d); - _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 deleted file mode 100644 index 7e6285b750b..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-31-heterogenous-struct-0.c +++ /dev/null @@ -1,30 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#include <assert.h> -#include <stdio.h> -#include <stddef.h> - -int -main () -{ - // unmodified a = 0, d = 5; e = 6; f = 7; b = 8; c = 9 - // 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; - printf("%d %d %d %d %d\n", p->a, p->d, p->e, p->f, p->c); - _Bool *a = &(p->a); - int *c = &(p->c); - ptrdiff_t d = (_Bool*)c - a; - printf("%d\n", d); - assert (d == 4); -} 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 deleted file mode 100644 index 9a7ea83f5ff..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-33-nested-struct-0.c +++ /dev/null @@ -1,39 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#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; - struct astruct_s a = outerstruct.a; - struct astruct_s b = outerstruct.b; - struct astruct_s c = outerstruct.c; - struct astruct_s d = outerstruct.d; - _Bool _a = a._a; - _Bool _c = a._c; - _Bool _d = a._d; -} - -/* { dg-final { scan-ipa-dump "replacing field a 0 with a 0" "type-escape-analysis" } } */ -/* { dg-final { scan-ipa-dump "replacing field b 32 with b 32" "type-escape-analysis" } } */ -/* { dg-final { scan-ipa-dump "replacing field c 64 with c 64" "type-escape-analysis" } } */ -/* { dg-final { scan-ipa-dump "replacing field d 96 with d 96" "type-escape-analysis" } } */ -/* { 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" } } */ -/* { dg-final { scan-ipa-dump "replacing field _d 24 with _d 16" "type-escape-analysis" } } */ 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 deleted file mode 100644 index ce32ed48f24..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-33-pointer-indirection-level-0.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#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 = &(astruct.c); - _Bool *c_ptr_from_1 = a_ptr + 1; - _Bool *a_ptr_2 = &((*p1)->a); - _Bool *c_ptr_from_2 = a_ptr_2 + 1; - assert (c_ptr == c_ptr_from_1); - assert (c_ptr == c_ptr_from_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 deleted file mode 100644 index 83f542e2d78..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-34-array-cast-0.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#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]; - printf("%d %d %d\n", b.a, b.c, b.d); -} - -/* { 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" } } */ -/* { dg-final { scan-ipa-dump "replacing field d 24 with d 16" "type-escape-analysis" } } */ 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 deleted file mode 100644 index 8850aad97d4..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-36-arguments-0.c +++ /dev/null @@ -1,42 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#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; - printf("%d %d %d\n", astruct.a, astruct.c, astruct.d); - foo (astruct); -} - -/* { 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" } } */ -/* { dg-final { scan-ipa-dump "replacing field d 24 with d 16" "type-escape-analysis" } } */ 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 deleted file mode 100644 index 5edd87d5490..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-37-arguments-0.c +++ /dev/null @@ -1,43 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#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) -{ - assert(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; - printf("%d %d %d\n", astruct.a, astruct.c, astruct.d); - foo (&astruct); -} - -/* { 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" } } */ -/* { dg-final { scan-ipa-dump "replacing field d 24 with d 16" "type-escape-analysis" } } */ 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 deleted file mode 100644 index db81ae564df..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-38-return-values-0.c +++ /dev/null @@ -1,39 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#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); - printf("%d %d %d\n", astruct.a, astruct.c, astruct.d); - _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 deleted file mode 100644 index 7b228d4b64c..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-39-typedef-0.c +++ /dev/null @@ -1,21 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#include <stdio.h> - -int -main () -{ - typedef struct astruct_s - { - _Bool a; - _Bool b; - _Bool c; - } astruct_s; - astruct_s astruct; - printf("%d %d", astruct.a, 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 c 8" "type-escape-analysis" } } */ 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 deleted file mode 100644 index 4bc98ab66a3..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-40-typedef-0.c +++ /dev/null @@ -1,22 +0,0 @@ -/* { 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; - }; - typedef struct astruct_s astruct_s; - astruct_s astruct; - printf("%d %d", astruct.a, 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 c 8" "type-escape-analysis" } } */ 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 deleted file mode 100644 index b4b3518e1b9..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-41-deref-0.c +++ /dev/null @@ -1,30 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#include <stdio.h> -#include <assert.h> -#include <stdbool.h> - -int -main () -{ - struct astruct_s - { - _Bool a; - _Bool b; - _Bool c; - }; - struct astruct_s astruct; - struct astruct_s *t, copy; - t = &astruct; - t->a = true; - t->c = true; - copy = *t; - printf("%d %d", copy.a, copy.c); - assert(astruct.a == true); - assert(astruct.c == true); - 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 c 8" "type-escape-analysis" } } */ 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 deleted file mode 100644 index 527bf4058f2..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-42-mem-ref-0.c +++ /dev/null @@ -1,35 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#include <stdlib.h> -#include <stdio.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; - arc_p 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]; - printf("%d %d %d %d %d %d %d %d\n", arcnew->id, arcnew->cost, arcnew->tail, arcnew->head, arcnew->ident, arcnew->nextin, arcnew->flow, arcnew->org_cost); - return 0; -} - -/* { dg-final { scan-ipa-dump "replacing field flow 448 with flow 384" "type-escape-analysis" } } */ -/* { dg-final { scan-ipa-dump "replacing field org_cost 512 with flow 448" "type-escape-analysis" } } */ 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 deleted file mode 100644 index ababf357473..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-43-args-0.c +++ /dev/null @@ -1,38 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#include <stdio.h> - -#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; - _Bool is_non_null = a_wrapper.a != NULL; - printf("%d %d %d", &a_wrapper.a, is_non_null ? a_wrapper.a->a : 0, is_non_null ? a_wrapper.a->c : 0); - bar (&a_wrapper); -} - -/* { 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-44-cond-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-44-cond-0.c deleted file mode 100644 index 2e3aab55a6e..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-44-cond-0.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -struct a -{ - struct arc *b; -} c (struct a *d) -{ - while (d) - ; -} -void -main () -{} - -/* { dg-final { scan-ipa-dump "deleting all fields for struct a" "type-escape-analysis" } } */ 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 deleted file mode 100644 index 82f47e64137..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-45-phis-0.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do link } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -struct a -{ - struct arc *b; -} c (struct a *d, struct a *e) -{ - while (e) - d = d; -} -int -main () -{} - -/* { dg-final { scan-ipa-dump "deleting all fields for struct a" "type-escape-analysis" } } */ 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 deleted file mode 100644 index fe2f78dc247..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-46-static-0.c +++ /dev/null @@ -1,23 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#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 deleted file mode 100644 index 9dff8a46e95..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-47-constructor-0.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#include <assert.h> -#include <stddef.h> -#include <stdio.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}; - struct arc a = an_another.d; - printf("%d %d %d %d %d", an_another.a, &a, a.a, a.c, an_another.c); -} 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 deleted file mode 100644 index 8b9f3e67501..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-48-function-ptr-0.c +++ /dev/null @@ -1,44 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#include <assert.h> -#include <stddef.h> -#include <stdio.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; - printf("%d %d", anArc.a, anArc.c); - // These test means that things remain equal - // A.k.a without an optimization. - // Why? Because a function pointer can be a - // pointer to anything - assert (func1 (anArc) != func2 (anArc)); -} 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 deleted file mode 100644 index 25c75db4f39..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-50-field-write-delete-0.c +++ /dev/null @@ -1,19 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#include <assert.h> -#include <stddef.h> -#include <stdbool.h> -#include <stdio.h> - -int -main (int argc, char **argv) -{ -struct astruct_s { _Bool a; _Bool delete_me; _Bool c;}; -struct astruct_s astruct; -printf("%d %d", astruct.a, astruct.c); -astruct.delete_me = false; -return 0; -} - -/* { dg-final { scan-ipa-dump "deleting field delete_me 8" "type-escape-analysis" } } */ 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 deleted file mode 100644 index d03f511078a..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-51-creduce-0.c +++ /dev/null @@ -1,6 +0,0 @@ -/* { 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 deleted file mode 100644 index a3adb081390..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-52-creduce-1.c +++ /dev/null @@ -1,12 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-w -flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - - -#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 deleted file mode 100644 index e653aaafade..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-53-csmith-2.c +++ /dev/null @@ -1,5 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-w -flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ -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 deleted file mode 100644 index 39c2d17ec0e..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-54-csmith-3.c +++ /dev/null @@ -1,21 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-w -flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#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 deleted file mode 100644 index 5e52dc26bf5..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-55-csmith-4.c +++ /dev/null @@ -1,10 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-w -flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#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 deleted file mode 100644 index eaffbb95970..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-56-csmith-5.c +++ /dev/null @@ -1,19 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-w -flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#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 deleted file mode 100644 index 2f8f59017b8..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-57-csmith-6.c +++ /dev/null @@ -1,6 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-w -flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -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 deleted file mode 100644 index e36f264298e..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-58-csmith-7.c +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-w -flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#include <stdint.h> -struct a { - int32_t b -} c; -d() { - for (;; c.b = 0) - ; -} -main() {} -/* { dg-final { scan-ipa-dump "deleting field b 0" "type-escape-analysis" } } */ 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 deleted file mode 100644 index fc02b460ef6..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-59-csmith-8.c +++ /dev/null @@ -1,12 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-w -flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -struct a { - signed b -}; -struct { - struct a b -} volatile c; -main() { c.b.b; } - -// we will do nothing because volatile 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 deleted file mode 100644 index 3f9253b7a2b..00000000000 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-60-csmith-9.c +++ /dev/null @@ -1,22 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-w -flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ - -#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() {} - -/* { dg-final { scan-ipa-dump "a.c may be deleted" "type-escape-analysis" } } */ diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 35dca10b09e..10415a58f9b 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -44,6 +44,8 @@ #include "tree-ssa.h" #include "tree-cfg.h" #include "graphds.h" +#include "gimple-pretty-print.h" +#include <map> /* The idea behind this analyzer is to generate set constraints from the program, then solve the resulting constraints in order to generate the @@ -8715,7 +8717,6 @@ get_alias_set (hash_set<tree> &C, hash_map<tree, bitmap> &alias_sets2) const bool illegal_alias_i = is_layout_incompatibility || escapes_i; layout_incompatibility.put(a_i, illegal_alias_i); - for (unsigned j = 0; j < varmap.length (); j++) { varinfo_t v_j = get_varinfo(j); @@ -8732,7 +8733,7 @@ get_alias_set (hash_set<tree> &C, hash_map<tree, bitmap> &alias_sets2) // decl_i points-to decl_j // We also should investigate what decl_j aliases. - const bool is_being_pointed_to = bitmap_bit_p(set_i, v_j->id); + const bool is_being_pointed_to = set_i ? bitmap_bit_p(set_i, v_j->id) : false; if (is_being_pointed_to) C.add(decl_j); bitmap set_j = v_j->solution; @@ -8774,29 +8775,18 @@ get_alias_set (hash_set<tree> &C, hash_map<tree, bitmap> &alias_sets2) } } -/* Compute the alias-sets for the LHS of malloc and calloc statements. */ static void -compute_alias_sets() +dump_alias_sets(FILE* dump_file, hash_map<tree, bitmap> &alias_sets) { - bitmap_obstack_initialize (&alias_obstack); - hash_set<tree> initial_candidates; - get_initial_candidates (initial_candidates); + if (!dump_file) return; - const bool is_empty = initial_candidates.is_empty (); - if (is_empty) return; - - hash_map<tree, bitmap> alias_sets; - get_alias_set (initial_candidates, alias_sets); - const bool has_no_alias_sets = alias_sets.is_empty (); - if (has_no_alias_sets) return; - - if (dump_file) fprintf(dump_file, "alias-sets\n"); + fprintf(dump_file, "alias-sets\n"); for (auto i = alias_sets.begin(), e = alias_sets.end(); i != e; ++i) { tree lhs = (*i).first; bitmap a_i = (*i).second; gcc_assert(a_i && !bitmap_empty_p(a_i)); - if (dump_file) fprintf(dump_file, "%s = { ", alias_get_name(lhs)); + fprintf(dump_file, "%s = { ", alias_get_name(lhs)); unsigned j = 0; bitmap_iterator bi; @@ -8806,35 +8796,41 @@ compute_alias_sets() gcc_assert(v_j); tree alias = v_j->decl; gcc_assert(alias); - if (dump_file) fprintf(dump_file, "%s ", alias_get_name(alias)); + fprintf(dump_file, "%s ", alias_get_name(alias)); } - if (dump_file) fprintf(dump_file, "}\n"); + fprintf(dump_file, "}\n"); } +} - // Let's dump the tree to refer to the alias_set +static void +get_vector_of_alias_sets(vec<bitmap> &alias_sets_unique, hash_map<tree, bitmap> &alias_sets, std::map<bitmap, unsigned> &index_map) +{ hash_set<bitmap> alias_set_no_tree; - for (auto i = alias_sets.begin(), e = alias_sets.end(); i != e; ++i) + unsigned index = 0; + for (auto i = alias_sets.begin(), e = alias_sets.end(); i != e; ++i, index++) { bitmap a_i = (*i).second; - alias_set_no_tree.add(a_i); - } + const bool already_in_set = alias_set_no_tree.contains (a_i); + if (already_in_set) continue; - vec<bitmap> alias_set_unique = vNULL; - for (auto i = alias_set_no_tree.begin(), e = alias_set_no_tree.end(); i != e; ++i) - { - bitmap a_i = *i; - alias_set_unique.safe_push(a_i); + alias_set_no_tree.add(a_i); + alias_sets_unique.safe_push(a_i); + index_map.insert({a_i, index}); } +} +static struct graph* +compute_SSG(vec<bitmap> &alias_set_unique, struct graph_edge*** edge_table) +{ int cardinality = alias_set_unique.length (); gcc_assert(cardinality > 0); + struct graph *SSG = new_graph(cardinality); unsigned index_i = 0; for (auto i = alias_set_unique.begin(), e = alias_set_unique.end(); i != e; ++i, index_i++) { bitmap a_i = *i; - if (dump_file) dump_bitmap(dump_file, a_i); bitmap a_i_points_to = BITMAP_ALLOC(&alias_obstack); unsigned j = 0; @@ -8853,17 +8849,219 @@ compute_alias_sets() { bitmap a_j = *j; const bool a_i_points_to_a_j = bitmap_intersect_p(a_i_points_to, a_j); - if (dump_file) fprintf(dump_file, "a_i_points_to_a_j ? %s\n", a_i_points_to_a_j ? "T" : "F"); if (!a_i_points_to_a_j) continue; - add_edge(SSG, index_i, index_j); - + struct graph_edge *e = add_edge(SSG, index_i, index_j); + edge_table[index_i][index_j] = e; } } + return SSG; +} + + +static void +label_to_edges(tree def, unsigned index_i, bitmap a_i, hash_set<bitmap> &invalid, hash_map<tree, bitmap> &tree_map, std::map<bitmap, unsigned> &index_map, struct graph_edge ***table, struct graph* SSG) +{ + gcc_assert(def); + gimple *use = NULL; + imm_use_iterator iterator; + bool is_alias_set_valid = true; + FOR_EACH_IMM_USE_STMT (use, iterator, def) + { + const enum gimple_code gcode_use = gimple_code(use); + is_alias_set_valid &= GIMPLE_ASSIGN == gcode_use; + if (!is_alias_set_valid) break; + + tree rhs1 = gimple_assign_rhs1 (use); + gcc_assert(rhs1); + const enum tree_code rhs_code = TREE_CODE(rhs1); + bool interesting = false; + switch (rhs_code) + { + case COMPONENT_REF: + case ADDR_EXPR: + interesting = true; + break; + case VAR_DECL: + case LT_EXPR: + case POINTER_PLUS_EXPR: + break; + default: + is_alias_set_valid = false; + break; + } + + if (!interesting || !is_alias_set_valid) continue; + // We need to get the lhs + // And the that find out if the lhs belongs to an alias set... + tree lhs = gimple_assign_lhs (use); + if (!lhs) continue; + + // So now we need to find out which alias-set lhs belongs... + bitmap *alias_set_to_ptr = tree_map.get (lhs); + // I think this is fine... + if (!alias_set_to_ptr) continue; + bitmap alias_set_to = *alias_set_to_ptr; + // what is the index of this alias_set? + const bool index_j_exists = index_map.find(alias_set_to) != index_map.end(); + // I think this is still fine... + if (!index_j_exists) continue; + unsigned index_j = index_map.at(alias_set_to); + // now we have from and to + // in index_i and index_j + struct graph_edge *e = table[index_i][index_j]; + // So, if there's no edge + // or if there's an edge + // is both possible. + if (!e) e = add_edge(SSG, index_i, index_j); + table[index_i][index_j] = e; + // What we need to do here is make sure that there's + // an edge and that it is labeled with the field offset + // that points to index_j... + + } + + if (!is_alias_set_valid) invalid.add(a_i); +} + +/* Compute the alias-sets for the LHS of malloc and calloc statements. */ +static void +compute_alias_sets() +{ + bitmap_obstack_initialize (&alias_obstack); + hash_set<tree> initial_candidates; + get_initial_candidates (initial_candidates); + + const bool is_empty = initial_candidates.is_empty (); + if (is_empty) return; + + hash_map<tree, bitmap> alias_sets; + get_alias_set (initial_candidates, alias_sets); + const bool has_no_alias_sets = alias_sets.is_empty (); + if (has_no_alias_sets) return; + + dump_alias_sets(dump_file, alias_sets); + vec<bitmap> alias_set_unique = vNULL; + std::map<bitmap, unsigned> index_map; + // we have a map of tree -> alias_set -> index + get_vector_of_alias_sets(alias_set_unique, alias_sets, index_map); + int cardinality = alias_set_unique.length (); + gcc_assert(cardinality > 0); + + struct graph_edge *** edge_table = (struct graph_edge***) xmalloc(cardinality * sizeof(struct graph_edge **)); + for (unsigned i = 0; i < cardinality; i++) + { + edge_table[i] = (struct graph_edge **) xmalloc(cardinality * sizeof(struct graph_edge**)); + } + struct graph *SSG = compute_SSG (alias_set_unique, edge_table); + + gcc_assert(SSG); if (dump_file) dump_graph(dump_file, SSG); + // TODO: I need to walk over the gimple to find out which fields points-to + // which alias-sets... + // I wonder if I can just look at the uses of the decl... + hash_set<bitmap> invalid; + unsigned index_i = 0; + for (auto i = alias_set_unique.begin(), e = alias_set_unique.end(); i != e; ++i, index_i++) + { + bitmap a_i = *i; + unsigned j = 0; + bitmap_iterator bi; + EXECUTE_IF_SET_IN_BITMAP (a_i, 0, j, bi) + { + varinfo_t v_j = get_varinfo(j); + if (!v_j) continue; + + if (v_j->is_heap_var) continue; + + tree decl = v_j->decl; + if (!decl) continue; + + const enum tree_code code = TREE_CODE(decl); + const bool is_ssa = SSA_NAME == code; + if (!is_ssa) continue; + + // can I get the uses of decl? + if (dump_file) fprintf(dump_file, "SSA variable: "); + if (dump_file) print_generic_expr(dump_file, decl); + if (dump_file) fprintf(dump_file, "\nDEF:\n"); + + gimple *def = SSA_NAME_DEF_STMT(decl); + if (dump_file) print_gimple_stmt (dump_file, def, 0); + const enum gimple_code gcode = gimple_code(def); + tree lhs = NULL; + switch (gcode) + { + case GIMPLE_ASSIGN: + lhs = gimple_assign_lhs (def); + break; + case GIMPLE_CALL: + lhs = gimple_call_lhs (def); + break; + default: + // TODO: Invalidate alias-set + // for stuff we don't yet handle + if (dump_file) fprintf(dump_file, "marking alias-set as invalid because of %s\n", gimple_code_name[gcode]); + invalid.add (a_i); + break; + } + + // At some point here... I will need to update the graph + // with new edges and annotate the edges... + //if (!lhs) break; + + // here we are going to replace all of this with label_to_edges... + /* + + gimple *use = NULL; + imm_use_iterator iterator; + if (dump_file) fprintf(dump_file, "USES:\n"); + FOR_EACH_IMM_USE_STMT (use, iterator, lhs) + { + if (!dump_file) break; + const enum gimple_code gcode_use = gimple_code(use); + // TODO: Expand this, but for now I think we are ok... + if (gcode_use != GIMPLE_ASSIGN) invalid.add (a_i); + if (gcode_use != GIMPLE_ASSIGN) continue; + + tree lhs_use = gimple_assign_rhs1(use); + gcc_assert(lhs_use); + const enum tree_code lhs_use_code = TREE_CODE(lhs_use); + + bool invalid_code = true; + bool interesting = false; + switch (lhs_use_code) + { + case VAR_DECL: + case LT_EXPR: + case POINTER_PLUS_EXPR: + invalid_code = false; + break; + case COMPONENT_REF: + invalid_code = false; + interesting = true; + break; + case ADDR_EXPR: + invalid_code = false; + interesting = true; + break; + default: + invalid.add(a_i); + break; + } + if (invalid_code || !interesting) continue; + + fprintf(dump_file, "This statement contains something of interest:"); + print_gimple_stmt (dump_file, use, 0); + fprintf(dump_file, "\nCODE:"); + } + */ + } + } + free_graph(SSG); } namespace { |