<div dir="auto">Thanks Johannes. That makes this makes it more understandable to me. What can I do for optimization that doesn’t have flag? How should I approach disabling them. </div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Mar 27, 2021 at 22:10 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">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 will<br>
> run on my code. Does Clang/LLVM permit such an approach?<br>
<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>
><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 involved<br>
> in. I realized that there are two sets of optimizations and 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>
<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>
><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 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 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>
<br>
Most, if not all, are mandatory.<br>
<br>
<br>
> 4) Is there any way to disable/enable specific LLVM optimization?<br>
<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>
<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>
><br>
> I appreciate immensely any help regarding these questions.<br>
<br>
Hope this helps, others might have more information.<br>
<br>
~ Johannes<br>
<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>