This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hello, we were doing something quite silly in reshape_init for arrays: using INTEGER_CST to track indices for the sole purposes of counting up from zero to the declared size of the array. For an array of 8 million of elements like that in c++/14179, it means that we allocate approximately 8 million of totally useless trees that we throw away the first time GC collects. This patch fixes it, by using a couple of unsigned HOST_WIDE_INTEGER (low+high) instead. This mimics INTEGER_CSTs but without building trees every time. I guess we cannot do it with a single HWI for cases like crosscompiling a 32bit application with arrays with more than 65536 elements on a 16bit host, so this is why I am using a couple of them (just like INTEGER_CST). While I was at it, I also noticed that designated initializers larger than the array size were not diagnosed. I know the extension is pretty much borked, but it was an easy fix so I put it in. With a reduced testcases with half million elements, we save approximately 13Mb. On the full testcase, the projected gain is around 200Mb. Together with Nathan's cache for INTEGER_CSTs, I think this solves the memory-hog on mainline. I will update the PR with updated measurements when/if this patch goes in. Bootstrapped on i686-pc-linux-gnu, OK for mainline? OK for 3.4 and 3.3 too? The patch does cure a regression, and it looks pretty safe to me. The diff looks more complex than it needs because of some refactoring and extracting the code into a new function -- if needed, I can prepare a stripped down version with minimal intrusiveness (assuming it's an English word...). Giovanni Bajo cp/ PR c++/14179 * decl.c (reshape_init): Extract array handling into... (reshape_init_array): New function. Use integers instead of trees for indices. Handle out-of-range designated initializers.
Attachment:
patch-pr14179-2.txt
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |