This is an archive of the discontinued LLVM Phabricator instance.

Setting fp trapping mode and denormal type
ClosedPublic

Authored by SjoerdMeijer on Aug 31 2016, 2:57 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

SjoerdMeijer retitled this revision from to Setting fp trapping mode and denormal type.
SjoerdMeijer updated this object.
SjoerdMeijer added a subscriber: llvm-commits.
rengolin edited edge metadata.Aug 31 2016, 3:24 AM

Overall looks good to me, too.

lib/Target/ARM/ARMAsmPrinter.cpp
460 ↗(On Diff #69820)

What if we have conflicting attributes?

jmolloy added inline comments.Aug 31 2016, 3:28 AM
lib/Target/ARM/ARMAsmPrinter.cpp
460 ↗(On Diff #69820)

Then we are completely, totally, and utterly broken. Both currently and with this patch.

The LTO build attribute emission needs full-on rework and there are several FIXMEs to this effect around the AsmPrinter :(

jmolloy accepted this revision.Aug 31 2016, 3:35 AM
jmolloy edited edge metadata.

After discussion with Renato on IRC, we're both happy with this.

This revision is now accepted and ready to land.Aug 31 2016, 3:35 AM
This revision was automatically updated to reflect the committed changes.
echristo reopened this revision.Aug 31 2016, 11:22 AM
echristo added inline comments.
llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp
454–460

No, this isn't the right place or way to do this.

You are going to want to look at iterating over the functions in a module in order to collect and collate options if you want to set a global asm marker.

This revision is now accepted and ready to land.Aug 31 2016, 11:22 AM
arsenm added a subscriber: arsenm.Aug 31 2016, 2:26 PM
arsenm added inline comments.
llvm/trunk/include/llvm/CodeGen/CommandFlags.h
158–159 ↗(On Diff #69850)

Should this be per-FP type? We currently use a subtarget feature for this but need to split between f16/f32/f64

SjoerdMeijer added inline comments.Sep 1 2016, 3:43 AM
llvm/trunk/include/llvm/CodeGen/CommandFlags.h
158–159 ↗(On Diff #69850)

I now see how you are using it. We adopted the same approach as some other fp options (no NaNs, no infs, etc), which are also not per FP type. So to be honest, I don't know if they should.

llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp
454–460

Ok, I will fix this.

arsenm added inline comments.Sep 1 2016, 9:12 AM
llvm/trunk/include/llvm/CodeGen/CommandFlags.h
158–159 ↗(On Diff #69850)

The other options are quite different from this. They are optimization hints that aren't required for correctness (and also are deprecated in favor of the per-instruction flags). The global denormal handling mode is different and required

SjoerdMeijer added inline comments.Sep 1 2016, 9:37 AM
llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp
454–460

I have looked at this again and got well confused (this is a messy bit of llvm). But I came to the same conclusion as earlier: it is not more broken than it already was. For example, options NoNaNsFPMath and NoInfsFPMath have the same problem. I think we all agree that the right approach is to "look at iterating over the functions in a module in order to collect and collate options". Do you want to fix this now? I started drafting a patch that fixes this issue for the options I introduced, but I am not happy with it. It does things in a different way than the other options, and I am not sure TargetMachine is the right place (I can upload the patch though if that is helpful).

SjoerdMeijer edited edge metadata.
SjoerdMeijer removed rL LLVM as the repository for this revision.

First attempt to iterate over the functions in a module in order to collect and collate options.

echristo accepted this revision.Sep 2 2016, 9:57 AM
echristo edited edge metadata.

One nit, then OK.

Thanks!

-eric

lib/Target/TargetMachine.cpp
94 ↗(On Diff #70138)

Bike shed:

No real reason to have this here, just go ahead an have it be a static function in the arm asm printer for now.

Thanks for the review! Will fix and commit.
Cheers.

This revision was automatically updated to reflect the committed changes.
SjoerdMeijer added inline comments.Sep 2 2016, 1:21 PM
llvm/trunk/include/llvm/CodeGen/CommandFlags.h
158–159 ↗(On Diff #69850)

One approach to implement setting denormals per-FP type could be to consider this as the "global flag" that sets all these per-type flags. Then any combination can be made by using the global flag that sets all, or omit it and specify one or more of the per-type flags.