aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2006-12-04 23:51:42 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2006-12-04 22:51:42 +0000
commit26979bc292e163864289597602beb01705188349 (patch)
treeaec6f99c441c9265e6586e4694d0aa72c7570eaa /gcc
parent477d851ce1a3b9fbe06c921ebd99925276792085 (diff)
downloadgcc-26979bc292e163864289597602beb01705188349.zip
gcc-26979bc292e163864289597602beb01705188349.tar.gz
gcc-26979bc292e163864289597602beb01705188349.tar.bz2
cp-objcp-common.c (cp_expr_size): Return NULL in the case size is undefined.
* cp-objcp-common.c (cp_expr_size): Return NULL in the case size is undefined. * builtins.c (fold_builtin_memory_op): Check that expr_size match. * explow.c (expr_size, int_expr_size): Assert that size is non_NULL. From-SVN: r119515
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/builtins.c8
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/cp-objcp-common.c46
-rw-r--r--gcc/explow.c11
5 files changed, 48 insertions, 27 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3fbc38a..1de07b1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2006-12-04 Jan Hubicka <jh@suse.cz>
+
+ * builtins.c (fold_builtin_memory_op): Check that expr_size match.
+ * explow.c (expr_size, int_expr_size): Assert that size is non_NULL.
+
2006-12-04 Daniel Berlin <dberlin@dberlin.org>
* tree-ssa-alias.c (compute_may_aliases):
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 80c5e1f..0cfdb9a 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -8202,8 +8202,8 @@ fold_builtin_memory_op (tree arglist, tree type, bool ignore, int endp)
|| !TYPE_SIZE_UNIT (desttype)
|| TREE_CODE (TYPE_SIZE_UNIT (srctype)) != INTEGER_CST
|| TREE_CODE (TYPE_SIZE_UNIT (desttype)) != INTEGER_CST
- || !operand_equal_p (TYPE_SIZE_UNIT (srctype), len, 0)
- || !operand_equal_p (TYPE_SIZE_UNIT (desttype), len, 0))
+ || !tree_int_cst_equal (TYPE_SIZE_UNIT (srctype), len)
+ || !tree_int_cst_equal (TYPE_SIZE_UNIT (desttype), len))
return 0;
if (get_pointer_alignment (dest, BIGGEST_ALIGNMENT)
@@ -8218,6 +8218,8 @@ fold_builtin_memory_op (tree arglist, tree type, bool ignore, int endp)
srcvar = build_fold_indirect_ref (src);
if (TREE_THIS_VOLATILE (srcvar))
return 0;
+ if (!tree_int_cst_equal (lang_hooks.expr_size (srcvar), len))
+ return 0;
/* With memcpy, it is possible to bypass aliasing rules, so without
this check i. e. execute/20060930-2.c would be misoptimized, because
it use conflicting alias set to hold argument for the memcpy call.
@@ -8233,6 +8235,8 @@ fold_builtin_memory_op (tree arglist, tree type, bool ignore, int endp)
destvar = build_fold_indirect_ref (dest);
if (TREE_THIS_VOLATILE (destvar))
return 0;
+ if (!tree_int_cst_equal (lang_hooks.expr_size (destvar), len))
+ return 0;
if (!var_decl_component_p (destvar))
return 0;
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f0f93c0..31c87e2 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2006-12-04 Jan Hubicka <jh@suse.cz>
+
+ * cp-objcp-common.c (cp_expr_size): Return NULL in the case
+ size is undefined.
+
2006-12-04 Mark Mitchell <mark@codesourcery.com>
PR c++/29733
diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c
index a3e19db..a364087 100644
--- a/gcc/cp/cp-objcp-common.c
+++ b/gcc/cp/cp-objcp-common.c
@@ -82,29 +82,29 @@ cp_expr_size (tree exp)
/* The backend should not be interested in the size of an expression
of a type with both of these set; all copies of such types must go
through a constructor or assignment op. */
- gcc_assert (!TYPE_HAS_COMPLEX_INIT_REF (type)
- || !TYPE_HAS_COMPLEX_ASSIGN_REF (type)
- /* But storing a CONSTRUCTOR isn't a copy. */
- || TREE_CODE (exp) == CONSTRUCTOR
- /* And, the gimplifier will sometimes make a copy of
- an aggregate. In particular, for a case like:
-
- struct S { S(); };
- struct X { int a; S s; };
- X x = { 0 };
-
- the gimplifier will create a temporary with
- static storage duration, perform static
- initialization of the temporary, and then copy
- the result. Since the "s" subobject is never
- constructed, this is a valid transformation. */
- || CP_AGGREGATE_TYPE_P (type));
-
- /* This would be wrong for a type with virtual bases, but they are
- caught by the assert above. */
- return (is_empty_class (type)
- ? size_zero_node
- : CLASSTYPE_SIZE_UNIT (type));
+ if (!TYPE_HAS_COMPLEX_INIT_REF (type)
+ || !TYPE_HAS_COMPLEX_ASSIGN_REF (type)
+ /* But storing a CONSTRUCTOR isn't a copy. */
+ || TREE_CODE (exp) == CONSTRUCTOR
+ /* And, the gimplifier will sometimes make a copy of
+ an aggregate. In particular, for a case like:
+
+ struct S { S(); };
+ struct X { int a; S s; };
+ X x = { 0 };
+
+ the gimplifier will create a temporary with
+ static storage duration, perform static
+ initialization of the temporary, and then copy
+ the result. Since the "s" subobject is never
+ constructed, this is a valid transformation. */
+ || CP_AGGREGATE_TYPE_P (type))
+ /* This would be wrong for a type with virtual bases. */
+ return (is_empty_class (type)
+ ? size_zero_node
+ : CLASSTYPE_SIZE_UNIT (type));
+ else
+ return NULL_TREE;
}
else
/* Use the default code. */
diff --git a/gcc/explow.c b/gcc/explow.c
index e21e9c1..a710274 100644
--- a/gcc/explow.c
+++ b/gcc/explow.c
@@ -245,7 +245,11 @@ expr_size (tree exp)
if (TREE_CODE (exp) == WITH_SIZE_EXPR)
size = TREE_OPERAND (exp, 1);
else
- size = SUBSTITUTE_PLACEHOLDER_IN_EXPR (lang_hooks.expr_size (exp), exp);
+ {
+ size = lang_hooks.expr_size (exp);
+ gcc_assert (size);
+ size = SUBSTITUTE_PLACEHOLDER_IN_EXPR (size, exp);
+ }
return expand_expr (size, NULL_RTX, TYPE_MODE (sizetype), 0);
}
@@ -261,7 +265,10 @@ int_expr_size (tree exp)
if (TREE_CODE (exp) == WITH_SIZE_EXPR)
size = TREE_OPERAND (exp, 1);
else
- size = lang_hooks.expr_size (exp);
+ {
+ size = lang_hooks.expr_size (exp);
+ gcc_assert (size);
+ }
if (size == 0 || !host_integerp (size, 0))
return -1;