ahatanak added a comment. clang marks the called function `foo` in p1.cpp as nounwind here: https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CodeGenFunction.cpp#L1284
clang can also mark a function declaration as nounwind based on the information in the source code, for example, when it is annotated with `__attribute__((pure))`. I haven't read everything discussed in https://reviews.llvm.org/D18634 yet, but it seems like it's safe to do this optimization when the called function is `linkonce_odr`. If clang or llvm's optimization determines one version of the function doesn't throw, then other versions of the same function can't throw either. But it looks like clang doesn't do the right thing when the `foo` is weak. clang emits a call instead of an invoke when it compiles the following code: int foo() __attribute__((weak, pure)); int bar() noexcept { return foo();}; Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83906/new/ https://reviews.llvm.org/D83906 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits