This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Replacing malloc with alloca.
- From: Ajit Kumar Agarwal <ajit dot kumar dot agarwal at xilinx dot com>
- To: Jeff Law <law at redhat dot com>, Richard Biener <richard dot guenther at gmail dot com>, "gcc at gcc dot gnu dot org" <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: Sun, 13 Sep 2015 12:12:26 +0000
- Subject: Replacing malloc with alloca.
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=pass (sender IP is 149.199.60.100) smtp.mailfrom=xilinx.com; gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=bestguesspass action=none header.from=xilinx.com;
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:23
All:
The replacement of malloc with alloca can be done on the following analysis.
If the lifetime of an object does not stretch beyond the immediate scope. In such cases the malloc can be replaced with alloca.
This increases the performance to a great extent.
Inlining helps to a great extent the scope of lifetime of an object doesn't stretch the immediate scope of an object.
And the scope of replacing malloc with alloca can be identified.
I am wondering what phases of our optimization pipeline the malloc is replaced with alloca and what analysis is done to transform
The malloc with alloca. This greatly increases the performance of the benchmarks? Is the analysis done through Escape Analysis?
If yes, then what data structure is used for the abstract execution interpretation?
Thanks & Regards
Ajit