diff --git a/include/clang/Basic/CodeGenOptions.def b/include/clang/Basic/CodeGenOptions.def index 25782bfa3b97..bc560c25b7a7 100644 --- a/include/clang/Basic/CodeGenOptions.def +++ b/include/clang/Basic/CodeGenOptions.def @@ -152,9 +152,6 @@ CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is CODEGENOPT(EnableSegmentedStacks , 1, 0) ///< Set when -fsplit-stack is enabled. CODEGENOPT(NoImplicitFloat , 1, 0) ///< Set when -mno-implicit-float is enabled. CODEGENOPT(NoInfsFPMath , 1, 0) ///< Assume FP arguments, results not +-Inf. -CODEGENOPT(NoInline , 1, 0) ///< Set when -fno-inline is enabled. - ///< Disables use of the inline keyword. -CODEGENOPT(ForceNoInline, 1, 1) ///< Set noinline as the default attribute CODEGENOPT(NoSignedZeros , 1, 0) ///< Allow ignoring the signedness of FP zero CODEGENOPT(NullPointerIsValid , 1, 0) ///< Assume Null pointer deference is defined. CODEGENOPT(Reassociate , 1, 0) ///< Allow reassociation of FP math ops diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index ec684d6fbd25..82601f8e392d 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -862,34 +862,15 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, assert(CurFn->isDeclaration() && "Function already has body?"); // Pass inline keyword to optimizer if it appears explicitly on any - // declaration. Also, in the case of -fno-inline attach NoInline - // attribute to all function that are not marked AlwaysInline. + // declaration. if (const FunctionDecl *FD = dyn_cast_or_null(D)) { - if (!CGM.getCodeGenOpts().NoInline) { - for (auto RI : FD->redecls()) - if (RI->isInlineSpecified()) { - // For MDF CM, emit inline attribute as alwaysinline. - if (getLangOpts().MdfCM) - Fn->addFnAttr(llvm::Attribute::AlwaysInline); - else - Fn->addFnAttr(llvm::Attribute::InlineHint); - break; - } - } else if (!FD->hasAttr()) - Fn->addFnAttr(llvm::Attribute::NoInline); - - // For a GenX function if it is not alwaysinline, it will be noinline to - // match the old compiler's behavior. This behavior can be overwritten - // with option -fno-force-noinline. - // - // For C++ members, make them always inline to optimize away this pointer. - if (getLangOpts().MdfCM && FD->isCXXInstanceMember()) - Fn->addFnAttr(llvm::Attribute::AlwaysInline); - - if (getLangOpts().MdfCM && - CGM.getCodeGenOpts().ForceNoInline && - !Fn->getAttributes().hasAttrSomewhere(llvm::Attribute::AlwaysInline)) - Fn->addFnAttr(llvm::Attribute::NoInline); + for (auto RI : FD->redecls()) { + if (RI->isInlineSpecified()) { + // For MDF CM, emit inline attribute as alwaysinline. + if (getLangOpts().MdfCM) + Fn->addFnAttr(llvm::Attribute::AlwaysInline); + } + } } // Finer control on the loop info for MDF cm. diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 5be50aab2dc4..38540a70568d 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -779,8 +779,6 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops, (Opts.OptimizationLevel > 1)); - // For CM only, set as noinline for functions without inline attribute. - Opts.ForceNoInline = !Args.hasArg(OPT_fno_force_noinline); if (Args.hasArg(OPT_mCM_import_bif)) Opts.GenXBiFName = Args.getLastArgValue(OPT_mCM_import_bif); // By default, CM global variables are not default initialized, this option diff --git a/test/CMFE/compiler_options/Ox_modes.cpp b/test/CMFE/compiler_options/Ox_modes.cpp new file mode 100755 index 000000000000..993c5c212fb8 --- /dev/null +++ b/test/CMFE/compiler_options/Ox_modes.cpp @@ -0,0 +1,45 @@ +/*========================== begin_copyright_notice ============================ + +Copyright (C) 2021 Intel Corporation + +SPDX-License-Identifier: MIT + +============================= end_copyright_notice ===========================*/ + +// RUN: IGC_CMFE_CC1_EXTRA="-O2;-disable-llvm-passes" %cmc -fcmocl -march=skl -emit-llvm -S -o %t.ll -- %s +// RUN: FileCheck --input-file=%t.ll %s --check-prefixes=MODE_O2,MODE_O2_NO_NOINLINE +// RUN: FileCheck --input-file=%t.ll %s --check-prefixes=MODE_O2,MODE_O2_NO_OPTNONE +// MODE_O2: subgroup_8{{.*}}#[[SUBGROUP_ATTR:[0-9]+]] +// MODE_O2: attributes #[[SUBGROUP_ATTR]] = { +// MODE_O2_NO_NOINLINE-NOT: noinline +// MODE_O2_NO_OPTNONE-NOT: optnone +// MODE_O2-SAME: } + +// RUN: %cmc -fcmocl -march=skl -emit-llvm -S -o %t.ll -- %s +// RUN: FileCheck --input-file=%t.ll %s --check-prefixes=MODE_O0,MODE_O0_NOINLINE +// RUN: FileCheck --input-file=%t.ll %s --check-prefixes=MODE_O0,MODE_O0_OPTNONE +// MODE_O0: subgroup_8{{.*}}#[[SUBGROUP_ATTR:[0-9]+]] +// MODE_O0: attributes #[[SUBGROUP_ATTR]] = { +// MODE_O0_NOINLINE-SAME: noinline +// MODE_O0_OPTNONE-SAME: optnone + +#include + +int S1(vector v_out) { + return v_out[0]; +} + +extern "C" _GENX_MAIN_ void subgroup_8( + SurfaceIndex L [[type("buffer_t")]], + SurfaceIndex R [[type("buffer_t")]], + SurfaceIndex Res [[type("buffer_t")]] +) { + vector l; + vector res; + + read(L, 0, l); + res = S1(l); + + write(Res, 0, res); +} +