<div dir="ltr"><div><div><div><div><div><div><div><div>Hi Renato,<br><br>> Based on the current behaviour, you only need one flag: nounwind,<br>> which should only be emitted if -fno-unwind-tables is chosen AND the<br>
> function can't unwind.<br><br></div><div>I don't quite understand what do you mean here.<br><br>I was trying to say: due to the design of .ARM.exidx, you won't be possible to emit both the cantunwind directive and the stack unwinding information at the same time (they share the same word.)  Thus, if -funwind-tables is available, then we should ignore the nounwind attribute.  Otherwise, the force unwind simply won't work.  That's the reason why I said that if the function has uwtable attribute, then we should not emit cantunwind directive.<br>
<br><br>> There has to be a way to disable unwind tables, so either the "no<br>
> attribute" behaviour above is wrong or we need a new attribute<br>> "noehtable".<br>
<br></div><div>IMO, `noehtable` attribute won't solve the issue.  In my article, I was using ehtable to provide the guarantee of the information to throw-and-catch the exception, but you are using in the converse way.  In fact, uwtable and ehtable means almost the SAME table in ARM EHABI (except the LSDA.)<br>
<br>Furthermore, no exception handling table (LSDA) will be generated for the functions without the landingpad instruction, even -funwind-tables are given.  IMO, adding `noehtable` attribute won't reach your goal to remove the unnecessary unwind table.<br>
</div><br><br>
> Also, do not assume that EHABI behaviour in LLVM is currently correct,<br>
> especially related to uwtable and nounwind. Those were made with the<br>> x86_64's ABI in mind, and have only interoperated seriously with<br>> DwarfCFIException until very recently.<br><br>If you don't care about the backward compatibility at LLVM assembly level at all, then the simplest solution is to determine whether we should generate unwind table by the existence of the uwtable function attribute.  The result should be:<br>
<br></div>- no attribute => no table generated<br></div>- with nounwind attribute => no table generated<br></div>- with uwtable attribute => generate unwind table (with LSDA)<br></div>- with uwtable+nounwind attribute => generate unwind table (without cantunwind)<br>
<br></div>This combination will work (including the interleaving of C and C++ programs).  The will be only a little difference when the function really throws an exception and the front-end did not generate the landingpad instruction.  Since clang will transform "throw ()" or "noexpect(true)" to:<br>
<br>define void @_Z3foov() nounwind {<br>  invoke void @_Z9may_throwv() to label %1 unwind label %2                                           <br><br>; <label>:1<br>  ret void<br><br>; <label>:2<br>  %3 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)<br>
          filter [0 x i8*] zeroinitializer<br>  %4 = extractvalue { i8*, i32 } %3, 0<br>  tail call void @__cxa_call_unexpected(i8* %4)<br>  unreachable<br>}<br></div><div><br></div><div>The landingpad instruction will be emitted to catch every exceptions, and call __cxa_call_unexpected() to stop the unwinding procedure.<br>
<br>BUT, this means that all of the front-ends should be updated if they was not emitting uwtable attribute.  I am afraid that this won't be a viable solution.<br></div><div><br></div><div>Best regards,<br></div><div>
Logan<br></div><div><br></div># Footnote<br></div>[1] To be precise, one additional word will be emit to mark the absence of LSDA but this word should be emitted anyway.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Sat, Mar 22, 2014 at 3:07 AM, Renato Golin <span dir="ltr"><<a href="mailto:renato.golin@linaro.org" target="_blank">renato.golin@linaro.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="">On 21 March 2014 18:47, Logan Chien <<a href="mailto:tzuhsiang.chien@gmail.com">tzuhsiang.chien@gmail.com</a>> wrote:<br>
> * There's the table for ARM target:<br>
><br>
> - no attribute => emit unwind table<br>
> - with nounwind => emit unwind table with cantunwind<br>
> - with uwtable => emit unwind table<br>
> - with uwtable+nounwind => emit unwind table WITHOUT the cantunwind<br>
><br>
> The cantunwind record will stop the unwinder, and cantunwind will conflict<br>
> with the stack unwind information according to EHABI.  Thus, we should not<br>
> emit cantunwind for the function with uwtable.<br>
<br>
</div>Logan,<br>
<br>
Based on the current behaviour, you only need one flag: nounwind,<br>
which should only be emitted if -fno-unwind-tables is chosen AND the<br>
function can't unwind.<br>
<br>
Also, do not assume that EHABI behaviour in LLVM is currently correct,<br>
especially related to uwtable and nounwind. Those were made with the<br>
x86_64's ABI in mind, and have only interoperated seriously with<br>
DwarfCFIException until very recently.<br>
<br>
There has to be a way to disable unwind tables, so either the "no<br>
attribute" behaviour above is wrong or we need a new attribute<br>
"noehtable".<br>
<br>
There has to be a way to emit CantUnwind, so if the behaviour above is<br>
right, the "uwtables" attribute is only related to forced unwind<br>
(debug, profiler), not exception handling.<br>
<br>
There has to be a way to map "throw()" into IR, and "nounwind" seems<br>
to be the one to use. The fact that CantUnwind is only emitted without<br>
"uwtable" reinforces the idea that "uwtable" is forced unwind.<br>
<br>
cheers,<br>
--renato<br>
</blockquote></div><br></div>