<div dir="ltr"><div>Hi,</div><div><br></div><div>I am working on a block annotation which should have a try-finally semantics. For example, given a code like this:</div><div><br></div><div><b>__speculate</b> <font color="#ff0000"><b>{</b></font></div><div>  if (x > 2) {</div><div>    y = 0;</div><div>  }</div><div><font color="#ff0000"><b>}</b></font></div><div><br></div><div>clang should produce something like</div><div><br></div><div>__exec_mode = <b><font color="#ff0000">__begin_spec</font></b>();</div><div>if (__exec_mode == SW) {</div><div>  if (__read_barrier(&x) > 2) {</div><div>    __write_barrier(&y, 0);</div><div>  }</div><div>  <font color="#ff0000"><b>__end_spec</b></font>();</div><div>} else {</div><div>  if (x > 2) {</div><div>    y = 0;</div><div>  }</div><div>  <b><font color="#ff0000">__end_spec</font></b>();</div><div>}</div><div><br></div><div>such that __end_spec() is guaranteed to be called on every exit of the  __speculate {}  block.</div><div><br></div><div>It is my understanding that Clang implements try-finally statements as a Microsoft Specific Extension. However, I would not like to have such restriction, since such extension is only available for a reduced number of targets.</div><div><br></div><div>My question is, how should I implement try-finally semantics? Through an IR pass (fixing up every exit with a call to __end_spec()) or it is possible to extend from CXXTryStmt (reusing some CodeGen code)?</div>-- <br><div dir="ltr" class="m_863750444281404145gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px">João Paulo L. de Carvalho<br>Computer Science |  IC-UNICAMP | Campinas , SP - Brazil</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px"><a href="mailto:jaopaulolc@gmail.com" target="_blank">jaopaulolc@gmail.com</a></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px"><a href="mailto:joao.carvalho@ic.unicamp.br" target="_blank">joao.carvalho@ic.unicamp.br</a></div></div></div></div>