DFA&:OPT-METAFrame: A Tool Kit for Program Analysis and Optimization

Similar documents
Code Optimization. Code Optimization

Code-Size Sensitive Partial Redundancy Elimination

Code Placement, Code Motion

Eliminating Annotations by Automatic Flow Analysis of Real-Time Programs

Utilizing Static Analysis for Programmable Logic Controllers

33. Model Transformation and Program Optimization with Graph Rewrite Systems

Lecture 5. Data Flow Analysis

An Implementation of Lazy Code Motion for Machine SUIF

Code Motion and Code Placement: Just Synonyms?*

Compiler Optimization and Code Generation

Technical Review of peephole Technique in compiler to optimize intermediate code

Static Program Analysis

ait: WORST-CASE EXECUTION TIME PREDICTION BY STATIC PROGRAM ANALYSIS

Data-Flow Analysis as Model Checking

Static Program Analysis

Static Slicing of Threaded Programs

An Eclipse Plug-in for Model Checking

7. Optimization! Prof. O. Nierstrasz! Lecture notes by Marcus Denker!

Lazy Code Motion. Jens Knoop FernUniversität Hagen. Oliver Rüthing University of Dortmund. Bernhard Steffen University of Dortmund

Data-Flow Based Detection of Loop Bounds

Combining Analyses, Combining Optimizations - Summary

Discovering Machine-Specific Code Improvements. Technical Report. S. L. Graham (415)

Fiona A Tool to Analyze Interacting Open Nets

International Colloquium on Graph and Model Transformation On the occasion of the 65th birthday of Hartmut Ehrig (GraMoT 2010)

Compiler Passes. Optimization. The Role of the Optimizer. Optimizations. The Optimizer (or Middle End) Traditional Three-pass Compiler

Experimental Comparison of call string and. functional Approaches to Interprocedural. Analysis? Florian Martin

Principles of Program Analysis: A Sampler of Approaches

Single-pass Static Semantic Check for Efficient Translation in YAPL

Natural Semantics [14] within the Centaur system [6], and the Typol formalism [8] which provides us with executable specications. The outcome of such

Goals of Program Optimization (1 of 2)

Advanced Slicing of Sequential and Concurrent Programs

CalFuzzer: An Extensible Active Testing Framework for Concurrent Programs Pallavi Joshi 1, Mayur Naik 2, Chang-Seo Park 1, and Koushik Sen 1

Time Stamps for Fixed-Point Approximation

Principles of Program Analysis. Lecture 1 Harry Xu Spring 2013

13 AutoFocus 3 - A Scientific Tool Prototype for Model-Based Development of Component-Based, Reactive, Distributed Systems

Lazy Code Motion. 1 Motivation. Jens Knoop Oliver Ruthing$ Bernhard Steffen

Extracting the Range of cps from Affine Typing

Managing test suites for services

CLAN: A Tool for Contract Analysis and Conflict Discovery

Modeling the Evolution of Aspect Configurations using Model Transformations

6. Intermediate Representation

SYED AMMAL ENGINEERING COLLEGE (An ISO 9001:2008 Certified Institution) Dr. E.M. Abdullah Campus, Ramanathapuram

TVLA: A SYSTEM FOR GENERATING ABSTRACT INTERPRETERS*

A Modelling and Analysis Environment for LARES

Analysis of Pointers and Structures

8. Static Single Assignment Form. Marcus Denker

Introduction to Machine-Independent Optimizations - 1

Concurrent Programming Constructs and First-Class Logic Engines

E-path PRE Partial Redundancy Elimination Made Easy

Prototype Environment for Refactoring Clean Programs

Efficient Separate Compilation of Object-Oriented Languages

A Graph Free Approach to Data Flow Analysis

Model Checking: Back and Forth Between Hardware and Software

CJT^jL rafting Cm ompiler

Constructing Control Flow Graph for Java by Decoupling Exception Flow from Normal Flow

MOPBox: A Library Approach to Runtime Verification

How to Uniformly Specify Program Analysis and Transformation with Graph Rewrite Systems

Duet: Static Analysis for Unbounded Parallelism

Compiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore

RATCOP: Relational Analysis Tool for Concurrent Programs

