Liveness学习

参照卡内基梅隆大学的一篇讲义

首先活跃性是指某一个变量会被后续计算中使用,那么就说此变量在此处开始活跃。

"A variable is live at a given program point if it will be used during the remainder of the computation, starting at this point."

用符号\(live(l, x)\)来表示x在标签l处活跃。

推理1: 如果有二元操作指令 \(l: x \leftarrow y \oplus z\), 那么变量\(y\)\(z\)在指令\(l\)处是活跃的

\[% L1公式 \begin{align} \frac {l: \, x \leftarrow y \oplus z} {\begin{array}{c} \text{live}(l, y) \\ \text{live}(l, z) \end{array}} L_1 \end{align} \]

推理2:如果有变量\(u\)在下一条指令\(l+1\)处活跃,且\(u \neq x\), 那么u在l处活跃。这个是反向传播的核心

\[% L2公式 \begin{align} \frac{\begin{array}{c} l: \, x \leftarrow y \oplus z \\ \text{live}(l + 1, u) \\ x \neq u \end{array}}{\text{live}(l, u)} L_2 \end{align} \]

neededness分析

"The crucial first idea is that the some variables are needed because an instruction they are involved in may have an effect. Let’s call such variable necessary. Formally, we write \(nec(l,x)\) to say that \(x\) is necessary at instruction \(l\)."

Control Flow Graph

Properties of the control flow of a program are embodied in the succ relation introduced in the previous section. The control flow graph is the graph whose vertices are the lines of the program and with an edge between l and l' whenever succ(l, l'). It captures the possible flows of control without regard to the actual values that are passed.

程序的控制流特性体现在前一节中介绍的 succ 关系中。控制流图 是一个图,其顶点是程序的各行代码,当存在 succ(l, l') 时,在 l 和 l' 之间有一条边。它捕捉了可能的控制流,而不考虑实际传递的值。

posted @ 2024-08-16 15:29  风冷无霜  阅读(6)  评论(0编辑  收藏  举报