This is the mail archive of the
mailing list for the GCC project.
RE: Optimized Allocation of Argument registers
- From: Ajit Kumar Agarwal <ajit dot kumar dot agarwal at xilinx dot com>
- To: Jeff Law <law at redhat dot com>, Vladimir Makarov <vmakarov at redhat dot com>, "gcc Mailing List" <gcc at gcc dot gnu dot org>
- Cc: Vinod Kathail <vinodk at xilinx dot com>, Shail Aditya Gupta <shailadi at xilinx dot com>, Vidhumouli Hunsigida <vidhum at xilinx dot com>, "Nagaraju Mekala" <nmekala at xilinx dot com>
- Date: Tue, 18 Nov 2014 13:32:57 +0000
- Subject: RE: Optimized Allocation of Argument registers
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=pass (sender IP is 184.108.40.206) smtp dot mailfrom=ajit dot kumar dot agarwal at xilinx dot com;
- References: <2f1c83a90d8840f8ba274d17ecf830fd at BY2FFO11FD054 dot protection dot gbl> <546A1AE4 dot 4080609 at redhat dot com>
From: Jeff Law [mailto:email@example.com]
Sent: Monday, November 17, 2014 9:27 PM
To: Ajit Kumar Agarwal; Vladimir Makarov; gcc Mailing List
Cc: Vinod Kathail; Shail Aditya Gupta; Vidhumouli Hunsigida; Nagaraju Mekala
Subject: Re: Optimized Allocation of Argument registers
On 11/17/14 06:13, Ajit Kumar Agarwal wrote:
> Hello All:
> I was looking at the optimized usage and allocation to argument registers. There are two aspects to it as follows.
> 1. We need to specify the argument registers as followed by ABI in the target specific code. Based on the function
> argument registers defined in the target dependent code the function argument registers are passed. If the
> number of argument registers defined in the Architecture is large say 6/8 function argument registers.
> Most of the time in the benchmarks we don't pass so many arguments and the number of arguments passed
> is quite less. Since we reserve the function arguments as specified
> in the target specific code for the given architecture, leads to unoptimized usage as this function argument registers will not be used in the function.
> Thus we need to steal some of the arguments registers and have the
> usage of those in the function depending on the support of the number of function argument registers. The stealing of function argument registers will
> lead more number of registers available that are to be used in the function and leading to less spill and fetch.
> 2. The other aspect of the function argument registers is not spill
> and fetch the argument registers as they are live across the function
> call. But the liveness is limited to certain point of the called
> function after that point the function argument registers are not live
> and can be used inside the called function. Other aspect is if there is a shortage of registers than can the function argument registers should be used as spill candidate? Will this lead to the optimized code.
> Please let me know what do you think.
>>Typically GCC ports do not reserve the function argument/return registers, they are allocatable just like any other call clobbered register.
>>In essence arguments for function calls are set up at each call site by copying values out of pseudo registers, memory, constant initializations, etc to the >>appropriate outgoing argument register. The allocator will, when possible and profitable try to assign the pseudo register to the appropriate argument >>register to eliminate the copies.
>>Similarly, GCC copies values out of the incoming argument registers and into pseudos at the start of a function. The allocator, again when possible and >>profitable, will try to allocate the pseudos to the incoming argument registers to avoid the copy.
>>So in summary, there is no reason to reserve registers for argument passing in GCC and doing so would be wasteful. Treat the argument registers as any >>other call clobbered register and allow the register allocator to make appropriate decisions based on liveness, expected uses, call-crossing liveness, related >>copies, etc etc.
Thanks Jeff for the explanation and Clarifications.
Thanks & Regards