<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Em ter., 14 de dez. de 2021 às 05:58, David Spickett <<a href="mailto:david.spickett@linaro.org">david.spickett@linaro.org</a>> escreveu:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> I see, but I was thinking about something simpler: adding -O2 and -fno-foo flags to disable optimizations (e.g., -fno-slp-vectorizer), WDYT?<br>
<br>
Worth a go for sure. I wasn't sure if all the passes would have an<br>
-fno for them but if it's one of those then all the better.<br></blockquote><div><br></div><div>Didn't work :/ Apparently -O2 only adds -vectorize-slp and -vectorize-loops and disabling both didn't solve the problem.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> Done: <a href="https://github.com/llvm/llvm-project/issues/52669" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/issues/52669</a><br>
<br>
Great. I'll see if I can reproduce it myself.<br>
<br>
On Mon, 13 Dec 2021 at 18:08, Mikhail R. Gadelha<br>
<<a href="mailto:mikhail.ramalho@gmail.com" target="_blank">mikhail.ramalho@gmail.com</a>> wrote:<br>
><br>
><br>
><br>
> Em seg., 13 de dez. de 2021 às 07:45, David Spickett <<a href="mailto:david.spickett@linaro.org" target="_blank">david.spickett@linaro.org</a>> escreveu:<br>
>><br>
>> Caveat that I'm on shaky ground when it comes to my understanding of<br>
>> how the pass managers work.<br>
>><br>
>> I think clang 13 uses the new pass manager, so this would be what you want:<br>
>> $ ./bin/clang /tmp/test.c -c -o /dev/null -O1 -Xclang -fdebug-pass-manager<br>
><br>
><br>
> Someone suggested looking into Alias Analysis as well.<br>
><br>
>><br>
>> Certainly I see a lot of differences trying that myself.<br>
>> (<a href="https://llvm.org/docs/NewPassManager.html#invoking-opt" rel="noreferrer" target="_blank">https://llvm.org/docs/NewPassManager.html#invoking-opt</a>)<br>
>><br>
>> That tells you what the target generic passes being run are, then the<br>
>> target specific things use the old pass manager which you can use<br>
>> "-mllvm -debug-pass=Structure" for instead.<br>
>> (<a href="https://llvm.org/docs/NewPassManager.html#status-of-the-new-and-legacy-pass-managers" rel="noreferrer" target="_blank">https://llvm.org/docs/NewPassManager.html#status-of-the-new-and-legacy-pass-managers</a>)<br>
>><br>
>> How you get an option from clang to opt to change which passes are<br>
>> run, I couldn't work out. There is "-passes=" for opt but that won't<br>
>> get through from clang with "-mllvm", maybe I just didn't do it<br>
>> correctly.<br>
>><br>
>> Though I found a good suggestion from Medhi Amini in another thread,<br>
>> that would mean you could use opt directly:<br>
>> "But you may start by bisecting the input files compiling half of them<br>
>> with O1 and the other half with O0 and recurse till you find the file<br>
>> that is miscompiled with O1. Then you can use opt to test variant of<br>
>> the pipeline on this file and relink manually."<br>
>> (<a href="https://groups.google.com/g/llvm-dev/c/Y1HHgpmBidM" rel="noreferrer" target="_blank">https://groups.google.com/g/llvm-dev/c/Y1HHgpmBidM</a>)<br>
>><br>
><br>
> I see, but I was thinking about something simpler: adding -O2 and -fno-foo flags to disable optimizations (e.g., -fno-slp-vectorizer), WDYT?<br>
><br>
> I've found this post from '14 about that: <a href="https://stackoverflow.com/questions/15548023/clang-optimization-levels" rel="noreferrer" target="_blank">https://stackoverflow.com/questions/15548023/clang-optimization-levels</a><br>
><br>
>><br>
>> Hope that helps but in any case please go ahead and open an issue and<br>
>> we can narrow it down further.<br>
><br>
><br>
> Done: <a href="https://github.com/llvm/llvm-project/issues/52669" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/issues/52669</a><br>
><br>
>><br>
>><br>
>> On Mon, 13 Dec 2021 at 10:27, David Spickett <<a href="mailto:david.spickett@linaro.org" target="_blank">david.spickett@linaro.org</a>> wrote:<br>
>> ><br>
>> > FWIW I think opening an issue with what you've got would be fine.<br>
>> ><br>
>> > > when I build JSC using either -O2 or -O3, I get random garbage when querying for the "Infinity" constant from javascript<br>
>> ><br>
>> > Can you elaborate on what JSC is and how you do the query? Is it something like:<br>
>> > * build an interpreter<br>
>> > * interpret javascript code that prints infinity<br>
>> > * check for expected value<br>
>> ><br>
>> > I know zero about javascript in general but if we can get a script to<br>
>> > do that then we could bisect it. It'll take a while but we (Linaro)<br>
>> > have access to some machines that could help there.<br>
>> > (assuming this presents on armv8 hardware, but if it doesn't it's at<br>
>> > least a data point)<br>
>> ><br>
>> > > It seems like some optimization introduced by -O2 is causing the issue.<br>
>> ><br>
>> > Agreed<br>
>> ><br>
>> > > Is there a flag in clang to print which optimizations are enabled for -O1 and -O2 so I can diff them?<br>
>> ><br>
>> > Yes but I can never remember which one it is, so let me try to find<br>
>> > it. Unless someone else knows it already and can reply.<br>
>> ><br>
>> > On Sat, 11 Dec 2021 at 18:01, Mikhail R. Gadelha via cfe-dev<br>
>> > <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br>
>> > ><br>
>> > > Hi everyone,<br>
>> > ><br>
>> > > This is kind of a follow-up to my previous email about compiling JSC using clang for ARMv7: when I build JSC using either -O2 or -O3, I get random garbage when querying for the "Infinity" constant from javascript, as if the constant was not being initialized. The variable is being initialized correctly, that I'm sure.<br>
>> > ><br>
>> > > Some tests I did:<br>
>> > > 1. Using -O1 or no optimization doesn't trigger the issue.<br>
>> > > 2. Using either -O2 or -O3 with address or the undef behavior sanitizers doesn't trigger the issue.<br>
>> > > 3. Building JSC with clang 11.0.1-2 (from Debian) and clang 12.0.1 (from github) doesn't trigger the issue.<br>
>> > > 4. The issue happens with clang 13.0.0 (from github) and the 13.0.1-rc1 (also from github).<br>
>> > ><br>
>> > > It seems like some optimization introduced by -O2 is causing the issue.<br>
>> > ><br>
>> > > Does anyone have any tips I can follow to improve this bug report? I'll try to compile JSC with -O2 and disable the optimizations manually to pinpoint what's causing the issue (hopefully it's a single optimization and not a combination of them). Is there a flag in clang to print which optimizations are enabled for -O1 and -O2 so I can diff them?<br>
>> > ><br>
>> > > I wish I had more information, but I'm still trying to debug why this is happening. I wanted to try to get more information first before opening a github issue.<br>
>> > ><br>
>> > > Thanks in advance,<br>
>> > ><br>
>> > > --<br>
>> > ><br>
>> > > Mikhail R. Gadelha.<br>
>> > > _______________________________________________<br>
>> > > cfe-dev mailing list<br>
>> > > <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
>> > > <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
><br>
><br>
><br>
> --<br>
><br>
> Mikhail Ramalho.<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><br></div><div>Mikhail Ramalho.</div></div></div></div>