[LLVMdev] BitCast or GEP?

Duncan Sands baldrick at free.fr
Mon Jan 28 03:39:07 PST 2013


Hi Rick,

On 28/01/13 12:12, Rick Mann wrote:
> I have a little simple inheritance thing going on:
>
> %struct.PDFrame = type { i64, i64, i8* }
> %struct.PDField = type { %struct.PDFrame, i8 }
>
> Is there any difference between bitcasting a pointer to the struct.PDField to struct.PDFrame, or using GEP to get a pointer to the "super" struct?

no there isn't.  The optimizers will turn the bitcast form into the GEP form as
a normalization.

>
> I'm not even sure it's possible to bitcast in this situation, but I imagine it should be.

Bitcasting a pointer to a pointer is always OK, in fact it's the most common use
of bitcast.

Ciao, Duncan.




More information about the llvm-dev mailing list