default behavior or

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

I believe support for trapping math is experimental/work in progress: https://reviews.llvm.org/D62731

looks like experimental/work in progress support: https://reviews.llvm.org/D62731

cced the author.

Here is problematic code:
https://github.com/llvm/llvm-project/blob/master/clang/lib/Driver/ToolChains/Clang.cpp#L2836

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");

any thoughts?

./kamlesh

Hi Kamlesh,

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.

https://clang.llvm.org/docs/UsersManual.html#cmdoption-ffp-model

-Cam