[llvm-dev] help me understand how nounwind attribute on functions works?
Andrew Kelley via llvm-dev
llvm-dev at lists.llvm.org
Sun Feb 5 08:32:44 PST 2017
> This function attribute indicates that the function never raises an
> exception. If the function does raise an exception, its runtime behavior is
> undefined. However, functions marked nounwind may still trap or generate
> asynchronous exceptions. Exception handling schemes that are recognized by
> LLVM to handle asynchronous exceptions, such as SEH, will still provide
> their implementation defined semantics.
Some things I noticed by looking at various C test programs with clang -S
* If a function definition is provided, it gets nounwind, even if it calls
a non-nounwind function
* If a function is external (no definition provided), it does not get
What I don't understand is:
* A non-nounwind function that calls a nounwind function, wouldn't the
ability for an exception to be thrown transfer? I thought if you don't
catch an exception, it bubbles up to the caller and so on.
* More importantly, if compiling in C mode, why doesn't every function
have nounwind? I thought that C does not have exceptions, so calling a
function and having it throw an exception would be undefined behavior
anyway. Wouldn't that mean every function should be nounwind?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev