diff --git a/level_zero/core/source/module/module_imp.cpp b/level_zero/core/source/module/module_imp.cpp index b968a0a977..c41063580c 100644 --- a/level_zero/core/source/module/module_imp.cpp +++ b/level_zero/core/source/module/module_imp.cpp @@ -1082,7 +1082,7 @@ bool ModuleImp::linkBinary() { isFullyLinked = true; return true; } - Linker linker(*linkerInput); + Linker linker(*linkerInput, type == ModuleType::user); Linker::SegmentInfo globals; Linker::SegmentInfo constants; Linker::SegmentInfo exportedFunctions; @@ -1165,12 +1165,8 @@ bool ModuleImp::linkBinary() { } isFullyLinked = false; return LinkingStatus::linkedPartially == linkStatus; - } else if (type != ModuleType::builtin) { - copyPatchedSegments(isaSegmentsForPatching); } else { - for (auto &kernelDescriptor : kernelDescriptors) { - kernelDescriptor->kernelAttributes.flags.requiresImplicitArgs = false; - } + copyPatchedSegments(isaSegmentsForPatching); } DBG_LOG(PrintRelocations, NEO::constructRelocationsDebugMessage(this->symbols)); diff --git a/level_zero/core/test/unit_tests/sources/module/test_module.cpp b/level_zero/core/test/unit_tests/sources/module/test_module.cpp index da6d6e68f0..9381dc4c6a 100644 --- a/level_zero/core/test/unit_tests/sources/module/test_module.cpp +++ b/level_zero/core/test/unit_tests/sources/module/test_module.cpp @@ -4615,7 +4615,7 @@ TEST_F(ModuleTests, givenConstDataStringSectionWhenLinkingModuleThenSegmentIsPat EXPECT_EQ(static_cast(stringsAddr), *reinterpret_cast(patchAddr)); } -TEST_F(ModuleTests, givenImplicitArgsRelocationAndStackCallsWhenLinkingBuiltinModuleThenSegmentIsNotPatchedAndImplicitArgsAreNotRequired) { +TEST_F(ModuleTests, givenImplicitArgsRelocationWhenLinkingBuiltinModuleThenSegmentIsPatchedWithZeroAndImplicitArgsAreNotRequired) { auto pModule = std::make_unique>(device, nullptr, ModuleType::builtin); char data[64]{}; @@ -4627,7 +4627,6 @@ TEST_F(ModuleTests, givenImplicitArgsRelocationAndStackCallsWhenLinkingBuiltinMo kernelImmData->setIsaPerKernelAllocation(pModule->allocateKernelsIsaMemory(kernelInfo->heapInfo.kernelHeapSize)); kernelImmData->initialize(kernelInfo, device, 0, nullptr, nullptr, true); - kernelImmData->kernelDescriptor->kernelAttributes.flags.useStackCalls = true; auto isaCpuPtr = reinterpret_cast(kernelImmData->isaGraphicsAllocation->getUnderlyingBuffer()); pModule->kernelImmDatas.push_back(std::move(kernelImmData)); pModule->translationUnit->programInfo.kernelInfos.push_back(kernelInfo); diff --git a/shared/source/compiler_interface/linker.cpp b/shared/source/compiler_interface/linker.cpp index 2f737d7acc..7a382509c9 100644 --- a/shared/source/compiler_interface/linker.cpp +++ b/shared/source/compiler_interface/linker.cpp @@ -657,7 +657,8 @@ void Linker::resolveImplicitArgs(const KernelDescriptorsT &kernelDescriptors, De if (pImplicitArgsRelocs != pImplicitArgsRelocationAddresses.end()) { for (const auto &pImplicitArgsReloc : pImplicitArgsRelocs->second) { UNRECOVERABLE_IF(!pDevice); - kernelDescriptor.kernelAttributes.flags.requiresImplicitArgs |= kernelDescriptor.kernelAttributes.flags.useStackCalls || pDevice->getDebugger() != nullptr; + bool addImplcictArgs = kernelDescriptor.kernelAttributes.flags.useStackCalls || (userModule && pDevice->getDebugger() != nullptr); + kernelDescriptor.kernelAttributes.flags.requiresImplicitArgs |= addImplcictArgs; if (kernelDescriptor.kernelAttributes.flags.requiresImplicitArgs) { uint64_t implicitArgsSize = 0; if (pDevice->getGfxCoreHelper().getImplicitArgsVersion() == 0) { diff --git a/shared/source/compiler_interface/linker.h b/shared/source/compiler_interface/linker.h index dab658d06e..e6ab21d879 100644 --- a/shared/source/compiler_interface/linker.h +++ b/shared/source/compiler_interface/linker.h @@ -227,7 +227,11 @@ struct Linker { using ExternalFunctionsT = std::vector; Linker(const LinkerInput &data) - : data(data) { + : Linker(data, true) { + } + + Linker(const LinkerInput &data, bool userModule) + : data(data), userModule(userModule) { } LinkingStatus link(const SegmentInfo &globalVariablesSegInfo, const SegmentInfo &globalConstantsSegInfo, const SegmentInfo &exportedFunctionsSegInfo, @@ -269,6 +273,7 @@ struct Linker { /* to */ std::unordered_map, 2>> pImplicitArgsRelocationAddresses; + bool userModule = true; }; static_assert(NEO::NonCopyableAndNonMovable);