summaryrefslogtreecommitdiff
path: root/tex/presentation/presentation.tex
blob: 914ba660412c5307bd78bcc507a3b944a06034e1 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
\documentclass{beamer}

\title{Implementing and Evaluating a Strategy-Iteration Based Static Analyser within the LLVM framework}
\author{Carlo Zancanaro}
\def\sid{309222257}
\def\supervisor{Bernhard Scholz}

\usepackage[numbers]{natbib}
\usepackage{mdframed}
\usepackage{algorithmicx}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.4} 
\algblockx[While]{While}{EndWhile}{\textbf{while}~}{\textbf{endwhile}}

\newcommand\Z{\mathbb{Z}}
\newcommand\CZ{\overline{\Z}}
\def\newblock{\hskip .11em plus .33em minus .07em} % important line

\begin{document}

\begin{frame}
  \maketitle
\end{frame}

\section{Introduction}
\begin{frame}{Bugs are bad}
  \begin{itemize}
  \item<1->
    Money - recently Knight Capital, US\$440 million lost in a day
  \item<2->
    Time - 50\% of development time is spent debugging\cite{debugging-book}
  \item<3->
    Security - buffer overflows and other security flaws
  \item<4->
    Lives - X-ray machines, helicopters, cars
  \end{itemize}
\end{frame}
\begin{frame}{Static analysis is good}
  \begin{itemize}
  \item<1->
    The more bugs we can catch at compile time, the better
  \item<2->
    We can't catch all bugs - Rice's theorem\cite{Rice}
  \end{itemize}
\end{frame}

\section{Prior work}
\begin{frame}[fragile]{Modelling programs}
  \begin{center}
    \begin{mdframed}
      \begin{algorithmic}
        \State $x = 0$
        \State $y = 1$
        \While {$x < 8$}
          \Comment{value at start of this line}
          \State $x = x + 2$
          \State $y = y + 2$
        \EndWhile
      \end{algorithmic}
    \end{mdframed}
  \end{center}
  \begin{align*}
    \only<1>{~ \\ ~}
    \only<2>{x &= \{0\} \\ y &= \{1\}}
    \only<3>{x &= \{0, 2\} \\ y &= \{1, 3\}}
    \only<4>{x &= \{0, 2, 4\} \\ y &= \{1, 3, 5\}}
    \only<5>{x &= \{0, 2, 4, 6\} \\ y &= \{1, 3, 5, 7\}}
    \only<6>{x &= \{0, 2, 4, 6, 8\} \\ y &= \{1, 3, 5, 7, 9\}}
  \end{align*}
\end{frame}

\begin{frame}{Abstract interpretation}
  Basic idea: simplify your domain

  Instead of arbitrary subsets of $\Z$, something less precise:

  \begin{itemize}
  \item
    signs\cite{CousotCousot77-1}: $x \in \{ \Z, \Z^+, \Z^-, 0\}$
  \item
    ranges\cite{CousotCousot77-1}: $x \le a; -x \le b, ~a,b \in \Z$
  \item
    zones\cite{mine:padoII}: $x - y \le c; \pm x \le c ~c \in Z$
  \end{itemize}
\end{frame}
\begin{frame}[fragile]{Abstract interpretation}
  \begin{figure}
    \begin{tikzpicture}[scale=0.6,dot/.style={circle,fill,inner sep=1pt}]
      \draw (0,0) -- coordinate (x axis mid) (10,0);
      \draw (0,0) -- coordinate (y axis mid) (0,10);
      
      \foreach \x in {0,...,10}
        \draw (\x,1pt) -- (\x,-3pt)
          node[anchor=north] {\x};
      \node[anchor=west] at (10,0) {$x$};
      \foreach \y in {0,...,10}
        \draw (1pt,\y) -- (-3pt,\y)
          node[anchor=east] {\y};
      \node[anchor=south] at (0,10) {$y$};

      \foreach \v in {0,...,4}
        \node [dot,radius=0.2pt] at (0 + 2*\v,1 + 2*\v) { };

      \draw [draw=black, fill=gray, fill opacity=0.2]
        (0,1) -- (0,9) -- (8,9) -- (8,1) -- (0,1);
    \end{tikzpicture}
    \caption{Comparison between concrete and abstract domains}
  \end{figure}
\end{frame}

\begin{frame}{$\max$-strategy improvement}
  \begin{itemize}
  \item
    Transform a program into equations
  \item
    Solve equations
  \end{itemize}
\end{frame}

\begin{frame}[fragile]{$\max$-strategy example}
  \begin{center}
    \begin{mdframed}
      \begin{algorithmic}
        \State $x = 0$
        \Comment $A$
        \While {$x \le 8$} \Comment $B$
          \State $x = x + 2$
        \EndWhile
        \State print$(x)$ \Comment $C$
      \end{algorithmic}
    \end{mdframed}
  \end{center}
  \alt<1>{\begin{align*}
      ub(x)_A &\ge \infty \\
      ub(x)_B &\ge 0 \\
      ub(x)_B &\ge \min(ub(x)_B, 8) + 2 \\
      ub(x)_C &\ge ub(x)_B
    \end{align*}
  }{\begin{align*}
      ub(x)_A &= \infty \\
      ub(x)_B &= \max(0, \min(ub(x)_B, 8) + 2) \\
      ub(x)_C &= ub(x)_B \\
      ~
    \end{align*}}
  \only<2>{}
\end{frame}

