SlideShare a Scribd company logo
1 of 87
Dataflow Analysis

Guido Wachsmuth




       Delft
                              Course IN4303, 2012/13
       University of
       Technology               Compiler Construction
       Challenge the future
Overview
today’s lecture

control flow graphs




                      Dataflow Analysis   2
Overview
today’s lecture

control flow graphs

data flow analyses

  •   liveness analysis
  •   reaching definitions
  •   available expressions




                              Dataflow Analysis   2
Overview
today’s lecture

control flow graphs

data flow analyses

  •   liveness analysis
  •   reaching definitions
  •   available expressions

non-local optimisations

  •   dead code elimination
  •   constant & copy propagation
  •   common subexpression elimination


                                         Dataflow Analysis   2
I
control-flow graphs




                      Dataflow Analysis   3
Intermediate language
quadruples

store                 jumps
   a ← b ⊕ c             L:
   a ← b                 goto L
                         if a ⊗ b
memory access
                              goto L1
   a ← M[b]
                         else
   M[a] ← b
                              goto L2
functions
   f(a1, …, an)
   b ← f(a1, …, an)

                                        Dataflow Analysis   4
Control-flow graphs
example

    a ← 0
L1: b ← a + 1
    c ← c + b
    a ← 2 * b
    if a < N
       goto L1
    else
       goto L2
L2: return c

                      Dataflow Analysis   5
Control-flow graphs
example

    a ← 0             a ← 0
L1: b ← a + 1
                      b ← a + 1
    c ← c + b
    a ← 2 * b         c ← c + b
    if a < N
       goto L1        a ← 2 * b

    else
                      if a < N
       goto L2
L2: return c          return c


                                  Dataflow Analysis   5
Control-flow graphs
terminology

              a ← 0


              b ← a + 1


              c ← c + b


              a ← 2 * b


              if a < N


              return c


                          Dataflow Analysis   6
Control-flow graphs
terminology

              a ← 0


node          b ← a + 1


              c ← c + b


              a ← 2 * b


              if a < N


              return c


                          Dataflow Analysis   6
Control-flow graphs
terminology

              a ← 0
                          in-edge
node          b ← a + 1


              c ← c + b


              a ← 2 * b


              if a < N


              return c


                              Dataflow Analysis   6
Control-flow graphs
terminology

              a ← 0
                          in-edge
node          b ← a + 1


              c ← c + b
                          in-edge
              a ← 2 * b


              if a < N


              return c


                              Dataflow Analysis   6
Control-flow graphs
terminology

predecessor   a ← 0
                          in-edge
node          b ← a + 1


              c ← c + b
                          in-edge
              a ← 2 * b


predecessor   if a < N


              return c


                              Dataflow Analysis   6
Control-flow graphs
terminology

predecessor   a ← 0
                          in-edge
node          b ← a + 1
                          out-edge
              c ← c + b
                          in-edge
              a ← 2 * b


predecessor   if a < N


              return c


                              Dataflow Analysis   6
Control-flow graphs
terminology

predecessor   a ← 0
                          in-edge
node          b ← a + 1
                          out-edge
successor     c ← c + b
                          in-edge
              a ← 2 * b


predecessor   if a < N


              return c


                              Dataflow Analysis   6
II
liveness analysis




                    Dataflow Analysis   7
Liveness analysis
terminology

              a ← 0


              b ← a + 1


              c ← c + b


              a ← 2 * b


              if a < N


              return c


                          Dataflow Analysis   8
Liveness analysis
terminology

definition    a ← 0


              b ← a + 1


              c ← c + b


              a ← 2 * b


              if a < N


              return c


                          Dataflow Analysis   8
Liveness analysis
terminology

definition    a ← 0


usage         b ← a + 1


              c ← c + b


              a ← 2 * b


              if a < N


              return c


                          Dataflow Analysis   8
Liveness analysis
terminology

definition    a ← 0


usage         b ← a + 1


              c ← c + b


definition    a ← 2 * b


              if a < N


              return c


                          Dataflow Analysis   8
Liveness analysis
terminology

definition    a ← 0


usage         b ← a + 1


              c ← c + b


definition    a ← 2 * b


usage         if a < N


              return c


                          Dataflow Analysis   8
Liveness analysis
terminology

definition    a ← 0


usage         b ← a + 1


              c ← c + b


definition    a ← 2 * b

                                 live-in
usage         if a < N


              return c


                          Dataflow Analysis   8
Liveness analysis
terminology

definition    a ← 0


usage         b ← a + 1


              c ← c + b


definition    a ← 2 * b
                          live-out

                                     live-in
usage         if a < N


              return c


                              Dataflow Analysis   8
Liveness analysis
terminology

definition    a ← 0

                          live-in
usage         b ← a + 1


              c ← c + b


definition    a ← 2 * b
                          live-out

                                      live-in
usage         if a < N


              return c


                               Dataflow Analysis   8
Liveness analysis
terminology

definition    a ← 0

                          live-in
usage         b ← a + 1


              c ← c + b


definition    a ← 2 * b
                          live-out

                                      live-in
usage         if a < N
                          live-out

              return c


                               Dataflow Analysis   8
Liveness analysis
terminology

definition    a ← 0       live-out

                          live-in
usage         b ← a + 1


              c ← c + b


definition    a ← 2 * b
                          live-out

                                      live-in
usage         if a < N
                          live-out

              return c


                               Dataflow Analysis   8
Liveness analysis
example

             a ← 0


             b ← a + 1


             c ← c + b


             a ← 2 * b


             if a < N


             return c


                         Dataflow Analysis   9
Liveness analysis
example

             a ← 0


             b ← a + 1


             c ← c + b


             a ← 2 * b


             if a < N


             return c


                         Dataflow Analysis   9
Liveness analysis
example

             a ← 0


             b ← a + 1


             c ← c + b


             a ← 2 * b


             if a < N


             return c


                         Dataflow Analysis   9
Liveness analysis
example

             a ← 0


             b ← a + 1


             c ← c + b


             a ← 2 * b


             if a < N


             return c


                         Dataflow Analysis   9
Liveness analysis
example

             a ← 0


             b ← a + 1


             c ← c + b


             a ← 2 * b


             if a < N


             return c


                         Dataflow Analysis   9
Liveness analysis
example

             a ← 0


             b ← a + 1


             c ← c + b


             a ← 2 * b


             if a < N


             return c


                         Dataflow Analysis   9
Liveness analysis
example

             a ← 0


             b ← a + 1


             c ← c + b


             a ← 2 * b


             if a < N


             return c


                         Dataflow Analysis   9
Liveness analysis
example

             a ← 0


             b ← a + 1


             c ← c + b


             a ← 2 * b


             if a < N


             return c


                         Dataflow Analysis   9
Liveness analysis
example

             a ← 0


             b ← a + 1


             c ← c + b


             a ← 2 * b


             if a < N


             return c


                         Dataflow Analysis   9
Liveness analysis
example

             a ← 0


             b ← a + 1


             c ← c + b


             a ← 2 * b


             if a < N


             return c


                         Dataflow Analysis   9
Liveness analysis
example

             a ← 0


             b ← a + 1


             c ← c + b


             a ← 2 * b


             if a < N


             return c


                         Dataflow Analysis   9
Liveness analysis
formalisation

                    in[n] = use[n]   ∪ (out[n] - def[n])

                          out[n] =   ∪  s∈succ[n]   in[s]



1. If a variable is used at node n, then it is live-in at n.

