[PATCH] D28404: IRGen: Add optnone attribute on function during O0

Paul Robinson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 11 11:04:44 PST 2017


probinson added a comment.

@rsmith could you say whether it seems reasonable to have a LangOpts flag that basically means "`pragma clang optimize off` is always in effect."  I think it would make the other optnone-related logic simpler.  It would not be the only sort-of-codegen-related flag in LangOpts (e.g. the PIC/PIE stuff).

In https://reviews.llvm.org/D28404#641538, @probinson wrote:

> There is another way to make use of the attribute, which I think will be more robust:
>
> Have Sema pretend the pragma is in effect at all times, at -O0.  Then all the existing conflict detection/resolution logic Just Works, and there's no need to spend 4 lines of code hoping to replicate the correct conditions in CodeGenModule.
>
> Because Sema does not have a handle on CodeGenOptions and therefore does not a-priori know the optimization level, probably the right thing to do is move the flag to LangOpts and set it under the correct conditions in CompilerInvocation.  It wouldn't be the first codegen-like option in LangOpts.



https://reviews.llvm.org/D28404





More information about the cfe-commits mailing list