This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Fix dangerous implementations of *_return_in_memory.
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Cc: rth at redhat dot com
- Date: Sat, 31 Jan 2004 15:56:28 -0500 (EST)
- Subject: [patch] Fix dangerous implementations of *_return_in_memory.
Hi,
Attached is a patch to fix dangerous implementations of
*_return_in_memory that do not check the return value of
int_size_in_bytes against -1.
For arc, I've removed TREE_ADDRESSABLE check as it's also done in
aggregate_value_p() in function.c.
Built cc1 of each port-elf. OK to apply?
Kazu Hirata
2004-01-30 Kazu Hirata <kazu@cs.umass.edu>
* config/arc/arc.c (arc_return_in_memory): Check the return
value of int_size_in_bytes against -1. Don't check
TREE_ADDRESSABLE.
* config/avr/avr.c (avr_return_in_memory): Check the return
value of int_size_in_bytes against -1.
* config/ip2k/ip2k.c (ip2k_return_in_memory): Likewise.
* config/m68hc11/m68hc11.c (m68hc11_return_in_memory):
Likewise.
* config/mcore/mcore.c (mcore_return_in_memory): Likewise.
* config/stormy16/stormy16.c (xstormy16_return_in_memory):
Likewise.
Index: arc/arc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/arc/arc.c,v
retrieving revision 1.48
diff -u -r1.48 arc.c
--- arc/arc.c 26 Jan 2004 23:22:51 -0000 1.48
+++ arc/arc.c 30 Jan 2004 23:40:48 -0000
@@ -2368,7 +2368,11 @@
static bool
arc_return_in_memory (tree type, tree fntype ATTRIBUTE_UNUSED)
{
- return (AGGREGATE_TYPE_P (type)
- || int_size_in_bytes (type) > 8
- || TREE_ADDRESSABLE (type));
+ if (AGGREGATE_TYPE_P (type))
+ return true;
+ else
+ {
+ HOST_WIDE_INT size = int_size_in_bytes (type);
+ return (size == -1 || size > 8);
+ }
}
Index: avr/avr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/avr/avr.c,v
retrieving revision 1.110
diff -u -r1.110 avr.c
--- avr/avr.c 30 Jan 2004 23:16:05 -0000 1.110
+++ avr/avr.c 30 Jan 2004 23:40:50 -0000
@@ -5384,9 +5384,13 @@
static bool
avr_return_in_memory (tree type, tree fntype ATTRIBUTE_UNUSED)
{
- return ((TYPE_MODE (type) == BLKmode)
- ? int_size_in_bytes (type) > 8
- : 0);
+ if (TYPE_MODE (type) == BLKmode)
+ {
+ HOST_WIDE_INT size = int_size_in_bytes (type);
+ return (size == -1 || size > 8);
+ }
+ else
+ return false;
}
#include "gt-avr.h"
Index: ip2k/ip2k.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/ip2k/ip2k.c,v
retrieving revision 1.31
diff -u -r1.31 ip2k.c
--- ip2k/ip2k.c 30 Jan 2004 23:16:07 -0000 1.31
+++ ip2k/ip2k.c 30 Jan 2004 23:40:52 -0000
@@ -6201,7 +6201,13 @@
static bool
ip2k_return_in_memory (tree type, tree fntype ATTRIBUTE_UNUSED)
{
- return (TYPE_MODE (type) == BLKmode) ? int_size_in_bytes (type) > 8 : 0;
+ if (TYPE_MODE (type) == BLKmode)
+ {
+ HOST_WIDE_INT size = int_size_in_bytes (type);
+ return (size == -1 || size > 8);
+ }
+ else
+ return false;
}
/* Worker function for TARGET_SETUP_INCOMING_VARARGS. */
Index: m68hc11/m68hc11.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/m68hc11/m68hc11.c,v
retrieving revision 1.93
diff -u -r1.93 m68hc11.c
--- m68hc11/m68hc11.c 30 Jan 2004 23:16:11 -0000 1.93
+++ m68hc11/m68hc11.c 30 Jan 2004 23:40:54 -0000
@@ -5549,9 +5549,13 @@
static bool
m68hc11_return_in_memory (tree type, tree fntype ATTRIBUTE_UNUSED)
{
- return ((TYPE_MODE (type) == BLKmode)
- ? (int_size_in_bytes (type) > 4)
- : (GET_MODE_SIZE (TYPE_MODE (type)) > 4));
+ if (TYPE_MODE (type) == BLKmode)
+ {
+ HOST_WIDE_INT size = int_size_in_bytes (type);
+ return (size == -1 || size > 4);
+ }
+ else
+ return GET_MODE_SIZE (TYPE_MODE (type)) > 4;
}
#include "gt-m68hc11.h"
Index: mcore/mcore.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mcore/mcore.c,v
retrieving revision 1.58
diff -u -r1.58 mcore.c
--- mcore/mcore.c 30 Jan 2004 23:16:12 -0000 1.58
+++ mcore/mcore.c 30 Jan 2004 23:40:55 -0000
@@ -3468,5 +3468,6 @@
static bool
mcore_return_in_memory (tree type, tree fntype ATTRIBUTE_UNUSED)
{
- return int_size_in_bytes (type) > 2 * UNITS_PER_WORD;
+ HOST_WIDE_INT size = int_size_in_bytes (type);
+ return (size == -1 || size > 2 * UNITS_PER_WORD);
}
Index: stormy16/stormy16.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/stormy16/stormy16.c,v
retrieving revision 1.54
diff -u -r1.54 stormy16.c
--- stormy16/stormy16.c 30 Jan 2004 23:16:22 -0000 1.54
+++ stormy16/stormy16.c 30 Jan 2004 23:40:57 -0000
@@ -2170,10 +2170,13 @@
return retval;
}
+/* Worker function for TARGET_RETURN_IN_MEMORY. */
+
static bool
xstormy16_return_in_memory (tree type, tree fntype ATTRIBUTE_UNUSED)
{
- return int_size_in_bytes (type) > UNITS_PER_WORD * NUM_ARGUMENT_REGISTERS;
+ HOST_WIDE_INT size = int_size_in_bytes (type);
+ return (size == -1 || size > UNITS_PER_WORD * NUM_ARGUMENT_REGISTERS);
}
#undef TARGET_ASM_ALIGNED_HI_OP