2. If a variable is live-out but not defined at node n, it is live-in at n.

3. If a variable is live-in at node n, then it is live-out at its predecessors.

                                                            Dataflow Analysis 10
Liveness analysis
algorithm

for each n
   in[n] ← {} ; out[n] ← {}
repeat
   for each n
         in'[n] = in[n] ; out'[n] = out[n]
         in[n] = use[n] ∪ (out[n] - def[n])
         for each s in succ[n]
            out[n] = out[n] ∪ in[s]
until
   for all n: in[n] = in'[n] and out[n] = out'[n]


                                              Dataflow Analysis 11
Liveness analysis
example

1a ← 0                       1       2           3           4           5          6       7

                 u d     i o     i o         i o         i o         i o        i o     i o
2b ← a + 1
             1       a                   a           a       ac c ac c ac c ac

3c ← c + b   2   a b     a       a bc ac bc ac bc ac bc ac bc ac bc

             3 bc c bc           bc b bc b bc b bc b bc bc bc bc
4a ← 2 * b
             4   b a     b       b a         b a         b ac bc ac bc ac bc ac
5 if a < N   5   a       a a     a ac ac ac ac ac ac ac ac ac ac ac

             6   c       c       c           c           c           c          c       c
6 return c


                                                                 Dataflow Analysis 12
Liveness analysis
example

1a ← 0                       1       2           3           4           5          6       7

                 u d     i o     i o         i o         i o         i o        i o     i o
2b ← a + 1
             1       a                   a           a       ac c ac c ac c ac

3c ← c + b   2   a b     a       a bc ac bc ac bc ac bc ac bc ac bc

             3 bc c bc           bc b bc b bc b bc b bc bc bc bc
4a ← 2 * b
             4   b a     b       b a         b a         b ac bc ac bc ac bc ac
5 if a < N   5   a       a a     a ac ac ac ac ac ac ac ac ac ac ac

             6   c       c       c           c           c           c          c       c
6 return c


                                                                 Dataflow Analysis 12
Liveness analysis
example

1a ← 0                       1       2           3           4           5          6       7

                 u d     i o     i o         i o         i o         i o        i o     i o
2b ← a + 1
             1       a                   a           a       ac c ac c ac c ac

3c ← c + b   2   a b     a       a bc ac bc ac bc ac bc ac bc ac bc

             3 bc c bc           bc b bc b bc b bc b bc bc bc bc
4a ← 2 * b
             4   b a     b       b a         b a         b ac bc ac bc ac bc ac
5 if a < N   5   a       a a     a ac ac ac ac ac ac ac ac ac ac ac

             6   c       c       c           c           c           c          c       c
6 return c


                                                                 Dataflow Analysis 12
Liveness analysis
example

1a ← 0                       1       2           3           4           5          6       7

                 u d     i o     i o         i o         i o         i o        i o     i o
2b ← a + 1
             1       a                   a           a       ac c ac c ac c ac

3c ← c + b   2   a b     a       a bc ac bc ac bc ac bc ac bc ac bc

             3 bc c bc           bc b bc b bc b bc b bc bc bc bc
4a ← 2 * b
             4   b a     b       b a         b a         b ac bc ac bc ac bc ac
5 if a < N   5   a       a a     a ac ac ac ac ac ac ac ac ac ac ac

             6   c       c       c           c           c           c          c       c
6 return c


                                                                 Dataflow Analysis 12
Liveness analysis
example

1a ← 0                       1       2           3           4           5          6       7

                 u d     i o     i o         i o         i o         i o        i o     i o
2b ← a + 1
             1       a                   a           a       ac c ac c ac c ac

3c ← c + b   2   a b     a       a bc ac bc ac bc ac bc ac bc ac bc

             3 bc c bc           bc b bc b bc b bc b bc bc bc bc
4a ← 2 * b
             4   b a     b       b a         b a         b ac bc ac bc ac bc ac
5 if a < N   5   a       a a     a ac ac ac ac ac ac ac ac ac ac ac

             6   c       c       c           c           c           c          c       c
6 return c


                                                                 Dataflow Analysis 12
Liveness analysis
example

1a ← 0                       1       2           3           4           5          6       7

                 u d     i o     i o         i o         i o         i o        i o     i o
2b ← a + 1
             1       a                   a           a       ac c ac c ac c ac

3c ← c + b   2   a b     a       a bc ac bc ac bc ac bc ac bc ac bc

             3 bc c bc           bc b bc b bc b bc b bc bc bc bc
4a ← 2 * b
             4   b a     b       b a         b a         b ac bc ac bc ac bc ac
5 if a < N   5   a       a a     a ac ac ac ac ac ac ac ac ac ac ac

             6   c       c       c           c           c           c          c       c
6 return c


                                                                 Dataflow Analysis 12
Liveness analysis
example

1a ← 0                       1       2           3           4           5          6       7

                 u d     i o     i o         i o         i o         i o        i o     i o
2b ← a + 1
             1       a                   a           a       ac c ac c ac c ac

3c ← c + b   2   a b     a       a bc ac bc ac bc ac bc ac bc ac bc

             3 bc c bc           bc b bc b bc b bc b bc bc bc bc
4a ← 2 * b
             4   b a     b       b a         b a         b ac bc ac bc ac bc ac
5 if a < N   5   a       a a     a ac ac ac ac ac ac ac ac ac ac ac

             6   c       c       c           c           c           c          c       c
6 return c


                                                                 Dataflow Analysis 12
Liveness analysis
example

1a ← 0                       1       2           3           4           5          6       7

                 u d     i o     i o         i o         i o         i o        i o     i o
2b ← a + 1
             1       a                   a           a       ac c ac c ac c ac

3c ← c + b   2   a b     a       a bc ac bc ac bc ac bc ac bc ac bc

             3 bc c bc           bc b bc b bc b bc b bc bc bc bc
4a ← 2 * b
             4   b a     b       b a         b a         b ac bc ac bc ac bc ac
5 if a < N   5   a       a a     a ac ac ac ac ac ac ac ac ac ac ac

             6   c       c       c           c           c           c          c       c
6 return c


                                                                 Dataflow Analysis 12
Liveness analysis
example

1a ← 0                       1       2           3           4           5          6       7

                 u d     i o     i o         i o         i o         i o        i o     i o
2b ← a + 1
             1       a                   a           a       ac c ac c ac c ac

3c ← c + b   2   a b     a       a bc ac bc ac bc ac bc ac bc ac bc

             3 bc c bc           bc b bc b bc b bc b bc bc bc bc
4a ← 2 * b
             4   b a     b       b a         b a         b ac bc ac bc ac bc ac
5 if a < N   5   a       a a     a ac ac ac ac ac ac ac ac ac ac ac

             6   c       c       c           c           c           c          c       c
6 return c


                                                                 Dataflow Analysis 12
Liveness analysis
optimisation

1a ← 0                           1            2              3

                    u   d   o        i   o        i      o       i
2b ← a + 1
               6    c                c            c              c

3c ← c + b     5    a       c        ac ac ac ac ac

               4    b   a   ac bc ac bc ac bc
4a ← 2 * b
               3   bc   c   bc bc bc bc bc bc
5 if a < N     2    a   b   bc ac bc ac bc ac

               1        a   ac       a   ac       c     ac       c
6 return c


                                                      Dataflow Analysis 13
Liveness analysis
optimisation

1a ← 0                           1            2              3

                    u   d   o        i   o        i      o       i
