diff options
author | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-06-09 13:55:18 +0200 |
---|---|---|
committer | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-06-09 13:55:18 +0200 |
commit | ea839b8d57733aecc413b4b91935fb59d04a3303 (patch) | |
tree | e8b10424602a49c5d29387363d1dbd85c7b5413b | |
parent | 7e87749b70a6955808682689962112b33ebb422b (diff) |
Adds test for volatile and union
-rw-r--r-- | gcc/expr-escaper.c | 1 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/ipa/ipa-ea-14-volatile-0.c | 14 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/ipa/ipa-ea-15-union-0.c | 15 | ||||
-rw-r--r-- | gcc/type-escaper.c | 11 |
4 files changed, 40 insertions, 1 deletions
diff --git a/gcc/expr-escaper.c b/gcc/expr-escaper.c index 31e66582c21..651cfe9c666 100644 --- a/gcc/expr-escaper.c +++ b/gcc/expr-escaper.c @@ -50,3 +50,4 @@ ExprEscaper::_walk_pre(const_tree e) typeEscaper.update(t, _r); } + 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 new file mode 100644 index 00000000000..b620185bfad --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-ea-14-volatile-0.c @@ -0,0 +1,14 @@ +/* { 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 new file mode 100644 index 00000000000..11777b0bc70 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-ea-15-union-0.c @@ -0,0 +1,15 @@ +/* { 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/type-escaper.c b/gcc/type-escaper.c index 65ff8d6f0d0..733e6e2ce6c 100644 --- a/gcc/type-escaper.c +++ b/gcc/type-escaper.c @@ -99,7 +99,16 @@ TypeEscaper::_update(const_tree t) gcc_assert(t); // assert type is in universe const bool already_in_typemap = calc.find(t) != calc.end(); - already_in_typemap ? calc[t] |= _reason : calc[t] = _reason; + // Do we have to invalidate all types which point to a volatile type? + // Or do we have to invalidate all types pointed to by a volatile type? + // Or do we only invalidate all types which are volatile. + // This is only the third option. + const bool is_volatile = TYPE_VOLATILE(t); + Reason _is_volatile; + _is_volatile.is_escaping = is_volatile; + _is_volatile.type_is_volatile = is_volatile; + Reason _inner = _reason | _is_volatile; + already_in_typemap ? calc[t] |= _inner : calc[t] = _inner; } void |