Talk

C++ exceptions through the prism of compiler optimizations

  • In Russian
Presentation pdf

21 century is outside, non-productive implementation of C++ exception handling based on setjmp/longjmp is a past. Modern compilers such as gcc and clang use an advanced implementation of C++ exceptions called zero-cost exception handling. But is this real zero-cost? Yes, we pay by increasing the size of binary file and also in the case when the exception is thrown starting the stack unwinding process calling destructors for local objects, etc. But do we lose performance if an exception isn't thrown? Are there any restrictions on compiler optimizations?

This talk describes how C++ exceptions affect compiler optimizations. Which optimizations can't be applied if the function can throw exceptions and which optimizations become more difficult to apply.

Examples of exceptions implementations and compiler optimizations are considered based on LLVM.

Talk aims to give an understanding of when it makes sense to build your application with -fno-exceptions and when you can enjoy C ++ exceptions, knowing that the code has not significantly lost performance compared to code where exceptions are disabled.

  • #exceptions
  • #llvm
  • #optimizations

Speakers

Talks