@@ -178,6 +178,9 @@ void CGen8CMProgram::CreateKernelBinaries() {
178178void CGen8CMProgram::GetZEBinary (llvm::raw_pwrite_stream &programBinary,
179179 unsigned pointerSizeInBytes) {
180180 llvm::raw_string_ostream ErrLog{m_ErrorLog};
181+ // Contains buffer to an optional debug info. Should exists till zebuilder
182+ // is destroyed.
183+ std::unique_ptr<llvm::MemoryBuffer> DebugInfoHolder;
181184 iOpenCL::ZEBinaryBuilder zebuilder{m_Platform, pointerSizeInBytes == 8 ,
182185 *m_programInfo, nullptr , 0 };
183186 zebuilder.setGfxCoreFamily (m_Platform.eRenderCoreFamily );
@@ -188,13 +191,14 @@ void CGen8CMProgram::GetZEBinary(llvm::raw_pwrite_stream &programBinary,
188191 kernel->getProgramOutput ().m_programSize , kernel->m_kernelInfo ,
189192 kernel->m_GRFSizeInBytes );
190193 }
194+
191195 if (m_ContextProvider.isProgramDebuggable ()) {
192- auto Buff = buildZeDebugInfo (m_kernels, ErrLog);
193- if (Buff ) {
196+ DebugInfoHolder = buildZeDebugInfo (m_kernels, ErrLog);
197+ if (DebugInfoHolder ) {
194198 // Unfortunately, we do need const_cast here, since API requires void*
195199 void *BufferStart = const_cast <void *>(
196- reinterpret_cast <const void *>(Buff ->getBufferStart ()));
197- zebuilder.addElfSections (BufferStart, Buff ->getBufferSize ());
200+ reinterpret_cast <const void *>(DebugInfoHolder ->getBufferStart ()));
201+ zebuilder.addElfSections (BufferStart, DebugInfoHolder ->getBufferSize ());
198202 }
199203 }
200204 zebuilder.getBinaryObject (programBinary);
0 commit comments