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

前端 未结 8 1796
闹比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:32

    A useful technique is to run the code under a good sampling profiler, e.g. Zoom under Linux or Instruments (with Time Profiler instrument) under Mac OS X. These profilers not only show you the hotspots in your code but also map source code to disassembled object code. Highlighting a source line shows the (not necessarily contiguous) lines of generated code that map to the source line (and vice versa). Online opcode references and optimization tips are a nice bonus.

    • Instruments: developer.apple.com
    • Zoom: www.rotateright.com

提交回复
热议问题