[cfe-dev] [LLVMdev] [PROPOSAL] per-function optimization level control

Xinliang David Li xinliangli at gmail.com
Thu Jun 13 11:15:29 PDT 2013


GCC's optimize attribute should work fine (at least with trunk):

__attribute__((optimize("O3","no-tree-pre"))) int foo( ...)
{
    ...
}

will turn on -O3 for 'foo', but disable PRE pass for it.

If you see any problems there, you should file a bug.

Regarding Andrea's proposal -- the new #pragma can be useful (in rare
cases when there is a compiler bug), the intended use cases are
questionable:
1) it should not be used as a mechanism to triage compiler bugs -- the
compiler backend should have mechanism to allow any pass to be
disabled for any (range of) function(s) via command line options so
that it can be automated -- you should not expect doing this via
source modification
2) Improve debuggability of optimized code. GCC has -Og option that
can be used to generate well optimized code with good debuggability.
3) there is a much bigger issue if the customer needs to resort to
this pragmas frequently to hide optimizer bugs.



David


On Wed, Jun 12, 2013 at 8:11 AM, Dallman, John <john.dallman at siemens.com> wrote:
>> Although both cases would be nice and our users have expressed some
>> interest in both, the critical one is the second case of making sure that
>> some functions are never optimized is the most critical one.  The major
>> use-case for this is for ease of debugging optimized builds.
>
> I have a similar usage case: I work on code that tends to show up optimiser
> bugs, possibly because it is very thoroughly tested. Optimization control
> pragmas are invaluable for locating optimizer bugs in a particular function;
> the lack of them is one of the reasons why my GCC and Clang builds don't have
> optimization turned up so high as on some other compilers.
>
> --
> John Dallman
> -----------------
> Siemens Industry Software Limited is a limited company registered in England and Wales.
> Registered number: 3476850.
> Registered office: Faraday House, Sir William Siemens Square, Frimley, Surrey, GU16 8QD.
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



More information about the cfe-dev mailing list