[LLVMdev] Padding in Aggregates Useful ?

Xin Tong trent.tong at gmail.com
Thu Apr 16 21:57:08 PDT 2015


Hi

I see that LLVM does not scalar replace aggregates used as the src or
dst of memcpy. and the reason is  memcpy could be moving around
elements that live in structure padding of the LLVM types. I wonder
what could live in the padding, but may actually used ?

02605   // Okay, we know all the users are promotable.  If the
aggregate is a memcpy
02606   // source and destination, we have to be careful.  In
particular, the memcpy
02607   // could be moving around elements that live in structure
padding of the LLVM
02608   // types, but may actually be used.  In these cases, we refuse
to promote the
02609   // struct.
02610   if (Info.isMemCpySrc && Info.isMemCpyDst &&
02611       HasPadding(AI->getAllocatedType(), DL))
02612     return false;

Thanks
Trent



More information about the llvm-dev mailing list