As discussed in the post-commit thread for:
rL330437 ( http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20180423/545906.html )
We need a way to opt-out of a float-to-int-to-float cast optimization because too much existing code relies on the platform-specific undefined result of those casts when the float-to-int overflows.
I speculatively committed the LLVM changes associated with adding this function attribute, but I'll change the name/implementation if there's a better alternative:
rL330947
rL330950
rL330951
Also as suggested, I changed the LLVM doc to mention the specific sanitizer flag that catches this problem:
rL330958
I tested the end-to-end results on x86 and see the expected outcome: 'roundss' is no longer produced in place of cvttss2si + cvtsi2ss with default optimization.
I would phrase this the other way around (and I think the flag name is already phrased the other way around?):
"""
Enable a workaround for incorrect code that casts floating point values to integers where the floating point value is not representable in the integer type. This code is incorrect according to the language standard, but this flag will attempt to generate code to cause <insert expected behavior with the flag enabled>.
"""
Essentially, this should be more like '-fwrapv'. Also, I think the default should be what the specification says. People can explicitly pass this flag if their code is broken in this way.