2b ← a + 1
               6    c                c            c              c

3c ← c + b     5    a       c        ac ac ac ac ac

               4    b   a   ac bc ac bc ac bc
4a ← 2 * b
               3   bc   c   bc bc bc bc bc bc
5 if a < N     2    a   b   bc ac bc ac bc ac

               1        a   ac       a   ac       c     ac       c
6 return c


                                                      Dataflow Analysis 13
Liveness analysis
optimisation

1a ← 0                           1            2              3

                    u   d   o        i   o        i      o       i
2b ← a + 1
               6    c                c            c              c

3c ← c + b     5    a       c        ac ac ac ac ac

               4    b   a   ac bc ac bc ac bc
4a ← 2 * b
               3   bc   c   bc bc bc bc bc bc
5 if a < N     2    a   b   bc ac bc ac bc ac

               1        a   ac       a   ac       c     ac       c
6 return c


                                                      Dataflow Analysis 13
Liveness analysis
optimisation

1a ← 0                           1            2              3

                    u   d   o        i   o        i      o       i
2b ← a + 1
               6    c                c            c              c

3c ← c + b     5    a       c        ac ac ac ac ac

               4    b   a   ac bc ac bc ac bc
4a ← 2 * b
               3   bc   c   bc bc bc bc bc bc
5 if a < N     2    a   b   bc ac bc ac bc ac

               1        a   ac       a   ac       c     ac       c
6 return c


                                                      Dataflow Analysis 13
Liveness analysis
optimisation

1a ← 0                           1            2              3

                    u   d   o        i   o        i      o       i
2b ← a + 1
               6    c                c            c              c

3c ← c + b     5    a       c        ac ac ac ac ac

               4    b   a   ac bc ac bc ac bc
4a ← 2 * b
               3   bc   c   bc bc bc bc bc bc
5 if a < N     2    a   b   bc ac bc ac bc ac

               1        a   ac       a   ac       c     ac       c
6 return c


                                                      Dataflow Analysis 13
Liveness analysis
generalisation

                 a ← 0


                 b ← a + 1


                 c ← c + b


                 a ← 2 * b


                 if a < N


                 return c


                             Dataflow Analysis 14
Liveness analysis
generalisation

kill             a ← 0


                 b ← a + 1


                 c ← c + b


                 a ← 2 * b


                 if a < N


                 return c


                             Dataflow Analysis 14
Liveness analysis
generalisation

kill             a ← 0


gen              b ← a + 1


                 c ← c + b


                 a ← 2 * b


                 if a < N


                 return c


                             Dataflow Analysis 14
Liveness analysis
generalisation

kill             a ← 0


gen              b ← a + 1


                 c ← c + b


kill             a ← 2 * b


                 if a < N


                 return c


                             Dataflow Analysis 14
Liveness analysis
generalisation

kill             a ← 0


gen              b ← a + 1


                 c ← c + b


kill             a ← 2 * b


gen              if a < N


                 return c


                             Dataflow Analysis 14
Liveness analysis
generalisation

kill             a ← 0

                             in
gen              b ← a + 1


                 c ← c + b


kill             a ← 2 * b


gen              if a < N


                 return c


                                  Dataflow Analysis 14
Liveness analysis
generalisation

kill             a ← 0       out

                             in
gen              b ← a + 1


                 c ← c + b


kill             a ← 2 * b


gen              if a < N


                 return c


                                   Dataflow Analysis 14
Liveness analysis
generalisation

kill             a ← 0       out

                             in
gen              b ← a + 1


                 c ← c + b


kill             a ← 2 * b


gen              if a < N
                             out

                 return c


                                   Dataflow Analysis 14
Liveness analysis
generalisation

kill             a ← 0       out

                             in
gen              b ← a + 1


                 c ← c + b


kill             a ← 2 * b

                                         in
gen              if a < N
                             out

                 return c


                                   Dataflow Analysis 14
Liveness analysis
generalisation

kill             a ← 0       out

                             in
gen              b ← a + 1


                 c ← c + b


kill             a ← 2 * b
                             out

                                         in
gen              if a < N
                             out

                 return c


                                   Dataflow Analysis 14
Liveness analysis
gen & kill

                     gen       kill
a ← b ⊕ c           {b,c}      {a}
a ← b                {b}       {a}
a ← M[b]             {b}       {a}
M[a] ← b            {a,b}
f(a1, …, an)       {a1,…,an}
a ← f(a1, …, an)   {a1,…,an}   {a}
goto L
if a ⊗ b            {a,b}



                                      Dataflow Analysis 15
Liveness analysis
gen & kill

                     gen       kill
a ← b ⊕ c           {b,c}      {a}
a ← b                {b}       {a}
a ← M[b]             {b}       {a}
M[a] ← b            {a,b}
f(a1, …, an)       {a1,…,an}
a ← f(a1, …, an)   {a1,…,an}   {a}
goto L
if a ⊗ b            {a,b}



                                      Dataflow Analysis 15
Liveness analysis
generalisation




            in[n] = gen[n]   ∪ (out[n] - kill[n])

                 out[n] =   ∪  s∈succ[n]   in[s]




                                                    Dataflow Analysis 16
coffee break




               Dataflow Analysis 17
III
more analyses




                Dataflow Analysis 18
More analyses
reaching definitions

                       1a ← 5


                       2c ← 1


                       3 if c > a


                       4c ← c + c


                       5 goto 3


                       6a ← c - a


                                    Dataflow Analysis 19
Reaching definitions
gen & kill

                      gen      kill
d: a ← b ⊕ c          {d}   defs(a)-{d}
d: a ← b              {d}   defs(a)-{d}
d: a ← M[b]           {d}   defs(a)-{d}
M[a] ← b
f(a1, …, an)
d: a ← f(a1, …, an)   {d}   defs(a)-{d}
goto L
if a ⊗ b



                                          Dataflow Analysis 20
Reaching definitions
gen & kill

                      gen      kill
d: a ← b ⊕ c          {d}   defs(a)-{d}
d: a ← b              {d}   defs(a)-{d}
d: a ← M[b]           {d}   defs(a)-{d}
M[a] ← b
f(a1, …, an)
d: a ← f(a1, …, an)   {d}   defs(a)-{d}
goto L
if a ⊗ b



                                          Dataflow Analysis 20
Reaching definitions
formalisation




                in[n] =   ∪
                          p∈pred[n]   out[p]

            out[n] = gen[n]   ∪ (in[n] - kill[n])




                                                    Dataflow Analysis 21
More analyses
available expressions

                    1c ← a + b


                    2d ← 1


                    3e ← a + b




                                 Dataflow Analysis 22
Available expressions
gen & kill

                          gen               kill
d: a ← b ⊕ c          {b⊕c}-kill          exps(a)
d: a ← b
d: a ← M[b]           {M[b]}-kill         exps(a)
M[a] ← b                                 exps(M[_])
f(a1, …, an)                             exps(M[_])
d: a ← f(a1, …, an)                 exps(M[_]) ∪ exps(a)
goto L
if a ⊗ b



                                             Dataflow Analysis 23
Available expressions
gen & kill

                          gen               kill
d: a ← b ⊕ c          {b⊕c}-kill          exps(a)
d: a ← b
d: a ← M[b]           {M[b]}-kill         exps(a)
M[a] ← b                                 exps(M[_])
f(a1, …, an)                             exps(M[_])
d: a ← f(a1, …, an)                 exps(M[_]) ∪ exps(a)
goto L
if a ⊗ b



                                             Dataflow Analysis 23
