[LLVMdev] Does nounwind have semantics?

Eli Friedman eli.friedman at gmail.com
Sun Jul 21 18:37:14 PDT 2013


On Sun, Jul 21, 2013 at 5:56 PM, Andrew Trick <atrick at apple.com> wrote:
> Does 'nounwind' have semantics that inform optimization passes? It seems to in some cases, but not consistently. For example...
>
> int32_t foo(int32_t* ptr) {
>   int i = 0;
>   int result;
>   do {
>     bar(ptr);
>     result = *ptr;
>     bar(ptr);
>   } while (i++ < *ptr);
>   return result;
> }
>
> Say we have a front end that declares bar as...
>
> declare void @bar(i32*) readonly;
>
> So 'bar' is 'readonly' and 'may-unwind'.

It's impossible to write a readonly function which throws a DWARF
exception.  Given that, I would imagine there are all sorts of bugs
nobody has ever run into.

-Eli



More information about the llvm-dev mailing list