[PATCH] D125723: [MSVC] Add support for MSVC pragma optimize

Dávid Bolvanský via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 14 08:15:34 PDT 2022


xbolva00 added a comment.

In D125723#3547789 <https://reviews.llvm.org/D125723#3547789>, @rnk wrote:

> I think it's fine to implement this, but I wanted to share some of the motivation for the current state of things. In our experience, the majority of uses of pragma optimize were to work around MSVC compiler bugs. So, instead of honoring them, we felt it was best to ignore them with a warning (`-Wignored-pragma-optimize`). Of course, that warning is typically disabled in build systems of large projects, so our current behavior can still surprise users. Implementing the feature is probably the most predictable and least surprising thing Clang can do.
>
> Something we can't easily support for either GCC or MSVC attribute is enabling optimizations for some functions in an -O0 build. Maybe it's now possible to set up a full pass pipeline after semantic analysis is complete, but it's not straightforward. You should consider what to do with that corner case.

What is a real motivation to have it in Clang as well? As you said, for MSVC, to work around bugs. You may say optimise(-Oz), but we have attribute minsize for that. Just to match MSVC?

As shown https://reviews.llvm.org/D126984, things work a bit different in Clang vs MSVC/GCC so to justify this pragma, optimise attribute (and related (huge, imho) rework to move other attributes under OptimiseAttr, maybe rework of LLVM attributes), I would like to hear quite strong motivating words.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125723/new/

https://reviews.llvm.org/D125723



More information about the cfe-commits mailing list