在我的通行证中,我检查了 runOnFunction() 中每个基本块的倒数第二条指令。我只对 ICMP 指令感兴趣。
if(BB->size()>1)
if(last->getPrevNode())
{
previous = last->getPrevNode();
ok=1;
}
我想获取先前的操作数,它是指令*类型。由于基于 getNumOperands 的测试,ICMP 有 2 个(正常)。
if ( ok && ((previous->getNumOperands())>=2) )
errs()<<"\nTTTTT "<<previous->getOperand(0)->getName()<<" | "
<<previous->getOperand(0)->getValueName()<<" | "
<<previous->getOperand(0)->getValueID()<<" | "
<<previous->getOperand(0)->getNumUses()<<" TTTTT\n";
getOperand(1) 的结果是相似的。输出是:
*PREVIOUS: store i32 %conv15, i32* %i, align 4
TTTTT conv15 | 0x9b69090 | 59 | 1 TTTTT
...
*PREVIOUS: store i32 %inc13, i32* %i, align 4
TTTTT inc13 | 0x9b76478 | 30 | 1 TTTTT
...
*PREVIOUS: %cmp11 = icmp sgt i32 %8, 3
TTTTT | 0x0 | 49 | 1 TTTTT
...
*PREVIOUS: store i32 %dec, i32* %i, align 4
TTTTT dec | 0x9b69130 | 30 | 1 TTTTT
...
*PREVIOUS: %cmp8 = icmp sle i32 %6, 2
TTTTT | 0x0 | 49 | 1 TTTTT
...
*PREVIOUS: store i32 %inc, i32* %i, align 4
TTTTT inc | 0x9b761c8 | 30 | 1 TTTTT
你知道我如何从 ICMP 指令中获取操作数吗?我需要在某些情况下使用它们吗?(也是他们的属性)。十分感谢 !