Verifying compiler optimizations in gcc/g++ by analyzing assembly listings

前端 未结 8 1999
闹比i
闹比i 2021-02-04 09:00

I just asked a question related to how the compiler optimizes certain C++ code, and I was looking around SO for any questions about how to verify that the compiler has performed

8条回答
  •  我寻月下人不归
    2021-02-04 09:21

    Victor, in your case the optimization you are looking for is just a smaller allocation of local memory on the stack. You should see a smaller allocation at function entry and a smaller deallocation at function exit if the space used by the empty class is optimized away.

    As for the general question, I've been reading (and writing) assembly language for more than (gulp!) 30 years and all I can say is that it takes practice, especially to read the output of a compiler.

提交回复
热议问题