From: Chad Rosier Date: Tue, 6 Mar 2012 18:49:20 +0000 (+0000) Subject: [driver] Add support for -fno-inline. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=250008b4678b19ef80866702e300bb4e53d9ff2d;p=clang [driver] Add support for -fno-inline. rdar://10972766 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152130 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td index 1aa96f0108..e896e6a4c2 100644 --- a/include/clang/Driver/CC1Options.td +++ b/include/clang/Driver/CC1Options.td @@ -496,6 +496,8 @@ def fgnu_keywords : Flag<"-fgnu-keywords">, HelpText<"Allow GNU-extension keywords regardless of language standard">; def fgnu89_inline : Flag<"-fgnu89-inline">, HelpText<"Use the gnu89 inline semantics">; +def fno_inline : Flag<"-fno-inline">, + HelpText<"Disable function inlining">; def fno_gnu_keywords : Flag<"-fno-gnu-keywords">, HelpText<"Disallow GNU-extension keywords regardless of language standard">; def fdollars_in_identifiers : Flag<"-fdollars-in-identifiers">, diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index dcc0e7bedc..cdfef91521 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -412,7 +412,7 @@ def fno_eliminate_unused_debug_symbols : Flag<"-fno-eliminate-unused-debug-symbo def fno_exceptions : Flag<"-fno-exceptions">, Group; def fno_gnu_keywords : Flag<"-fno-gnu-keywords">, Group; def fno_inline_functions : Flag<"-fno-inline-functions">, Group; -def fno_inline : Flag<"-fno-inline">, Group; +def fno_inline : Flag<"-fno-inline">; def fno_keep_inline_functions : Flag<"-fno-keep-inline-functions">, Group; def fno_lax_vector_conversions : Flag<"-fno-lax-vector-conversions">, Group; def fno_limit_debug_info : Flag<"-fno-limit-debug-info">, Group, diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 08af9f77ca..0849c8d620 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -2138,6 +2138,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, false)) CmdArgs.push_back("-fgnu89-inline"); + if (Args.hasArg(options::OPT_fno_inline)) + CmdArgs.push_back("-fno-inline"); + // -fobjc-nonfragile-abi=0 is default. ObjCRuntime objCRuntime; unsigned objcABIVersion = 0; diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 14cdefb9af..43ac475211 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1096,6 +1096,9 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, // We must always run at least the always inlining pass. Opts.Inlining = (Opts.OptimizationLevel > 1) ? CodeGenOptions::NormalInlining : CodeGenOptions::OnlyAlwaysInlining; + // -fno-inline overrides OptimizationLevel > 1. + Opts.Inlining = Args.hasArg(OPT_fno_inline) ? + CodeGenOptions::OnlyAlwaysInlining : Opts.Inlining; Opts.DebugInfo = Args.hasArg(OPT_g); Opts.LimitDebugInfo = !Args.hasArg(OPT_fno_limit_debug_info) @@ -1915,8 +1918,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, // optimization level and -fno-inline, not actually whether the backend has // inlining enabled. // - // FIXME: This is affected by other options (-fno-inline). - Opts.NoInline = !Opt; + Opts.NoInline = !Opt || Args.hasArg(OPT_fno_inline); Opts.FastMath = Args.hasArg(OPT_ffast_math); diff --git a/test/CodeGen/noinline.c b/test/CodeGen/noinline.c new file mode 100644 index 0000000000..18d34e1600 --- /dev/null +++ b/test/CodeGen/noinline.c @@ -0,0 +1,14 @@ +// Make sure -fno-inline is behaving correctly. +// rdar://10972766 + +// RUN: %clang_cc1 -O3 -fno-inline -emit-llvm %s -o - | FileCheck -check-prefix=NOINLINE %s + +int dont_inline_me(int a, int b) { return(a+b); } + +volatile int *pa = (int*) 0x1000; +void foo() { +// NOINLINE: @foo +// NOINLINE: dont_inline_me + pa[0] = dont_inline_me(pa[1],pa[2]); +} + diff --git a/test/Driver/noinline.c b/test/Driver/noinline.c new file mode 100644 index 0000000000..f6cac03535 --- /dev/null +++ b/test/Driver/noinline.c @@ -0,0 +1,10 @@ +// Make sure the driver is correctly passing -fno-inline +// rdar://10972766 + +// RUN: %clang -target x86_64-apple-darwin10 \ +// RUN: -fno-inline -### -fsyntax-only %s 2> %t +// RUN: FileCheck --check-prefix=CHECK < %t %s + +// CHECK: clang +// CHECK: "-fno-inline" +