COP 5021 meeting -*- Outline -*- * constraint based analysis (1.3.2 and 1.4) Based on section 1.4 of Nielson, Nielson and Hankin's book Program Analysis (Springer, 1999) and the article: Aiken, Alexander. "Introduction to set constraint-based program analysis." Science of Computer Programming 35, no. 2-3 (1999): 79-111. https://www.sciencedirect.com/science/article/pii/S0167642399000076/pdf ** goals The main goal is a modular analysis... Q: What's the difference between a data flow analysis and a constraint-based analysis? ------------------------------------------ DATA FLOW VS. CONSTRAINT-BASED ANALYSIS Main differences? ------------------------------------------ ... for the data flow analysis the constraints are the equivalent of two subset constraints (i.e., == is <= and >=) so are: - more restrictive vs. more expressive) - have to be complete all in one place (vs. compositional) ** example ------------------------------------------ REACHING DEFINITIONS USING CONSTRAINTS For the program: [y := x]^1; [z := 1]^2; while [y>1]^3 do ([z:=z*y]^4; [y:=y-1]^5); [y:= 0]^6 ------------------------------------------ ... RDexit(1) \supseteq RDentry(1) \ {(y,l)|l in Lab*} RDexit(1) \supseteq {(y,1)} RDexit(2) \supseteq RDentry(2) \ {(z,l)|l in Lab*} RDexit(1) \supseteq {(z,2)} RDexit(3) \supseteq RDentry(3) RDexit(4) \supseteq RDentry(4) \ {(z,l)|l in Lab*} RDexit(4) \supseteq {(z,4)} RDexit(5) \supseteq RDentry(5) \ {(y,l)|l in Lab*} RDexit(5) \supseteq {(y,5)} RDexit(6) \supseteq RDentry(6) \ {(y,l)|l in Lab*} RDexit(5) \supseteq {(y,5)} RDentry(1) \supseteq {(x,?),(y,?),(z,?)} RDentry(2) \supseteq RDexit(1) RDentry(3) \supseteq RDexit(2) RDentry(3) \supseteq RDexit(5) RDentry(4) \supseteq RDexit(3) RDentry(5) \supseteq RDexit(4) RDentry(6) \supseteq RDexit(3) Note that there is for an assignment there is: - a constraint that takes out the variable being assigned - a (separate) constraint that adds in variable being assigned Note that the entry constraints directly encode the control flows and there are two for the entry into 3. ** Solutions Also want the least solution, which works here too as it's more precise. The least solution exists and is the same