[llvm-dev] bug report on mem2reg
Fangrui Song via llvm-dev
llvm-dev at lists.llvm.org
Thu May 14 23:15:32 PDT 2020
On 2020-05-14, David Blaikie via llvm-dev wrote:
>This is still a rather long test case - I expect it should be able to be
>reduced further while still demonstrating the problem.
>
>I also don't understand what the correct/incorrect behavior it is you're
>looking for - at least casually, the program prints the same result at -O0,
>which doesn't run mem2reg, and at -O3 which does run mem2reg.
Agreed the case is complex. After clang -O3 -S -emit-llvm opts.c
opt -da -analyze opts.ll => assertion failure at
https://github.com/llvm/llvm-project/blob/master/llvm/lib/Analysis/DependenceAnalysis.cpp#L1155
// CommonLevels == 0
assert(0 < Level && Level <= CommonLevels && "level out of range");
So there is definitely a bug in dependency analysis, but I haven't spent time investigating it.
>On Thu, May 14, 2020 at 5:14 PM liubaosen at tsinghua.edu.cn <
>liubaosen at tsinghua.edu.cn> wrote:
>
>> Hi, David, and anyone regards,
>> Thanks for discussing. I meant you can run the main.c with what I affixed
>> in last mail. Anyway, I reprepared a complete while least pack of codes,
>> which is affixed. I've tried it with following process,
>>
>> clang colapse.c -o colapse
>> ./colapse
>> valgrind --tool=memcheck --leak-check=yes ./colapse
>> clang colapse.c -emit-llvm -g -c -S -o colapse.ll -Xclang
>> -disable-O0-optnone
>> opt -mem2reg -da -analyze colapse.ll
>>
>> so, principly, it is for sure able to recur. There are totally 3 functions
>> can cause collapses (maybe by a same reason), and all of them are contained
>> in the file. Please help me debug it.
>>
>> Thanks again.
>>
>> ------------------------------
>> liubaosen at tsinghua.edu.cn
>>
>>
>> *From:* David Blaikie <dblaikie at gmail.com>
>> *Date:* 2020-05-15 06:31
>> *To:* liubaosen at tsinghua.edu.cn; llvm-dev <llvm-dev at lists.llvm.org>
>> *Subject:* Re: Re: [llvm-dev] bug report on mem2reg
>> Sorry, I'm not sure I'll be able to help you - main.c uses other code
>> (optsfind/check/etc) that I don't have/don't know what that code is, and
>> even with it it's probably a bit big/complicated for me to
>> debug/reduce/etc. If you can reconstruct the smallest complete (reducing
>> the total lines of all source/header files needed to reproduce the problem)
>> example that might be more practical to discuss here & see whether it's a
>> mem2reg bug, etc.
>>
>> On Wed, May 13, 2020 at 6:52 PM liubaosen at tsinghua.edu.cn <
>> liubaosen at tsinghua.edu.cn> wrote:
>>
>>> Hi, David and anyone relevent,
>>>
>>> Thank you for replying, first.
>>> I tried it with valgrind, no error is reported, so I'm sure it's not our
>>> problem.
>>> The valgrind log is affixed and a mian.c which you may need to generate
>>> an executable is also affixed.
>>> Please do me a favor and investigate what causes the colapse. Your help
>>> will be greatly appreciated.
>>>
>>> Best regards
>>>
>>> ------------------------------
>>> liubaosen at tsinghua.edu.cn
>>>
>>>
>>> *From:* David Blaikie <dblaikie at gmail.com>
>>> *Date:* 2020-05-12 11:45
>>> *To:* liubaosen at tsinghua.edu.cn
>>> *CC:* llvm-dev <llvm-dev at lists.llvm.org>
>>> *Subject:* Re: [llvm-dev] bug report on mem2reg
>>> Tried testing it with things like Undefined Behaivor Sanitizer (or other
>>> sanitizers - memory/address) or valgrind?
>>>
>>> Often "program works sometimes and doesn't work other times" is
>>> because the program has undefined behavior in it & the times its working
>>> are just luck.
>>>
>>> On Mon, May 11, 2020 at 8:41 PM liubaosen at tsinghua.edu.cn via llvm-dev <
>>> llvm-dev at lists.llvm.org> wrote:
>>>
>>>> Hi, all,
>>>>
>>>> I think I found a bug on mem2reg in a particular case.
>>>> When I ran opt -mem2reg -basicaa -scalar-evolution -loops -da -analyze
>>>> opts.ll, it collapsed. While without mem2reg option, it runs well. so I
>>>> guess it has something to do with mem2reg.
>>>> The relative files have been affixed, please check them for me.
>>>> Thanks in advance.
>>>>
>>>> ------------------------------
>>>> liubaosen at tsinghua.edu.cn
>>>> _______________________________________________
>>>> LLVM Developers mailing list
>>>> llvm-dev at lists.llvm.org
>>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>>>
>>>
>_______________________________________________
>LLVM Developers mailing list
>llvm-dev at lists.llvm.org
>https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
More information about the llvm-dev
mailing list