<div dir="ltr"><div><div>How do you disable optimization for a function?<br><br></div>I ask because my application often compiles machine-generated code that results in pathological structures that take a long time to optimize, for little benefit. As an example, if a basic block has over a million instructions in it, then DSE can take a while, as it is O(n^2) in the number of instructions in the block. In my application (at least), this block is typically executed only once at run time, and is not part of a loop, so I really don't care about code quality for that block.<br><br></div>I am able to identify some of these conditions. I would like to tell LLVM to "not try so hard" on the pathological blocks, while keeping optimizations active for ordinary cases.<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 24, 2017 at 1:17 PM, Matthias Braun via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">+CC llvm-dev again!<br>
<br>
> On Apr 24, 2017, at 12:46 AM, Max Muster <<a href="mailto:olimex5812@gmail.com">olimex5812@gmail.com</a>> wrote:<br>
><br>
> Hi Matthias,<br>
><br>
> thanks for your answer.<br>
><br>
> The reason it would be useful for me is that I am inserting a basic block at IR level as part of a function pass.<br>
> However, LLVM's optimization passes are clever enough to optimize my inserted code at IR level.<br>
Of course a compiler is only concerned about the observable effects of a program. Whether there is an extra block or not is not considered part of that. You should probably reconsider what you actually want here. We also cannot really help you with the information given so far, I am pretty sure you have higher goals than just keeping a basic block (otherwise you could just stop the compiler after your pass and the block would stay :)<br>
<br>
><br>
> Are there other possibilities to avoid optimization at certain parts of IR code?<br>
Add some instructions triggering observable effects. Typical examples for "tricking" optimizers would be volatile loads or volatile asm blocks (possibly without actual instructions inside).<br>
<br>
- Matthias<br>
<div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</div></div></blockquote></div><br></div>