Skip to content

Commit 226e1ef

Browse files
aparshin-intelKonstantin Vladimirov
authored and
Konstantin Vladimirov
committed
remove counter-intuitive modifications of inline attributes
1 parent e3bdf0b commit 226e1ef

File tree

4 files changed

+53
-32
lines changed

4 files changed

+53
-32
lines changed

include/clang/Basic/CodeGenOptions.def

-3
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,6 @@ CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is
152152
CODEGENOPT(EnableSegmentedStacks , 1, 0) ///< Set when -fsplit-stack is enabled.
153153
CODEGENOPT(NoImplicitFloat , 1, 0) ///< Set when -mno-implicit-float is enabled.
154154
CODEGENOPT(NoInfsFPMath , 1, 0) ///< Assume FP arguments, results not +-Inf.
155-
CODEGENOPT(NoInline , 1, 0) ///< Set when -fno-inline is enabled.
156-
///< Disables use of the inline keyword.
157-
CODEGENOPT(ForceNoInline, 1, 1) ///< Set noinline as the default attribute
158155
CODEGENOPT(NoSignedZeros , 1, 0) ///< Allow ignoring the signedness of FP zero
159156
CODEGENOPT(NullPointerIsValid , 1, 0) ///< Assume Null pointer deference is defined.
160157
CODEGENOPT(Reassociate , 1, 0) ///< Allow reassociation of FP math ops

lib/CodeGen/CodeGenFunction.cpp

+8-27
Original file line numberDiff line numberDiff line change
@@ -862,34 +862,15 @@ void CodeGenFunction::StartFunction(GlobalDecl GD,
862862
assert(CurFn->isDeclaration() && "Function already has body?");
863863

864864
// Pass inline keyword to optimizer if it appears explicitly on any
865-
// declaration. Also, in the case of -fno-inline attach NoInline
866-
// attribute to all function that are not marked AlwaysInline.
865+
// declaration.
867866
if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D)) {
868-
if (!CGM.getCodeGenOpts().NoInline) {
869-
for (auto RI : FD->redecls())
870-
if (RI->isInlineSpecified()) {
871-
// For MDF CM, emit inline attribute as alwaysinline.
872-
if (getLangOpts().MdfCM)
873-
Fn->addFnAttr(llvm::Attribute::AlwaysInline);
874-
else
875-
Fn->addFnAttr(llvm::Attribute::InlineHint);
876-
break;
877-
}
878-
} else if (!FD->hasAttr<AlwaysInlineAttr>())
879-
Fn->addFnAttr(llvm::Attribute::NoInline);
880-
881-
// For a GenX function if it is not alwaysinline, it will be noinline to
882-
// match the old compiler's behavior. This behavior can be overwritten
883-
// with option -fno-force-noinline.
884-
//
885-
// For C++ members, make them always inline to optimize away this pointer.
886-
if (getLangOpts().MdfCM && FD->isCXXInstanceMember())
887-
Fn->addFnAttr(llvm::Attribute::AlwaysInline);
888-
889-
if (getLangOpts().MdfCM &&
890-
CGM.getCodeGenOpts().ForceNoInline &&
891-
!Fn->getAttributes().hasAttrSomewhere(llvm::Attribute::AlwaysInline))
892-
Fn->addFnAttr(llvm::Attribute::NoInline);
867+
for (auto RI : FD->redecls()) {
868+
if (RI->isInlineSpecified()) {
869+
// For MDF CM, emit inline attribute as alwaysinline.
870+
if (getLangOpts().MdfCM)
871+
Fn->addFnAttr(llvm::Attribute::AlwaysInline);
872+
}
873+
}
893874
}
894875

895876
// Finer control on the loop info for MDF cm.

lib/Frontend/CompilerInvocation.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -779,8 +779,6 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
779779
Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops,
780780
(Opts.OptimizationLevel > 1));
781781

782-
// For CM only, set as noinline for functions without inline attribute.
783-
Opts.ForceNoInline = !Args.hasArg(OPT_fno_force_noinline);
784782
if (Args.hasArg(OPT_mCM_import_bif))
785783
Opts.GenXBiFName = Args.getLastArgValue(OPT_mCM_import_bif);
786784
// By default, CM global variables are not default initialized, this option
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*========================== begin_copyright_notice ============================
2+
3+
Copyright (C) 2021 Intel Corporation
4+
5+
SPDX-License-Identifier: MIT
6+
7+
============================= end_copyright_notice ===========================*/
8+
9+
// RUN: IGC_CMFE_CC1_EXTRA="-O2;-disable-llvm-passes" %cmc -fcmocl -march=skl -emit-llvm -S -o %t.ll -- %s
10+
// RUN: FileCheck --input-file=%t.ll %s --check-prefixes=MODE_O2,MODE_O2_NO_NOINLINE
11+
// RUN: FileCheck --input-file=%t.ll %s --check-prefixes=MODE_O2,MODE_O2_NO_OPTNONE
12+
// MODE_O2: subgroup_8{{.*}}#[[SUBGROUP_ATTR:[0-9]+]]
13+
// MODE_O2: attributes #[[SUBGROUP_ATTR]] = {
14+
// MODE_O2_NO_NOINLINE-NOT: noinline
15+
// MODE_O2_NO_OPTNONE-NOT: optnone
16+
// MODE_O2-SAME: }
17+
18+
// RUN: %cmc -fcmocl -march=skl -emit-llvm -S -o %t.ll -- %s
19+
// RUN: FileCheck --input-file=%t.ll %s --check-prefixes=MODE_O0,MODE_O0_NOINLINE
20+
// RUN: FileCheck --input-file=%t.ll %s --check-prefixes=MODE_O0,MODE_O0_OPTNONE
21+
// MODE_O0: subgroup_8{{.*}}#[[SUBGROUP_ATTR:[0-9]+]]
22+
// MODE_O0: attributes #[[SUBGROUP_ATTR]] = {
23+
// MODE_O0_NOINLINE-SAME: noinline
24+
// MODE_O0_OPTNONE-SAME: optnone
25+
26+
#include <cm/cm.h>
27+
28+
int S1(vector<int, 8> v_out) {
29+
return v_out[0];
30+
}
31+
32+
extern "C" _GENX_MAIN_ void subgroup_8(
33+
SurfaceIndex L [[type("buffer_t")]],
34+
SurfaceIndex R [[type("buffer_t")]],
35+
SurfaceIndex Res [[type("buffer_t")]]
36+
) {
37+
vector<int64_t, 8> l;
38+
vector<int64_t, 8> res;
39+
40+
read(L, 0, l);
41+
res = S1(l);
42+
43+
write(Res, 0, res);
44+
}
45+

0 commit comments

Comments
 (0)