next up previous
Next: Analysis of Functions Containing Up: Method/Technique Previous: Method/Technique

Analysis of Functions Containing Stores/Loads but No Function Calls

For simplicity, we begin by considering functions that do not contain function calls. Let us consider the discriminating factors between reusable (const and pure) and unreusable functions: the elements of the MOD set for its statements. This is a good place to start, because once we know that a function is unreusable, then it cannot be either const or pure, so we do not need to check the REF set of its statements. Furthermore, we do not need to compute all the elements of the MOD set. Any modification to non-local variables in a statement implies that the function is unreusable, so once we find one such case, the analysis can terminate with the result that the function is unreusable. Included in this kind of statement are stores to global variables and stores to aliased memory. This is a case where the full information of the Banning set is not needed.

If the function is found to be reusable through the above step, then now we need to find whether it is const or pure. In the previous section, we described that this can be done by looking at the elements of the REF set of the statements in the function. In our method, instead of calculating the REF set, we look for a statement containing load of non-local variables. Any occurrence of such a statement will mean that the function is pure, so we need to look only for the first occurrence. When such a statement is found, we can terminate the analysis with the result that the function is pure. If after going through all statements in the function without finding any statements loading non-local variables, then we can terminate the analysis with the result that the function is const.


next up previous
Next: Analysis of Functions Containing Up: Method/Technique Previous: Method/Technique
Indrayana Rustandi 2003-12-04