0
在我的通行證我檢查從每一個基本塊runOnFunction倒數第二條指令()。我只對ICMP指令感興趣。LLVM指令* - > getOperand()無法正常工作ICMP
if(BB->size()>1)
if(last->getPrevNode())
{
previous = last->getPrevNode();
ok=1;
}
我想獲得以前的操作數,它是Instruction *類型。根據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指令獲取操作數?我需要在某些條件下使用它們? (也是他們的屬性)。 非常感謝!
我已經做到了,它的工作原理:)謝謝您的解答! – Alex