<div dir="ltr">Hi 

Sudakshina,<div><br></div><div>> The optimization applied in the optimization pass depends on the source program; hence, the number of optimizations applied differs from source program to source program.</div><div><br></div><div>"applied" is still ambiguous, at least to me. If by "applied" you mean "attempted", then no, that does not depend on the source program. It depends on the optimization level (e.g., O1, O2, ...) or the individual passes that you may request yourself.</div><div>That is, for -O1 for example, there is a predetermined sequence of passes that _attempt_ to optimize the program and you can see that with the options I mentioned above (e.g., `-mllvm -opt-bisect-limit=-1`)</div><div><br></div><div>If by applied you mean "actually changed the code", then yes, this differs from program to program. You can see that with `print-changed`, it'll show you the IR after every transformation that changed your program.</div><div><br></div><div>Finally, if you want to see why a transformation could or not change the code, you can use the related comments about remarks.</div><div><br></div><div>Best,</div><div>Stefanos</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Στις Κυρ, 24 Ιαν 2021 στις 7:24 π.μ., ο/η Sudakshina Dutta <<a href="mailto:sudakshina@iitgoa.ac.in">sudakshina@iitgoa.ac.in</a>> έγραψε:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div>Dear all,<div dir="auto"><br></div><div dir="auto">In the optimization phase, the compiler applies some optimization to generate an optimized program. The optimization applied in the optimization pass depends on the source program; hence, the number of optimizations applied differs from source program to source program. By mentioning "applied" transformation, I wanted to know what all transformations are applied for a specific input program when subjected to the LLVM optimizer.</div><div dir="auto"><br></div><div dir="auto">Thanks,</div><div dir="auto">Sudakshina </div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 24 Jan 2021, 09:27 Stefanos Baziotis, <<a href="mailto:stefanos.baziotis@gmail.com" target="_blank">stefanos.baziotis@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Sudakshina,<br><br>Not really sure what you mean by "applied", so, let me offer some more ideas other than Brian's and Adrian's great suggestions. First, there are some<div>diagnostics / remarks flags in Clang like the -R family [1] or some -f flags about printing optimization reports [2] from Clang. They can be useful or useless depending</div><div>on your case. They can also be parsed relatively easily.</div><div><br></div><div>If you just want to see a list of passes that were attempted in your code, you can do it with: `-mllvm -opt-bisect-limit=-1`</div><div>You can also use `-mllvm-debug-pass=Arguments` to see the arguments that were passed.</div><div><br></div><div>Moving into opt, you can use something like `print-after-all`, which was already mentioned. If you don't know what these flags do, is they show you</div><div>the IR in different stages in the pipeline (e.g., `print-after-all` shows you each pass attempted and how the IR is after it).</div><div><br></div><div>Hope it helps,</div><div>Stefanos<br><br>[1] <a href="https://clang.llvm.org/docs/ClangCommandLineReference.html#diagnostic-flags" rel="noreferrer" target="_blank">https://clang.llvm.org/docs/ClangCommandLineReference.html#diagnostic-flags</a></div><div>[2] <a href="https://clang.llvm.org/docs/UsersManual.html#cmdoption-f-no-save-optimization-record" rel="noreferrer" target="_blank">https://clang.llvm.org/docs/UsersManual.html#cmdoption-f-no-save-optimization-record</a></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Στις Κυρ, 24 Ιαν 2021 στις 5:47 π.μ., ο/η Adrian Vogelsgesang via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" rel="noreferrer" target="_blank">llvm-dev@lists.llvm.org</a>> έγραψε:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="en-DE">
<div>
<p class="MsoNormal"><span lang="EN-US">I used “-print-changed”, “-print-before-all”, “print-after-all” last time I wanted to see the passes together with their inout/output IR modules.<br>
<br>
In my case, I used them through “clang++”, i.e. I had to prefix them with “-mllvm”<br>
> clang++ test_file.cpp -mllvm -print-after-all<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12pt"><b><span style="font-size:12pt;color:black">From:
</span></b><span style="font-size:12pt;color:black">llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" rel="noreferrer" target="_blank">llvm-dev-bounces@lists.llvm.org</a>> on behalf of Brian Cain via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" rel="noreferrer" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Date: </b>Sunday, 24. January 2021 at 04:40<br>
<b>To: </b>Sudakshina Dutta <<a href="mailto:sudakshina@iitgoa.ac.in" rel="noreferrer" target="_blank">sudakshina@iitgoa.ac.in</a>><br>
<b>Cc: </b>LLVM Development List <<a href="mailto:llvm-dev@lists.llvm.org" rel="noreferrer" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Subject: </b>Re: [llvm-dev] LLVM log file<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal">I don't know if it's exhaustive but there's the "remarks" feature:<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><a href="https://llvm.org/docs/Remarks.html#introduction-to-the-llvm-remark-diagnostics" rel="noreferrer" target="_blank">https://llvm.org/docs/Remarks.html#introduction-to-the-llvm-remark-diagnostics</a><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Sat, Jan 23, 2021 at 9:20 PM Sudakshina Dutta via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" rel="noreferrer" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal">Dear all,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Good morning. I want to know whether LLVM creates any log file consisting of applied optimizations in the optimization phase. It will be really useful for the researchers who work on compilers, formal methods, etc.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Sudakshina<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal">_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" rel="noreferrer" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal">-- <u></u><u></u></p>
<div>
<p class="MsoNormal">-Brian<u></u><u></u></p>
</div>
</div>
</div>

_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" rel="noreferrer" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>
</blockquote></div></div></div>
</blockquote></div>