-
Notifications
You must be signed in to change notification settings - Fork 789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The F# compiler ignores MethodImplOptions.AggressiveInlining
flag
#1637
Comments
It might be beneficial to review the other pseudo-custom attributes (see e.g. the list here) in addition to |
Is this still the case for the latest F# shipped with VS2017? |
AFAIK nobody has fixed this |
I tried to find it in ECMA 335 but it's not there!? |
WIP in #3154 |
btw: it looks like noinlining is not respected as well. |
I have created a simple workaround for this - just to rewrite IL after build and repack it with ilasm. It was simpler than #3154 for me. Such trick was used in corefxlab in the very early implementation of the To add the attribute, one should add a custom attribute Tools and samples are in this folder. I couldn't integrate it with build automatically, but after manually calling rewrite scripts as admin the command This gives small but stable c.5% performance improvement for the hottest method in the library. |
@buybackoff The fix #3154 is now ready |
@dsyme Thanks a lot! When it will be available? Several percents are not a game changer but they are real and free 😄 |
@buybackoff probably not until Visual Studio 2017 Update 4, unless you're using some other packaging of the F# compiler. Maybe Visual Studio 2017 Update 3 but that depends on what the Microsoft ship people decide. |
Merged |
The F# compiler ignores the
System.Runtime.CompilerServices.MethodImplAttribute
applied to methods/functions if theMethodImplOptions.AggressiveInlining
flag is set and consequently doesn't emit the required IL metadata ("aggressiveinlining" method flag = 0x0100).Descriptive Example
For example, compiling the following F# code
yields the following IL
In contrast, the C# compiler translates
to
generating the required
aggressiveinling
flag.Further Experiments
The same behavior can be observed for
MethodImplOptions.AggressiveInlining
flags applied to methods or static methods of class types. Strangely enough, if applied to indexerget
/set
methods, the F# compiler doesn't ignore the attribute, but treats it like a custom attribute (instead of a pseudo custom attribute). For instance,becomes
Known workarounds
None.
Related information
According to @kvb,
PreserveSig
,Synchronized
, andNoInlining
flags seem to be respected by the compiler, see this StackOverflow question.Test environment:
The text was updated successfully, but these errors were encountered: