<div style="font-family: arial, helvetica, sans-serif; font-size: 10pt">On Sat, Nov 10, 2012 at 3:55 AM, Nick Lewycky <span dir="ltr"><<a href="mailto:nlewycky@google.com" target="_blank">nlewycky@google.com</a>></span> wrote:<br>
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div class="im">On 9 November 2012 08:56, Alexey Samsonov <span dir="ltr"><<a href="mailto:samsonov@google.com" target="_blank">samsonov@google.com</a>></span> wrote:<br>


</div><div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi nicholas,<br>
<br>
When optimizer inlines a function, it creates llvm.lifetime.start/end intrinsics to mark<br>
the lifetime of static allocations in inlined functions. However, it doesn't set sizes of these<br>
memory objects. This patch tries to guess them using the information stored in AllocaInst.<br></blockquote><div><br></div></div><div>Could you give me some context on why you want this?</div></div></div></blockquote><div>
<br></div><div>Yeah, sorry for not providing it. We think of using llvm.lifetime intrinsics in AddressSanitizer:</div><div><a href="http://code.google.com/p/address-sanitizer/issues/detail?id=83">http://code.google.com/p/address-sanitizer/issues/detail?id=83</a>.</div>
<div>For example, if we encounter llvm.lifetime.end(<size>, <ptr>) intrinsic in ASan function pass,</div><div>we may mark the corresponding memory region as "unaddressable", so that any further access to</div>
<div>it will produce an error report.</div><div><br></div><div>As I can see, llvm.lifetime intrinsics are not that popular now, but probably we can emit them (in Clang)</div><div>to find addressability issues with ASan and enable stack re-use with StackColoring machine function pass.</div>
<div>void f() {</div><div>  int *p;</div><div>  {</div><div>     int a = 0;</div><div>     p = &a;</div><div>  }</div><div>  *p = 42; // Error!</div><div>} </div><div><br></div><div>That said, llvm.lifetime intrinsics are pretty useless for ASan if <size> argument is undefined :)</div>
<div><br></div><div>Interestingly, I observed that sometimes <size> argument is not filled in when llvm.lifetime</div><div>intrinsics are created (during function inlining), but is calculated in SROA pass. But...</div>
<div>why don't we fill it in in the first place?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="font-family:arial,helvetica,sans-serif;font-size:10pt">
<div class="gmail_quote"><div><br></div><div>Nick</div><div>

 </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><a href="http://llvm-reviews.chandlerc.com/D110" target="_blank">http://llvm-reviews.chandlerc.com/D110</a></blockquote>


<div><br></div><div> </div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Alexey Samsonov, MSK</div><br>
</div>