LLVM 插桩 LLVM IR PHI指令

今天在进行 LLVM 插桩时,遇到一个神奇的报错

PHI nodes not grouped at top of basic block!
  %12 = phi i32 [ %.pre, %if.then15 ], [ %argc, %maybe_close_fd_mask.exit ], !dbg !381
label %if.end19
PHI nodes not grouped at top of basic block!
  %18 = phi i32 [ %.pr, %if.else49thread-pre-split ], [ %12, %if.end19 ], !dbg !422
label %if.else49
PHI nodes not grouped at top of basic block!
  %N.1 = phi i32 [ %conv.i, %if.then34 ], [ %N.0, %if.else49 ], !dbg !431
label %if.end57
PHI nodes not grouped at top of basic block!
  %indvars.iv = phi i64 [ 1, %for.body.preheader ], [ %indvars.iv.next, %cleanup ]
label %for.body
PHI nodes not grouped at top of basic block!
  %fd.039 = phi i32 [ %call5, %if.end ], [ 0, %for.body ]
label %if.end8
LLVM ERROR: Broken module found, compilation aborted!

经过 STFW,找到如下网址 https://stackoverflow.com/questions/16754324/input-in-llvm-i-think-i-do-not-understand-dominance-and-the-location-of-phi-nod

在这里插入图片描述
意思很明显,如果一个基本块里有 phi 指令,那么从基本块的开头到 phi 指令之间必须全都是 phi 指令。也就是说,phi 指令必须堆在 basic block 的开头

所以,插桩的时候要注意,不要违背了这个原则。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值