gcc argument register spilling on x86-64

后端 未结 2 1737
春和景丽
春和景丽 2020-12-19 07:56

I\'m doing some experimenting with x86-64 assembly. Having compiled this dummy function:

long myfunc(long a, long b, long c, long d,
            long e, long         


        
2条回答
  •  旧时难觅i
    2020-12-19 08:58

    A couple of reasons:

    1. In the general case, an argument to a function has to be treated like a local variable because it could be stored to or have its address taken within the function. Therefore, it is simplest to just allocate a stack slot for every arguments.
    2. Debug information becomes much simpler to emit with stack locations: the argument's value is always at some specific location, instead of moving around between registers and memory.

    When you're looking at -O0 code in general, consider that the compiler's top priorities are reducing compile-time as much as possible and generating high-quality debugging information.

提交回复
热议问题