Hi,
I previously made a proposal for adding a pragma for per-function
optimization level control due to a number of requests from our customers
(See http://comments.gmane.org/gmane.comp.compilers.clang.devel/28958 for
the previous discussion), however the discussion was inconclusive. Some
of my colleagues recently had the opportunity to discuss the proposal with
a number of people at and before the recent Bay Area social where it was
generally agreed that we should resubmit a new scaled-down proposal that
still addresses our users' primary use-case without introducing the
complexity of full per-function optimization level control at this time.
This proposal is to create a new function-level attribute which would tell
the compiler to not to perform any optimizing transformations on the
specified function.
The use-case is to be able to selectively disable optimizations when
debugging a small number of functions in a compilation unit to provide an
-O0-like quality of debugging in cases where compiling the whole unit at
anything less than full optimization would make the program run too
slowly. A useful secondary-effect of this feature would be to allow users
to temporarily work-around optimization bugs in LLVM without having to
reduce the optimization level for the whole compilation unit, however we
do not consider this the most important use-case.
Our suggestion for the name for this attribute is "optnone" which seems to
be in keeping with the existing "optsize" attribute, although it could
equally be called "noopt" or something else entirely. It would be exposed
to Clang users through __attribute__((optnone)) or [[optnone]].
I would like to discuss this proposal with the rest of the community to
share opinions and have feedback on this.