静态单赋值形式与函数式中间表示
1. 从SSA形式转换回来
在将静态单赋值(SSA)形式的程序转换回普通形式时,需要进行活跃性分析并构建干涉图。以下是相关算法:
LivenessAnalysis() =
for each variable v
M ←{}
for each site-of-use s of v
if s is a φ-function with
v as its ith argument
let p be the ith predecessor of
the block containing s
LiveOutAtBlock(p, v)
else LiveInAtStatement(s, v)
LiveOutAtBlock(n, v) =
v is live-out at n
if n ∉ M
M ← M ∪ {n}
let s be the last statement in n
LiveOutAtStatement(s, v)
LiveInAtStatement(s, v) =
v is live-in at s
if s is the first statement of some block n
v is live-in at n
for each predecessor p of n
LiveOutAtBlock(p,