\begin{frame}[fragile]{$\max$-strategies}
  A $\max$-strategy is a decision about which argument in a
  $\max$-expression to choose.
  \begin{align*}
    ub(x)_A &= \infty \\
    ub(x)_B &= \max(\alert<2>{0}, \alert<3>{\min(ub(x)_B, 8) + 2}) \\
    ub(x)_C &= ub(x)_B
  \end{align*}
\end{frame}

\begin{frame}[fragile]{Solver}
  \begin{figure}
    \begin{tikzpicture}
      \node [rectangle, draw, align=center](max) at (0,0) {Maximiser \\ improve strategy};
      \node [rectangle, draw, align=center](min) at (0,-3) {Minimiser \\ find assignment};

      \path[]
      (min) edge[bend left,arrows={-latex}]
      node[anchor=east]{variable assignment}
      (max)
      
      (max) edge[bend left,arrows={-latex}]
      node[anchor=west]{$\max$-strategy}
      (min);
    \end{tikzpicture}
    \caption{The high-level structure of the solver presented in
      \cite{Gawlitza:2007:PFC:1762174.1762203}}
  \end{figure}
\end{frame}

\section{Contribution}
\begin{frame}[fragile]{Solver - enhancements}
  The big idea: take into account data-dependencies
  \begin{align*}
    \alert<4>{x} &\alert<4>{= \max(0, \min(x - 1, \alert<3>{y}))} \\
    \alert<2-4>{y} &= \max(0, x + 5, x) \\
    z &= \max(0, z + 1, x)
  \end{align*}
\end{frame}

\begin{frame}[fragile]{Solver - enhancements}
  \begin{figure}
    \begin{tikzpicture}
      \node [rectangle, draw, align=center](max) at (0,0) {Maximiser \\ improve strategy};
      \node [rectangle, draw, align=center](min) at (0,-3) {Minimiser \\ find assignment};

      \path[]
      (min) edge[bend left,arrows={-latex}]
      node[anchor=east,align=right]{variable assignment \\ change set}
      (max)
      
      (max) edge[bend left,arrows={-latex}]
      node[anchor=west,align=left]{$\max$-strategy \\ change set}
      (min);
    \end{tikzpicture}
    \caption{The high-level structure of our enhanced solver}
  \end{figure}
\end{frame}

\section{Results}
\begin{frame}{Implementation}
  \begin{itemize}
  \item
    Implemented in C++
  \item
    Integrated into the LLVM/Clang static analysis framework
  \end{itemize}
\end{frame}

\begin{frame}{Example system}
  \begin{align*}
    x_0 &= \max(-\infty, 0) \\
    x_1 &= \max(-\infty, x_0) \\
    x_2 &= \max(-\infty, x_1) \\
    ... &~ ... \\
    x_n &= \max(-\infty, x_{n-1})
  \end{align*}
\end{frame}

\begin{frame}{Runtime improvements}
  \begin{figure}
    \begin{tikzpicture}
      \begin{loglogaxis}[% 
          scale only axis,
          width=9cm,
          height=5cm,
          xmin=1, xmax=65536,
          xlabel=size of equation system,
          ymin=0, ymax=40,
          ylabel=time (in seconds),
          axis on top]
        \addplot[
          ybar,
          bar width=0.5cm, 
          bar shift=0in,
          fill=red,
          draw=black]
        plot coordinates{ 
          (1,0.000021982 )
          (2,0.000037083 )
          (4,0.000090918 )
          (8,0.000331411 )
          (16,0.001678790 )
          (32,0.010238535 )
          (64,0.069774912 )
          (128,0.520062180 )
          (256,3.983806321 )
          (512,31.469653195 )
        };

      \end{loglogaxis}
    \end{tikzpicture}
    \caption{Performance of the naive algorithm}
  \end{figure}
\end{frame}

\begin{frame}{Runtime improvements}
  \begin{figure}
    \begin{tikzpicture}
      \begin{loglogaxis}[%
          scale only axis,
          width=9cm,
          height=5cm,
          xmin=1, xmax=65536,
          xlabel=size of equation system,
          ymin=0, ymax=40,
          ylabel=time (in seconds),
          axis on top]
        \addplot[
          ybar,
          bar width=0.5cm, 
          bar shift=0in,
          fill=red,
          draw=black] 
        plot coordinates{ 
          (1,0.000044508 )
          (2,0.000063953 )
          (4,0.000094303 )
          (8,0.000176679 )
          (16,0.000312958 )
          (32,0.000642421 )
          (64,0.001194996 )
          (128,0.002451839 )
          (256,0.004786286 )
          (512,0.009280946 )
          (1024,0.019159827 )
          (2048,0.038067689 )
          (4096,0.080535540 )
          (8192,0.151181571 )
          (16384,0.339113750 )
          (32768,0.593622054 )
          (65536,1.217525509 )
        };

      \end{loglogaxis}
    \end{tikzpicture}
    \caption{Performance of our improved algorithm}
  \end{figure}
\end{frame}

\section{Future work}
\begin{frame}{Future work}
  \begin{itemize}
    \item
      Still slightly over-approximating dependencies
    \item
      LLVM/Clang integration is only a proof-of-concept
  \end{itemize}
\end{frame}

\begin{frame}[fragile,allowframebreaks]{References}
  \phantomsection
  \bibliographystyle{abbrvnat}
  \bibliography{references}
\end{frame}

\begin{frame}{Contributions}
  \begin{itemize}
    \item
      Improvement of $\max$-strategy iteration algorithm, leveraging
      sparsity of variable dependencies
    \item
      Implementation of a $\max$-strategy iteration based static
      analyser in the LLVM/Clang framework
  \end{itemize}
\end{frame}

\end{document}