Clang: How to check if LTO was performed

不羁的心 提交于 2019-12-07 19:23:16

问题


For gcc, this answer tells us how we can verify that Link-Time Optimization was performed. For clang, I cannot see any entries similar to .gnu.lto.

More specifically, I have a binary where I am quite sure that LTO should have a significant benefit, but I am seeing nothing. I wonder if cmake actually does the right thing.

Is there any way to tell if clang performed LTO by looking at a binary or an *.o file?


回答1:


An option would be to try running llvm-dis on one of your .o files. If the LTO was actually performed, the .o files contain llvm bitcode and llvm-dis will produce the .ll file containing humain-readable llvm ir. Otherwise it will produce the error message "error: Invalid bitcode signature".




回答2:


The file utility will report that the file is "LLVM IR bitcode". LLVM/clang's LTO facilities don't produce "fat" object files, it's just IR.



来源:https://stackoverflow.com/questions/51048414/clang-how-to-check-if-lto-was-performed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!