<div dir="auto">Makes sense thank you. I have to look at the dependencies between different optimization passes too I guess. </div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Mar 28, 2021 at 17:33 Johannes Doerfert <<a href="mailto:johannesdoerfert@gmail.com">johannesdoerfert@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I recommend adding such a flag to the pass you want to disable.<br>
Whenever `runOnXXX` is called, check the flag and exit if set.<br>
<br>
~ Johannes<br>
<br>
<br>
On 3/28/21 5:27 PM, Navid Rahimi wrote:<br>
> Thanks Johannes. That makes this makes it more understandable to me. What<br>
> can I do for optimization that doesn’t have flag? How should I approach<br>
> disabling them.<br>
><br>
> On Sat, Mar 27, 2021 at 22:10 Johannes Doerfert <<a href="mailto:johannesdoerfert@gmail.com" target="_blank">johannesdoerfert@gmail.com</a>><br>
> wrote:<br>
><br>
>> Hi Navid,<br>
>><br>
>> comments inlined.<br>
>><br>
>> On 3/27/21 9:24 PM, Navid Rahimi via llvm-dev wrote:<br>
>>> Hi everyone,<br>
>>><br>
>>> tl;dr: I want to control which optimization and transformation can and<br>
>> will<br>
>>> run on my code. Does Clang/LLVM permit such an approach?<br>
>> There is no unified approach to this as far as I know. The closest<br>
>> I'm aware of was some research prototype:<br>
>>     <a href="https://compilers.cs.uni-saarland.de/projects/noise/" rel="noreferrer" target="_blank">https://compilers.cs.uni-saarland.de/projects/noise/</a><br>
>><br>
>><br>
>>> I am doing this with GCC. But at first, it seems for some reason GCC does<br>
>>> not allow optimizations to run unless I am passing -Ox flag (x>=1). The<br>
>>> approach I thought would work is using -O3 and disabling all the<br>
>>> optimizations one by one with -fno-XXX, then passing each optimization I<br>
>>> want with -fXXX. Even after doing that it seems GCC does take the flags<br>
>>> seriously. Sometimes it might consider the -fXXX flags, but sometimes it<br>
>>> totally ignores.<br>
>>><br>
>>> I was investigating this issue more recently due to a project I am<br>
>> involved<br>
>>> in. I realized that there are two sets of optimizations and<br>
>> transformation<br>
>>> can happen in Clang/LLVM. Clang can do a few optimizations itself on AST<br>
>>> and then LLVM will run its own optimizations. Please correct me if I am<br>
>>> wrong.<br>
>> I'm not aware of optimizations/transformation we do on the AST,<br>
>> except the things that "have to" happen on that level.<br>
>><br>
>><br>
>>> Here is a list of few questions I am trying to find an answer for:<br>
>>> 1) I am looking for a list of optimizations that Clang might do. Where<br>
>> can<br>
>>> I find them?<br>
>> I doubt there are "optimzations" to speak of, constant propagation<br>
>> can happen though.<br>
>><br>
>><br>
>>> 2) I am looking for a list of optimizations that LLVM might do. Where<br>
>> can I<br>
>>> find them?<br>
>> Most passes that exist in LLVM are listed in<br>
>>     llvm/lib/Passes/PassRegistry.def<br>
>><br>
>> There are (outdated) lists online as well.<br>
>><br>
>><br>
>>> 3) Is there any way to disable/enable specific Clang optimization?<br>
>> Most, if not all, are mandatory.<br>
>><br>
>><br>
>>> 4) Is there any way to disable/enable specific LLVM optimization?<br>
>> Some, not all, have command line flags to disable them, I would do:<br>
>>     opt -help-hidden | grep disable<br>
>>     opt -help-hidden | grep enable<br>
>><br>
>> if I needed a list.<br>
>><br>
>>> 5) Would LLVM/Clang respect specific optimization flags?<br>
>> I don't think you can build your own optimization pipelines via clang<br>
>> but you can emit IR and do it with opt.<br>
>><br>
>><br>
>>> I appreciate immensely any help regarding these questions.<br>
>> Hope this helps, others might have more information.<br>
>><br>
>> ~ Johannes<br>
>><br>
>><br>
>>> Best wishes,<br>
>>> Navid.<br>
>>><br>
>>><br>
>>> _______________________________________________<br>
>>> LLVM Developers mailing list<br>
>>> <a href="mailto:llvm-dev@lists.llvm.org" 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><br>
</blockquote></div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">Best wishes,<br>Navid.</div>