exit() emits exception handling?

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

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.

Thanks Reid,

That explains. And the local variables turn out to be of type “std::string”. Although it is not possible to ask the customer not to use std::string, at least I can explain it :slight_smile: Adapting my analysis pass is another thing.

Thanks,
Welson