[all-commits] [llvm/llvm-project] 88dd82: [opt-viewer] Fix demangler usage with multiprocess...
Ömer Sinan Ağacan via All-commits
all-commits at lists.llvm.org
Sat Oct 3 13:22:26 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 88dd82f800f46c3ec4c16932a705091434e17ae0
https://github.com/llvm/llvm-project/commit/88dd82f800f46c3ec4c16932a705091434e17ae0
Author: Ömer Sinan Ağacan <omer at osa1.net>
Date: 2026-10-03 (Sat, 03 Oct 2026)
Changed paths:
M llvm/tools/opt-viewer/opt-viewer.py
M llvm/tools/opt-viewer/optrecord.py
Log Message:
-----------
[opt-viewer] Fix demangler usage with multiprocessing (#228388)
Because of how `multiprocessing.Pool` creates new processes on macOS,
parallel `_render_file`s create their own demangler processes.
However the CLI flag `--demangler` also does not set an inherited state
that's used by the subprocesses, so the new demanglers are created from
the default command, which is `c++filt -n`.
This also means that the semaphore in class `Remark` is not useful on
macOS. It's also not properly cleaned up, causing warnings on exit:
.../python3.9/multiprocessing/resource_tracker.py:216: UserWarning:
resource_tracker: There appear to be 36 leaked semaphore objects to
clean up at shutdown
With this patch we now pass the `--demangler` value to the `Remark`
class so the subprocesses can make use of it. We also remove the
semaphore and make each subprocess have their own demangler process.
This simplifies the code (no need for locking) as the demangler
processes are cheap to start and keep running and don't need to be
shared.
To observe the bug on macOS, generate inlining remarks with
-fsave-optimization-record -foptimization-record-passes=inline
-gline-tables-only
then render as HTML:
python3 <llvm checkout>/llvm/tools/opt-viewer/opt-viewer.py \
--demangler 'sed -l s/^/[CUSTOM]/' -s <source dir> \
-o html <remark file dir>
In the output, you'll see that the index.html has the demangled symbols
starting with '[CUSTOM]', but if you click on the pages the demangled
symbols don't have the same prefix, because the `--demangler` command is
not used in the subprocesses.
The new demangling implementation should work on all platforms as it no
longer relies on process state inheriting behavior.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list