public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Nathan Sidwell <nathan@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/c++-modules] analyzer: simplify store::eval_alias Date: Fri, 28 Aug 2020 16:00:02 +0000 (GMT) [thread overview] Message-ID: <20200828160002.3D9B73948492@sourceware.org> (raw) https://gcc.gnu.org/g:c199723d7ed0032db095abc75b82a9710eaa5e56 commit c199723d7ed0032db095abc75b82a9710eaa5e56 Author: David Malcolm <dmalcolm@redhat.com> Date: Fri Aug 21 18:55:11 2020 -0400 analyzer: simplify store::eval_alias I have followup patches that add new conditions to store::eval_alias. Rather than duplicate all conditions for symmetry, split it up and call it on both (A, B) and (B, A). gcc/analyzer/ChangeLog: * store.cc (store::eval_alias): Make const. Split out 2nd half into store::eval_alias_1 and call it twice for symmetry, avoiding test duplication. (store::eval_alias_1): New function, split out from the above. * store.h (store::eval_alias): Make const. (store::eval_alias_1): New decl. Diff: --- gcc/analyzer/store.cc | 45 ++++++++++++++++++++++++--------------------- gcc/analyzer/store.h | 4 +++- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/gcc/analyzer/store.cc b/gcc/analyzer/store.cc index d854f4e504a..298088f6ef9 100644 --- a/gcc/analyzer/store.cc +++ b/gcc/analyzer/store.cc @@ -1544,7 +1544,7 @@ store::set_value (store_manager *mgr, const region *lhs_reg, tristate store::eval_alias (const region *base_reg_a, - const region *base_reg_b) + const region *base_reg_b) const { /* SSA names can't alias. */ tree decl_a = base_reg_a->maybe_get_decl (); @@ -1554,31 +1554,34 @@ store::eval_alias (const region *base_reg_a, if (decl_b && TREE_CODE (decl_b) == SSA_NAME) return tristate::TS_FALSE; + /* Try both ways, for symmetry. */ + tristate ts_ab = eval_alias_1 (base_reg_a, base_reg_b); + if (ts_ab.is_false ()) + return tristate::TS_FALSE; + tristate ts_ba = eval_alias_1 (base_reg_b, base_reg_a); + if (ts_ba.is_false ()) + return tristate::TS_FALSE; + return tristate::TS_UNKNOWN; +} + +/* Half of store::eval_alias; called twice for symmetry. */ + +tristate +store::eval_alias_1 (const region *base_reg_a, + const region *base_reg_b) const +{ if (const symbolic_region *sym_reg_a = base_reg_a->dyn_cast_symbolic_region ()) { const svalue *sval_a = sym_reg_a->get_pointer (); - if (sval_a->get_kind () == SK_INITIAL - && decl_b - && !is_global_var (decl_b)) - { - /* The initial value of a pointer can't point to a local. */ - return tristate::TS_FALSE; - } - } - if (const symbolic_region *sym_reg_b - = base_reg_b->dyn_cast_symbolic_region ()) - { - const svalue *sval_b = sym_reg_b->get_pointer (); - if (sval_b->get_kind () == SK_INITIAL - && decl_a - && !is_global_var (decl_a)) - { - /* The initial value of a pointer can't point to a local. */ - return tristate::TS_FALSE; - } + if (sval_a->get_kind () == SK_INITIAL) + if (tree decl_b = base_reg_b->maybe_get_decl ()) + if (!is_global_var (decl_b)) + { + /* The initial value of a pointer can't point to a local. */ + return tristate::TS_FALSE; + } } - return tristate::TS_UNKNOWN; } diff --git a/gcc/analyzer/store.h b/gcc/analyzer/store.h index bc9dc2e0b5c..636a9547f2c 100644 --- a/gcc/analyzer/store.h +++ b/gcc/analyzer/store.h @@ -553,7 +553,7 @@ public: cluster_map_t::iterator end () const { return m_cluster_map.end (); } tristate eval_alias (const region *base_reg_a, - const region *base_reg_b); + const region *base_reg_b) const; template <typename BindingVisitor> void for_each_binding (BindingVisitor &v) @@ -569,6 +569,8 @@ public: private: void remove_overlapping_bindings (store_manager *mgr, const region *reg); + tristate eval_alias_1 (const region *base_reg_a, + const region *base_reg_b) const; cluster_map_t m_cluster_map;
reply other threads:[~2020-08-28 16:00 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200828160002.3D9B73948492@sourceware.org \ --to=nathan@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).