<div dir="ltr">Anything could live there. Run this IR through clang and you'll see an alloca with a struct type where the padding is used by memset and 'use_bytes':<div><br></div><div><div><div>#include <string.h></div><div>void use_bytes(char *);</div><div>int main() {</div><div>  union {</div><div>    char bytes[8];</div><div>    struct {</div><div>      char c;</div><div>      int i;</div><div>    } with_padding;</div><div>  } u = { .with_padding = {'a', 42} };</div><div>  memset(u.bytes, 8, 0);</div><div>  use_bytes(u.bytes);</div><div>}</div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 16, 2015 at 9:57 PM, Xin Tong <span dir="ltr"><<a href="mailto:trent.tong@gmail.com" target="_blank">trent.tong@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi<br>
<br>
I see that LLVM does not scalar replace aggregates used as the src or<br>
dst of memcpy. and the reason is  memcpy could be moving around<br>
elements that live in structure padding of the LLVM types. I wonder<br>
what could live in the padding, but may actually used ?<br>
<br>
02605   // Okay, we know all the users are promotable.  If the<br>
aggregate is a memcpy<br>
02606   // source and destination, we have to be careful.  In<br>
particular, the memcpy<br>
02607   // could be moving around elements that live in structure<br>
padding of the LLVM<br>
02608   // types, but may actually be used.  In these cases, we refuse<br>
to promote the<br>
02609   // struct.<br>
02610   if (Info.isMemCpySrc && Info.isMemCpyDst &&<br>
02611       HasPadding(AI->getAllocatedType(), DL))<br>
02612     return false;<br>
<br>
Thanks<br>
Trent<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</blockquote></div><br></div>