Optimization Prof. James L. Frankel Harvard University

Abstract formula. Net formula

Symbolic Automata Library for Fast Prototyping

CS 6110 S11 Lecture 12 Naming and Scope 21 February 2011

Compositional Model Based Software Development

Probabilistic Worst-Case Response-Time Analysis for the Controller Area Network

Resource Aware ML. 1 Introduction. Jan Hoffmann 1, Klaus Aehlig 2, and Martin Hofmann 2

Programming Language Processor Theory

Regression Verification - a practical way to verify programs

COMS W4115 Programming Languages and Translators Lecture 21: Code Optimization April 15, 2013

Efficient Separate Compilation of Object-Oriented Languages

Optimizing for Space and Time Usage with Speculative Partial Redundancy Elimination

Outline. Register Allocation. Issues. Storing values between defs and uses. Issues. Issues P3 / 2006

Static Safety Analysis of UML Action Semantics for Critical Systems Development

Modularization Based Code Optimization Technique for Ensuring Software Product Quality

TIMES A Tool for Modelling and Implementation of Embedded Systems

A graphical user interface for service adaptation

Leslie Lamport: The Specification Language TLA +

Thunks (continued) Olivier Danvy, John Hatcli. Department of Computing and Information Sciences. Kansas State University. Manhattan, Kansas 66506, USA

Designing a Semantic Ground Truth for Mathematical Formulas

Refactoring via Database Representation

Advanced Compiler Construction

Ufo: A Framework for Abstraction- and Interpolation-Based Software Verification

Model Checking DSL-Generated C Source Code

CSE 501: Compiler Construction. Course outline. Goals for language implementation. Why study compilers? Models of compilation

Principles of Compiler Construction ( )

Static analysis and all that

UC Irvine UC Irvine Previously Published Works

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Subject Name: CS2352 Principles of Compiler Design Year/Sem : III/VI

XI International PhD Workshop OWD 2009, October Fuzzy Sets as Metasets

Graphs in METAFrame: The Unifying Power of Polymorphism

On the Reduction of Dublin Core Metadata Application Profiles to Description Logics and OWL

A Class-Specific Optimizing Compiler

Petri-net-based Workflow Management Software

A Visual Editor for Reconfigurable Object Nets based on the ECLIPSE Graphical Editor Framework

Models in Conflict Towards a Semantically Enhanced Version Control System for Models

Bypassing Memory Leak in Modern C++ Realm

nfn2dlp: A Normal Form Nested Programs Compiler

CS Advanced Compiler Design Course Project

Annales UMCS Informatica AI 2 (2004) UMCS. An algorithm and case study for the object oriented abstraction.

Transcription:

DFA&:OPT-METAFrame: A Tool Kit for Program Analysis and Optimization Marion Klein* Dirk Koschiitzki t Jens Knoop t Bernhard Steffen t ABSTRACT Whereas the construction process of a compiler for the early and late phases like syntactic analysis and code generation is well-supported by powerful tools, the optimizer, the key component for achieving highly efficient code is usually still hand-coded. The tool kit presented here supports this essential step in the construction of a compiler. The two key features making it exceptional are (1) that it automatically generates global program analyses for intraprocedural~ interprocedural and parallel data flow problems, and (2) that it supports the combination of the results obtained to program optimizations. 1 OVERVIEW Compilers are expected to produce highly ej~cient code. Thus, optimizers are integrated in order to detect and remove inefficiencies in application programs. Typically, optimization proceeds in two steps: First, a program analysis, usually a data flow analysis (DFA), which detects the side conditions under which an optimizing program transformation is applicable, and second, the concrete transformation based on the data flow facts computed by the preceding analysis. The algorithms realizing these two steps are usually still hand-coded. As the construction process for essentially every other phase of compilation is well-supported by powerful tools, the construction of the optimizer still belongs to the most expensive, time consuming, and error prone steps in the construction of a compiler. The DFA&OPT-METAFrame tool kit supports this essential step of compiler construction. It automatically generates efficient DFA-algorithms from concise specifications given in a modal logic (cf. [St]). In essence, the DFAgenerator of the tool kit works by partially evaluating an appropiate model checker with respect to the modal formula specifying the data flow property *Lehrstuhl fiir Informatik II, Rheinisch-Westf~ilische Technische Hochschule Aachen, AhornstraBe 55, D-52056 Aachen, Germany E-mail: marion~informatik.rwth-aachen.de tfakult~t fiir Mathematik und Informatik, Universit~t Passau, Innstrasse 33, D-94032 Passau, Germany. E-mail: {knoop I koschuetzki I steffen}~fmi.uni-passau.de

