我的问题很简单。给定类型分支的指令,如何从中提取标签? 例如:
br label %while.cond
应该给我while.cond
br label %while.end
应该给我while.end
br i1 %cmp1, label %if.then, label %if.end
如果,if.then,if.end分别给我。
答案 0 :(得分:0)
首先检查inst->isConditional()
,然后访问inst->getOperand(1)
和inst->getOperand(2)
以防它为真,如果inst->getOperand(0)
则为假。
整个BasicBlock是BranchInst
实际接受的。如果您想要%if.then
行,请在其上调用getName()
。
答案 1 :(得分:0)
我使用以下代码段来获取您提出的所有上述信息。
if (inst->getNumSuccessors() == 1)
return; //indicates not a branching instruction
unsigned int i;
for (i = 0; i <= inst->getNumSuccessors(); i++) {
llvm::outs() << inst->getOperand(i)->getName();
}