[llvm-dev] Disable optimization on basic block level
Matthias Braun via llvm-dev
llvm-dev at lists.llvm.org
Mon Apr 24 10:17:23 PDT 2017
+CC llvm-dev again!
> On Apr 24, 2017, at 12:46 AM, Max Muster <olimex5812 at gmail.com> wrote:
> Hi Matthias,
> thanks for your answer.
> 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.
> However, LLVM's optimization passes are clever enough to optimize my inserted code at IR level.
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 :)
> Are there other possibilities to avoid optimization at certain parts of IR code?
Add some instructions triggering observable effects. Typical examples for "tricking" optimizers would be volatile loads or volatile asm blocks (possibly without actual instructions inside).
More information about the llvm-dev