<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54181>54181</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
The LLVM remark diagnostics YAML file has incorrectly formed YAML blocks causing opt-viewer.py tool to crash..
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
r-swamy
</td>
</tr>
</table>
<pre>
**Description :**
============
- Compiler : clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04
- The usage of flags -fsave-optimization-record -foptimization-record-file=x264_llvm-13.01_report.yaml would enable the remark diagnostics to eject the LLVM optimization information as YAML blocks into the specifed file x264_llvm-13.01_report.yaml.
- The specified YAML block template construct as the documentation at below
link : https://llvm.org/docs/Remarks.html#emitting-remark-diagnostics-in-the-object-file
**General template of a single yaml block:**
===============================
>>
--- !<TYPE>
Pass: <pass>
Name: <name>
DebugLoc: { File: <file>, Line: <line>, Column: <column> }
Function: <function>
Hotness: <hotness>
Args:
- <key>: <value>
DebugLoc: { File: <arg-file>, Line: <arg-line>, Column: <arg-column> }
<<
Symptoms :
===========
- During the process of ejection of the yaml block by using remark objects converted to llvm::remarks::Remark, the YAML block gets costructed is partial or incorrectly formed.
- Due to this incorretly formed YAMl block the opt-viewer.py ( optimization report tool ) ejects exception as below,
>>
$ opt-viewer.py x264_llvm-13.01_report.yaml
Reading YAML files...
1 of 1multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "/home/user1/install/anaconda3/lib/python3.7/multiprocessing/pool.py", line 121, in worker
result = (True, func(*args, **kwds))
File "/home/user1/install/anaconda3/lib/python3.7/multiprocessing/pool.py", line 44, in mapstar
return list(map(*args))
File "/home/user1/llvm-pre-built-binaries/13.01/clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04/share/opt-viewer/optpmap.py", line 25, in _wrapped_func
return func(argument, filter_)
File "/home/user1/llvm-pre-built-binaries/13.01/clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04/share/opt-viewer/optrecord.py", line 282, in get_remarks
for remark in docs:
File "/home/user1/install/anaconda3/lib/python3.7/site-packages/yaml/__init__.py", line 130, in load_all
yield loader.get_data()
File "/home/user1/install/anaconda3/lib/python3.7/site-packages/yaml/constructor.py", line 37, in get_data
return self.construct_document(self.get_node())
File "ext/_yaml.pyx", line 699, in _yaml.CParser.get_node
File "ext/_yaml.pyx", line 725, in _yaml.CParser._compose_document
File "ext/_yaml.pyx", line 776, in _yaml.CParser._compose_node
File "ext/_yaml.pyx", line 892, in _yaml.CParser._compose_mapping_node
File "ext/_yaml.pyx", line 905, in _yaml.CParser._parse_next_event
yaml.scanner.ScannerError: mapping values are not allowed in this context
in "x264_llvm-13.01_report.yaml", line 30202, column 41
"""
<<
$ vim "x264_llvm-13.01_report.yaml" +30202
>>
--- !Missed
Pass: gvn
Name: LoadClobb { File: 'common/pixel.c', Line: 462, Column: 0 }
Function: x264_pixel_sad_x3_4x4
Args:
- NumInstructions: '369'
- String: ' instructions in function'
...
<<
The correct YAML block would have been as below:
>>
_--- !Missed
Pass: gvn
Name: LoadClobb
DebugLoc: { File: 'common/pixel.c', Line: 462, Column: 0 }
Function: x264_pixel_sad_x3_4x4
Args:
- NumInstructions: '369'
- String: ' instructions in function'_
...
<<
**Note :**
- The framework for optimization report witgh YAML block ejection needs to be addressed.
- The malformed yaml blocks occurs at different places in the file x264_llvm-13.01_report.yaml.
Steps to reproduce the issue :
====================
$ git clone https://github.com/jpsdr/x264.git
$ which clang
$ export CC=clang
$ cd x264/
$ ./configure --extra-cflags="-Ofast -fsave-optimization-record -foptimization-record-file=x264_llvm-13.01_report.yaml" --extra-ldflags="-Ofast -fsave-optimization-record -foptimization-record-file=x264_llvm-13.01_report.yaml"
$ make -j
$ opt-viewer.py x264_llvm-13.01_report.yaml
Reading YAML files...
1 of 1multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "/home/user1/install/anaconda3/lib/python3.7/multiprocessing/pool.py", line 121, in worker
result = (True, func(*args, **kwds))
File "/home/user1/install/anaconda3/lib/python3.7/multiprocessing/pool.py", line 44, in mapstar
return list(map(*args))
File "/home/user1/llvm-pre-built-binaries/13.01/clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04/share/opt-viewer/optpmap.py", line 25, in _wrapped_func
return func(argument, filter_)
File "/home/user1/llvm-pre-built-binaries/13.01/clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04/share/opt-viewer/optrecord.py", line 282, in get_remarks
for remark in docs:
File "/home/user1/install/anaconda3/lib/python3.7/site-packages/yaml/__init__.py", line 130, in load_all
yield loader.get_data()
File "/home/user1/install/anaconda3/lib/python3.7/site-packages/yaml/constructor.py", line 37, in get_data
return self.construct_document(self.get_node())
File "ext/_yaml.pyx", line 699, in _yaml.CParser.get_node
File "ext/_yaml.pyx", line 725, in _yaml.CParser._compose_document
File "ext/_yaml.pyx", line 776, in _yaml.CParser._compose_node
File "ext/_yaml.pyx", line 892, in _yaml.CParser._compose_mapping_node
File "ext/_yaml.pyx", line 905, in _yaml.CParser._parse_next_event
yaml.scanner.ScannerError: mapping values are not allowed in this context
in "x264_llvm-13.01_report.yaml", line 30202, column 41
"""
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWVtv2zYU_jXOCyHBlhxfHvyQOs02IO2KNRjQJ4GSaJsNJQokFdv79fsOJcuyc2lTdMOARRAsiZfDc-d36FTn-8UgusJ9LWxmZOWkLtkgvmoaB8PrwfBqEF9_-_YjA7bURSWVMESDZYqX60H0TqmHIhjF4TAcBbvZJJmMAyXLehesyzqo07p0dTCahcPxgcrdRrDa8rVgesVWiq8tC1aWP4hAg8NC_sWJz8CITJscXU-0BiuwAcZ20WScdAyMEiMqbVy454ViW12rnImSp0owhzWNKLi5Z7nk61JbJzPLnGbiq8ic77-9_fMD6y_GZLnSpmjeuWVfrj7cslTp7N6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