Nemo_Sol
Nemo_Sol

Reputation: 352

Detecting Integer Comparison conditional in LLVM

#include <stdio.h>
#include <string.h>

int main (){
    unsigned short int a = 10;
    if (a == 10){
     //something
    }
}

In an LLVM pass, how would I detect 2 operand integer comparison conditional statements like the one shown above: (a == 10)? Please let me know what I should look for in the LLVM api.

Upvotes: 1

Views: 685

Answers (1)

arnt
arnt

Reputation: 9675

What you have there is an ICmpInst whose operands are integers. Since both operands have to have the same type, isa<ICmpInst>(foo) && isa<IntegerType>(foo->getOperand(0)) is enough to identify whether a particular instruction is the kind you want to detect.

Upvotes: 1

Related Questions