[llvm-dev] Check if getElementPtr Operand

Bernard Nongpoh via llvm-dev llvm-dev at lists.llvm.org
Wed Aug 31 00:35:30 PDT 2016


Hello Pierre,
Great!!!
Thanks for your recommendation,
Bernard

On Wed, Aug 31, 2016 at 12:59 PM, Pierre Gagelin <up833083 at myport.ac.uk>
wrote:

> Hi, just a remark in your code below
>
> How to check in the instruction, whether the operand is a structure or not
>>>
>>> if(isa<GetElementPtrInst>(instruction))
>>> {GetElementPtrInst *getElementPtrInst=dyn_cast<GetElementPtrInst>(&instruction);
>>>
>>> //check if getElemetPtrInst operands structure or array.
>>>
>>> }
>>>
>>> dyn_cast does the job of isa already (and the job of cast if isa is
> true), here you better do this directly:
>
> if( GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(&instruction) ) {
> 	// processing on GEP
> }
>
> And beware of your isa: it should operate on a pointer to an instruction,
> not the instruction instance itself (just like for dyn_cast). Hope that
> helps, Pierre
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160831/dc6e8fc6/attachment.html>


More information about the llvm-dev mailing list