feature: use llvm bc for ir-level linking as alternative to spirv

This forces clCompile outputs (clLink inputs) to use llvm bc format
unless underlying compiler's preferred IR is spirV.

Related-To: NEO-16362

Signed-off-by: Chodor, Jaroslaw <jaroslaw.chodor@intel.com>
This commit is contained in:
Chodor, Jaroslaw
2025-10-12 17:42:38 +00:00
committed by Compute-Runtime-Automation
parent 8e60b53415
commit 6a280a4790
3 changed files with 26 additions and 0 deletions

View File

@@ -211,6 +211,9 @@ TranslationOutput::ErrorCode CompilerInterface::compile(
if (outType == IGC::CodeType::undefined) { if (outType == IGC::CodeType::undefined) {
outType = getPreferredIntermediateRepresentation(device); outType = getPreferredIntermediateRepresentation(device);
if (outType != IGC::CodeType::spirV) {
outType = IGC::CodeType::llvmBc;
}
} }
CIF::CIFMain *fclMain = nullptr; CIF::CIFMain *fclMain = nullptr;

View File

@@ -169,6 +169,13 @@ class MockCompilerInterface : public CompilerInterface {
} }
}; };
IGC::CodeType::CodeType_t getPreferredIntermediateRepresentation(const Device &device) override {
if (preferredIr != IGC::CodeType::undefined) {
return preferredIr;
}
return CompilerInterface::getPreferredIntermediateRepresentation(device);
}
static std::vector<char> getDummyGenBinary(); static std::vector<char> getDummyGenBinary();
static void releaseDummyGenBinary(); static void releaseDummyGenBinary();
@@ -190,6 +197,7 @@ class MockCompilerInterface : public CompilerInterface {
SipKernelType requestedSipKernel = SipKernelType::count; SipKernelType requestedSipKernel = SipKernelType::count;
IGC::IgcOclDeviceCtxTagOCL *peekIgcDeviceCtx(Device *device) { return igcDeviceContexts[device].get(); } IGC::IgcOclDeviceCtxTagOCL *peekIgcDeviceCtx(Device *device) { return igcDeviceContexts[device].get(); }
IGC::CodeType::CodeType_t preferredIr = IGC::CodeType::undefined;
}; };
template <> template <>

View File

@@ -173,6 +173,21 @@ TEST_F(CompilerInterfaceTest, WhenPreferredIntermediateRepresentationSpecifiedTh
EXPECT_EQ(TranslationOutput::ErrorCode::success, err); EXPECT_EQ(TranslationOutput::ErrorCode::success, err);
} }
TEST_F(CompilerInterfaceTest, GivenCompileCommandWhenPreferredIntermediateNotSpirvThenUseLlvmBc) {
USE_REAL_FILE_SYSTEM();
CompilerCacheConfig config = {};
config.enabled = false;
auto tempCompilerCache = std::make_unique<CompilerCache>(config);
pCompilerInterface->cache.reset(tempCompilerCache.release());
inputArgs.outType = IGC::CodeType::undefined;
pCompilerInterface->preferredIr = IGC::CodeType::oclC;
TranslationOutput translationOutput;
auto err = pCompilerInterface->compile(*pDevice, inputArgs, translationOutput);
EXPECT_EQ(IGC::CodeType::llvmBc, translationOutput.intermediateCodeType);
EXPECT_EQ(TranslationOutput::ErrorCode::success, err);
}
TEST_F(CompilerInterfaceTest, whenCompilerIsNotAvailableThenBuildFailsGracefully) { TEST_F(CompilerInterfaceTest, whenCompilerIsNotAvailableThenBuildFailsGracefully) {
pCompilerInterface->defaultIgc.entryPoint.reset(nullptr); pCompilerInterface->defaultIgc.entryPoint.reset(nullptr);
pCompilerInterface->failLoadIgc = true; pCompilerInterface->failLoadIgc = true;