[llvm-dev] How to the get the PHI Nodes in a basic block?

Quentin Colombet via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 27 11:17:19 PDT 2019

Hi Alberto,

You’ll have to indeed iterate over the instructions, but you don’t have to go through all of them.
You can use MachineBasicBlock::getFirstNonPHI and then iterate backward.


> On Jun 27, 2019, at 11:07 AM, Alberto Barbaro via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> Hi all,
> I have an Instruction object I from where I can correctly obtain the parent doing I.getParent(). Now I would like to understand how to obtain the PHI Nodes in that block. Do you suggest to iterate all over the instructions since the PHI nodes are always at the beginning or should I use another approach? What the best way to iterate over the instructions in a block?
> Thanks
> Alberto
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

More information about the llvm-dev mailing list