Algorithm 2.2 Build-CFG

Input: a set BB of kk basic blocks.

Output: all edges in CFG derived from BB.

1:for all basic block bb in BB do

2:if b.last.type=b.last.type = JUMP then

3:targetStmt=b.last.targettargetStmt = b.last.target // 跳转语句的目标语句

4:Let targetBlocktargetBlock be the basic block containing targetStmttargetStmt.

5:output btargetBlockb\to targetBlock

6:end if

7:if b.last.typeb.last.type \ne UCONDITIONAL-JUMP then

8:nextStmt=b.last.nextnextStmt = b.last.next

9:Let nextBlocknextBlock be the basic block containing nextStmtnextStmt.

10:output bnextBlockb\to nextBlock

11:end if

12:end for