diff options
author | Thomas Young <wenzhang5800@gmail.com> | 2021-07-11 10:25:18 +0800 |
---|---|---|
committer | Thomas Young <wenzhang5800@gmail.com> | 2021-07-11 14:21:05 +0800 |
commit | 200fcaad46236f83d46ae277fa6e902419db2e58 (patch) | |
tree | 0ba44f96515f1e8e181d2596c830da49fcab87b9 | |
parent | 4560f469ee33536cec6af0f8e5816ff97de60de0 (diff) | |
download | gcc-200fcaad46236f83d46ae277fa6e902419db2e58.zip gcc-200fcaad46236f83d46ae277fa6e902419db2e58.tar.gz gcc-200fcaad46236f83d46ae277fa6e902419db2e58.tar.bz2 |
add some comments about FindEntryPoints and MarkLive in dead code scan pass
-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) { |