How to emit opt report when using LTO

I'm using clang frontend.
I'm interested in some particular hot loop in my code and I emit a
report from vectorizer optimizations passes.
I receive nice output if passing -Rpass* flags as long as I'm building
without LTO?
But with -flto it just prints nothing.
Is there a way to emit opt reports when using LTO?

For now I can only approximate about whether my the loop will be
vectorized. I remove -flto and check opt reports. But as I understand,
decision about loop vectorization may be changed on LTO stage, so it
is only an approximation.

Unfortunately, -Rpass options are not currently passed to the linker invoked when you do the LTO link. To workaround, pass the internal LLVM option which are -pass-remarks* (e.g. -pass-remarks=. -pass-remarks-missed=. etc). How you do this will depend on the linker you are using. If gold, then when you do the LTO link pass via -plugin-opt: -Wl,-plugin-opt,-pass-remarks=. for example. If using lld, I believe it would be -Wl,-mllvm -Wl,-pass-remarks=. (i.e. each internal LLVM option needs to be preceeded by an -mllvm on the link link).


Hello Teresa,

Thank you very much!
It works for me with gold linker!