diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-07-12 08:36:08 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-12 08:36:08 +0000 |
commit | 7cecfe983b389fb05b339ea9be71ade9e016dbb9 (patch) | |
tree | 4994d0b0fe6667064d1bed535c70ce5b90ff68cd /gcc | |
parent | 6d2a3d03ad256ab924dfddb4d200d1b6c11c7410 (diff) | |
parent | 200fcaad46236f83d46ae277fa6e902419db2e58 (diff) | |
download | gcc-7cecfe983b389fb05b339ea9be71ade9e016dbb9.zip gcc-7cecfe983b389fb05b339ea9be71ade9e016dbb9.tar.gz gcc-7cecfe983b389fb05b339ea9be71ade9e016dbb9.tar.bz2 |
Merge #559
559: add some comments about FindEntryPoints and MarkLive in dead code sca… r=philberty a=thomasyonug
Add some comments about FindEntryPoints and MarkLive in dead code scan
Co-authored-by: Thomas Young <wenzhang5800@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/lint/rust-lint-marklive.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/rust/lint/rust-lint-marklive.cc b/gcc/rust/lint/rust-lint-marklive.cc index 099f37e..d436f1a 100644 --- a/gcc/rust/lint/rust-lint-marklive.cc +++ b/gcc/rust/lint/rust-lint-marklive.cc @@ -16,6 +16,9 @@ // along with GCC; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. +// The idea is that all reachable symbols are live, codes called +// from live codes are live, and everything else is dead. + #include "rust-lint-marklive.h" #include "rust-hir-full.h" #include "rust-name-resolver.h" @@ -23,6 +26,13 @@ namespace Rust { namespace Analysis { +// This class trys to find the live symbols which can be used as +// seeds in MarkLive +// +// 1. TODO: explicit live +// - Attribute like #[allow(dead_code)] +// - Attribute like #[lang=".."], it's not a intra-crate item. +// 2. TODO: foreign item class FindEntryPoint : public MarkLiveBase { using Rust::Analysis::MarkLiveBase::visit; @@ -62,6 +72,11 @@ MarkLive::Analysis (HIR::Crate &crate) return marklive.liveSymbols; } +// pop a live symbol from worklist every iteration, +// if it's a function then walk the function body, and +// 1. save all the live symbols in worklist which is +// visited first time +// 2. save all the live symbols in liveSymbols void MarkLive::go (HIR::Crate &crate) { |