Skip to content

opencl-neo build fails on non-checked llvm::Expected on IGC side #77

Closed
@dvrogozh

Description

@dvrogozh

The build of scheduler.cl via ocloc:
LD_LIBRARY_PATH=/home/compute-runtime/build/bin /home/compute-runtime/build/bin/ocloc -q -file scheduler.cl -device skl -cl-intel-greater-than-4GB-buffer-required -64 -out_dir /home/compute-runtime/build/bin/scheduler/x64/gen9 -cpp_file -options -I/home/install.llvm8.igc/include/igc\ -I/home/install.llvm8.igc/include/igc/cif\ -I/home/install.llvm8.igc/include/igc/ocl_igc_shared/executable_format\ -I/home/install.llvm8.igc/include/igc/ocl_igc_shared/device_enqueue\ -I\ ../gen9\ -cl-kernel-arg-info\ -cl-std=CL2.0

May fail as follows:

Expected<T> must be checked before access or destruction.
Expected<T> value was in success state. (Note: Expected<T> values in success mode must still be checked prior to being destroyed).

#0  0x00007ffff6e05277 in raise () from /lib64/libc.so.6
#1  0x00007ffff6e06968 in abort () from /lib64/libc.so.6
#2  0x00007ffff2dfbbc3 in llvm::Expected<std::unique_ptr<llvm::Module, std::default_delete<llvm::Module> > >::fatalUncheckedExpected() const () from /lib64/libigc.so
#3  0x00007ffff2fe2035 in IGC::PreCompiledFuncImport::runOnModule(llvm::Module&) [clone .part.576] () from /lib64/libigc.so
#4  0x00007ffff3ef2972 in (anonymous namespace)::MPPassManager::runOnModule (this=0x804140, M=...) at /home/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1744
#5  0x00007ffff3ef310a in llvm::legacy::PassManagerImpl::run (this=0x7abd00, M=...) at /home/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1857
#6  0x00007ffff3ef3339 in llvm::legacy::PassManager::run (this=0x7fffffffc7a0, M=...) at /home/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1888
#7  0x00007ffff2f552fc in void IGC::CodeGen<IGC::OpenCLProgramContext>(IGC::OpenCLProgramContext*, llvm::MapVector<llvm::Function*, IGC::CShaderProgram*, llvm::DenseMap<llvm::Function*, unsigned int, llvm::DenseMapInfo<llvm::Function*>, llvm::detail::DenseMapPair<llvm::Function*, unsigned int> >, std::vector<std::pair<llvm::Function*, IGC::CShaderProgram*>, std::allocator<std::pair<llvm::Function*, IGC::CShaderProgram*> > > >&) () from /lib64/libigc.so
#8  0x00007ffff2f31024 in IGC::CodeGen(IGC::OpenCLProgramContext*) () from /lib64/libigc.so
#9  0x00007ffff2dff074 in TC::TranslateBuild(TC::STB_TranslateInputArgs const*, TC::STB_TranslateOutputArgs*, TC::TB_DATA_FORMAT, IGC::CPlatform const&, float) () from /lib64/libigc.so
#10 0x00007ffff2ecbb51 in IGC::IgcOclTranslationCtx<0ul>::Impl::Translate(unsigned long, CIF::Builtins::Buffer<1ul>*, CIF::Builtins::Buffer<1ul>*, CIF::Builtins::Buffer<1ul>*, CIF::Builtins::Buffer<1ul>*, CIF::Builtins::Buffer<1ul>*, CIF::Builtins::Buffer<1ul>*, unsigned int, void*) const () from /lib64/libigc.so
#11 0x00007ffff2ece273 in IGC::IgcOclTranslationCtx<1ul>::TranslateImpl(unsigned long, CIF::Builtins::Buffer<1ul>*, CIF::Builtins::Buffer<1ul>*, CIF::Builtins::Buffer<1ul>*, CIF::Builtins::Buffer<1ul>*, unsigned int) () from /lib64/libigc.so
#12 0x000000000041d159 in OCLRT::OfflineCompiler::buildSourceCode() ()
#13 0x0000000000420fbe in OCLRT::OfflineCompiler::build() ()
#14 0x0000000000425164 in int SafetyGuardLinux::call<int, OCLRT::OfflineCompiler, int (OCLRT::OfflineCompiler::*)()>(OCLRT::OfflineCompiler*, int (OCLRT::OfflineCompiler::*)(), int) ()
#15 0x0000000000425064 in buildWithSafetyGuard(OCLRT::OfflineCompiler*) ()
#16 0x00000000004117a2 in main ()

This happens because IGC does not check llvm::Expected here:

std::unique_ptr<llvm::Module> m_pBuiltinModule = std::move(*ModuleOrErr);

while it should according to LLVM documentation and it actually does that in few other places except this one.

I was building IGC per this instruction against LLVM-8: https://github.com/dvrogozh/intel-graphics-compiler/tree/rfc_readme. Additionally the following patches were applied:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions