diff options
author | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-03-10 16:51:58 +0100 |
---|---|---|
committer | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-04-28 23:35:51 +0200 |
commit | 0596baf17363d377726cd4cc377aacf6b15ddd92 (patch) | |
tree | 69dee4beeace7d7366a4a6fc919582a8c32d5020 | |
parent | 7d9c4cde273f1dee6cacfaf222cdd472f85c660b (diff) |
Counts simple writes to fields
-rw-r--r-- | gcc/ipa-hello-world.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/ipa/ipa-access-counter-01-simple-write-0.c | 19 |
2 files changed, 21 insertions, 1 deletions
diff --git a/gcc/ipa-hello-world.c b/gcc/ipa-hello-world.c index 1ec86ff5bb6..6d911082b58 100644 --- a/gcc/ipa-hello-world.c +++ b/gcc/ipa-hello-world.c @@ -133,6 +133,7 @@ count_access_for_type_in_component_ref(const_tree component_ref, const record_se ; log("%s is in non_escaping_records ? %s\n", get_type_name(tree_type_struct), in_set ? "true" : "false"); + log("access is %s\n", access == READ_ACCESS ? "read_access" : "write_access"); if (!in_set) return; const_tree field = TREE_OPERAND(component_ref, 1); @@ -153,11 +154,11 @@ count_access_for_type_in_component_ref(const_tree component_ref, const record_se log("%s.%s read %d\n", get_type_name(tree_type_struct), get_field_name(field), access_counter.first); break; case WRITE_ACCESS: - break; //TODO: do not use pair. //This names are unintelligible access_counter.second++; log("%s.%s write %d\n", get_type_name(tree_type_struct), get_field_name(field), access_counter.second); + break; default: gcc_unreachable(); break; diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-01-simple-write-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-01-simple-write-0.c new file mode 100644 index 00000000000..6e7b3236294 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-access-counter-01-simple-write-0.c @@ -0,0 +1,19 @@ +/* { dg-do link } */ +/* { dg-options "-flto -fipa-hello-world -fdump-ipa-hello-world" } */ + +#include <stdio.h> + +struct astruct_s { _Bool a; _Bool b; _Bool c;}; +struct astruct_s astruct; + + +int +main () +{ + astruct.a++; + astruct.a = 3; +} + +/* { dg-final { scan-wpa-ipa-dump "collected,astruct_s" "hello-world" } } */ +/* { dg-final { scan-wpa-ipa-dump "astruct_s.a write 1" "hello-world" } } */ +/* { dg-final { scan-wpa-ipa-dump "astruct_s.a write 2" "hello-world" } } */ |