[LLVMdev] Re: [PATCH] BasicBlock::getFirstNonPHI

Vladimir Prus ghost at cs.msu.su
Mon Jun 5 01:11:09 PDT 2006


Chris Lattner wrote:

> On Sun, 4 Jun 2006, Vladimir Prus wrote:
>> everytime one has to add instruction at the beginning of a basic block,
>> one has to skip past PHI nodes that are already there. How about adding a
>> new method to BasicBlock, to get that first non-PHI instruction? So,
>> adding an instruction will be as simple as:
>>
>>      new SomeInstruction(............., BB->getFirstNonPHI())
> 
> Sure, sounds good.  A couple requests:
> 
> 1. Please add a const version that returns a const Instruction* also.

I was considering it, but then decided that given that you can't pass 'const
Instruction*' as 'insert before' parameter of any other instruction,
there's no point in adding it. 

Maybe, the method should be

  Instruction* getFirstNonPHI() const

? Given that in C++ constness is generally not deep -- i.e. don't apply to
contained objects.

- Volodya









More information about the llvm-dev mailing list