[SYCL][ESIMD] Fix leak of the demangler output buffer - #23079
Open
uditagarwal97 wants to merge 1 commit into
Open
[SYCL][ESIMD] Fix leak of the demangler output buffer#23079uditagarwal97 wants to merge 1 commit into
uditagarwal97 wants to merge 1 commit into
Conversation
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) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The cleanup follows OutputBuffer’s ownership contract without changing pass behavior.
Pull request overview
Fixes a per-function demangling buffer leak in ESIMD lowering.
Changes:
- Adds
<cstdlib>forstd::free. - Frees the demangled-name buffer after namespace checks.
File summaries
| File | Description |
|---|---|
llvm/lib/SYCLLowerIR/ESIMD/LowerESIMD.cpp |
Releases OutputBuffer storage before returning. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
uditagarwal97
marked this pull request as ready for review
September 1, 2026 23:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
SYCLLowerESIMDPass::prepareForAlwaysInliner()demangles each function name to decide whether it belongs to the ESIMD namespaces:llvm::itanium_demangle::OutputBuffergrows its storage withreallocand has a defaulted destructor — it does not own that storage, and the caller is required tostd::free(getBuffer()). This lambda is invoked once per function in the module and leaks the buffer every time.LeakSanitizer report (ASan+UBSan build, leak reached through
clang++ -fsyclon an ESIMD test):Observed 998 B to ~14 KB per compilation depending on how many ESIMD functions the module contains.
Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com