diff mbox

[target/i386] PR 61599

Message ID CAAs8Hmyp9mN3vHxN4La3p0EcyYX_+ENRd1aas4R+VVhSkXtqow@mail.gmail.com
State New
Headers show

Commit Message

Sriraman Tallam July 7, 2014, 10:47 p.m. UTC
Hi,

   I have attached a patch for this bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61599. Is this alright?

Thanks
Sri
Patch to fix PR 61599: 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61599

Function int_size_in_bytes returns -1 in as the size in cases where
the size of the type can vary or is larger than integer.  In these
cases it is safer to assume that this is in large data.

	PR target/61599
	* config/i386/i386.c (ix86_in_large_data_p): Check for size less
	than zero.

	* gcc.target/i386/pr61599-1.c: New test.
	* gcc.target/i386/pr61599-2.c: New test.

Comments

Jan Hubicka July 7, 2014, 11:15 p.m. UTC | #1
> Hi,
> 
>    I have attached a patch for this bug:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61599. Is this alright?
> 
> Thanks
> Sri

> Patch to fix PR 61599: 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61599
> 
> Function int_size_in_bytes returns -1 in as the size in cases where
> the size of the type can vary or is larger than integer.  In these
> cases it is safer to assume that this is in large data.
> 
> 	PR target/61599
> 	* config/i386/i386.c (ix86_in_large_data_p): Check for size less
> 	than zero.
> 
> 	* gcc.target/i386/pr61599-1.c: New test.
> 	* gcc.target/i386/pr61599-2.c: New test.

OK,
thanks!
Honza
diff mbox

Patch

Index: testsuite/gcc.target/i386/pr61599-1.c
===================================================================
--- testsuite/gcc.target/i386/pr61599-1.c	(revision 0)
+++ testsuite/gcc.target/i386/pr61599-1.c	(revision 0)
@@ -0,0 +1,14 @@ 
+/* PR target/61599 */
+/* { dg-options "-mcmodel=medium -fdata-sections" } */
+/* { dg-additional-sources pr61599-2.c } */
+/* { dg-do run } */
+
+char a[1*1024*1024*1024];
+char b[1*1024*1024*1024];
+char c[1*1024*1024*1024];
+
+extern int bar();
+int main()
+{
+  return bar() + c[225];
+}
Index: testsuite/gcc.target/i386/pr61599-2.c
===================================================================
--- testsuite/gcc.target/i386/pr61599-2.c	(revision 0)
+++ testsuite/gcc.target/i386/pr61599-2.c	(revision 0)
@@ -0,0 +1,12 @@ 
+/* PR target/61599 */
+/* With -mcmodel=medium, all the arrays will be treated as large data.  */
+/* { dg-options "-mcmodel=medium -fdata-sections" } */
+
+extern char a[];
+extern char b[];
+extern char c[];
+
+int bar()
+{
+  return a[2] + b[16] + c[256];
+}
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 212336)
+++ config/i386/i386.c	(working copy)
@@ -5039,8 +5039,11 @@  ix86_in_large_data_p (tree exp)
       HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp));
 
       /* If this is an incomplete type with size 0, then we can't put it
-	 in data because it might be too big when completed.  */
-      if (!size || size > ix86_section_threshold)
+	 in data because it might be too big when completed.  Also,
+	 int_size_in_bytes returns -1 if size can vary or is larger than
+	 an integer in which case also it is safer to assume that it goes in
+	 large data.  */
+      if (size <= 0 || size > ix86_section_threshold)
 	return true;
     }