Skip to content

Commit ea7aff4

Browse files
aratajewigcbot
authored andcommitted
Remove OptimizeNone attribute from optnone builtins after clang
compilation.
1 parent afd9bc4 commit ea7aff4

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

IGC/AdaptorCommon/ProcessFuncAttributes.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -413,20 +413,27 @@ bool ProcessFuncAttributes::runOnModule(Module& M)
413413
if (isKernel)
414414
continue;
415415

416+
// OptNone builtins are special versions of builtins assuring that all
417+
// theirs parameters are constant values.
418+
if(isOptNoneBuiltin(F->getName()))
419+
{
420+
// OptimizeNone attribute was only required to prevent clang optimizations.
421+
// We can remove it now to unblock IGC optimizations.
422+
F->removeFnAttr(llvm::Attribute::OptimizeNone);
423+
// Treat optnone builtins as stackcalls to avoid kernel bloat.
424+
pCtx->m_enableStackCall = true;
425+
F->addFnAttr("visaStackCall");
426+
continue;
427+
}
428+
416429
// Flag for function calls where alwaysinline must be true
417430
bool mustAlwaysInline = false;
418431

419432
// Add always attribtue if function is a builtin
420433
if (F->hasFnAttribute(llvm::Attribute::Builtin) ||
421434
F->getName().startswith(spv::kLLVMName::builtinPrefix))
422435
{
423-
if(isOptNoneBuiltin(F->getName()))
424-
{
425-
pCtx->m_enableStackCall = true;
426-
F->addFnAttr("visaStackCall");
427-
}
428-
else
429-
mustAlwaysInline = true;
436+
mustAlwaysInline = true;
430437
}
431438
// inline all OCL math functions if __FastRelaxedMath is set
432439
else if (fastMathFunct.find(F) != fastMathFunct.end())

0 commit comments

Comments
 (0)