[llvm-dev] Is trapping allowed when an add with nsw flag overflows?
David Majnemer via llvm-dev
llvm-dev at lists.llvm.org
Fri Apr 15 10:42:21 PDT 2016
On Fri, Apr 15, 2016 at 10:28 AM, Manuel Jacob via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> In our backend, we currently emit add operations that trap on overflow if
> the IR operation has the nsw flag set. Is this allowed?
No. Operations like `add nsw` can be hoisted around control dependencies
and unconditionally executed.
The only information that flag yields is that downstream users of the
instruction don't need to worry about the instruction producing a result
which results in wrapping when taking it's operands into account.
> According to the documentation about poison values, overflowing a nsw add
> is undefined behavior. However I didn't find a formal definition of
> undefined behavior in LLVM. Judging from previous discussions on the
> mailing list, there seems to be a vague line of what LLVM is allowed to do
> in case of undefined behavior. Is trapping allowed?
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev