Copy propagation and SSA_NAME replacement support routines.
Copyright (C) 2004-2025 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>.
This file implements the copy propagation pass and provides a
handful of interfaces for performing const/copy propagation and
simple expression replacement which keep variable annotations
up-to-date.
We require that for any copy operation where the RHS and LHS have
a non-null memory tag the memory tag be the same. It is OK
for one or both of the memory tags to be NULL.
We also require tracking if a variable is dereferenced in a load or
store operation.
We enforce these requirements by having all copy propagation and
replacements of one SSA_NAME with a different SSA_NAME to use the
APIs defined in this file.
Lattice for copy-propagation. The lattice is initialized to
UNDEFINED (value == NULL) for SSA names that can become a copy
of something or VARYING (value == self) if not (see get_copy_of_val
and stmt_may_generate_copy). Other values make the name a COPY
of that value.
When visiting a statement or PHI node the lattice value for an
SSA name can transition from UNDEFINED to COPY to VARYING.