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

Reid Kleckner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 31 10:26:23 PDT 2022


rnk added a comment.

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.



================
Comment at: clang/lib/Parse/ParsePragma.cpp:3706
-  }
-  PP.Diag(StartLoc, diag::warn_pragma_optimize);
 }
----------------
This diagnostic is probably dead now, please remove it from the .td file.


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