Break down C++ code size

前端 未结 7 1904
心在旅途
心在旅途 2021-02-04 10:51

I\'m looking for a nice Stack Overflow-style answer to the first question in the old blog post C++ Code Size, which I\'ll repeat below:

I’d

7条回答
  •  死守一世寂寞
    2021-02-04 11:48

    I don't know how to map code->generated assembly in general.

    For template instantiations you can use something like "strings -a |grep |sort -u|gc++filt" to get a rough picture of what's being created.

    The other two items you mentioned seem pretty subjective actually. What is "too much" inlining? Are you worried your binary file is getting inflated? The only thing to do there is actually go into gdb and disassemble the caller to see what it generated, nothing to check for "excessive" inlining in general.

    For function size, again I'm curious why it matters? Are you trying to find code that expands unexpectedly when compiled? How do you even define what an expected size is for a tool to examine? Again, you can always dissemble any function that you suspect is compiling to far more code than you want, and see exactly what the compiler is doing.

提交回复
热议问题