diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-06-07 13:40:26 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-06-07 13:40:26 +0000 |
commit | ab658f56a56ea548b1f293a4a3ada68feb11b417 (patch) | |
tree | 41e7bd6de969ae9edea1bea87de7ab39d4829475 /gcc/go/gofrontend/expressions.h | |
parent | e733243a3693142bd9c9486451c38d2dc20270ac (diff) | |
download | gcc-ab658f56a56ea548b1f293a4a3ada68feb11b417.zip gcc-ab658f56a56ea548b1f293a4a3ada68feb11b417.tar.gz gcc-ab658f56a56ea548b1f293a4a3ada68feb11b417.tar.bz2 |
compiler: do simple deadcode elimination
Normally the backend will do deadcode elimination and this is
sufficient. However, the escape analysis operates on the AST that
may have deadcode, and may cause things to escape that otherwise
do not.
This CL adds a simple deadcode elimination, run before the escape
analysis.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/181080
From-SVN: r272043
Diffstat (limited to 'gcc/go/gofrontend/expressions.h')
-rw-r--r-- | gcc/go/gofrontend/expressions.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/go/gofrontend/expressions.h b/gcc/go/gofrontend/expressions.h index 09c71ad..6ba7fe1 100644 --- a/gcc/go/gofrontend/expressions.h +++ b/gcc/go/gofrontend/expressions.h @@ -581,6 +581,12 @@ class Expression string_constant_value(std::string* val) const { return this->do_string_constant_value(val); } + // If this is not a constant expression with boolean type, return + // false. If it is one, return true, and set VAL to the value. + bool + boolean_constant_value(bool* val) const + { return this->do_boolean_constant_value(val); } + // This is called if the value of this expression is being // discarded. This issues warnings about computed values being // unused. This returns true if all is well, false if it issued an @@ -1125,6 +1131,12 @@ class Expression do_string_constant_value(std::string*) const { return false; } + // Return whether this is a constant expression of boolean type, and + // set VAL to the value. + virtual bool + do_boolean_constant_value(bool*) const + { return false; } + // Called by the parser if the value is being discarded. virtual bool do_discarding_value(); @@ -1771,6 +1783,9 @@ class Type_conversion_expression : public Expression bool do_string_constant_value(std::string*) const; + bool + do_boolean_constant_value(bool*) const; + Type* do_type() { return this->type_; } @@ -1965,6 +1980,9 @@ class Unary_expression : public Expression bool do_numeric_constant_value(Numeric_constant*) const; + bool + do_boolean_constant_value(bool*) const; + Type* do_type(); @@ -2120,6 +2138,9 @@ class Binary_expression : public Expression do_numeric_constant_value(Numeric_constant*) const; bool + do_boolean_constant_value(bool*) const; + + bool do_discarding_value(); Type* |