<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Mar 1, 2016 at 1:39 PM, Akira Hatanaka via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>If we want to insert the missing lifetime.end markers for the strings, we'll have to insert them at the beginning of lpad's successors, %eh.resume and %terminate.lpad, because the destructor call in lpad is an invoke instruction. However, if we insert the lifetime.end markers for all of them, the lifetimes of the strings will overlap clang generates only one resume block and one terminate block per function.</div></div></blockquote><div><br></div><div>In C++11, destructors are noexcept by default, so I'm not sure this really matters that much going forward. You can still declare your destructor noexcept(false), in which case, maybe we don't care as much about optimizing your stack slot usage.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>To get tighter bounds for the strings' lifetimes, I'm considering attaching lifetime.end metadata to the destructor calls in clang:</div><div><br></div><div>invoke void @foo("basic_string"* %str) to label %eh.resume unwind label %terminate.lpad, !lifetime_end !10</div><div><br></div><div>!10 = !{i32 0}</div><div><br></div><div>SelectionDAGBuilder will then insert a lifetime.end node if there is a lifetime.end attached to an invoke instruction.</div><div><br></div><div>Does this sound like a reasonable approach? Or are there better ways to tell the backend that the lifetimes do not overlap?</div></div>
</blockquote></div><br></div><div class="gmail_extra">I think there are issues with this proposal. How does this approach interact with IPO like inlining? Would we insert lifetime.end in the inliner? What if we delete the dtor because it has no side effects, do we lose the lifetime info?</div><div class="gmail_extra"><br></div><div class="gmail_extra">LLVM CFG soup makes this stuff kind of awkward. :(<br></div></div>