From 44d061a4714769b33e17c6099a35a61e3c62b726 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Wed, 22 Jun 2016 16:56:16 +0000 Subject: Add support for /Ob1 and -finline-hint-functions flags Add support for /Ob1 (and equivalent -finline-hint-functions), which enable inlining only for functions marked inline, either explicitly (via inline keyword, for example), or implicitly (function definition in class body, for example). This works by enabling inlining pass, and adding noinline attribute to every function not marked inline. Patch by Rudy Pons ! Differential Revision: http://reviews.llvm.org/D20647 llvm-svn: 273440 --- clang/lib/Frontend/CompilerInvocation.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'clang/lib/Frontend/CompilerInvocation.cpp') diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 0836bdcc9f4..ba6f6918aa8 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -442,10 +442,15 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, // -fno-inline-functions overrides OptimizationLevel > 1. Opts.NoInline = Args.hasArg(OPT_fno_inline); if (Arg* InlineArg = Args.getLastArg(options::OPT_finline_functions, + options::OPT_finline_hint_functions, options::OPT_fno_inline_functions)) { - Opts.setInlining( - InlineArg->getOption().matches(options::OPT_finline_functions) ? - CodeGenOptions::NormalInlining : CodeGenOptions::OnlyAlwaysInlining); + 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); } if (Arg *A = Args.getLastArg(OPT_fveclib)) { -- cgit v1.2.3