Liveness Analysis
:material-circle-edit-outline: 约 205 个字 :material-clock-time-two-outline: 预计阅读时间 1 分钟
Flow Graph Terminology
Liveness
A variable is live on an edge if:
- this variable will be used later
- this variable will not be re-defined before being used
Live-in: A variable is live-in at a node if it is live on any of the in-edges of that node;
Live-out: A variable is live-out at a node if it is live on any of the out-edges of the node
Calculation of Liveness
从后往前分析
Interference Graphs
冲突图,用于寄存器分配,冲突主要指两个变量的生存期重叠
冲突图构建方法如下:
- 第一条即我定义新变量时不应使用还会活跃的变量在使用的寄存器
- 第二条即针对进行复制操作的 MOVE 指令,我们不给 a 和 c 之间添加冲突边
此外,每条 MOVE 指令的两个变量用虚线连接,即合并边,如果已有干涉边就不用了