<div dir="ltr"><div><div>I for one think this sounds like a very useful tool for LLVM developers. I'll try it out with an actual investigation.<br><br></div>Seems to me like this could be a valuable addition to the utils/ directory. From my experience with tools such as this, it is the existence of clear documentation that makes or breaks the tool. If it is possible, I think it would be good to start with a document describing the tool's capabilities and instructions for use along with the code itself. This would allow people with very limited Python knowledge (such as myself) to evaluate the tool as well.<br><br></div>Lets see if others in the community are interested in this tool joining the LLVM arsenal, but I would certainly like to thank you for sharing it and offering to contribute it.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 22, 2018 at 5:15 AM, Alexander Richardson <span dir="ltr"><<a href="mailto:arichardson.kde@gmail.com" target="_blank">arichardson.kde@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">In our fork of LLVM we often need to reduce a crash testcase for a<br>
specific assertion. After writing lots of "only give me this specific<br>
assertion" scripts like the above I decided to write a script that<br>
automates all this for me:<br>
<<a href="https://github.com/CTSRD-CHERI/clang/blob/master/utils/creduce_crash_testcase.py" rel="noreferrer" target="_blank">https://github.com/CTSRD-<wbr>CHERI/clang/blob/master/utils/<wbr>creduce_crash_testcase.py</a>>.<br>
(It's called creduce_crash_test.py but it will actually use bugpoint<br>
-compile-custom if it detects that it is not a clang frontend crash).<br>
If you point the script at a clang crash reproducer .sh file it will<br>
infer the assertion message/llvm_unreachable/<wbr>infinite loop (if it<br>
takes longer than x seconds it treats it as an infinite loop) and then<br>
try to produce a reduced test case for that issue. If you point it at<br>
a non.sh file it will parse that file for RUN: lines and try to reduce<br>
the crashes it finds there. It currently handles RUN: lines containing<br>
llc or %clang/%clang_cc1 and our custom lit substitutions.<br>
<br>
If people are interested in this I'm very happy to try and submit this upstream.<br>
<br>
On 20 March 2018 at 16:52, Nemanja Ivanovic via llvm-dev<br>
<<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
> I'm not sure if this helps, but here it is in case it does.<br>
><br>
> I typically use bugpoint in a way as to keep the actual failure that I'm<br>
> after. For example, with the test case you've pasted, I was looking for a<br>
> specific assert. So I used bugpoint this way:<br>
><br>
> $ cat reduceme.sh<br>
> #!/bin/bash<br>
> llc -filetype=obj $1 2>&1 | grep 'Cannot lower calls with arbitrary operand<br>
> bundles'<br>
> RC=$?<br>
> if [[ $RC -eq 0 ]]<br>
> then<br>
>   exit 1<br>
> fi<br>
> exit 0<br>
><br>
> $ bugpoint -compile-custom -compile-command=$PWD/<wbr>reduceme.sh input.ll<br>
><br>
> That will ensure that bugpoint retains the specific desired failure<br>
> behaviour as it is reducing the test case.<br>
><br>
> Hope that helps,<br>
> Nemanja<br>
><br>
> P.S. It is not that I am specifically interested in that assert - just that<br>
> that's how the original test case was failing so that's what I wanted to<br>
> preserve as an illustration.<br>
><br>
> On Tue, Mar 20, 2018 at 11:14 AM, Valentin Churavy <<a href="mailto:v.churavy@gmail.com">v.churavy@gmail.com</a>><br>
> wrote:<br>
>><br>
>> Thank you both!<br>
>><br>
>> I was running into the issue that bugpoint was reducing my test-case into<br>
>> other failures and I hadn't managed yet to find the right point in the Julia<br>
>> pass pipeline to insert the module to reproduce the issue reliably from llc<br>
>> and that's why I started looking at using the MIR.<br>
>><br>
>> I will go back at looking at the pass pipeline and the IR and get a<br>
>> reproducer that way!<br>
>><br>
>> Thanks,<br>
>> Valentin<br>
>><br>
>> On Tue, 20 Mar 2018 at 07:51 Nemanja Ivanovic <<a href="mailto:nemanja.i.ibm@gmail.com">nemanja.i.ibm@gmail.com</a>><br>
>> wrote:<br>
>>><br>
>>> Valentin,<br>
>>> in terms of limitations as Sean pointed out, an important one is that<br>
>>> .mir doesn't have MachineFunctionInfo which may result in failure on<br>
>>> accesses to global variables due to use of register X2. The verifier<br>
>>> considers it an undefined register.<br>
>>> Also, it's probably easier to reduce test cases using bugpoint starting<br>
>>> from an IR test case. With the code you provided, I get a different crash<br>
>>> than what you apparently get. Here are the test case and the backtrace.<br>
>>><br>
>>> Test case: <a href="https://pastebin.com/fxjRtJD0" rel="noreferrer" target="_blank">https://pastebin.com/fxjRtJD0</a><br>
>>> Backtrace: <a href="https://pastebin.com/FsXMvbGK" rel="noreferrer" target="_blank">https://pastebin.com/FsXMvbGK</a><br>
>>><br>
>>> Nemanja<br>
>>><br>
>>> On Mon, Mar 19, 2018 at 11:51 PM, Sean Fertile via llvm-dev<br>
>>> <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
>>>><br>
>>>> Hello Valentin,<br>
>>>><br>
>>>> To generate a mir test case i think the process is to first create an IR<br>
>>>> file by passing '-S -emit-llvm' to clang, then you can feed that file into<br>
>>>> llc and use stop-before to get the mir just before the if-converter pass,<br>
>>>> eg: `llc -stop-before=if-converter  -simplify-mir -o test.mir test.ll`.<br>
>>>><br>
>>>> Also there is a MIR language reference:<br>
>>>> <a href="https://llvm.org/docs/MIRLangRef.html" rel="noreferrer" target="_blank">https://llvm.org/docs/<wbr>MIRLangRef.html</a> which has some of the limitations<br>
>>>> documented, as well as tips for further simplifying the generated mir if<br>
>>>> need be.<br>
>>>><br>
>>>> Regards,<br>
>>>> Sean<br>
>>>><br>
>>>> On Mon, Mar 19, 2018 at 7:53 PM, Valentin Churavy via llvm-dev<br>
>>>> <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
>>>>><br>
>>>>> Hello,<br>
>>>>><br>
>>>>> I am trying to isolate an assertion failure in if-converter (on PPC)<br>
>>>>> and I generated a textual debuglog with:<br>
>>>>><br>
>>>>> ```<br>
>>>>> LLVM_ARGS=-print-before-all -print-module-scope<br>
>>>>> -filter-print-funcs=japi1__<wbr>require_7687<br>
>>>>> ```<br>
>>>>><br>
>>>>> and after splicing out the the MIR before the if-converter pass<br>
>>>>> I would like to run `llc -march=ppc64le -run-pass=if-converter<br>
>>>>> input.mir` so that I can start minimising the MIR.<br>
>>>>><br>
>>>>> This steps fails for me with a:<br>
>>>>> ```<br>
>>>>> error: YAML:188:20: Unrecognized character while tokenizing.<br>
>>>>> Function Live Ins: %x4<br>
>>>>>                    ^<br>
>>>>><br>
>>>>> error: YAML:188:1: Map value must not be empty<br>
>>>>> Function Live Ins: %x4<br>
>>>>> ^~~~~~~~~~~~~~~~~<br>
>>>>> ```<br>
>>>>><br>
>>>>> Should I expect this to work, or is some part of my workflow wrong?<br>
>>>>><br>
>>>>> I put the full log and just the extracted MIR file online:<br>
>>>>> <a href="https://drive.google.com/open?id=1Br0s9Qvr4tzPv8nqbnV_nWezpEH5Ci7B" rel="noreferrer" target="_blank">https://drive.google.com/open?<wbr>id=1Br0s9Qvr4tzPv8nqbnV_<wbr>nWezpEH5Ci7B</a> and<br>
>>>>> would appreciate any guidance whether I should file this as a deserialiser<br>
>>>>> bug.<br>
>>>>><br>
>>>>> Best,<br>
>>>>> Valentin<br>
>>>>><br>
>>>>><br>
>>>>><br>
>>>>> ______________________________<wbr>_________________<br>
>>>>> LLVM Developers mailing list<br>
>>>>> <a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
>>>>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
>>>>><br>
>>>><br>
>>>><br>
>>>> ______________________________<wbr>_________________<br>
>>>> LLVM Developers mailing list<br>
>>>> <a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
>>>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
>>>><br>
>>><br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
><br>
</blockquote></div><br></div>