1 / 18

CS 201 Compiler Construction

CS 201 Compiler Construction. Lecture Interprocedural Data Flow Analysis. Intraprocedural Analysis. Individual procedures are analyzed in isolation; worst-case assumpltion are made while processing call sites. Example:. X = 3; P(); … = X

Download Presentation

CS 201 Compiler Construction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 201Compiler Construction Lecture Interprocedural Data Flow Analysis

  2. Intraprocedural Analysis • Individual procedures are analyzed in isolation; • worst-case assumpltion are made while processing call sites. Example: X = 3; P(); … = X Does definiton X=3 reach this point? Yes Is X a constant? No We assume that P() does not kill any definition for reaching definitions analysis and we assume P() kills all constants that reach the call P().

  3. Interprocedural Analysis By considering interactions between calling and called procedures, analyze the whole program. Challenges • Scoping Rules • Aliasing due to reference parameters Procedure P (f1,f2) f1 = … f2 = … …. = f1 where if f1 defined ? f1 =… what about call P(X,X)?

  4. Interprocedural Analysis Challenges contd… • Calling Context – cannot represent call-return using simple control flow edges. Invalid paths are created by simple control flow edges causing definition of X at statement 1 to reach use of X at statement 4.

  5. Handling Calling Context Various Approaches: • Procedure Inlining – replace the call by procedure body. Drawbacks • Code size increases • Recursion causes problems • Call String Approach – add calling context information to data flow values by tagging them with call-return history.

  6. Handling Calling Context • Functional Approach Two phases • Analyze effect of procedure invocation independent of calling context  find a summary transfer function for the entire procedure • Analyze each procedure using summary functions for all called procedures

  7. Functional Approach

  8. Functional Approach Contd..

  9. Functional Approach Contd..

  10. Functional Approach Contd..

  11. Functional Approach Contd..

  12. Functional Approach Contd..

  13. Example: Available Expressions

  14. Example: Available Expressions

  15. Example: Available Expressions

  16. Example: Available Expressions Summary functions

  17. Example: Available Expressions

  18. Sample Problems Interprocedural Data Flow Analysis

More Related