Skip to content

Commit dab7218

Browse files
FilipFudalasys_zuul
authored andcommitted
Replace memsets with list initialization in SOpenCLKernelInfo
to avoid potential memleaks Change-Id: I39e29a9d9f4a08492f9613f6d047f77f91091b5a
1 parent 6a9d8ec commit dab7218

File tree

3 files changed

+17
-31
lines changed

3 files changed

+17
-31
lines changed

IGC/AdaptorOCL/OCL/KernelAnnotations.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,9 @@ struct ExecutionEnivronment
308308
bool IsFinalizer = false;
309309
bool SubgroupIndependentForwardProgressRequired = false;
310310
bool CompiledForGreaterThan4GBBuffers = false;
311-
DWORD FixedWorkgroupSize[3];
312-
DWORD NumGRFRequired;
313-
DWORD WorkgroupWalkOrder[3] = { 3, 3, 3 };
311+
DWORD FixedWorkgroupSize[3] = {};
312+
DWORD NumGRFRequired = 0;
313+
DWORD WorkgroupWalkOrder[3] = {};
314314
bool HasGlobalAtomics = false;
315315
};
316316

IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ namespace IGC
7373
m_pBtiLayout = &(ctx->btiLayout);
7474
m_Platform = &(ctx->platform);
7575
m_DriverInfo = &(ctx->m_DriverInfo);
76-
77-
// Prefer to not memset a struct - initializers are safer!
78-
memset(&m_kernelInfo.m_kernelProgram, 0, sizeof(SKernelProgram));
7976
}
8077

8178
COpenCLKernel::~COpenCLKernel()

IGC/Compiler/CodeGenPublic.h

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -511,21 +511,10 @@ namespace IGC
511511
int Index;
512512
};
513513

514-
SOpenCLKernelInfo()
515-
{
516-
m_printfBufferAnnotation = nullptr;
517-
m_syncBufferAnnotation = nullptr;
518-
m_startGAS = nullptr;
519-
m_WindowSizeGAS = nullptr;
520-
m_PrivateMemSize = nullptr;
521-
522-
memset(&m_threadPayload, 0, sizeof(m_threadPayload));
523-
memset(&m_executionEnivronment, 0, sizeof(m_executionEnivronment));
524-
memset(&m_kernelProgram, 0, sizeof(m_kernelProgram));
525-
};
514+
SOpenCLKernelInfo() {};
526515

527-
std::string m_kernelName;
528-
QWORD m_ShaderHashCode;
516+
std::string m_kernelName = {};
517+
QWORD m_ShaderHashCode = {};
529518

530519
std::vector<iOpenCL::PointerInputAnnotation*> m_pointerInput;
531520
std::vector<iOpenCL::PointerArgumentAnnotation*> m_pointerArgument;
@@ -538,26 +527,26 @@ namespace IGC
538527
std::vector<iOpenCL::KernelArgumentInfoAnnotation*> m_kernelArgInfo;
539528
std::vector<iOpenCL::PrintfStringAnnotation*> m_printfStringAnnotations;
540529

541-
iOpenCL::PrintfBufferAnnotation* m_printfBufferAnnotation;
542-
iOpenCL::SyncBufferAnnotation* m_syncBufferAnnotation;
543-
iOpenCL::StartGASAnnotation* m_startGAS = NULL;
544-
iOpenCL::WindowSizeGASAnnotation* m_WindowSizeGAS = NULL;
545-
iOpenCL::PrivateMemSizeAnnotation* m_PrivateMemSize = NULL;
546-
std::string m_kernelAttributeInfo;
530+
iOpenCL::PrintfBufferAnnotation* m_printfBufferAnnotation = nullptr;
531+
iOpenCL::SyncBufferAnnotation* m_syncBufferAnnotation = nullptr;
532+
iOpenCL::StartGASAnnotation* m_startGAS = nullptr;
533+
iOpenCL::WindowSizeGASAnnotation* m_WindowSizeGAS = nullptr;
534+
iOpenCL::PrivateMemSizeAnnotation* m_PrivateMemSize = nullptr;
535+
std::string m_kernelAttributeInfo = {};
547536

548537
bool m_HasInlineVmeSamplers = false;
549538

550539
// This maps argument numbers to BTI and sampler indices
551540
// (e.g. kernel argument 3, which is is an image_2d, may be mapped to BTI 6)
552-
std::map<DWORD, unsigned int> m_argIndexMap;
541+
std::map<DWORD, unsigned int> m_argIndexMap = {};
553542

554-
iOpenCL::ThreadPayload m_threadPayload;
543+
iOpenCL::ThreadPayload m_threadPayload = {};
555544

556-
iOpenCL::ExecutionEnivronment m_executionEnivronment;
545+
iOpenCL::ExecutionEnivronment m_executionEnivronment = {};
557546

558-
iOpenCL::KernelTypeProgramBinaryInfo m_kernelTypeInfo;
547+
iOpenCL::KernelTypeProgramBinaryInfo m_kernelTypeInfo = {};
559548

560-
SKernelProgram m_kernelProgram;
549+
SKernelProgram m_kernelProgram = {};
561550
};
562551

563552

0 commit comments

Comments
 (0)