This is an archive of the discontinued LLVM Phabricator instance.

Add function attribute 'optnone'
ClosedPublic

Authored by andreadb on Aug 5 2013, 10:02 AM.

Details

Reviewers
andreadb
Summary

Hi all,

here is the first of a sequence of patches that implements a new function attributed called 'optnone'.
Attribute optnone has been discussed here: http://llvm.1065342.n5.nabble.com/RFC-add-Function-Attribute-to-disable-optimization-td58549.html

Function attribute 'optnone' indicates that the function is not optimized by optimization or code generation passes with the exception of interprocedural optimization passes. This attribute cannot be used together with the 'alwaysinline' attribute; also it is incompatible with both 'minsize' and 'optsize'.
The inliner is not allowed to inline functions marked as 'optnone' in any situation. 'alwaysinline' functions are the only valid candidates for inlining inside the body of 'optnone' functions.

This patch defines the optnone function attribute.
I added rules to check that optnone is never used along with 'alwaysinline' or 'optsize' or 'minsize'.
I added a test under Features to verify that we correctly assemble/disassemble 'optnone'; this also required a small change in the bitcode reader/writer.
This patch also updates LangRef.rst with a short description of the new attribute.

A patch will follow that implements the required changes to the optimizer.
The last patch of the sequence will add support for the attribute to clang.

Please let me know what you think. Any feedback would be appreciated.

Thanks,
Andrea Di Biagio
SN Systems - Sony Computer Entertainment Group

Diff Detail

Event Timeline

Ping.
Any feedback on this?

void added a comment.Aug 21 2013, 5:30 PM

Hi Andrea,

What was the status of the proposal to add this new attribute? Was it accepted that it should be added?

-bw

Hi Bill,

The proposal didn't receive strong objections but nor did it receive a clear accept. The lack of proper feedback made it difficult to understand what to do next. A couple of colleagues discussed this at one of the last Bay-area socials; the consensus there was that sending a first patch for review would be a reasonable next-step since nobody really expressed strong objections on it.

Thanks,
Andrea Di Biagio

void added a comment.Aug 22 2013, 11:50 AM

Okay. The patch looks good to me. I skimmed over the thread you linked here. It sounds like people are generally in favor of this option. I say go ahead and commit it. If there are strong objections afterwards, we can revert this before the next release.

-bw

Bill, Thanks for the review.
I committed this patch at r189101.
I agree that if there will be strong objections, then this patch can be reverted.

Thanks,
Andrea Di Biagio

andreadb accepted this revision.Sep 5 2013, 10:54 AM
andreadb closed this revision.