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]

Re: [PATCH,TESTSUITE]Reduce malloc size used by ipa-sra-2.c


You assumptions about sizes are correct.

int is 16 bit
pointers are 16bit
long are 32 bit



Richard Guenther wrote:
On Sun, Nov 1, 2009 at 12:37 PM, Andrew Hutchinson
<andrewhutchinson@cox.net> wrote:
That's an interesting point !

AVR does not reject this. It never gets to see it. Error is:

error: size of array 'data' is too large

which appear to come from c-decl.c or perhaps c-common.c

The former has check for array size (in bytes) overflowing integer max+1.
Which for AVR would be 32768 bytes. (this actually raises another issue
where 'unsigned' size of 65536 bytes should be limit)

Hmm. I think the constant is parsed as a long (which is 32bits on avr?), but the C frontend uses c_common_signed_type (sizetype) as canonical index type here which is only 16 bits (you have 16bits sizetype I guess).

I suspect that choosing such a small sizetype is the problem, but the
C frontend rejecting the program is probably non-conforming as well
(it could warn and put error_mark_node in the size or so).

Maybe Joseph can clarify this.

Richard.

Andy


Richard Guenther wrote:
On Sun, Nov 1, 2009 at 11:40 AM, Andrew Hutchinson
<andrewhutchinson@cox.net> wrote:

Its the array size:

int data[1000000]

Yes, I could equally skip this.

But the array is not allocated - does AVR really reject a program just
because there appears a possibly unused large type?

Richard.


Richard Guenther wrote:

On Sat, Oct 31, 2009 at 8:27 PM, Andrew Hutchinson
<andrewhutchinson@cox.net> wrote:


Thanks - patch was not as tested. Correction below.

This patch corrects a testcase where malloc size 1,000,000 is way too
big
for target.
Size requested is reduce if stack size is below 16000.

The patch removes failures for AVR target.
Ok to commit?


I think for this kind of tests you should simply skip AVR.  Note that it
mallocs sizeof (struct small), which is small.  So I don't see why
you get a failure here anyway.

Richard.



2009-10-31 Andy Hutchinson <hutchinsonandy@gcc.gnu.org>

 *gcc.c-torture/execute/ipa-sra-2.c: Reduce allocation if stack is
small.



Index: ipa-sra-2.c
===================================================================
--- ipa-sra-2.c    (revision 153773)
+++ ipa-sra-2.c    (working copy)
@@ -1,6 +1,11 @@
+#if defined(STACK_SIZE) && STACK_SIZE < 16000
+#define ARRAY_SIZE (STACK_SIZE)
+#else
+#define ARRAY_SIZE 1000000
+#endif
struct big
{
-  int data[1000000];
+  int data[ARRAY_SIZE];
};

struct small
@@ -23,7 +28,7 @@
{
 int r;
 if (fail)
-    r = agg->big.data[999999];
+    r = agg->big.data[ARRAY_SIZE - 1];
 else
 r = agg->small.data[0];
 return r;







Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]