optimizing compilers
play

Optimizing Compilers information from different paths. for bit - PowerPoint PPT Presentation

Property Space Towards a General Framework The analyses operate over a property space representing the The property space, L , is used to represent the data flow inform and the combination operator, : P ( L ) L , is used to combin


  1. Property Space Towards a General Framework • The analyses operate over a property space representing the The property space, L , is used to represent the data flow inform and the combination operator, � : P ( L ) → L , is used to combin analysis information Optimizing Compilers information from different paths. – for bit vector frameworks: P ( D ) for finite set D – more generally: complete lattice ( L, ⊑ ) Data Flow Analysis • L is a complete lattice Frameworks and Algorithms • The analyses of programs are defined in terms of transfer functions meaning that it is a partially ordered set, ( L, ⊑ ) , such that e subset, Y , has a least upper bound, � Y . – for bit vector frameworks: f ℓ ( X ) = ( X \ kill ℓ ) ∪ gen ℓ Markus Schordan – more generally: monotone functions f ℓ : L → L • L satisfies the Ascending Chain Condition Institut f¨ ur Computersprachen meaning that ascending chain eventually statbilises: if ( l n ) n Technische Universit ¨ at Wien that l 1 ⊑ l 2 ⊑ l 3 ⊑ . . . , then there exists n such that l n = l n + Markus Schordan October 2, 2007 1 Markus Schordan October 2, 2007 2 Markus Schordan October 2, 2007 Complete Lattice Example Chain Let Y be a subset of L . Then A subset Y ⊆ L of a partially ordered set L = ( L, ⊑ ) is a chain if s { a, b, c } s ∅ ✟ ❍❍❍❍ ✟ ❍❍❍❍ ✟ ✟ • l is an upper bound if ∀ l ′ ∈ Y : l ′ ⊑ l and ✟ ✟ ✟ ✟ ∀ l 1 , l 2 ∈ Y : ( l 1 ⊑ l 2 ) ∨ ( l 2 ⊑ l 1 ) s { a, b } s { a, c } s { b, c } s { a } s { b } s { c } ✟ ❍ ✟ ❍ ✟ ❍❍❍❍ ✟ ❍❍❍❍ ❍ ✟ ❍ ✟ • l is a lower bound if ∀ l ′ ∈ Y : l ⊑ l ′ . ❍ ✟ ✟✟✟✟ ❍ ✟ ✟✟✟✟ ❍ ✟ ✟ ❍ It is a finite chain if it is a finite subset of L . ✟ ❍ ✟ ❍ s { a } s { b } s { c } s { a, b } s { a, c } s { b, c } ✟ ❍ ✟ ❍ ❍ ❍ • l is a least upper bound of Y if it is an upper bound of Y that ❍ ✟ ❍ ✟ A sequence ( l n ) n = ( l n ) n ∈ N of elements in L is an ❍ ✟✟✟✟ ❍ ✟✟✟✟ ❍ ❍ satisfies l ⊑ l 0 whenever l 0 is another upper bound of Y . ❍ ❍ s ∅ s { a, b, c } ❍ ❍ • ascending chain if n ≤ m → l n ⊑ l m • l is a greatest lower bound of Y if it is a lower bound of Y that • descending chain if n ≤ m → l m ⊑ l n satisfies l 0 ⊑ l whenever l 0 is another lower bound of Y . lattice ( P ( { a, b, c } ) , ⊆ ) ( P ( { a, b, c } ) , ⊇ ) We shall say that a sequence ( l n ) n eventually stabilizes if and on A complete lattice L = ( L, ⊑ ) is partially ordered set ( L, ⊑ ) such that all subsets have least upper bounds as well as greatest lower bounds. � � � ∃ n 0 ∈ N : ∀ n ∈ N : n ≥ n 0 → l n = l n 0 ⊥ ∅ { a, b, c } ⊤ = � ∅ = � L is the greatest element of L Notation: ⊥ = � ∅ = � L is the least element of L Markus Schordan October 2, 2007 4 Markus Schordan October 2, 2007 5 Markus Schordan October 2, 2007

  2. Ascending and Descending Chain Conditions Transfer Functions Frameworks A partially ordered set L = ( L, ⊑ ) has finite height if and only if all The set of transfer functions, F , is a set of monotone functions over A Monotone Framework consists of: chains are finite. L = ( L, ⊑ ) , meaning that • a complete lattice, L , that satisfies the Ascending Chain The partially ordered set L satisfies the Condition; we write � for the least upper bound operator l ⊑ l ′ → f ℓ ( l ) ⊑ f ℓ ( l ′ ) • Ascending Chain Condition if and only if all ascending chains • a set F of monotone functions from L to L that contains the for all l, l ′ ∈ L and furthermore they fulfill the following conditions eventually stabilies. identity function and that is closed under function composit • F contains all the transfer functions f ℓ : L → L in question (for • Descending Chain Condition if and only if all descending chains A Distributive Framework is a monotone framework where addit ℓ ∈ Lab ⋆ ) eventually stabilies. all functions f of F are required to be distributive: • F contains the identity function Lemma: A partially ordered set L = ( L, ⊑ ) has finite height if and only if • F is closed under composition of functions f ( l 1 ⊔ l 2 ) = f ( l 1 ) ⊔ f ( l 2 ) it satisfies both the Ascending and Descending Chain Conditions. A Bit Vector Framework is a Monotone Framework where additio A lattice L = ( L, ⊑ ) satisfies the ascending chain condition if all is a powerset of a finite set and all functions f of F have the form ascending chains eventually stabilize; it satisfies the descending chain condition if all descending chains eventually stabilize. f ( l ) = ( l \ kill ) ∪ gen Markus Schordan October 2, 2007 7 Markus Schordan October 2, 2007 8 Markus Schordan October 2, 2007 Equations of the Instance On Bit Vector Frameworks (1) Instances of a Framework An instance of a Framework consists of A Bit Vector Framework is a Monotone Framework � { Analysis • ( ℓ ′ ) | ( ℓ ′ , ℓ ) ∈ F } ⊔ ι ℓ Analysis ◦ ( ℓ ) = E • the complete lattice, L , of the framework • P ( D ) is a complete lattice satisfying the Ascending Chain  ι : if ℓ ∈ E  Condition (because D is finite) • the space of functions, F , of the framework where ι ℓ E = ⊥ : if ℓ / ∈ E  • the transfer functions f ℓ ( l ) = ( l \ kill ℓ ) ∪ gen ℓ • a finite flow, F (typically flow ( S ⋆ ) or flow R ( S ⋆ ) ) Analysis • ( ℓ ) = f ℓ ( Analysis ◦ ( ℓ )) – are monotone: l 1 ⊆ l 2 → l 1 \ kill ℓ ⊆ l 2 \ kill ℓ • a finite set of extremal labels, E (typically { init ( S ⋆ ) } or final ( S ⋆ ) ) → ( l 1 \ kill ℓ ) ∪ gen ℓ ⊆ ( l 2 \ kill ℓ ) ∪ ge • an extremal value, ι ∈ L , for the extremal labels → f ℓ ( l 1 ) ⊆ f ℓ ( l 2 ) • a mapping, f. , from the labels Lab ⋆ to transfer functions in F . – contain the identity function: id ( l ) = ( l \∅ ) ∪ ∅ – are closed under function composition: ((( l \ kill 1 l ) \ kill 2 f 2 ◦ f 1 = f 2 ( f 1 ( l )) = l ) ∪ gen 1 l ) ∪ gen 2 l ( l \ ( kill 1 l ∪ kill 2 l \ kill 2 l )) ∪ (( gen 1 = l ) ∪ g Markus Schordan October 2, 2007 10 Markus Schordan October 2, 2007 11 Markus Schordan October 2, 2007

  3. On Bit Vector Frameworks (2) Minimal Fixed Point Algorithm (MFP) Generic Worklist Algorithm A Bit Vector Framework is a Distributive Framework W:=nil; Input: an instance ( L, F , F, E, ι, f. ) of a Monotone Framework foreach ( ℓ, ℓ ′ ) ∈ F do W := cons( ( ℓ, ℓ ′ ) ,W); od; foreach ℓ ∈ E ∪ { ℓ, ℓ ′ | ( ℓ, ℓ ′ ) ∈ F } do • a Bit Vector Framework is a Monotone Framework Output: the MFP Solution: MFP ◦ , MFP • if ℓ ∈ E then • the transfer functions of a Bit Vector Framework are distributive MFP ◦ ( ℓ ) := A[ ℓ ] A [ ℓ ] := ι else MFP • ( ℓ ) := f ℓ (A[ ℓ ]) f ( l 1 ⊔ l 2 ) = f ( l 1 ∪ l 2 ) A [ ℓ ] := ⊥ L = (( l 1 ∪ l 2 ) \ kill l ) ∪ gen l Data Structures: to represent a work list and the analysis result fi od • The result A : the current analysis result for block entries = (( l 1 \ kill l ) ∪ ( l 2 \ kill l )) ∪ gen l while W � = nil do • The workliks W : a list of pairs ( ℓ, ℓ ′ ) indicating that the current ( ℓ, ℓ ′ ) := head(W); = (( l 1 \ kill l ) ∪ gen l ) ∪ (( l 2 \ kill l ) ∪ gen l ) W := tail(W); analysis result has changed at the entry to the block ℓ and f ( l 1 ) ∪ f ( l 2 ) = f ℓ ( l 1 ) ⊔ f ℓ ( l 2 ) = if f ℓ ( A [ ℓ ]) �⊑ A [ ℓ ′ ] then hence the information must be recomputed for ℓ ′ . A [ ℓ ′ ] := A [ ℓ ′ ] ⊔ f ℓ ( A [ ℓ ]) ; Analogous for the case with ⊔ being ∩ . foreach ℓ ′′ with ( ℓ ′ , ℓ ′′ ) in F do Lemma: The worklist algorithm always terminates and computes the W := cons( ( ℓ ′ , ℓ ′′ ) ,W); least (or MFP a ) solution to the instance given as input. Note, a Bit Vector Framework is (a special case of) a Distributive Frame- od work. And a Distributive Framework is (a special case of) a Monotone fi a for historical reasons MFP is also called maximal fixed point in the literature od Framework. Markus Schordan October 2, 2007 13 Markus Schordan October 2, 2007 14 Markus Schordan October 2, 2007 Complexity Meet Over All Paths Solution (MOP) MOP Solution • The solution up to but not including ℓ : Assume that Idea: Propagate analysis information along paths to determine the information available at the different program points. � ℓ ( ι ) | � • E and F contain at most b ≥ 1 distinct labels { f � ℓ ∈ path ◦ ( ℓ ) } MOP ◦ ( ℓ ) = • The paths up to but not including ℓ : • F contains at most e ≥ b pairs, and • The solution up to and including ℓ : path ◦ ( ℓ ) = { [ ℓ 1 , . . . , ℓ n − 1 ] | n ≥ 1 ∧ ∀ i < n : ( ℓ, ℓ ′ ) ∈ F ∧ ℓ 1 ∈ E ∧ ℓ n = ℓ } • L has finite height of at most h ≥ 1 . • The paths up to and including ℓ : � ℓ ( ι ) | � { f � ℓ ∈ path • ( ℓ ) } MOP • ( ℓ ) = Count as basic operations the application of f ℓ , applications of ⊔ , or path • ( ℓ ) = { [ ℓ 1 , . . . , ℓ n ] | n ≥ 1 ∧ ∀ i < n : ( ℓ, ℓ ′ ) ∈ F ∧ ℓ 1 ∈ E ∧ ℓ n = ℓ } updates of A. With each path � ℓ = [ ℓ 1 , . . . , ℓ n ] we associate a transfer function: Then there will be at most O ( e · h ) basic operations. f � ℓ = f ℓ n ◦ · · · ◦ f ℓ 1 ◦ id Markus Schordan October 2, 2007 16 Markus Schordan October 2, 2007 17 Markus Schordan October 2, 2007

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend