<div dir="ltr">Is this example what you had in mind?<div><br></div><div>void f() {</div><div>  int *p = get_p();</div><div>  use_p(p);</div><div>  try {</div><div>   may_throw(p);<br>  } catch (int) {</div><div>    // don't need p</div><div>  }</div><div>  use_p(p);<br>}</div><div><br></div><div>The idea is that because p is not modified or used within the catch region (the funclet), it can live in a callee-saved register across the whole function.</div><div><br></div><div>That is true, it is possible, but I don't think it fits very well in our current model and CFG. Given that it doesn't fit the model, I don't think it's helpful to try to explain this in the documentation. The document is intended to aid LLVM developers who don't particularly care about WinEH but want to understand it enough to avoid breaking it.</div><div><br></div><div>If we wanted to exploit this optimization opportunity, we would clip funclets out of the CFG and add edges from invokes to all possible catchret destinations. Then the CSR mask of the call would naturally provide the right register allocation barrier.</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, May 24, 2018 at 8:13 AM Jay K via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><a href="https://llvm.org/docs/ExceptionHandling.html#wineh" rel="noreferrer" target="_blank">https://llvm.org/docs/ExceptionHandling.html#wineh</a><br>
<br>
> No variables live in to or out of the funclet can be allocated in registers.<br>
<br>
I don't think this is quite true. though it might be a useful simplification.<br>
Obviously it is true for volatile registers, but  I believe the funclet receives a CONTEXT<br>
with the nonvolatiles restored. Obviously cumbersome to access, but it lets you enregister them across calls like  normal in the "original" function.<br>
<br>
I  haven't seen Visual  C++ to such enregistration (nonvolatiles across calls in functions with EH), but  you  can do it in assembly.<br>
<br>
nvlocala.asm here  <a href="http://jaykrell2.blogspot.com/2017/10/windows-amd64-abi-nuances-part-1.html" rel="noreferrer" target="_blank">http://jaykrell2.blogspot.com/2017/10/windows-amd64-abi-nuances-part-1.html</a><br>
<br>
I should change it to print the nonvolatiles from context to demonstrate the point.<br>
<br>
 - Jay<br>
<br>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>