[llvm-dev] Check if getElementPtr Operand

Pierre Gagelin via llvm-dev llvm-dev at lists.llvm.org
Wed Aug 31 00:29:40 PDT 2016


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/c7d2e697/attachment.html>


More information about the llvm-dev mailing list