[cfe-dev] exit() emits exception handling?

Reid Kleckner via cfe-dev cfe-dev at lists.llvm.org
Tue Oct 6 09:47:02 PDT 2015


If you have local variables with non-trivial destructors (say,
std::unique_ptr or std::vector), then Clang will turn calls into invokes.
The unwind edge of the invoke executes when an exception is thrown from the
call, and the code along that edge destroys local objects in scope before
resuming unwinding.

On Tue, Oct 6, 2015 at 9:25 AM, Welson Sun via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hi,
>
> I am trying to understand some LLVM IR Clang generates. Since I cannot
> publish the source code, I can only describe what I see and my guess.
>
> This is the main() function of some code, which allocates some memory and
> sequentially calls a list of functions. There are no explicit exception
> handling code in the source code, however, *for each function call*, the
> LLVM IR for the function call becomes "invoke ... unwind ...". I am
> wondering what causes the generation of such code. One thing I noticed in
> the source code is the exit() call in main().
>
> If I compile with -fno-exceptions, all function calls become normal
> "call", without any "unwind" attribute.
>
>
> Thanks
> - Welson
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151006/ff76ce95/attachment.html>


More information about the cfe-dev mailing list