Available expressions
formalisation




                in[n] =   ∩
                          p∈pred[n]   out[p]

            out[n] = gen[n]   ∪ (in[n] - kill[n])




                                                    Dataflow Analysis 24
IV
optimisations




                Term Rewriting 25
Dead code elimination
example

a ← 0              a ← 0
b ← a + 1          b ← a + 1
c ← c + b          c ← c + b
a ← 2 * b          return c
return c




                               Dataflow Analysis 26
Constant propagation
example

a ← 0             a ← 0
b ← a + 1         b ← 0 + 1
c ← c + b         c ← c + b
a ← 2 * b         a ← 2 * b
return c          return c




                              Dataflow Analysis 27
Copy propagation
example

a ← e              a ← e
b ← a + 1          b ← e + 1
c ← c + b          c ← c + b
a ← 2 * b          a ← 2 * b
return c           return c




                               Dataflow Analysis 28
Common subexpression elimination
example

c ← a + b         x ← a + b
d ← 1             c ← x
e ← a + b         d ← 1
                  e ← x




                              Dataflow Analysis 29
V
summary




          Term Rewriting 30
Summary
lessons learned

liveness analysis

  •   intermediate language
  •   control-flow graphs
  •   definition & algorithm

more dataflow analyses

  •   reaching definitions
  •   available expressions

optimisations



                               Dataflow Analysis 31
Literature
learn more

Andrew W. Appel, Jens Palsberg: Modern Compiler
Implementation in Java, 2nd edition. 2002




                                                  Dataflow Analysis 32
copyrights & credits




                       Dataflow Analysis 33
Dataflow Analysis 34
Pictures
copyrights

Slide 1:
   ink swirl by Graham Richardson, some rights reserved

Slide 25:
   Seattle's Best Coffee by Dominica Williamson, some rights reserved

Slide 32:
   Animal Ark Reno by Joel Riley, some rights reserved




                                                                        Dataflow Analysis 35

More Related Content

What's hot

Multilayer Neural Networks
Multilayer Neural NetworksMultilayer Neural Networks
Multilayer Neural NetworksESCOM
 
RedisConf18 - Lower Latency Graph Queries in Cypher with Redis Graph
RedisConf18 - Lower Latency Graph Queries in Cypher with Redis GraphRedisConf18 - Lower Latency Graph Queries in Cypher with Redis Graph
RedisConf18 - Lower Latency Graph Queries in Cypher with Redis GraphRedis Labs
 
Query Rewriting and Optimization for Ontological Databases
Query Rewriting and Optimization for Ontological DatabasesQuery Rewriting and Optimization for Ontological Databases
Query Rewriting and Optimization for Ontological DatabasesGiorgio Orsi
 
Story of static code analyzer development
Story of static code analyzer developmentStory of static code analyzer development
Story of static code analyzer developmentAndrey Karpov
 
bayesImageS: Bayesian computation for medical Image Segmentation using a hidd...
bayesImageS: Bayesian computation for medical Image Segmentation using a hidd...bayesImageS: Bayesian computation for medical Image Segmentation using a hidd...
bayesImageS: Bayesian computation for medical Image Segmentation using a hidd...Matt Moores
 
R package 'bayesImageS': a case study in Bayesian computation using Rcpp and ...
R package 'bayesImageS': a case study in Bayesian computation using Rcpp and ...R package 'bayesImageS': a case study in Bayesian computation using Rcpp and ...
R package 'bayesImageS': a case study in Bayesian computation using Rcpp and ...Matt Moores
 
Data Stream Outlier Detection Algorithm
Data Stream Outlier Detection Algorithm Data Stream Outlier Detection Algorithm
Data Stream Outlier Detection Algorithm Hamza Aslam
 
On Resolution Proofs for Combinational Equivalence
On Resolution Proofs for Combinational EquivalenceOn Resolution Proofs for Combinational Equivalence
On Resolution Proofs for Combinational Equivalencesatrajit
 
Kernel for Chordal Vertex Deletion
Kernel for Chordal Vertex DeletionKernel for Chordal Vertex Deletion
Kernel for Chordal Vertex DeletionAkankshaAgrawal55
 
Bayesian Inference and Uncertainty Quantification for Inverse Problems
Bayesian Inference and Uncertainty Quantification for Inverse ProblemsBayesian Inference and Uncertainty Quantification for Inverse Problems
Bayesian Inference and Uncertainty Quantification for Inverse ProblemsMatt Moores
 
Querying Temporal Databases via OWL 2 QL
Querying Temporal Databases via OWL 2 QLQuerying Temporal Databases via OWL 2 QL
Querying Temporal Databases via OWL 2 QLSzymon Klarman
 
Module 13 Gradient And Area Under A Graph
Module 13  Gradient And Area Under A GraphModule 13  Gradient And Area Under A Graph
Module 13 Gradient And Area Under A Graphguestcc333c
 
Reducing Structural Bias in Technology Mapping
Reducing Structural Bias in Technology MappingReducing Structural Bias in Technology Mapping
Reducing Structural Bias in Technology Mappingsatrajit
 
icml2004 tutorial on spectral clustering part I
icml2004 tutorial on spectral clustering part Iicml2004 tutorial on spectral clustering part I
icml2004 tutorial on spectral clustering part Izukun
 
icml2004 tutorial on spectral clustering part II
icml2004 tutorial on spectral clustering part IIicml2004 tutorial on spectral clustering part II
icml2004 tutorial on spectral clustering part IIzukun
 
Deep Convolutional GANs - meaning of latent space
Deep Convolutional GANs - meaning of latent spaceDeep Convolutional GANs - meaning of latent space
Deep Convolutional GANs - meaning of latent spaceHansol Kang
 
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...ijceronline
 

What's hot (20)

Multilayer Neural Networks
Multilayer Neural NetworksMultilayer Neural Networks
Multilayer Neural Networks
 
RedisConf18 - Lower Latency Graph Queries in Cypher with Redis Graph
RedisConf18 - Lower Latency Graph Queries in Cypher with Redis GraphRedisConf18 - Lower Latency Graph Queries in Cypher with Redis Graph
RedisConf18 - Lower Latency Graph Queries in Cypher with Redis Graph
 
Query Rewriting and Optimization for Ontological Databases
Query Rewriting and Optimization for Ontological DatabasesQuery Rewriting and Optimization for Ontological Databases
Query Rewriting and Optimization for Ontological Databases
 
Story of static code analyzer development
Story of static code analyzer developmentStory of static code analyzer development
Story of static code analyzer development
 
bayesImageS: Bayesian computation for medical Image Segmentation using a hidd...
bayesImageS: Bayesian computation for medical Image Segmentation using a hidd...bayesImageS: Bayesian computation for medical Image Segmentation using a hidd...
bayesImageS: Bayesian computation for medical Image Segmentation using a hidd...
 
R package 'bayesImageS': a case study in Bayesian computation using Rcpp and ...
R package 'bayesImageS': a case study in Bayesian computation using Rcpp and ...R package 'bayesImageS': a case study in Bayesian computation using Rcpp and ...
R package 'bayesImageS': a case study in Bayesian computation using Rcpp and ...
 
Ef24836841
Ef24836841Ef24836841
Ef24836841
 
Data Stream Outlier Detection Algorithm
Data Stream Outlier Detection Algorithm Data Stream Outlier Detection Algorithm
Data Stream Outlier Detection Algorithm
 
