Hi all,
I’ve been looking at this bug:
https://bugs.llvm.org/show_bug.cgi?id=32611
The bug involves a function that is specified as not throwing anything but in reality it does throw.
void func() throw() {
throw 100;
}
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.
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.
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.
I’ve added a patch
https://reviews.llvm.org/D50908
that does the same thing for PowerPC as is done on x86 and it fixes the bug.
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.
Has anyone encountered an issue where a function marked as nounwind actually requires unwind tables? Does anyone know of a better solution for this?
Thank you,
Stefan