From 4de6027e35eb676c9342680312aaf07b0670ca86 Mon Sep 17 00:00:00 2001 From: "Agarwal, Udit" Date: Tue, 1 Sep 2026 03:48:51 +0200 Subject: [PATCH] [SYCL][ESIMD] Fix leak of the demangler output buffer itanium_demangle's OutputBuffer does not own the buffer it reallocs; the caller must free it. prepareForAlwaysInliner() created one for every function it inspected and dropped it, leaking between 1 and 14 KB per compilation. Co-Authored-By: Claude Opus 5 (1M context) --- llvm/lib/SYCLLowerIR/ESIMD/LowerESIMD.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/llvm/lib/SYCLLowerIR/ESIMD/LowerESIMD.cpp b/llvm/lib/SYCLLowerIR/ESIMD/LowerESIMD.cpp index 7ab30118bb398..9ea5f54989cb0 100644 --- a/llvm/lib/SYCLLowerIR/ESIMD/LowerESIMD.cpp +++ b/llvm/lib/SYCLLowerIR/ESIMD/LowerESIMD.cpp @@ -41,6 +41,7 @@ #include "llvm/Transforms/IPO/AlwaysInliner.h" #include +#include #include #include @@ -1981,12 +1982,16 @@ bool SYCLLowerESIMDPass::prepareForAlwaysInliner(Module &M) { if (NameNode->getKind() == id::Node::KLocalName) return false; + // OutputBuffer does not own its buffer - it must be freed by the caller. id::OutputBuffer NameBuf; NameNode->print(NameBuf); StringRef Name(NameBuf.getBuffer(), NameBuf.getCurrentPosition()); - return Name.starts_with("sycl::_V1::ext::intel::esimd::") || - Name.starts_with("sycl::_V1::ext::intel::experimental::esimd::"); + bool IsESIMDFunction = + Name.starts_with("sycl::_V1::ext::intel::esimd::") || + Name.starts_with("sycl::_V1::ext::intel::experimental::esimd::"); + std::free(NameBuf.getBuffer()); + return IsESIMDFunction; }; bool NeedInline = false; for (auto &F : M) {