Reputation: 900
I'm trying to write a pass that will check the control flow of a code. Given a br instruction, I need to access the basic blocks referred to in the label fields.
For example, for the code:
for(i = 0; i < count; i++){
sum = add(sum, array[i]);
}
I get the IR representation
br i1 %cmp, label %for.body, label %for.end
Now when I come across this instruction in the pass, I need to know exactly where these labels are pointing to. Can anybody please tell me how I can do that?
Upvotes: 4
Views: 2062
Reputation: 34401
Call ->getOperand(1)
and ->getOperand(2)
methods for that instruction. This would give you 1st and 2nd BB respectively. See http://llvm.org/doxygen/classllvm_1_1User.html#abe1de1520a21f77ac57cc210bf0fb0b4
Upvotes: 1