<font size=2 face="sans-serif">In that case this may be a bug on all targets.
</font><br><br><font size=2 face="sans-serif"> /// True if this function needs
an unwind table.</font><br><font size=2 face="sans-serif"> bool needsUnwindTableEntry()
const {</font><br><font size=2 face="sans-serif"> return hasUWTable() ||
!doesNotThrow();</font><br><font size=2 face="sans-serif"> }</font><br><font size=2 face="sans-serif"><br>This is part of the target independent Function class. We determine if
we need an unwind table entry by checking that we either have the uwtable
attribute that I mentioned or that we do not have nounwind. What you are
saying is that in this case we should also check to see if the function
has an EH personality. Does that sound reasonable? </font><br><br><br><br><br><font size=1 color=#5f5f5f face="sans-serif">From:
</font><font size=1 face="sans-serif">Reid Kleckner <rnk@google.com></font><br><font size=1 color=#5f5f5f face="sans-serif">To:
</font><font size=1 face="sans-serif">stefanp@ca.ibm.com</font><br><font size=1 color=#5f5f5f face="sans-serif">Cc:
</font><font size=1 face="sans-serif">cfe-dev <cfe-dev@lists.llvm.org></font><br><font size=1 color=#5f5f5f face="sans-serif">Date:
</font><font size=1 face="sans-serif">2018/08/17 02:54 PM</font><br><font size=1 color=#5f5f5f face="sans-serif">Subject:
</font><font size=1 face="sans-serif">Re: [cfe-dev]
Enable -funwind-tables by default on Power PC (Bugzilla Bug 32611)</font><br><hr noshade><br><br><br><font size=3>I think not generating unwind tables for nounwind functions
with EH personalities is a bug.</font><br><br><font size=3>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.</font><br><br><font size=3>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.</font><br><br><font size=3>On Fri, Aug 17, 2018 at 10:47 AM Stefan Pintilie via cfe-dev
<</font><a href="mailto:cfe-dev@lists.llvm.org"><font size=3 color=blue><u>cfe-dev@lists.llvm.org</u></font></a><font size=3>>
wrote:</font><br><font size=2 face="sans-serif">Hi all, </font><font size=3><br></font><font size=2 face="sans-serif"><br>I've been looking at this bug:</font><font size=3 color=blue><u><br></u></font><a href="https://bugs.llvm.org/show_bug.cgi?id=32611" target="_blank"><font size=2 color=blue face="sans-serif"><u>https://bugs.llvm.org/show_bug.cgi?id=32611</u></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.</font><font size=3><br></font><font size=2 face="sans-serif"><br>void func() throw() {<br> throw 100;<br>}<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><font size=3><br></font><font size=2 face="sans-serif"><br>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. <br>I've added a patch </font><font size=3 color=blue><u><br></u></font><a href="https://reviews.llvm.org/D50908" target="_blank"><font size=2 color=blue face="sans-serif"><u>https://reviews.llvm.org/D50908</u></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. <br>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><font size=3><br></font><font size=2 face="sans-serif"><br>Thank you,<br>Stefan</font><font size=3><br><br><br>_______________________________________________<br>cfe-dev mailing list</font><font size=3 color=blue><u><br></u></font><a href="mailto:cfe-dev@lists.llvm.org" target="_blank"><font size=3 color=blue><u>cfe-dev@lists.llvm.org</u></font></a><font size=3 color=blue><u><br></u></font><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" target="_blank"><font size=3 color=blue><u>http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</u></font></a><br><BR>