InterProcConstProp Class ReferenceThe DUMMY_PGM_FILE macro (defined in the g++ command) holds the side-effects of procedures not in the given set of program units.
More...
#include <InterProcConstProp.h>
List of all members.
Detailed Description
The DUMMY_PGM_FILE macro (defined in the g++ command) holds the side-effects of procedures not in the given set of program units.
Polaris Constant - See also:
- InterProcConstProp.h
InterProcConstProp.h
This class performs interprocedural symbolic constant propagation on the given Program. That is, it can propagate integer, logical, and symbolic constants across procedure boundaries. It is also capable of eliminating unreachable code and propagate some constant values from DATA statements or the tests of IF statements. See constant.h for more details.
Procedure cloning is performed to allow greater opportunity to propagate constants accross procedure boundaries. Procedure cloning is the copying and renaming of a procedure to decrease the number of call sites that invoke the procedure. Procedure cloning aids constant propagation since a procedure argument has a constant value on entry to the procedure only when the same constant value is passed into that procedure for all call sites.
In addition to propagating interprocedural constants, the pass also determines the side effects of each procedure. More specifically, it determines what variables may be modified by a procedure. The pass annotates each call site with a MAYMOD assertion that identifies these modified variables. Only those call sites for procedures that are in the given Program object are annotated with MAYMOD assertions. These MAYMOD assertions may contain global variables that were not passed in as an argument to the call site. Aliasing and equivalencing is taken into account when computing side-effects.
When the interprocedural constant propagator encounters a call site for a procedure that hasn't been declared, it first tries to find the procedure in the file DUMMY_PGM_FILE. This file contains a set of false declarations of commonly used fortran programs, such as CPUTIM or ELAPSE. These declarations only provide enough code to determine which arguments are modified and which are not. If the procedure is not in DUMMY_PGM_FILE, it then checks whether the the call site has a MAYMOD assertion. If so, it uses the assertion to determine what variables are modified by the call site. If it doesn't have a MAYMOD assertion, the pass assumes that the call site modifies all its arguments as well as all global variables and formal parameters of the caller. Setting the switch "pc_call_mods" to 1 would cause it to assume that only call site's arguments are modified in this case.
The following code segment will propagate and substitute all integer, logical, and symbolic constants in the given Program object. These constants will be allowed to cross procedure boundaries.
InterProcConstProp propagator(pgms, IGNORE_REALS, IGNORE_ARRAYS);
propagator.iter_clone_and_propagate(REMOVE_UNREACHABLE_CODE);
propagator.expand_all_substituted();
Conditional (flow-sensitive) constants cannot be propagated out of procedure calls by a single pass of interprocedural constant propagation. This is why the methods double_clone_and_propagate() and iter_clone_and_propagate() were provided.
Symbolic constants containing local variables cannot be propagated outside a procedure.
Constructor will go in an infinite loop if the given set of programs contain recursive procedure calls.
See "Known Bugs or Limitations" in constant.h for other potential problems.
Definition at line 102 of file InterProcConstProp.h.
Constructor & Destructor Documentation
|
|
Compute the interprocedural constants that enter each program unit in pgms.
The class pgms must contain a main program and not contain any recursive procedure calls.
If subst_reals == IGNORE_REALS, then only constant expressions that are integer or logical types are computed. Otherwise if subst_reals == SUBST_REALS, then real, double and complex constant expressions are computed as well.
If subst_arrays == IGNORE_ARRAYS, then only constant expressions that do not contain array references are computed. Otherwise, if subst_arrays == SUBST_ARRAYS, then constant expressions with array references are computed. |
Member Function Documentation
| void InterProcConstProp::clone_and_propagate |
( |
PC_UNREACH_BOOL |
remove_unreachable |
) |
|
|
|
|
Clone all procedures that have multiple sets of constants entering them.
Then forward substitute the generated constants for each procedure. These constants are not physically substituted into the program. Instead the constants are placed in the substituted() field for all constant variables.
If remove_unreachable == REMOVE_UNREACH_CODE, then any code that the pass determines to be unreachable is deleted. Otherwise, the unreachable code is left in place.
Definition at line 654 of file InterProcConstProp.cc.
Referenced by main(). |
| void InterProcConstProp::double_clone_and_propagate |
( |
PC_UNREACH_BOOL |
remove_unreachable |
) |
|
|
|
|
Like clone_and_propagate except that interprocedural constants are computed a second time.
One may wish to do this because the second interprocedural constant propagation pass may use the constants from the first pass to eliminate more unreachable code and to propagate more conditional constants. This method is about twice as slow as clone_and_propagate().
Definition at line 665 of file InterProcConstProp.cc.
Referenced by main(). |
| void InterProcConstProp::iter_clone_and_propagate |
( |
PC_UNREACH_BOOL |
remove_unreachable |
) |
|
|
| void InterProcConstProp::expand_all_substituted |
( |
|
) |
|
|
| void InterProcConstProp::pgms_can_be_called_externally |
( |
|
) |
|
|
| void InterProcConstProp::print_consts_sets |
( |
ostream & |
o |
) |
const |
|
|
|
silvius: make this public:
Definition at line 754 of file InterProcConstProp.cc.
References IPCPProcData::const_sets(), Iterator< T >::current(), KeyIterator< S, T >::current_data(), KeyIterator< S, T >::current_key(), IPCPConstants::print_constants(), Iterator< T >::valid(), and KeyIterator< S, T >::valid().
Referenced by iter_clone_and_propagate(), and main(). |
| void InterProcConstProp::add_maymods |
( |
|
) |
[inline] |
|
| void InterProcConstProp::propagate_constants |
( |
PC_UNREACH_BOOL |
remove_unreachable |
) |
[inline] |
|
| void InterProcConstProp::print |
( |
ostream & |
o |
) |
const [virtual] |
|
Friends And Related Function Documentation
The documentation for this class was generated from the following files:
|