On Resolution Proofs for Combinational Equivalence
On Resolution Proofs for Combinational EquivalenceOn Resolution Proofs for Combinational Equivalence
On Resolution Proofs for Combinational Equivalence
 
Kernel for Chordal Vertex Deletion
Kernel for Chordal Vertex DeletionKernel for Chordal Vertex Deletion
Kernel for Chordal Vertex Deletion
 
Bayesian Inference and Uncertainty Quantification for Inverse Problems
Bayesian Inference and Uncertainty Quantification for Inverse ProblemsBayesian Inference and Uncertainty Quantification for Inverse Problems
Bayesian Inference and Uncertainty Quantification for Inverse Problems
 
Querying Temporal Databases via OWL 2 QL
Querying Temporal Databases via OWL 2 QLQuerying Temporal Databases via OWL 2 QL
Querying Temporal Databases via OWL 2 QL
 
Vectorization in ATLAS
Vectorization in ATLASVectorization in ATLAS
Vectorization in ATLAS
 
Module 13 Gradient And Area Under A Graph
Module 13  Gradient And Area Under A GraphModule 13  Gradient And Area Under A Graph
Module 13 Gradient And Area Under A Graph
 
Reducing Structural Bias in Technology Mapping
Reducing Structural Bias in Technology MappingReducing Structural Bias in Technology Mapping
Reducing Structural Bias in Technology Mapping
 
icml2004 tutorial on spectral clustering part I
icml2004 tutorial on spectral clustering part Iicml2004 tutorial on spectral clustering part I
icml2004 tutorial on spectral clustering part I
 
icml2004 tutorial on spectral clustering part II
icml2004 tutorial on spectral clustering part IIicml2004 tutorial on spectral clustering part II
icml2004 tutorial on spectral clustering part II
 
Deep Convolutional GANs - meaning of latent space
Deep Convolutional GANs - meaning of latent spaceDeep Convolutional GANs - meaning of latent space
Deep Convolutional GANs - meaning of latent space
 
By32474479
By32474479By32474479
By32474479
 
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
 

More from Guido Wachsmuth

Domain-Specific Type Systems
Domain-Specific Type SystemsDomain-Specific Type Systems
Domain-Specific Type SystemsGuido Wachsmuth
 
Declarative Syntax Definition - Pretty Printing
Declarative Syntax Definition - Pretty PrintingDeclarative Syntax Definition - Pretty Printing
Declarative Syntax Definition - Pretty PrintingGuido Wachsmuth
 
Compiler Components and their Generators - LR Parsing
Compiler Components and their Generators - LR ParsingCompiler Components and their Generators - LR Parsing
Compiler Components and their Generators - LR ParsingGuido Wachsmuth
 
Compiling Imperative and Object-Oriented Languages - Garbage Collection
Compiling Imperative and Object-Oriented Languages - Garbage CollectionCompiling Imperative and Object-Oriented Languages - Garbage Collection
Compiling Imperative and Object-Oriented Languages - Garbage CollectionGuido Wachsmuth
 
Compiler Components and their Generators - Lexical Analysis
Compiler Components and their Generators - Lexical AnalysisCompiler Components and their Generators - Lexical Analysis
Compiler Components and their Generators - Lexical AnalysisGuido Wachsmuth
 
Compiler Components and their Generators - Traditional Parsing Algorithms
Compiler Components and their Generators - Traditional Parsing AlgorithmsCompiler Components and their Generators - Traditional Parsing Algorithms
Compiler Components and their Generators - Traditional Parsing AlgorithmsGuido Wachsmuth
 
Pure and Declarative Syntax Definition: Paradise Lost and Regained
Pure and Declarative Syntax Definition: Paradise Lost and RegainedPure and Declarative Syntax Definition: Paradise Lost and Regained
Pure and Declarative Syntax Definition: Paradise Lost and RegainedGuido Wachsmuth
 
Introduction - Imperative and Object-Oriented Languages
Introduction - Imperative and Object-Oriented LanguagesIntroduction - Imperative and Object-Oriented Languages
Introduction - Imperative and Object-Oriented LanguagesGuido Wachsmuth
 
Compiling Imperative and Object-Oriented Languages - Activation Records
Compiling Imperative and Object-Oriented Languages - Activation RecordsCompiling Imperative and Object-Oriented Languages - Activation Records
Compiling Imperative and Object-Oriented Languages - Activation RecordsGuido Wachsmuth
 
Declarative Semantics Definition - Code Generation
Declarative Semantics Definition - Code Generation Declarative Semantics Definition - Code Generation
Declarative Semantics Definition - Code Generation Guido Wachsmuth
 
Declarative Semantics Definition - Static Analysis and Error Checking
Declarative Semantics Definition - Static Analysis and Error CheckingDeclarative Semantics Definition - Static Analysis and Error Checking
Declarative Semantics Definition - Static Analysis and Error CheckingGuido Wachsmuth
 
Declarative Semantics Definition - Term Rewriting
Declarative Semantics Definition - Term RewritingDeclarative Semantics Definition - Term Rewriting
Declarative Semantics Definition - Term RewritingGuido Wachsmuth
 
Declarative Syntax Definition - Grammars and Trees
Declarative Syntax Definition - Grammars and TreesDeclarative Syntax Definition - Grammars and Trees
Declarative Syntax Definition - Grammars and TreesGuido Wachsmuth
 

More from Guido Wachsmuth (16)

Language
LanguageLanguage
Language
 
Domain-Specific Type Systems
Domain-Specific Type SystemsDomain-Specific Type Systems
Domain-Specific Type Systems
 
Declarative Syntax Definition - Pretty Printing
Declarative Syntax Definition - Pretty PrintingDeclarative Syntax Definition - Pretty Printing
Declarative Syntax Definition - Pretty Printing
 
Compiler Components and their Generators - LR Parsing
Compiler Components and their Generators - LR ParsingCompiler Components and their Generators - LR Parsing
Compiler Components and their Generators - LR Parsing
 
Compiling Imperative and Object-Oriented Languages - Garbage Collection
Compiling Imperative and Object-Oriented Languages - Garbage CollectionCompiling Imperative and Object-Oriented Languages - Garbage Collection
Compiling Imperative and Object-Oriented Languages - Garbage Collection
 
Compiler Components and their Generators - Lexical Analysis
Compiler Components and their Generators - Lexical AnalysisCompiler Components and their Generators - Lexical Analysis
Compiler Components and their Generators - Lexical Analysis
 
Compiler Components and their Generators - Traditional Parsing Algorithms
Compiler Components and their Generators - Traditional Parsing AlgorithmsCompiler Components and their Generators - Traditional Parsing Algorithms
Compiler Components and their Generators - Traditional Parsing Algorithms
 
Pure and Declarative Syntax Definition: Paradise Lost and Regained
Pure and Declarative Syntax Definition: Paradise Lost and RegainedPure and Declarative Syntax Definition: Paradise Lost and Regained
Pure and Declarative Syntax Definition: Paradise Lost and Regained
 
Introduction - Imperative and Object-Oriented Languages
Introduction - Imperative and Object-Oriented LanguagesIntroduction - Imperative and Object-Oriented Languages
Introduction - Imperative and Object-Oriented Languages
 
Compiling Imperative and Object-Oriented Languages - Activation Records
Compiling Imperative and Object-Oriented Languages - Activation RecordsCompiling Imperative and Object-Oriented Languages - Activation Records
Compiling Imperative and Object-Oriented Languages - Activation Records
 
