LLVM程序分析日记之 basic blocks could have duplicate predecessors

We used the predecessors() to get the predecessors of a basic block based on LLVM's IR. The code is like:

for (llvm::BasicBlock* pred_bb : predecessors(cur_bb)) {
   printf("prev_bb=%p\n", pred_bb); /* for debug */
}

However, we found that the predecessors() could return duplicate basic block pointers. The output of above code could be:

prev_bb=0x56407eaee190
prev_bb=0x56407eaee190
prev_bb=0x56407eaee190
prev_bb=0x56407eaee190
prev_bb=0x56407eaee190

We further found these duplicate predecessors mostly apear in switch instructions. An github issue has mentioned this situtaion (https://github.com/NETMF/llilum/issues/76).

To resolve this situation, we have to check the result of predecessors() before usage.

上一篇:Monitorix :支持服务器和树莓派的轻量级系统监控系统


下一篇:想将算法进一步开发吗?手把手教你搭建基于CNN模型的Flask Web应用