Skip to content

release/20.x: Avoid a race condition in opt-viewer/optrecord (#131214) #134058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions llvm/tools/opt-viewer/optrecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,19 @@ class Remark(yaml.YAMLObject):

default_demangler = "c++filt -n"
demangler_proc = None
demangler_lock = Lock()

@classmethod
def set_demangler(cls, demangler):
cls.demangler_proc = subprocess.Popen(
demangler.split(), stdin=subprocess.PIPE, stdout=subprocess.PIPE
)
cls.demangler_lock = Lock()

@classmethod
def demangle(cls, name):
with cls.demangler_lock:
if not cls.demangler_proc:
cls.set_demangler(cls.default_demangler)
cls.demangler_proc.stdin.write((name + "\n").encode("utf-8"))
cls.demangler_proc.stdin.flush()
return cls.demangler_proc.stdout.readline().rstrip().decode("utf-8")
Expand Down Expand Up @@ -323,8 +325,6 @@ def get_remarks(input_file, filter_=None):
def gather_results(filenames, num_jobs, should_print_progress, filter_=None):
if should_print_progress:
print("Reading YAML files...")
if not Remark.demangler_proc:
Remark.set_demangler(Remark.default_demangler)
remarks = optpmap.pmap(
get_remarks, filenames, num_jobs, should_print_progress, filter_
)
Expand Down
Loading