This is an archive of the discontinued LLVM Phabricator instance.

New options -fexceptions-fp-math and -fdenormal-fp-math
ClosedPublic

Authored by SjoerdMeijer on Aug 24 2016, 8:22 AM.

Details

Summary

This adds options -fexceptions-fp-math and -fdenormal-fp-math, which are translated to function attributes. This is intended to be mapped on build attributes FP_exceptions and FP_denormal. Setting these build attributes allows better selection of floating point libraries.

Diff Detail

Repository
rL LLVM

Event Timeline

SjoerdMeijer retitled this revision from to New options -fexceptions-fp-math and -fdenormal-fp-math.
SjoerdMeijer updated this object.
SjoerdMeijer added a subscriber: cfe-commits.
jmolloy edited edge metadata.Aug 26 2016, 1:33 AM

Hi Sjoerd,

These make sense - we currently lack any way to inform the backend of the user's FP strictness requirements for exceptions and denormals which forces us to be conservative in the backend build attribute generation.

Your new -fno-exceptions-fp-math appears to be the same as GCC's "-ftrapping-math" which we already implement in the Driver. In fact, it looks like this code never passes -ftrapping-math through to CC1; it only uses it to determine if -menable-unsafe-fpmath should be set.

Therefore I think passing -ftrapping-math through to CC1 is the right thing here.

It seems to me that GCC doesn't have an equivalent flag to -fdenormal-fp-math, so inventing a flag sounds like the right thing to do. This patch should provide a docs patch for http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation , which is generated from docs/UsersManual.rst.

Cheers,

James

SjoerdMeijer edited edge metadata.

Hi James,

Thanks for the review. I got rid of that new option -fexceptions-fp-math and now use -ftrapping-math for that which indeed was not passed through to CC1.

Cheers.

Hi Sjoerd,

This still needs a docs patch. I'd also really appreciate someone else to help sign this off - While it looks fine, I don't commit enough to clang to give the go-ahead.

Cheers,

James

rengolin edited edge metadata.Aug 26 2016, 8:09 AM

Hi James,

Also looks good to me, though it need docs (in the same patch).

Is there an LLVM counter part to this patch? Where is this going to be used?

From the fact that trapping-math wasn't passed down, its documentation may be missing/outdated/wrong, and probably nothing down the pipe is using it either. What are the plans for that?

cheers,
--renato

SjoerdMeijer edited edge metadata.

Sorry, forgot to add the doc patch, but it has been included now.

This will be used in llvm to emit and appropriately set build attributes ABI_FP_denormal and ABI_FP_exceptions. I am now trying to get a llvm patch ready for that (not uploaded yet, but it will mainly affect only ARMAsmPrinter.cpp and perhaps TargetOptions to query buildattributes).

jmolloy accepted this revision.Aug 26 2016, 9:05 AM
jmolloy edited edge metadata.

LGTM.

Cheers,

James

This revision is now accepted and ready to land.Aug 26 2016, 9:05 AM
This revision was automatically updated to reflect the committed changes.