How does GCC decide what order to output assembly functions in?

后端 未结 1 1687
感动是毒
感动是毒 2021-02-13 14:21

Reading through the assembly GCC generates for C files in my project, I notice functions are not outputted in assembly in the same order they appear in the source file. What is

相关标签:
1条回答
  • 2021-02-13 15:01

    The later parts of the inter-procedural optimisation phase use a bottom-up traversal of the call graph; that's the ordering that you see. There's a paper about the original design of this part of GCC here (from a while ago; this stuff first appeared in GCC 3.4).

    You can prevent the reordering using -fno-toplevel-reorder (or -fno-unit-at-a-time for less recent versions of GCC), but that disables some of the related optimisations.

    0 讨论(0)
提交回复
热议问题