link-time-optimization

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

Can LTO for gcc or clang optimize across C and C++ methods

旧巷老猫 提交于 2019-11-26 21:49:13
问题 If link-time optimization (LTO) is being used with gcc or clang, is it possible that code can be optimized across the C and C++ language boundary? For example, can a C function be inlined into a C++ caller? 回答1: Yes! Link-time optimization typically works on intermediate representation (IR) present in "fat" object files, which can contain both machine code for traditional linking, and IR for LTO linking. At this stage, there are no more high-level language constructs, so link-time