首页 > 其他 > 详细

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

时间:2020-12-06 11:51:29      阅读:20      评论:0      收藏:0      [点我收藏+]

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.

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

原文:https://www.cnblogs.com/bjchan9an/p/14092063.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!