如何在 LLVM 中提取 Icmp inst 或 binaryOperator Inst 的目标位置?

Posted

技术标签:

【中文标题】如何在 LLVM 中提取 Icmp inst 或 binaryOperator Inst 的目标位置?【英文标题】:How to extract the destination place of an Icmp inst or a binaryOperator Inst in LLVM? 【发布时间】:2020-04-25 12:32:23 【问题描述】:

现在我想获取 Icmp Inst 的目标位置,例如,如果我有一个 Icmp Inst,例如:

%cmp = icmp sgt i32 %0, 1

我怎样才能得到目的地'%cmp'? 对于 BinaryOperator Inst,例如:

%dec = add nsw i32 %2, -1

我怎样才能得到“%dec”?

我尝试过使用 Value* des = icmp->getOperand(0);,但似乎不对。我尝试在谷歌搜索,但没有得到满意的答案,有人可以告诉我如何解决这个问题吗?非常感谢。

【问题讨论】:

【参考方案1】:

如果我理解正确,那么 icmp 本身就是您要查找的目标值。即,

改变

Value* des = icmp->getOperand(0);

Value* des = icmp;

【讨论】:

以上是关于如何在 LLVM 中提取 Icmp inst 或 binaryOperator Inst 的目标位置?的主要内容,如果未能解决你的问题,请参考以下文章