2017년 5월 1일 월요일

Data flow analysis

Data flow analysis

The data flow analysis (British: Data-flow analysis) is technique to collect the information about the set of the value that I can take at various positions in the program. I collect information whether the value of the variable transmits using control flow graph (CFG) and use it. A compiler uses the information collected in this way for optimization. The basics of the data flow analysis are arrival definitions (reaching definition).

I repeat those expressions and calculate it until the simple method to perform the data flow analysis of a certain program sets a data flow equation about each node of the control flow graph and arrives at the, as a whole, stable state namely firmness point. A data flow equation based on the firmness point data flow analysis is necessary to guarantee to be completed. In other words, the local update of each expression is monotonous. When Gary kill Dole told it in navy postgraduate course university, I developed the basics of this technique [1].

Table of contents

Repetition algorithm

I can calculate the immovable point of the data flow equation using "round robin repetition algorithm".

     for i ← 1 to N          I initialize node i     while (a meeting still changes)          for i ← 1 to N               It is recomputation by a meeting in node i      

Issue of order

The efficiency of the repetition calculation of the data flow equation is influenced by order to visit the node group. I influence it what happens to the grant of the number that is the calculation order of nodes in the round robin repetition algorithm mentioned above. Furthermore, a data flow equation influences a control flow graph whether it is analyzed the rear whether it is analyzed front. In the following, I comment on repetition order to solve a data flow equation slightly. A concept like the repetition order of control flow graphs includes scanning of the hierarchy structure.

Unintentional order (random order)
I solve a data flow equation without minding order. The performance is lower than others.
後行順 (return cliff order) (postorder)
Repetition order general by the issue of backward data flow. I am equivalent to order to visit the pro-node after visiting all the child nodes if I say in hierarchy structure. Generally, I am implemented as a strategic part given priority to depth.
After reverse line order (reverse postorder)
Repetition order general by the issue of front data flow. It is approximately reverse movement of 後行順, but is different from precedent order (preorder).

Example

I show the example which calculates below the characteristic of the computer program by data flow analysis. As for the well-thought characteristic, it should be noted the point that is a real characteristic simple approximation by data flow analysis. Data flow analysis does not simulate the control flow of the program exactly, and this is because I only trace structure of CFG. However, it is effective at the point of view called the optimization even if it is an approximation.

Front analysis

Arrival definition
By the arrival definition analysis, I calculate the set of the definition that may arrive at there about each point of the program.
 It is if b==4 then 1 2:    a = 5, It is else 3  4:    a = 3, It is endif 5 6: It is if a <4 then 7 8:    ... 

The arrival definition in the seventh bank of variable "a" is line number meeting {2, 4}.

Backward analysis

Survival variable (live variables)
I calculate whether it may be read before a variable is updated by the survival variable analysis next at each point of the program.
 1 a = 3: 2 b = 5: 3: c = a + b; 

The set of the survival variable in line number 2 is {a, b}, but the set of the survival variable in line number 1 is only {a}. This is because variable "b" is updated with line number 2 how if it becomes.

sensitivity (sensitivity)

The data flow analysis is thing (flow-sensitive) about the flow essentially. The course can define the data flow equation that (path-insensitive) which is not considered can use for course analysis by the data flow analysis generally. In addition, the following terms are not things peculiar to data flow analysis.

flow-sensitive
I consider the order of sentences of the program. For example, the pointer alias analysis that is flow-insensitive judges the pointer alias analysis that is flow-sensitive if I judge, "variable x and y may refer to the same position" saying "variable x and y may refer to the same position after line number 20".
path-sensitive
I analyze information about condition judgment in the condition divergence order. For example, it is x≤0 and can judge it when I continue processing without a condition of the condition divergence just diverging in the case of x>0 when it is in x>0 when I diverge.
context-sensitive
It is a part of the analysis between the procedure and considers the context of the side that called it in the analysis of the function call. Particularly, I can be sent back to a caller if I use such an information, but when it is not context-sensitive, analysis information will spread to all the points calling a function, and precision is lost.

Footnote

  1. ^ Kildall, Gary (1973). "A Unified Approach to Global Program Optimization". Proceedings of the 1st Annual ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages. http://portal.acm.org/citation.cfm?id=512945&coll=portal&dl=ACM November 20, 2006 reading. . 

References

  • Aho, Alfred V. Sethi, Ravi. Ullman, Jeffrey D. Compilers: Principles, Techniques and Tools. Addison Wesley. 1986.
  • Appel, Andrew W. Modern Compiler Implementation in ML. Cambridge University Press. 1999.
  • Cooper, Keith D. and Torczon, Linda. Engineering a Compiler. Morgan Kaufmann. 2005.
  • Muchnick, Steven S. Advanced Compiler Design and Implementation. Morgan Kaufmann. 1997.
  • Hecht, Matthew S. Flow Analysis of Computer Programs. Elsevier North-Holland Inc. 1977.

This article is taken from the Japanese Wikipedia Data flow analysis

This article is distributed by cc-by-sa or GFDL license in accordance with the provisions of Wikipedia.

Wikipedia and Tranpedia does not guarantee the accuracy of this document. See our disclaimer for more information.

In addition, Tranpedia is simply not responsible for any show is only by translating the writings of foreign licenses that are compatible with CC-BY-SA license information.

0 개의 댓글:

댓글 쓰기