summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2006-02-13 21:28:03 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2006-02-13 21:28:03 +0000
commitac88cb275fbc1d58f85da6eb8952edfe5190ddc8 (patch)
tree1f4da557cb99e9845fb71b7c810d10b3f6f929cc /gcc
parent693c40a771f342e973776e04bff265b580fcf2cf (diff)
downloadgcc-ac88cb275fbc1d58f85da6eb8952edfe5190ddc8.tar.gz
PR middle-end/26092
* gimplify.c (gimplify_call_expr): Don't call get_callee_fndecl twice if decl is a builtin. When trying again, call get_callee_fndecl first to verify it is still a builtin. * gcc.c-torture/compile/20060208-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@110927 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/gimplify.c28
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/20060208-1.c10
4 files changed, 37 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 15c3fc47c19..46d5b68e37b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2006-02-13 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/26092
+ * gimplify.c (gimplify_call_expr): Don't call get_callee_fndecl
+ twice if decl is a builtin. When trying again, call get_callee_fndecl
+ first to verify it is still a builtin.
+
2006-02-13 Geoffrey Keating <geoffk@apple.com>
* dwarf2out.c (base_type_die): Don't add AT_name here.
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 710569888ec..82e747f0070 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1970,9 +1970,8 @@ gimplify_call_expr (tree *expr_p, tree *pre_p, bool want_value)
decl = get_callee_fndecl (*expr_p);
if (decl && DECL_BUILT_IN (decl))
{
- tree fndecl = get_callee_fndecl (*expr_p);
tree arglist = TREE_OPERAND (*expr_p, 1);
- tree new = fold_builtin (fndecl, arglist, !want_value);
+ tree new = fold_builtin (decl, arglist, !want_value);
if (new && new != *expr_p)
{
@@ -2026,19 +2025,22 @@ gimplify_call_expr (tree *expr_p, tree *pre_p, bool want_value)
TREE_OPERAND (*expr_p, 1) = nreverse (TREE_OPERAND (*expr_p, 1));
/* Try this again in case gimplification exposed something. */
- if (ret != GS_ERROR && decl && DECL_BUILT_IN (decl))
+ if (ret != GS_ERROR)
{
- tree fndecl = get_callee_fndecl (*expr_p);
- tree arglist = TREE_OPERAND (*expr_p, 1);
- tree new = fold_builtin (fndecl, arglist, !want_value);
-
- if (new && new != *expr_p)
+ decl = get_callee_fndecl (*expr_p);
+ if (decl && DECL_BUILT_IN (decl))
{
- /* There was a transformation of this call which computes the
- same value, but in a more efficient way. Return and try
- again. */
- *expr_p = new;
- return GS_OK;
+ tree arglist = TREE_OPERAND (*expr_p, 1);
+ tree new = fold_builtin (decl, arglist, !want_value);
+
+ if (new && new != *expr_p)
+ {
+ /* There was a transformation of this call which computes the
+ same value, but in a more efficient way. Return and try
+ again. */
+ *expr_p = new;
+ return GS_OK;
+ }
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 113914077f7..1f2fdb7e55f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2006-02-13 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/26092
+ * gcc.c-torture/compile/20060208-1.c: New test.
+
2006-02-13 Paul Thomas <pault@gcc.gnu.org>
PR fortran/26074
diff --git a/gcc/testsuite/gcc.c-torture/compile/20060208-1.c b/gcc/testsuite/gcc.c-torture/compile/20060208-1.c
new file mode 100644
index 00000000000..01e471a7b0c
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/20060208-1.c
@@ -0,0 +1,10 @@
+/* PR middle-end/26092 */
+typedef __SIZE_TYPE__ size_t;
+extern void *malloc (size_t);
+
+void *(*const foo) (size_t) = malloc;
+
+void *test (void)
+{
+ return (*foo) (3);
+}