- DxilModule was not freed
- PragmaMatrixHandler was freed twice when the compiler execution was aborted
  prematurely by an exception
- Improve diagnostic tracing in CompilerTest::CompileWhenNoMemThenOOM
This commit is contained in:
Helena Kotas 2018-11-07 12:51:37 -08:00 коммит произвёл GitHub
Родитель 740b6701af
Коммит 2a7c520fcb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 34 добавлений и 7 удалений

Просмотреть файл

@ -117,6 +117,7 @@ DxilModule::DxilModule(Module *pModule)
DXASSERT_NOMSG(m_pModule != nullptr);
m_pModule->pfnRemoveGlobal = &DxilModule_RemoveGlobal;
m_pModule->pfnResetDxilModule = &DxilModule_ResetModule;
#if defined(_DEBUG) || defined(DBG)
// Pin LLVM dump methods.

Просмотреть файл

@ -169,7 +169,8 @@ class Parser : public CodeCompletionHandler {
std::unique_ptr<PragmaHandler> LoopHintHandler;
std::unique_ptr<PragmaHandler> UnrollHintHandler;
std::unique_ptr<PragmaHandler> NoUnrollHintHandler;
std::unique_ptr<PragmaHandler> PackMatrixHandler; // HLSL Change -packmatrix.
PragmaHandler *pPackMatrixHandler = nullptr; // // HLSL Change -packmatrix
std::unique_ptr<CommentHandler> CommentSemaHandler;

Просмотреть файл

@ -251,8 +251,11 @@ void Parser::initializePragmaHandlers() {
} // HLSL Change, matching HLSL check to remove pragma processing
else {
// HLSL Change Begin - packmatrix.
PackMatrixHandler.reset(new PragmaPackMatrixHandler(Actions));
PP.AddPragmaHandler(PackMatrixHandler.get());
// The pointer ownership goes to PP, which deletes it in its destructor
// unless it is removed & deleted via resetPragmaHandlers
std::unique_ptr<PragmaHandler> pHandler(new PragmaPackMatrixHandler(Actions));
PP.AddPragmaHandler(pHandler.get());
pPackMatrixHandler = pHandler.release();
// HLSL Change End.
}
}
@ -328,8 +331,9 @@ void Parser::resetPragmaHandlers() {
} // HLSL Change - close conditional for skipping pragmas
else {
// HLSL Change Begin - packmatrix.
PP.RemovePragmaHandler(PackMatrixHandler.get());
PackMatrixHandler.reset();
PP.RemovePragmaHandler(pPackMatrixHandler);
delete pPackMatrixHandler;
pPackMatrixHandler = nullptr;
// HLSL Change End.
}
}

Просмотреть файл

@ -2565,6 +2565,17 @@ public:
}
virtual void STDMETHODCALLTYPE HeapMinimize(void) {}
void DumpLeaks() {
PtrData *ptr = (PtrData*)AllocList.Flink;;
PtrData *end = (PtrData*)AllocList.Blink;;
WEX::Logging::Log::Comment(FormatToWString(L"Leaks total size: %d", (signed int)m_Size).data());
while (ptr != end) {
WEX::Logging::Log::Comment(FormatToWString(L"Memory leak at 0x0%X, size %d, alloc# %d", ptr + 1, ptr->Size, ptr->AllocAtCount).data());
ptr = (PtrData*)ptr->Entry.Flink;
}
}
};
#ifndef DXC_ON_APPVEYOR_CI
@ -2615,7 +2626,12 @@ TEST_F(CompilerTest, CompileWhenNoMemThenOOM) {
// allocations or references.
//
// First leak is in ((InstrumentedHeapMalloc::PtrData *)InstrMalloc.AllocList.Flink)
VERIFY_IS_TRUE(0 == InstrMalloc.GetSize());
if (InstrMalloc.GetSize() != 0) {
WEX::Logging::Log::Comment(L"Memory leak(s) detected");
InstrMalloc.DumpLeaks();
VERIFY_IS_TRUE(0 == InstrMalloc.GetSize());
}
VERIFY_ARE_EQUAL(initialRefCount, InstrMalloc.GetRefCount());
// In Debug, without /D_ITERATOR_DEBUG_LEVEL=0, debug iterators will be used;
@ -2651,7 +2667,12 @@ TEST_F(CompilerTest, CompileWhenNoMemThenOOM) {
VERIFY_FAILED(hrOp);
pCompiler.Release();
pResult.Release();
VERIFY_IS_TRUE(0 == InstrMalloc.GetSize()); // breakpoint for i failure - i == val
if (InstrMalloc.GetSize() != 0) {
WEX::Logging::Log::Comment(FormatToWString(L"Memory leak(s) detected, allocCount = %d", i).data());
InstrMalloc.DumpLeaks();
VERIFY_IS_TRUE(0 == InstrMalloc.GetSize());
}
VERIFY_ARE_EQUAL(initialRefCount, InstrMalloc.GetRefCount());
}
}