Hi Devs,
going by this link https://llvm.org/docs/LangRef.html#floatenv
it says that floating point operation does not have side effects by defaults.
but when compile a test case
i.e.
cat a.c
float foo(float a, float b)
{
return a+b;
}
$clang a.c -O2 -S -emit-llvm
emit ir like:
$cat a.ll
if TrappingMath is false it should set “-fno-trapping-math”,but it isn’t because there is another else if.
it should be changed to
if (TrappingMath) {
// FP Exception Behavior is also set to strict
assert(FPExceptionBehavior.equals(“strict”));
CmdArgs.push_back("-ftrapping-math");
} else
CmdArgs.push_back("-fno-trapping-math");
I haven't looked in a few months, but IINM, -trapping-math is a no-op
in LLVM. But yes, what you found is confusing and should be sorted
out.
The front end currently generates experimental constrained intrinsics
if -ftrapping-math is present on the command line. If you want to
generate trap-safe code, you could try that option or
-ffp-model/-ffp-exception-behavior depending on your needs.