Nevertheless, some information such as ``what is the statement of the
current module'' is often used in many places and it is cumbersome
having to pass this information through some recursions. For that
purpose, some interesting global variables exist but they have been
encapsulated in set_
and reset_
methods to insure that a
variable will not be left with an old value when leaving a phase. The
get_
method is used to use the value.
In the main function of dead code elimination on
Figure 6, the current module statement and
entity are stored by using the set_current_module_statement()
and set_current_module_entity()
.
local_name_to_top_level_entity(n)
gets the entity corresponding
to the module name. The module statement and entity are useful to
directly access data structures that are global to the current module
(such as variables, etc.) when doing some code analysis or
transformation.
Since the dead code elimination needs to know some semantical
information about the current module, such as the proper effects of a
statement to deal with I/Os and the preconditions to have
informations on variable values, it is stored with
set_proper_effects_map()
and set_precondition_map()
for
later use.
At the end of the procedure, the global variables are reset
accordingly.