423 of interest (cf. [SCKKM]). The result is a usual iterative DFA-algorithm, which runs on the machine the model checker is implemented on, and which can immediately be integrated into the compiler under construction. A high level programming language allows to combine the results of different analyses to optimizing program transformations. It serves as the connecting link for combining program analysis and optimization, such that the tool kit supports the complete process of the optimizer construction. The benefits of this approach are as follows: The DFA-algorithms required are directly specified in terms of the data flow properties of interest. All the details about the corresponding computation procedures are hidden in the tool kit. This yields concise high-level specifications, simplifies and structures the specification development, and supports the reasoning about features such as correctness and optimality of the DFAs. In fact, the DFA-algorithms required by the program optimizations considered below result from two to five line specifications in a modal logic. They are not only significantly shorter, but also more intuitive than their traditionally specified counterparts. Moreover, our practical experience shows that the generated DFA-algorithms are as efficient as their hand-coded counterparts. Summarizing, we profit from: 9 Concise specifications directly in terms of the data flow properties 9 Combining global program analysis (DFA) and optimization 9 Simple reasoning about DFA and optimization on a very high level 9 Hiding of all details of the computation procedure 9 No efficiency penalty in comparison to hand-coded algorithms 9 High flexibility supporting rapid prototyping 2 SCREEN SHOTS FROM A SAMPLE SESSION We illustrate the usage of the tool kit by means of two screen shots from a sample session. The optimization considered is to remove all partially redundant computations in a program (in the example of 'a + b') by means of the busy code motion (BCM) transformation of [KRS1]. This transformation requires the computation of all program points being down-safe and up-sa/e for a computation, here 'a + b'. The results of the corresponding DFA-algorithms, which are automatically generated from the specifications shown in the lower left window, are displayed in the right window of Figure 1, which shows the argument program in an automatically generated and layouted transition system like representation. The states represent program points, and the transitions the control flow and the basic blocks of the underlying procedure. The analysis and optimization process is controlled by means of the high level language, whose commands are executed by an interpreter running in the upper left window.

424 FIGURE 1. First Screen Shot After computing the set of up-safe and down-safe program points, the BCM-transformation can be specified within the high level language: (1) Initializing a new temporary h by a + b at all down-safe program points which have an incoming edge modifying a or b, or an unsafe predecessor. (2) Replacing all original occurrences of a + b by h. The result of the complete transformation is displayed in the right window of Figure 2. 3 SCOPE AND CURRENT STATE The DFA&OPT-METAFrame tool kit supports data flow analysis and optimization of intraprocedural, interprocedural and parallel programs (cf. [KS, KSV1, KSV2, St]). It is particularly well-suited for optimizations based on bitvector analyses, which are most relevant in practice due to their broad scope of powerful and practically relevant optimizations ranging from code motion over assignment motion and partial dead code elimination to strength reduction and (via definition-use chains) to constant propagation and constant ]olding. Moreover, all these techniques can be performed in the parallel and interprocedural program setting as efficiently as in the sequential intraprocedural one. The intraprocedural sequential case is fully implemented in the current prototype of our tool kit, i.e., the program analyses are directly generated from their modal logic specifications (cf. [SCKKM]). Interprocedural and parallel DFA-problems are specified in terms of local semantic functionals

