1 /* Header file for the context-aware pointer equivalence tracker. 2 Copyright (C) 2020-2022 Free Software Foundation, Inc. 3 Contributed by Aldy Hernandez <aldyh@redhat.com> 4 5 This file is part of GCC. 6 7 GCC is free software; you can redistribute it and/or modify it under 8 the terms of the GNU General Public License as published by the Free 9 Software Foundation; either version 3, or (at your option) any later 10 version. 11 12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY 13 WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with GCC; see the file COPYING3. If not see 19 <http://www.gnu.org/licenses/>. */ 20 21 #ifndef GCC_VALUE_POINTER_EQUIV_H 22 #define GCC_VALUE_POINTER_EQUIV_H 23 24 // Simple context-aware pointer equivalency analyzer that returns what 25 // a pointer SSA name is equivalent to at a given point during a walk 26 // of the IL. 27 // 28 // Note that global equivalency take priority over conditional 29 // equivalency. That is, p = &q takes priority over a later p == &t. 30 // 31 // This class is meant to be called during a DOM walk. 32 33 class pointer_equiv_analyzer 34 { 35 public: 36 pointer_equiv_analyzer (gimple_ranger *r); 37 ~pointer_equiv_analyzer (); 38 void enter (basic_block); 39 void leave (basic_block); 40 void visit_stmt (gimple *stmt); 41 tree get_equiv (tree ssa); 42 43 private: 44 void visit_edge (edge e); 45 tree get_equiv_expr (tree_code code, tree expr); 46 void set_global_equiv (tree ssa, tree pointee); 47 void set_cond_equiv (tree ssa, tree pointee); 48 49 gimple_ranger *m_ranger; 50 // Global pointer equivalency indexed by SSA_NAME_VERSION. 51 auto_vec<tree> m_global_points; 52 // Conditional pointer equivalency. 53 class ssa_equiv_stack *m_cond_points; 54 }; 55 56 inline bool supported_pointer_equiv_p(tree expr)57supported_pointer_equiv_p (tree expr) 58 { 59 return TREE_CODE (expr) == SSA_NAME && POINTER_TYPE_P (TREE_TYPE (expr)); 60 } 61 62 #endif // GCC_VALUE_POINTER_EQUIV_H 63