as @Anton has mentioned above, these Compiler passes are meant to be used with llvm-opt not the clang, clang only supports the standard optimization level -O[X]. However if you would like to use your compiler flags. i.e. "-instcombine", first you have to add the option -emit-llvm while using the clang.
Some comments and examples:
The list of the LLVM-opt could be found Here!
Here is a short example of using the LLVM-opt:
clang -S -emit-llvm foo.c -lm
opt ${<MY_DESIRED_COMPILER_FLAGS>} -S -o foo_OPTIMIZED.ll foo.ll
clang foo_OPTIMIZED.ll -lm
Now, if you take a diff
of the both versions of LLVM-IR
or .ll
files, you can see the differences.
- OPTing a whole project
For that matter, you should put these commands in loop and apply the opt on each of every files you need
OR
Write a makefile that does this for you.
OR
Create your own pass consisting of your desired passes and include them as a .so file. More Info Here!
Hope that helps.