Declarative Semantics Definition - Code Generation
Declarative Semantics Definition - Code Generation Declarative Semantics Definition - Code Generation
Declarative Semantics Definition - Code Generation
 
Declarative Semantics Definition - Static Analysis and Error Checking
Declarative Semantics Definition - Static Analysis and Error CheckingDeclarative Semantics Definition - Static Analysis and Error Checking
Declarative Semantics Definition - Static Analysis and Error Checking
 
Declarative Semantics Definition - Term Rewriting
Declarative Semantics Definition - Term RewritingDeclarative Semantics Definition - Term Rewriting
Declarative Semantics Definition - Term Rewriting
 
Syntax Definition
Syntax DefinitionSyntax Definition
Syntax Definition
 
Declarative Syntax Definition - Grammars and Trees
Declarative Syntax Definition - Grammars and TreesDeclarative Syntax Definition - Grammars and Trees
Declarative Syntax Definition - Grammars and Trees
 
Software Languages
Software LanguagesSoftware Languages
Software Languages
 

Recently uploaded

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 

Recently uploaded (20)

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 

Compiling Imperative and Object-Oriented Languages - Dataflow Analysis

  • 1. Dataflow Analysis Guido Wachsmuth Delft Course IN4303, 2012/13 University of Technology Compiler Construction Challenge the future
  • 2. Overview today’s lecture control flow graphs Dataflow Analysis 2
  • 3. Overview today’s lecture control flow graphs data flow analyses • liveness analysis • reaching definitions • available expressions Dataflow Analysis 2
  • 4. Overview today’s lecture control flow graphs data flow analyses • liveness analysis • reaching definitions • available expressions non-local optimisations • dead code elimination • constant & copy propagation • common subexpression elimination Dataflow Analysis 2
  • 5. I control-flow graphs Dataflow Analysis 3
  • 6. Intermediate language quadruples store jumps a ← b ⊕ c L: a ← b goto L if a ⊗ b memory access goto L1 a ← M[b] else M[a] ← b goto L2 functions f(a1, …, an) b ← f(a1, …, an) Dataflow Analysis 4
  • 7. Control-flow graphs example a ← 0 L1: b ← a + 1 c ← c + b a ← 2 * b if a < N goto L1 else goto L2 L2: return c Dataflow Analysis 5
  • 8. Control-flow graphs example a ← 0 a ← 0 L1: b ← a + 1 b ← a + 1 c ← c + b a ← 2 * b c ← c + b if a < N goto L1 a ← 2 * b else if a < N goto L2 L2: return c return c Dataflow Analysis 5
  • 9. Control-flow graphs terminology a ← 0 b ← a + 1 c ← c + b a ← 2 * b if a < N return c Dataflow Analysis 6
  • 10. Control-flow graphs terminology a ← 0 node b ← a + 1 c ← c + b a ← 2 * b if a < N return c Dataflow Analysis 6
  • 11. Control-flow graphs terminology a ← 0 in-edge node b ← a + 1 c ← c + b a ← 2 * b if a < N return c Dataflow Analysis 6
  • 12. Control-flow graphs terminology a ← 0 in-edge node b ← a + 1 c ← c + b in-edge a ← 2 * b if a < N return c Dataflow Analysis 6
  • 13. Control-flow graphs terminology predecessor a ← 0 in-edge node b ← a + 1 c ← c + b in-edge a ← 2 * b predecessor if a < N return c Dataflow Analysis 6
  • 14. Control-flow graphs terminology predecessor a ← 0 in-edge node b ← a + 1 out-edge c ← c + b in-edge a ← 2 * b predecessor if a < N return c Dataflow Analysis 6
  • 15. Control-flow graphs terminology predecessor a ← 0 in-edge node b ← a + 1 out-edge successor c ← c + b in-edge a ← 2 * b predecessor if a < N return c Dataflow Analysis 6
  • 16. II liveness analysis Dataflow Analysis 7
  • 17. Liveness analysis terminology a ← 0 b ← a + 1 c ← c + b a ← 2 * b if a < N return c Dataflow Analysis 8
  • 18. Liveness analysis terminology definition a ← 0 b ← a + 1 c ← c + b a ← 2 * b if a < N return c Dataflow Analysis 8
  • 19. Liveness analysis terminology definition a ← 0 usage b ← a + 1 c ← c + b a ← 2 * b if a < N return c Dataflow Analysis 8
  • 20. Liveness analysis terminology definition a ← 0 usage b ← a + 1 c ← c + b definition a ← 2 * b if a < N return c Dataflow Analysis 8
  • 21. Liveness analysis terminology definition a ← 0 usage b ← a + 1 c ← c + b definition a ← 2 * b usage if a < N return c Dataflow Analysis 8
  • 22. Liveness analysis terminology definition a ← 0 usage b ← a + 1 c ← c + b definition a ← 2 * b live-in usage if a < N return c Dataflow Analysis 8
  • 23. Liveness analysis terminology definition a ← 0 usage b ← a + 1 c ← c + b definition a ← 2 * b live-out live-in usage if a < N return c Dataflow Analysis 8
  • 24. Liveness analysis terminology definition a ← 0 live-in usage b ← a + 1 c ← c + b definition a ← 2 * b live-out live-in usage if a < N return c Dataflow Analysis 8
  • 25. Liveness analysis terminology definition a ← 0 live-in usage b ← a + 1 c ← c + b definition a ← 2 * b live-out live-in usage if a < N live-out return c Dataflow Analysis 8
  • 26. Liveness analysis terminology definition a ← 0 live-out live-in usage b ← a + 1 c ← c + b definition a ← 2 * b live-out live-in usage if a < N live-out return c Dataflow Analysis 8
  • 27. Liveness analysis example a ← 0 b ← a + 1 c ← c + b a ← 2 * b if a < N return c Dataflow Analysis 9
  • 28. Liveness analysis example a ← 0 b ← a + 1 c ← c + b a ← 2 * b if a < N return c Dataflow Analysis 9
  • 29. Liveness analysis example a ← 0 b ← a + 1 c ← c + b a ← 2 * b if a < N return c Dataflow Analysis 9
  • 30. Liveness analysis example a ← 0 b ← a + 1 c ← c + b a ← 2 * b if a < N return c Dataflow Analysis 9
  • 31. Liveness analysis example a ← 0 b ← a + 1 c ← c + b a ← 2 * b if a < N return c Dataflow Analysis 9
  • 32. Liveness analysis example a ← 0 b ← a + 1 c ← c + b a ← 2 * b if a < N return c Dataflow Analysis 9
  • 33. Liveness analysis example a ← 0 b ← a + 1 c ← c + b a ← 2 * b if a < N return c Dataflow Analysis 9
  • 34. Liveness analysis example a ← 0 b ← a + 1 c ← c + b a ← 2 * b if a < N return c Dataflow Analysis 9
  • 35. Liveness analysis example a ← 0 b ← a + 1 c ← c + b a ← 2 * b if a < N return c Dataflow Analysis 9
  • 36. Liveness analysis example a ← 0 b ← a + 1 c ← c + b a ← 2 * b if a < N return c Dataflow Analysis 9
  • 37. Liveness analysis example a ← 0 b ← a + 1 c ← c + b a ← 2 * b if a < N return c Dataflow Analysis 9
  • 38. Liveness analysis formalisation in[n] = use[n] ∪ (out[n] - def[n]) out[n] = ∪ s∈succ[n] in[s] 1. If a variable is used at node n, then it is live-in at n. 2. If a variable is live-out but not defined at node n, it is live-in at n. 3. If a variable is live-in at node n, then it is live-out at its predecessors. Dataflow Analysis 10
  • 39. Liveness analysis algorithm for each n in[n] ← {} ; out[n] ← {} repeat for each n in'[n] = in[n] ; out'[n] = out[n] in[n] = use[n] ∪ (out[n] - def[n]) for each s in succ[n] out[n] = out[n] ∪ in[s] until for all n: in[n] = in'[n] and out[n] = out'[n] Dataflow Analysis 11
  • 40. Liveness analysis example 1a ← 0 1 2 3 4 5 6 7 u d i o i o i o i o i o i o i o 2b ← a + 1 1 a a a ac c ac c ac c ac 3c ← c + b 2 a b a a bc ac bc ac bc ac bc ac bc ac bc 3 bc c bc bc b bc b bc b bc b bc bc bc bc 4a ← 2 * b 4 b a b b a b a b ac bc ac bc ac bc ac 5 if a < N 5 a a a a ac ac ac ac ac ac ac ac ac ac ac 6 c c c c c c c c 6 return c Dataflow Analysis 12
  • 41. Liveness analysis example 1a ← 0 1 2 3 4 5 6 7 u d i o i o i o i o i o i o i o 2b ← a + 1 1 a a a ac c ac c ac c ac 3c ← c + b 2 a b a a bc ac bc ac bc ac bc ac bc ac bc 3 bc c bc bc b bc b bc b bc b bc bc bc bc 4a ← 2 * b 4 b a b b a b a b ac bc ac bc ac bc ac 5 if a < N 5 a a a a ac ac ac ac ac ac ac ac ac ac ac 6 c c c c c c c c 6 return c Dataflow Analysis 12
  • 42. Liveness analysis example 1a ← 0 1 2 3 4 5 6 7 u d i o i o i o i o i o i o i o 2b ← a + 1 1 a a a ac c ac c ac c ac 3c ← c + b 2 a b a a bc ac bc ac bc ac bc ac bc ac bc 3 bc c bc bc b bc b bc b bc b bc bc bc bc 4a ← 2 * b 4 b a b b a b a b ac bc ac bc ac bc ac 5 if a < N 5 a a a a ac ac ac ac ac ac ac ac ac ac ac 6 c c c c c c c c 6 return c Dataflow Analysis 12
  • 43. Liveness analysis example 1a ← 0 1 2 3 4 5 6 7 u d i o i o i o i o i o i o i o 2b ← a + 1 1 a a a ac c ac c ac c ac 3c ← c + b 2 a b a a bc ac bc ac bc ac bc ac bc ac bc 3 bc c bc bc b bc b bc b bc b bc bc bc bc 4a ← 2 * b 4 b a b b a b a b ac bc ac bc ac bc ac 5 if a < N 5 a a a a ac ac ac ac ac ac ac ac ac ac ac 6 c c c c c c c c 6 return c Dataflow Analysis 12
  • 44. Liveness analysis example 1a ← 0 1 2 3 4 5 6 7 u d i o i o i o i o i o i o i o 2b ← a + 1 1 a a a ac c ac c ac c ac 3c ← c + b 2 a b a a bc ac bc ac bc ac bc ac bc ac bc 3 bc c bc bc b bc b bc b bc b bc bc bc bc 4a ← 2 * b 4 b a b b a b a b ac bc ac bc ac bc ac 5 if a < N 5 a a a a ac ac ac ac ac ac ac ac ac ac ac 6 c c c c c c c c 6 return c Dataflow Analysis 12
  • 45. Liveness analysis example 1a ← 0 1 2 3 4 5 6 7 u d i o i o i o i o i o i o i o 2b ← a + 1 1 a a a ac c ac c ac c ac 3c ← c + b 2 a b a a bc ac bc ac bc ac bc ac bc ac bc 3 bc c bc bc b bc b bc b bc b bc bc bc bc 4a ← 2 * b 4 b a b b a b a b ac bc ac bc ac bc ac 5 if a < N 5 a a a a ac ac ac ac ac ac ac ac ac ac ac 6 c c c c c c c c 6 return c Dataflow Analysis 12
  • 46. Liveness analysis example 1a ← 0 1 2 3 4 5 6 7 u d i o i o i o i o i o i o i o 2b ← a + 1 1 a a a ac c ac c ac c ac 3c ← c + b 2 a b a a bc ac bc ac bc ac bc ac bc ac bc 3 bc c bc bc b bc b bc b bc b bc bc bc bc 4a ← 2 * b 4 b a b b a b a b ac bc ac bc ac bc ac 5 if a < N 5 a a a a ac ac ac ac ac ac ac ac ac ac ac 6 c c c c c c c c 6 return c Dataflow Analysis 12
  • 47. Liveness analysis example 1a ← 0 1 2 3 4 5 6 7 u d i o i o i o i o i o i o i o 2b ← a + 1 1 a a a ac c ac c ac c ac 3c ← c + b 2 a b a a bc ac bc ac bc ac bc ac bc ac bc 3 bc c bc bc b bc b bc b bc b bc bc bc bc 4a ← 2 * b 4 b a b b a b a b ac bc ac bc ac bc ac 5 if a < N 5 a a a a ac ac ac ac ac ac ac ac ac ac ac 6 c c c c c c c c 6 return c Dataflow Analysis 12
  • 48. Liveness analysis example 1a ← 0 1 2 3 4 5 6 7 u d i o i o i o i o i o i o i o 2b ← a + 1 1 a a a ac c ac c ac c ac 3c ← c + b 2 a b a a bc ac bc ac bc ac bc ac bc ac bc 3 bc c bc bc b bc b bc b bc b bc bc bc bc 4a ← 2 * b 4 b a b b a b a b ac bc ac bc ac bc ac 5 if a < N 5 a a a a ac ac ac ac ac ac ac ac ac ac ac 6 c c c c c c c c 6 return c Dataflow Analysis 12
  • 49. Liveness analysis optimisation 1a ← 0 1 2 3 u d o i o i o i 2b ← a + 1 6 c c c c 3c ← c + b 5 a c ac ac ac ac ac 4 b a ac bc ac bc ac bc 4a ← 2 * b 3 bc c bc bc bc bc bc bc 5 if a < N 2 a b bc ac bc ac bc ac 1 a ac a ac c ac c 6 return c Dataflow Analysis 13
  • 50. Liveness analysis optimisation 1a ← 0 1 2 3 u d o i o i o i 2b ← a + 1 6 c c c c 3c ← c + b 5 a c ac ac ac ac ac 4 b a ac bc ac bc ac bc 4a ← 2 * b 3 bc c bc bc bc bc bc bc 5 if a < N 2 a b bc ac bc ac bc ac 1 a ac a ac c ac c 6 return c Dataflow Analysis 13
  • 51. Liveness analysis optimisation 1a ← 0 1 2 3 u d o i o i o i 2b ← a + 1 6 c c c c 3c ← c + b 5 a c ac ac ac ac ac 4 b a ac bc ac bc ac bc 4a ← 2 * b 3 bc c bc bc bc bc bc bc 5 if a < N 2 a b bc ac bc ac bc ac 1 a ac a ac c ac c 6 return c Dataflow Analysis 13
  • 52. Liveness analysis optimisation 1a ← 0 1 2 3 u d o i o i o i 2b ← a + 1 6 c c c c 3c ← c + b 5 a c ac ac ac ac ac 4 b a ac bc ac bc ac bc 4a ← 2 * b 3 bc c bc bc bc bc bc bc 5 if a < N 2 a b bc ac bc ac bc ac 1 a ac a ac c ac c 6 return c Dataflow Analysis 13
  • 53. Liveness analysis optimisation 1a ← 0 1 2 3 u d o i o i o i 2b ← a + 1 6 c c c c 3c ← c + b 5 a c ac ac ac ac ac 4 b a ac bc ac bc ac bc 4a ← 2 * b 3 bc c bc bc bc bc bc bc 5 if a < N 2 a b bc ac bc ac bc ac 1 a ac a ac c ac c 6 return c Dataflow Analysis 13
  • 54. Liveness analysis generalisation a ← 0 b ← a + 1 c ← c + b a ← 2 * b if a < N return c Dataflow Analysis 14
  • 55. Liveness analysis generalisation kill a ← 0 b ← a + 1 c ← c + b a ← 2 * b if a < N return c Dataflow Analysis 14
  • 56. Liveness analysis generalisation kill a ← 0 gen b ← a + 1 c ← c + b a ← 2 * b if a < N return c Dataflow Analysis 14
  • 57. Liveness analysis generalisation kill a ← 0 gen b ← a + 1 c ← c + b kill a ← 2 * b if a < N return c Dataflow Analysis 14
  • 58. Liveness analysis generalisation kill a ← 0 gen b ← a + 1 c ← c + b kill a ← 2 * b gen if a < N return c Dataflow Analysis 14
  • 59. Liveness analysis generalisation kill a ← 0 in gen b ← a + 1 c ← c + b kill a ← 2 * b gen if a < N return c Dataflow Analysis 14
  • 60. Liveness analysis generalisation kill a ← 0 out in gen b ← a + 1 c ← c + b kill a ← 2 * b gen if a < N return c Dataflow Analysis 14
  • 61. Liveness analysis generalisation kill a ← 0 out in gen b ← a + 1 c ← c + b kill a ← 2 * b gen if a < N out return c Dataflow Analysis 14
  • 62. Liveness analysis generalisation kill a ← 0 out in gen b ← a + 1 c ← c + b kill a ← 2 * b in gen if a < N out return c Dataflow Analysis 14
  • 63. Liveness analysis generalisation kill a ← 0 out in gen b ← a + 1 c ← c + b kill a ← 2 * b out in gen if a < N out return c Dataflow Analysis 14
  • 64. Liveness analysis gen & kill gen kill a ← b ⊕ c {b,c} {a} a ← b {b} {a} a ← M[b] {b} {a} M[a] ← b {a,b} f(a1, …, an) {a1,…,an} a ← f(a1, …, an) {a1,…,an} {a} goto L if a ⊗ b {a,b} Dataflow Analysis 15
  • 65. Liveness analysis gen & kill gen kill a ← b ⊕ c {b,c} {a} a ← b {b} {a} a ← M[b] {b} {a} M[a] ← b {a,b} f(a1, …, an) {a1,…,an} a ← f(a1, …, an) {a1,…,an} {a} goto L if a ⊗ b {a,b} Dataflow Analysis 15
  • 66. Liveness analysis generalisation in[n] = gen[n] ∪ (out[n] - kill[n]) out[n] = ∪ s∈succ[n] in[s] Dataflow Analysis 16
  • 67. coffee break Dataflow Analysis 17
  • 68. III more analyses Dataflow Analysis 18
  • 69. More analyses reaching definitions 1a ← 5 2c ← 1 3 if c > a 4c ← c + c 5 goto 3 6a ← c - a Dataflow Analysis 19
  • 70. Reaching definitions gen & kill gen kill d: a ← b ⊕ c {d} defs(a)-{d} d: a ← b {d} defs(a)-{d} d: a ← M[b] {d} defs(a)-{d} M[a] ← b f(a1, …, an) d: a ← f(a1, …, an) {d} defs(a)-{d} goto L if a ⊗ b Dataflow Analysis 20
  • 71. Reaching definitions gen & kill gen kill d: a ← b ⊕ c {d} defs(a)-{d} d: a ← b {d} defs(a)-{d} d: a ← M[b] {d} defs(a)-{d} M[a] ← b f(a1, …, an) d: a ← f(a1, …, an) {d} defs(a)-{d} goto L if a ⊗ b Dataflow Analysis 20
  • 72. Reaching definitions formalisation in[n] = ∪ p∈pred[n] out[p] out[n] = gen[n] ∪ (in[n] - kill[n]) Dataflow Analysis 21
  • 73. More analyses available expressions 1c ← a + b 2d ← 1 3e ← a + b Dataflow Analysis 22
  • 74. Available expressions gen & kill gen kill d: a ← b ⊕ c {b⊕c}-kill exps(a) d: a ← b d: a ← M[b] {M[b]}-kill exps(a) M[a] ← b exps(M[_]) f(a1, …, an) exps(M[_]) d: a ← f(a1, …, an) exps(M[_]) ∪ exps(a) goto L if a ⊗ b Dataflow Analysis 23
  • 75. Available expressions gen & kill gen kill d: a ← b ⊕ c {b⊕c}-kill exps(a) d: a ← b d: a ← M[b] {M[b]}-kill exps(a) M[a] ← b exps(M[_]) f(a1, …, an) exps(M[_]) d: a ← f(a1, …, an) exps(M[_]) ∪ exps(a) goto L if a ⊗ b Dataflow Analysis 23
  • 76. Available expressions formalisation in[n] = ∩ p∈pred[n] out[p] out[n] = gen[n] ∪ (in[n] - kill[n]) Dataflow Analysis 24
  • 77. IV optimisations Term Rewriting 25
  • 78. Dead code elimination example a ← 0 a ← 0 b ← a + 1 b ← a + 1 c ← c + b c ← c + b a ← 2 * b return c return c Dataflow Analysis 26
  • 79. Constant propagation example a ← 0 a ← 0 b ← a + 1 b ← 0 + 1 c ← c + b c ← c + b a ← 2 * b a ← 2 * b return c return c Dataflow Analysis 27
  • 80. Copy propagation example a ← e a ← e b ← a + 1 b ← e + 1 c ← c + b c ← c + b a ← 2 * b a ← 2 * b return c return c Dataflow Analysis 28
  • 81. Common subexpression elimination example c ← a + b x ← a + b d ← 1 c ← x e ← a + b d ← 1 e ← x Dataflow Analysis 29
  • 82. V summary Term Rewriting 30
  • 83. Summary lessons learned liveness analysis • intermediate language • control-flow graphs • definition & algorithm more dataflow analyses • reaching definitions • available expressions optimisations Dataflow Analysis 31
  • 84. Literature learn more Andrew W. Appel, Jens Palsberg: Modern Compiler Implementation in Java, 2nd edition. 2002 Dataflow Analysis 32
  • 85. copyrights & credits Dataflow Analysis 33
  • 87. Pictures copyrights Slide 1: ink swirl by Graham Richardson, some rights reserved Slide 25: Seattle's Best Coffee by Dominica Williamson, some rights reserved Slide 32: Animal Ark Reno by Joel Riley, some rights reserved Dataflow Analysis 35

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. round-up on every lecture\n\nwhat to take with you\n\ncheck yourself, pre- and post-paration\n
  103. \n
  104. \n