diff options
author | Philip Herron <philip.herron@embecosm.com> | 2022-03-04 15:14:12 +0000 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2022-03-07 12:16:18 +0000 |
commit | 7820ff8b8b14e1309aade205e50ef30bb08cb3e5 (patch) | |
tree | 33ca33f20795707b58b694fab16039d0c2c7374a /gcc/rust/rust-gcc.cc | |
parent | e00311aa9aabf447f27031cc5ffc114c5fbd8551 (diff) | |
download | gcc-7820ff8b8b14e1309aade205e50ef30bb08cb3e5.zip gcc-7820ff8b8b14e1309aade205e50ef30bb08cb3e5.tar.gz gcc-7820ff8b8b14e1309aade205e50ef30bb08cb3e5.tar.bz2 |
Remove old unused code pass this was too generic
This now uses the TREE_USED fields on GCC tree's to track the usage of
VAR_DECLS, PARM_DECLS and CONST_DECLS. The code does a pass over the body
and parameters of functions as a lint pass.
Fixes #676
Diffstat (limited to 'gcc/rust/rust-gcc.cc')
-rw-r--r-- | gcc/rust/rust-gcc.cc | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc index 60923d1..70c07c1 100644 --- a/gcc/rust/rust-gcc.cc +++ b/gcc/rust/rust-gcc.cc @@ -86,9 +86,15 @@ private: tree Bvariable::get_tree (Location location) const { - if (this->orig_type_ == NULL || this->t_ == error_mark_node - || TREE_TYPE (this->t_) == this->orig_type_) - return this->t_; + if (this->t_ == error_mark_node) + return error_mark_node; + + TREE_USED (this->t_) = 1; + if (this->orig_type_ == NULL || TREE_TYPE (this->t_) == this->orig_type_) + { + return this->t_; + } + // Return *(orig_type*)&decl. */ tree t = build_fold_addr_expr_loc (location.gcc_location (), this->t_); t = fold_build1_loc (location.gcc_location (), NOP_EXPR, @@ -1063,10 +1069,7 @@ Gcc_backend::zero_expression (tree t) tree Gcc_backend::var_expression (Bvariable *var, Location location) { - tree ret = var->get_tree (location); - if (ret == error_mark_node) - return error_mark_node; - return ret; + return var->get_tree (location); } // An expression that indirectly references an expression. @@ -2394,7 +2397,6 @@ Gcc_backend::local_variable (tree function, const std::string &name, tree decl = build_decl (location.gcc_location (), VAR_DECL, get_identifier_from_string (name), type_tree); DECL_CONTEXT (decl) = function; - TREE_USED (decl) = 1; if (decl_var != NULL) { @@ -2417,7 +2419,7 @@ Gcc_backend::parameter_variable (tree function, const std::string &name, get_identifier_from_string (name), type_tree); DECL_CONTEXT (decl) = function; DECL_ARG_TYPE (decl) = type_tree; - TREE_USED (decl) = 1; + rust_preserve_from_gc (decl); return new Bvariable (decl); } |