summaryrefslogtreecommitdiffstats
path: root/gcc
diff options
context:
space:
mode:
authorsteven <steven@138bc75d-0d04-0410-961f-82ee72b054a4>2004-05-17 21:25:32 +0000
committersteven <steven@138bc75d-0d04-0410-961f-82ee72b054a4>2004-05-17 21:25:32 +0000
commit7f94ca93efd7e4bd2fa1c499234b64b294d39599 (patch)
treee120c60ebe7b84548205ca3f7b6991210a7476a1 /gcc
parent795c59e98ffae0810d7f48ddde10d93905a3fc90 (diff)
downloadppe42-gcc-7f94ca93efd7e4bd2fa1c499234b64b294d39599.tar.gz
ppe42-gcc-7f94ca93efd7e4bd2fa1c499234b64b294d39599.zip
* tree-ssa-operands.c (get_expr_operands): Do not treat malloc
attributed functions as pure or const. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@81951 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/20040517-1.c20
-rw-r--r--gcc/tree-ssa-operands.c9
4 files changed, 33 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index db93d50c46d..ea3b7f97897 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2004-05-17 Steven Bosscher <stevenb@suse.de>
+
+ * tree-ssa-operands.c (get_expr_operands): Do not treat malloc
+ attributed functions as pure or const.
+
2004-05-17 Frank Ch. Eigler <fche@redhat.com>
* tree-mudflap.c (mx_register_decls): Tolerate decl trees resulting
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ad748bcee66..82a596b454a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2004-05-17 Steven Bosscher <stevenb@suse.de>
+
+ * gcc.dg/tree-ssa/20040517-1.c: New test.
+
2004-05-15 Andrew Pinski <pinskia@physics.uc.edu>
* gcc.dg/tree-ssa/20040514-1.c: Add '}' that was forgotten.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/20040517-1.c b/gcc/testsuite/gcc.dg/tree-ssa/20040517-1.c
new file mode 100644
index 00000000000..c38f1b360f1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/20040517-1.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-ssa-vops" } */
+int a;
+
+extern void __attribute__ ((malloc)) *foo ();
+
+void bar (void)
+{
+ a = 1;
+ foo ();
+ if (a)
+ abort ();
+}
+
+/* We used to treat malloc functions like pure and const functions, but
+ malloc functions may clobber global memory. Only the function result
+ does not alias any other pointer.
+ Hence, we must have a VDEF for a before and after the call to foo(). */
+/* { dg-final { scan-tree-dump-times "VDEF" 2 "ssa"} } */
+
diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c
index de5b16d1fd4..f0112755d96 100644
--- a/gcc/tree-ssa-operands.c
+++ b/gcc/tree-ssa-operands.c
@@ -1023,12 +1023,11 @@ get_expr_operands (tree stmt, tree *expr_p, int flags, voperands_t prev_vops)
if (bitmap_first_set_bit (call_clobbered_vars) >= 0)
{
+ /* A 'pure' or a 'const' functions never call clobber anything.
+ A 'noreturn' function might, but since we don't return anyway
+ there is no point in recording that. */
if (!(call_flags
- & (ECF_PURE
- | ECF_CONST
- | ECF_NORETURN
- | ECF_MALLOC
- | ECF_MAY_BE_ALLOCA)))
+ & (ECF_PURE | ECF_CONST | ECF_NORETURN)))
add_call_clobber_ops (stmt, prev_vops);
else if (!(call_flags & (ECF_CONST | ECF_NORETURN)))
add_call_read_ops (stmt, prev_vops);
OpenPOWER on IntegriCloud