I am looking for a right way to get a next immediate instruction that follows a given instruction.
Let's assume that I have the following:
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %17
I have a
CmpInst *cmpInst = dyn_cast<CmpInst>(&V);
which corresponds to %10
.
How do I get an access to the BranchInst
that follows my CmpInst
?
I assume that a solution should take both cases into account: when there is a next instruction and when there is no one i.e. it is the end of a BasicBlock
.
It turned out to be as simple as this:
Instruction *instruction = cmpInst->getNextNode();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With