Dear Stefanos,
Thank you for your reply. It helped me to understand the optimization phase
of LLVM. However, I did not find any 'print-changed' option for llvm.
Can
you kindly help me in this regard ? I want to generate the IRs after each
optimization pass.
Regards,
Sudakshina
On Sun, Jan 24, 2021 at 7:13 PM Stefanos Baziotis <
stefanos.baziotis at gmail.com> wrote:
> Hi Sudakshina,
>
> > 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.
>
> "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.
> 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`)
>
> 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.
>
> Finally, if you want to see why a transformation could or not change the
> code, you can use the related comments about remarks.
>
> Best,
> Stefanos
>
> Στις Κυρ, 24 Ιαν 2021 στις 7:24 π.μ., ο/η Sudakshina Dutta <
> sudakshina at iitgoa.ac.in> έγραψε:
>
>> Dear all,
>>
>> 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.
>>
>> Thanks,
>> Sudakshina
>>
>>
>> On Sun, 24 Jan 2021, 09:27 Stefanos Baziotis, <
>> stefanos.baziotis at gmail.com> wrote:
>>
>>> Hi Sudakshina,
>>>
>>> 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
>>> 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
>>> on your case. They can also be parsed relatively easily.
>>>
>>> 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`
>>> You can also use `-mllvm-debug-pass=Arguments` to see the arguments
that
>>> were passed.
>>>
>>> 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
>>> 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).
>>>
>>> Hope it helps,
>>> Stefanos
>>>
>>> [1]
>>>
https://clang.llvm.org/docs/ClangCommandLineReference.html#diagnostic-flags
>>> [2]
>>>
https://clang.llvm.org/docs/UsersManual.html#cmdoption-f-no-save-optimization-record
>>>
>>> Στις Κυρ, 24 Ιαν 2021 στις 5:47 π.μ., ο/η Adrian Vogelsgesang via
>>> llvm-dev <llvm-dev at lists.llvm.org> έγραψε:
>>>
>>>> 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.
>>>>
>>>> In my case, I used them through “clang++”, i.e. I had to prefix
them
>>>> with “-mllvm”
>>>> > clang++ test_file.cpp -mllvm -print-after-all
>>>>
>>>>
>>>>
>>>> *From: *llvm-dev <llvm-dev-bounces at lists.llvm.org> on
behalf of Brian
>>>> Cain via llvm-dev <llvm-dev at lists.llvm.org>
>>>> *Date: *Sunday, 24. January 2021 at 04:40
>>>> *To: *Sudakshina Dutta <sudakshina at iitgoa.ac.in>
>>>> *Cc: *LLVM Development List <llvm-dev at lists.llvm.org>
>>>> *Subject: *Re: [llvm-dev] LLVM log file
>>>>
>>>> I don't know if it's exhaustive but there's the
"remarks" feature:
>>>>
>>>>
>>>>
>>>>
>>>>
https://llvm.org/docs/Remarks.html#introduction-to-the-llvm-remark-diagnostics
>>>>
>>>>
>>>>
>>>> On Sat, Jan 23, 2021 at 9:20 PM Sudakshina Dutta via llvm-dev
<
>>>> llvm-dev at lists.llvm.org> wrote:
>>>>
>>>> Dear all,
>>>>
>>>>
>>>>
>>>> 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.
>>>>
>>>>
>>>>
>>>> Thanks,
>>>>
>>>> Sudakshina
>>>>
>>>> _______________________________________________
>>>> LLVM Developers mailing list
>>>> llvm-dev at lists.llvm.org
>>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> -Brian
>>>> _______________________________________________
>>>> LLVM Developers mailing list
>>>> llvm-dev at lists.llvm.org
>>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20210126/f9c1d655/attachment-0001.html>