<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/62403>62403</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            `AttributeError: type object 'Missed' has no attribute 'demangler_lock'` running opt-viewer
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          nico
      </td>
    </tr>
</table>

<pre>
    On an M1 Max.

Compiling this file https://github.com/ibogosavljevic/johnysswlab/blob/f677ea00bde2fcc69f48e36d2028619e428c05ef/2022-12-optimizationreport/compiler-optimizations.cpp

Installed deps with `pip3 install pygments` and `pip3 install PyYAML`.

```
% clang -O3 comp-opt.cc -fsave-optimization-record -c -std=c++17

% python3 ~/src/llvm-project/llvm/tools/opt-viewer/opt-viewer.py comp-opt.opt.yaml     
Reading YAML files...
Rendering index page...
Rendering HTML files...
        2 of 2multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/multiprocessing/pool.py", line 48, in mapstar
    return list(map(*args))
  File "/Users/thakis/src/llvm-project/llvm/tools/opt-viewer/optpmap.py", line 25, in _wrapped_func
    return func(argument, filter_)
  File "/Users/thakis/src/llvm-project/llvm/tools/opt-viewer/opt-viewer.py", line 243, in _render_file
    SourceFileRenderer(source_dir, output_dir, filename, no_highlight).render(remarks)
  File "/Users/thakis/src/llvm-project/llvm/tools/opt-viewer/opt-viewer.py", line 184, in render
    self.render_source_lines(self.source_stream, line_remarks)
  File "/Users/thakis/src/llvm-project/llvm/tools/opt-viewer/opt-viewer.py", line 105, in render_source_lines
    self.render_inline_remarks(remark, html_line)
  File "/Users/thakis/src/llvm-project/llvm/tools/opt-viewer/opt-viewer.py", line 108, in render_inline_remarks
    inlining_context = r.DemangledFunctionName
  File "/Users/thakis/src/llvm-project/llvm/tools/opt-viewer/optrecord.py", line 146, in DemangledFunctionName
    return self.demangle(self.Function)
 File "/Users/thakis/src/llvm-project/llvm/tools/opt-viewer/optrecord.py", line 70, in demangle
    with cls.demangler_lock:
AttributeError: type object 'Missed' has no attribute 'demangler_lock'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/thakis/src/llvm-project/llvm/tools/opt-viewer/opt-viewer.py", line 379, in <module>
    main()
  File "/Users/thakis/src/llvm-project/llvm/tools/opt-viewer/opt-viewer.py", line 368, in main
    generate_report(all_remarks,
  File "/Users/thakis/src/llvm-project/llvm/tools/opt-viewer/opt-viewer.py", line 292, in generate_report
    optpmap.pmap(_render_file_bound,
  File "/Users/thakis/src/llvm-project/llvm/tools/opt-viewer/optpmap.py", line 50, in pmap
    result = pool.map(_wrapped_func, func_and_args, *args, **kwargs)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/multiprocessing/pool.py", line 364, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/multiprocessing/pool.py", line 771, in get
    raise self._value
AttributeError: type object 'Missed' has no attribute 'demangler_lock'
```


Works fine if I pass `-j 1` too.

Also mentioned here https://github.com/androm3da/optviewer-demo/issues/4#issuecomment-718117214 and here https://reviews.llvm.org/D41784.

This is at LLVM e23891a3823e6bf (yesterday's HEAD).

@anemet 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUWF1v4zYW_TX0C2FBomRJfvCDJx6hBSbbojvb3X0yKOpK4oQiCZKKx33Y3764smzHbjoPu02KCRwn_NQ594P3UNx72WmADVl9IKvdgo-hN26jpTCL2jTH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