[PATCH] D63046: [Attributor] Deduce "willreturn" function attribute

Nick Lewycky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 9 20:17:34 PDT 2019


nicholas added a comment.

In D63046#1535804 <https://reviews.llvm.org/D63046#1535804>, @nicholas wrote:

> > The current algorithm can deduce only for very simple cases.
> > 
> > - A function doesn't have any loop.
> > - A function doesn't have any recursion.
>
> What about functions that exit the program, throw an exception, or longjmp?


I know I just posted, but I think I figured out the right rule. The rule you want is a) doesn't have a cycle b) all calls have `willreturn`. A function with no calls (and no cycles) can have `willreturn`, and a function that calls only `willreturn` functions (and no cycles) can have `willreturn`. That's assuming you don't mind a function being both `willreturn` and `noreturn` at the same time (a function that ends in unreachable). I think we just accept that, there's no point trying to prove any code free from undefined behaviour.

If I'm right, this patch doesn't need to depend on `norecurse`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63046/new/

https://reviews.llvm.org/D63046





More information about the llvm-commits mailing list