More aggressively apply `noexcept` annotations

Issue #399 new
Dan Bonachea created an issue

Our spec says:

All functions are declared noexcept unless specifically called out.

And we have only a few functions (notably storage allocation) that allow for possible exceptions.

However our current implementation is not very good about actually including noexcept annotations on the declarations of our various functions (internal and external) to tell the compiler analysis about this property. I think it's likely that compiler optimization on client code is suffering due to the potential for exceptions, despite the fact that we've explicitly prohibited them "on paper" in most places.

Much of our code is inline in public headers, where the compiler analysis can see a lack of throws, and I'm less worried about fully-inlinable leaf functions.

I expect this effect to be most pronounced in places where control flow potentially crosses the *.a library boundary, where the analysis of user code cannot assume anything about exceptions that might be thrown out of libupcxx.a (in the absence of LTO or -fno-exceptions). This notably includes things like upcxx::progress() (which is not annotated, but probably should be). Similarly for internal functions like backend::globalize_memory() which are not part of the public API but are a library crossing used to inline implement things like upcxx::to_global_ptr() that might matter to app performance. Probably we should apply the annotation to all functions defined in a *.cpp file.

Comments (7)

  1. Log in to comment