diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-03-07 12:17:40 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-07 12:17:40 +0000 |
commit | 865b6090a8f8981cdfc050ea2ee44abbe92de141 (patch) | |
tree | 33ca33f20795707b58b694fab16039d0c2c7374a /gcc/rust/backend/rust-compile-item.cc | |
parent | 366c53371ad40025984a98e01b02d452d49816aa (diff) | |
parent | 7820ff8b8b14e1309aade205e50ef30bb08cb3e5 (diff) | |
download | gcc-865b6090a8f8981cdfc050ea2ee44abbe92de141.zip gcc-865b6090a8f8981cdfc050ea2ee44abbe92de141.tar.gz gcc-865b6090a8f8981cdfc050ea2ee44abbe92de141.tar.bz2 |
Merge #992
992: Cleanup bad unused code warnings r=philberty a=philberty
This patchset contains 4 distinct fixes:
When a constant is declared after where it is used the code-generation pass falls
back to a query compilation of the HIR::Item this did not contain a check to verify
if it was already compiled and results in duplicate CONST_DECLS being generated
if query compilation was used.
We were using a zero precision integer to contain unit-type expressions this results
in VAR_DECLS being lost in the GENERIC graph which does not allow us to perform
any static analysis upon the DECL. This changes the unit type to use an empty struct
and for initialization of a VAR_DECL we can simply pass an empty constructor and let
GCC optimize this code for us.
Update our DEAD_CODE scan to take into account modules of items and also respect
if structures are prefixed with an underscore we can ignore generating an unused warning.
Remove our AST scan for unused code and reuse GCC TREE_USED to track wether
VAR_DECL, PARM_DECL, CONST_DECL are actually used or not. We reuse the GCC
walk_tree functions to have this as nice separate lint.
Fixes #676
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-item.cc')
-rw-r--r-- | gcc/rust/backend/rust-compile-item.cc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-item.cc b/gcc/rust/backend/rust-compile-item.cc index d42cc1e..21cbb1c 100644 --- a/gcc/rust/backend/rust-compile-item.cc +++ b/gcc/rust/backend/rust-compile-item.cc @@ -73,6 +73,10 @@ CompileItem::visit (HIR::StaticItem &var) void CompileItem::visit (HIR::ConstantItem &constant) { + if (ctx->lookup_const_decl (constant.get_mappings ().get_hirid (), + &reference)) + return; + // resolve the type TyTy::BaseType *resolved_type = nullptr; bool ok |