<div dir="ltr">I think not generating unwind tables for nounwind functions with EH personalities is a bug.<div><br></div><div>It's true that the program never unwinds out of func, but it internally catches all possibly unwinding exceptions and calls __cxa_call_unexpected. That requires .cfi directives.</div><div><br></div><div>It looks like this bug applies to both ppc64 and x86_64. It must be in common prologue emission code, or all the targets have the same bug. We shouldn't need the uwtable attribute to get this case right.</div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Aug 17, 2018 at 10:47 AM Stefan Pintilie via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-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"><font size="2" face="sans-serif">Hi all, </font><br><br><font size="2" face="sans-serif">I've been looking at this bug:<br></font><a href="https://bugs.llvm.org/show_bug.cgi?id=32611" target="_blank"><font size="2" color="blue" face="sans-serif">https://bugs.llvm.org/show_bug.cgi?id=32611</font></a><font size="2" face="sans-serif"><br><br>The bug involves a function that is specified as not throwing anything
but in reality it does throw.<br></font><br><font size="2" face="sans-serif">void func() throw() {</font><br><font size="2" face="sans-serif"> throw 100;</font><br><font size="2" face="sans-serif">}<br><br>When this code is run we should see a call to __cxa_call_unexpected but
we do not. The reason is because the function does not generate the unwind
tables.<br>func() is marked with the nounwind attribute as is expected due to the
fact the user has told us it does not throw anything. However, that attribute
also blocks the generation of the unwind tables which are required for
the proper functioning of the call to unexpected. The solution is to also
use the attribute uwtable which forces the generation of the unwind tables.
</font><br><br><font size="2" face="sans-serif">Checking how this works on x86 I realised
that this works because -funwind-tables is on by default for x86 and therefore
adds the uwtable attribute to almost all of the functions being compiled.
</font><br><font size="2" face="sans-serif">I've added a patch <br></font><a href="https://reviews.llvm.org/D50908" target="_blank"><font size="2" color="blue" face="sans-serif">https://reviews.llvm.org/D50908</font></a><font size="2" face="sans-serif"><br>that does the same thing for PowerPC as is done on x86 and it fixes the
bug.<br><br>However, I feel like this solution adds a function attribute to a whole
set of functions where it is not needed. The vast majority of functions
that will now receive the uwtable attribute don't actually need it. </font><br><font size="2" face="sans-serif">Has anyone encountered an issue where
a function marked as nounwind actually requires unwind tables? Does anyone
know of a better solution for this?</font><br><br><font size="2" face="sans-serif">Thank you,</font><br><font size="2" face="sans-serif">Stefan</font><br><br><br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>