Bitcode is IR in binary form.
llvm-dis will convert that to textual form,
llvm-as will convert the textual form back to bitcode.
It’s entirely possible to compile to bitcode at -O0 and then optimize it later with whatever flags you want. Beware that by default, clang -O0 will annotate each function with the
optnone attribute, meaning most optimizations will have no effect. You can avoid this by compiling your C/C++ with
clang -O0 -Xclang -disable-O0-optnone.
thanks for the explanation.
we have a bc generated by glow. when I compile it using clang to assembly with Oz it still vectorize and unroll loops although it should not be done.
I see very manor changes between compiling it with -O3 or -Oz.
so I wondered what do I miss.
if there are attributes that override opt level, how can I see it?
If you just want to look at the IR, use
llvm-dis to “disassemble” the bitcode to textual IR. Then you can look at the attributes on different functions and see what is going on. There are descriptions of the attributes here.