[llvm-dev] How and where optimizing of undefined behavior happens
David Chisnall via llvm-dev
llvm-dev at lists.llvm.org
Sun Nov 19 04:13:30 PST 2017
On 18 Nov 2017, at 20:55, John Regehr via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>
> By default, Clang has little or nothing to do with UB, its job is to do a straightforward translation to IR.
That’s not quite true, because the mapping to IR helps define what is UB in the source language. For example, if you don’t enable the undefined behaviour sanitiser or pass -ftrapv / -fwrapv, clang will set the nsw (no signed wrap) flag on IR arithmetic operations on types that are signed in C, which then permits the optimisers to treat wrapping behaviour as undefined.
David
More information about the llvm-dev
mailing list