425 of earliest and replace~nt points, [~DS&(('Sta=tIl<{~d_a+b}>ITlll<.>~{'('DS)&~('US))))ll<{* :omp_.+b}>it) ~J~P -_max (<{n_r162 color.d blue. colored yell~, RBP-State. ~rq colored green. ~',:~ FIGURE 2. Second Screen Shot giving abstract semantics to statements, the direction of data flow, and the kind of fixpoint desired as it is common in classical data flow analysis. For the interprocedural setting the current version supports programs composed of procedures with global variables. An extension to local variables, and value and reference parameters is in progress. The tool kit has successfully been tested on the program optimizations mentioned above. 4 RELATED WORK Early approaches to the automatic generation of optimizers concentrated on peephole optimizations, which do not require global program analyses (cf. [DF, Ke]). These approaches are contrasted by others which address the generation of global analyses, but do not support the construction of program transformations (cf. [AM, YH]). Both steps, i.e., global analyses and program transformations, are supported by the systems of [VF, WS], which support intraprocedural optimization. Whereas the system of [VF] concentrates on 'classical' intraprocedural optimizations, the one of [WS] is particularly well-suited for local transformations based on data dependency information which are important for the automatic parallelization of sequential programs. The generality of the DFA&OPT-METAFrame tool kit that it works for intraprocedural, interprocedural, and parallel programs, and supports the generation of global program analyses and their combination to optimizations, is in fact exceptional.

426 5 REFERENCES [AM] [DF] [Ke] [KRS1] [KRS2] [KS] [KSV1] [KSV2] [St] Alt, M., and Martin, F. Generation of efficient interprocedural analyzers with PAG. In Proc. 2 ~ Internat. Static Analysis Symposium (SAS'95), Glasgow, UK, Springer-Verlag, LNCS 983 (1995), 33-50. Davidson, J. W., and Fraser, C. W. Automatic generation of peephole transformations. In Proc. ACM SIGPLAN'84 Syrup. on Comp. Construct., Montreal, Canada, SIGPLAN Notices 19, 6 (1984), 111-115. Kessler, R. R. Peep - An architectural description driven peephole transformer. In Proc. ACM SIGPLAN'84 Syrup. on Comp. Construct., Montreal, Canada, SIGPLAN Notices 19, 6 (1984), 106-110. Knoop, J., Riithing, O., and Stefien, B. Optimal code motion: Theory and practice. Transactions on Programming Languages and Systems 16, 4 (1994), 1117-1155. Knoop, J., Rfithing, O., and Steffen, B. The power of assignment motion. In Proc. ACM SIGPLAN'95 Con]. on Programming Language Design and Implementation (PLDI'95), La Jolla, California, BIG- PLAN Notices 30, 6 (1995), 233-245. Knoop, J., and Stefien, B. The interprocedural coincidence theorem. In Proc..~th lnternat. Conference on Compiler Construction (CC'92), Paderborn, Germany, Springer-Verlag, LNCS 641 (1992), 125-140. Knoop, J., Steffen, B., and Vollmer, J. Parallelism for free: Efficient and optimal bitvector analyses for parallel programs. Accepted for Transactions on Programming Languages and Systems. Knoop, J., Stefien, B., and Vollmer, J. Parallelism for free: Bitvector analyses :=~ No state explosion! In Proc. I st Internat. Workshop on Tools and Algorithms for the Construction and Analysis of Systems (TACAS'95), Springer-Verlag, LNCS 1019 (1995), 264-289. Steffen, B. Generating data flow analysis algorithms from modal specifications. Science of Computer Programming 2I, (1993), 115-139. [SCKKM] Stefien, B., Clatlen, A., Klein, M., Knoop, J., and Margaria, T. The fixpoint-analysis machine. In Proc. 6 th Internat. Conference on Concurrency Theory (CONCUR'95), Philadelphia, Pennsylvania, Springer-Verlag, LNCS 962 (1995), 72-87. [VF] [WS] [YH] Venkatesh, G. V., and Fischer, C. N. Spare: A development evironment for program analysis algorithms. In IEEE Transactions on Software Engineering 18, 4 (1992), 304-318. Whitfield, D., and Sofia, M. L. Automatic generation of global optimizers. In Proc. ACM SIGPLAN'91 Conference on Programming Language Design and Implementation (PLDI'91), Toronto, Ontario, Canada, SIGPLAN Notices 26, 6 (1991), 120-129. Yi, K., and Harrison III, W. L. Automatic generation and management of interprocedural program analyses. In ACM SIGPLAN-SIGACT, (Jan. 1993).