opt: how to invoke optimizations manually?


I'd like to measure the impact of optimizations.
Trying this (for DCE):

* clang -S -emit-llvm test.c
* opt -S test.ll > without_dce.ll
* opt -S -dce test.ll > with_dce.ll

gives without_dce.ll and with_dce.ll having the same content.

How can you apply certain optimizations in a specified order?



You should add this option to the first command “-disable-O0-optnone” so clang -Xclang -disable-O0-optnone -emit-llvm -S -o without_dce.ll test.c then opt -dce -S < without_dce.ll > with_dce.ll


Works. Thanks a lot!

I feel like it might save people some significant time in the long run if opt printed a helpful little error message when it is instructed to run >0 transformation passes and also all functions it sees are optnone.


one more guy fell into "optnone":
  [llvm-dev] LLVM Alias Analysis (Load and store from same address is not showed up in same set)