Skip to content

Commit d062d53

Browse files
jaladreipsigcbot
authored andcommitted
CodeGenContext changes wrt LLVMContext
Do not leak LLVMContext in InitLLVMContextWrapper Recreate LLVMContext in resetOnRetry
1 parent dc026d1 commit d062d53

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

IGC/Compiler/CodeGenContext.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ LLVMContextWrapper::LLVMContextWrapper(bool createResourceDimTypes) : m_UserAddr
321321
if (WA_OpaquePointersCL && WA_OpaquePointersCL->getNumOccurrences() > 0) {
322322
IGC_IsPointerModeAlreadySet = true;
323323
}
324-
324+
325325
if (IGC::canOverwriteLLVMCtxPtrMode(basePtr, IGC_IsPointerModeAlreadySet)) {
326326
bool enableOpaquePointers = AreOpaquePointersEnabled();
327327
IGCLLVM::setOpaquePointers(basePtr, enableOpaquePointers);
@@ -389,6 +389,9 @@ void CodeGenContext::print(llvm::raw_ostream &stream) const {
389389
}
390390

391391
void CodeGenContext::initLLVMContextWrapper(bool createResourceDimTypes) {
392+
if (llvmCtxWrapper)
393+
llvmCtxWrapper->Release();
394+
392395
llvmCtxWrapper = new LLVMContextWrapper(createResourceDimTypes);
393396
llvmCtxWrapper->AddRef();
394397
}
@@ -704,7 +707,11 @@ void CodeGenContext::EmitWarning(const char *warningstr, const llvm::Value *cont
704707

705708
CompOptions &CodeGenContext::getCompilerOption() { return getModuleMetaData()->compOpt; }
706709

707-
void CodeGenContext::resetOnRetry() { m_tempCount = 0; }
710+
void CodeGenContext::resetOnRetry() {
711+
m_tempCount = 0;
712+
clear();
713+
initLLVMContextWrapper();
714+
}
708715

709716
int32_t CodeGenContext::getNumThreadsPerEU() const { return -1; }
710717

0 commit comments

Comments
 (0)