Skip to content

Commit 2a1e219

Browse files
dlei6gpszymich
authored andcommitted
Emit error for unsupported stackcalls only when compiler option is used
Emit error for unsupported stackcalls only when "-emit-lib-compile-errors" compiler option is used.
1 parent e4a1887 commit 2a1e219

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

IGC/AdaptorCommon/AddImplicitArgs.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,15 @@ bool BuiltinCallGraphAnalysis::pruneCallGraphForStackCalls(CallGraph& CG)
557557
// since these attributes are always coupled together.
558558
if (pF->hasFnAttribute("referenced-indirectly"))
559559
{
560-
if (IGC_IS_FLAG_DISABLED(EnableGlobalStateBuffer))
560+
CodeGenContext* pCtx = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
561+
bool emitError = false;
562+
if (pCtx->type == ShaderType::OPENCL_SHADER)
563+
{
564+
// If this option is passed, emit error when extern functions use implicit arg buffer
565+
auto ClContext = static_cast<OpenCLProgramContext*>(pCtx);
566+
emitError = ClContext->m_Options.EmitErrorsForLibCompilation;
567+
}
568+
if (IGC_IS_FLAG_DISABLED(EnableGlobalStateBuffer) && emitError)
561569
{
562570
IGC_ASSERT_MESSAGE(0, "Cannot force inline indirect calls! Requires IA Buffer support, i.e. EnableGlobalStateBuffer = 1");
563571
getAnalysis<CodeGenContextWrapper>().getCodeGenContext()->EmitError("Exported functions does not support implicit arguments", pF);

IGC/Compiler/CodeGenPublic.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,6 +1890,10 @@ namespace IGC
18901890
{
18911891
IsLibraryCompilation = true;
18921892
}
1893+
if (strstr(options, "-emit-lib-compile-errors"))
1894+
{
1895+
EmitErrorsForLibCompilation = true;
1896+
}
18931897
if (const char* op = strstr(options, "-intel-reqd-eu-thread-count"))
18941898
{
18951899
IntelRequiredEUThreadCount = true;
@@ -1909,6 +1913,7 @@ namespace IGC
19091913
bool EnableTakeGlobalAddress = false;
19101914
bool IsLibraryCompilation = false;
19111915
bool IntelRequiredEUThreadCount = false;
1916+
bool EmitErrorsForLibCompilation = false;
19121917
uint32_t requiredEUThreadCount = 0;
19131918
// Enable compiler heuristics ("regSharingHeuristics" in VISA) for large GRF selection.
19141919
bool IntelEnableAutoLargeGRF = false;

IGC/Compiler/Optimizer/OpenCLPasses/LocalBuffers/InlineLocalsResolution.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,10 @@ bool InlineLocalsResolution::unusedGlobal(Value* V, std::unordered_set<Value*>&
296296

297297
void InlineLocalsResolution::collectInfoOnSharedLocalMem(Module& M)
298298
{
299-
299+
const auto pCtx = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
300300
// first we collect SLM usage on GET_MEMPOOL_PTR
301301
if (M.getFunction(BUILTIN_MEMPOOL) != nullptr)
302302
{
303-
const auto pCtx = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
304303
const GT_SYSTEM_INFO platform = pCtx->platform.GetGTSystemInfo();
305304

306305
SmallVector<CallInst*, 8> callsToReplace;
@@ -446,7 +445,14 @@ void InlineLocalsResolution::collectInfoOnSharedLocalMem(Module& M)
446445
}
447446

448447
Function* parentF = user->getParent()->getParent();
449-
if (parentF->hasFnAttribute("referenced-indirectly"))
448+
bool emitError = false;
449+
if (pCtx->type == ShaderType::OPENCL_SHADER)
450+
{
451+
// If this option is passed, emit error when extern functions use local SLM
452+
auto ClContext = static_cast<OpenCLProgramContext*>(pCtx);
453+
emitError = ClContext->m_Options.EmitErrorsForLibCompilation;
454+
}
455+
if (parentF->hasFnAttribute("referenced-indirectly") && emitError)
450456
{
451457
IGC_ASSERT_MESSAGE(0, "Cannot reference localSLM in indirectly-called functions");
452458
getAnalysis<CodeGenContextWrapper>().getCodeGenContext()->EmitError("Cannot reference localSLM in indirectly-called functions", globalVar);

0 commit comments

Comments
 (0)