[PATCH] D74298: Honor -finline-functions and -finline-hint-functions at -O0

David Zarzycki via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 9 09:19:18 PST 2020


davezarzycki created this revision.
davezarzycki added a reviewer: chandlerc.
davezarzycki added a project: clang.

This fixes a regression introduced (over three years ago!) by fcd33149b48885ab8e4ca4ffb6977bce5be2e623.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74298

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -694,19 +694,23 @@
   Opts.setInlining((Opts.OptimizationLevel == 0)
                        ? CodeGenOptions::OnlyAlwaysInlining
                        : CodeGenOptions::NormalInlining);
-  // Explicit inlining flags can disable some or all inlining even at
-  // optimization levels above zero.
+  // Handle inlining overrides
   if (Arg *InlineArg = Args.getLastArg(
           options::OPT_finline_functions, options::OPT_finline_hint_functions,
           options::OPT_fno_inline_functions, options::OPT_fno_inline)) {
-    if (Opts.OptimizationLevel > 0) {
-      const Option &InlineOpt = InlineArg->getOption();
-      if (InlineOpt.matches(options::OPT_finline_functions))
-        Opts.setInlining(CodeGenOptions::NormalInlining);
-      else if (InlineOpt.matches(options::OPT_finline_hint_functions))
-        Opts.setInlining(CodeGenOptions::OnlyHintInlining);
-      else
-        Opts.setInlining(CodeGenOptions::OnlyAlwaysInlining);
+    const Option &InlineOpt = InlineArg->getOption();
+    if (InlineOpt.matches(options::OPT_fno_inline)) {
+      Opts.setInlining(CodeGenOptions::OnlyAlwaysInlining);
+    } else if (InlineOpt.matches(options::OPT_fno_inline_functions)) {
+      Opts.setInlining(CodeGenOptions::OnlyAlwaysInlining);
+    } else if (InlineOpt.matches(options::OPT_finline_functions)) {
+      Opts.setInlining(CodeGenOptions::NormalInlining);
+    } else {
+      assert(InlineOpt.matches(options::OPT_finline_hint_functions) &&
+             "Option parsing bug");
+      Opts.setInlining(Args.hasArg(OPT_finline_functions)
+                           ? CodeGenOptions::NormalInlining
+                           : CodeGenOptions::OnlyHintInlining);
     }
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74298.243451.patch
Type: text/x-patch
Size: 1914 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200209/f0b61e3e/attachment.bin>


More information about the cfe-commits mailing list