summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/20050503-1.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2005-05-03 22:22:02 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2005-05-03 22:22:02 +0000
commit0b25db2159a2082ba5b70c17bd8ca2800036e50c (patch)
tree4366b13e06448d5bee414e03f73b1dc515a238a0 /gcc/testsuite/gcc.dg/20050503-1.c
parentb53451fc9637f05de2a734820c168df6fb155561 (diff)
downloadgcc-0b25db2159a2082ba5b70c17bd8ca2800036e50c.tar.gz
PR middle-end/21265
* expr.h (enum block_op_methods): Add BLOCK_OP_TAILCALL. (clear_storage): Add argument. * expr.c (emit_block_move_via_libcall, clear_storage_via_libcall): Add tailcall argument, set CALL_EXPR_TAILCALL of the CALL_EXPR to tailcall. (emit_block_move): Handle BLOCK_OP_TAILCALL method. (clear_storage): Add method argument, handle BLOCK_OP_TAILCALL. (store_expr, store_constructor): Adjust callers. * builtins.c (expand_builtin_memcpy): Pass BLOCK_OP_TAILCALL to emit_block_move if CALL_EXPR_TAILCALL (exp). (expand_builtin_memmove): Add ORIG_EXP argument, copy CALL_EXPR_TAILCALL from ORIG_EXP to the new CALL_EXPR. (expand_builtin_bcopy): Replace ARGLIST and TYPE arguments with EXP. Pass EXP to expand_builtin_memmove. (expand_builtin_memset): Add ORIG_EXP argument, pass BLOCK_OP_TAILCALL to clear_storage if CALL_EXPR_TAILCALL (orig_exp). (expand_builtin_bzero): Replace ARGLIST argument with EXP. Pass EXP to expand_builtin_memset. (expand_builtin_strcmp): Copy CALL_EXPR_TAILCALL from EXP to the new CALL_EXPR. (expand_builtin_strncmp): Likewise. (expand_builtin_printf): Replace ARGLIST argument with EXP. Copy CALL_EXPR_TAILCALL from EXP to the new CALL_EXPR. (expand_builtin_fprintf): Likewise. (expand_builtin): Adjust calls to expand_builtin_{memmove,bcopy,memset,bzero,{,f}printf}. * gcc.dg/20050503-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@99187 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/20050503-1.c')
-rw-r--r--gcc/testsuite/gcc.dg/20050503-1.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/20050503-1.c b/gcc/testsuite/gcc.dg/20050503-1.c
new file mode 100644
index 00000000000..f8246dbbd3f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/20050503-1.c
@@ -0,0 +1,49 @@
+/* PR middle-end/21265
+ Test whether tail call information is propagated through builtin
+ expanders. */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+#define F(n, rettype, name, args, callargs) \
+extern rettype name args; \
+rettype test##n args \
+{ \
+ return name callargs; \
+}
+#define F1(n, rettype, name, t1, callargs) \
+ F (n, rettype, name, (t1 a1), callargs)
+#define F2(n, rettype, name, t1, t2, callargs) \
+ F (n, rettype, name, (t1 a1, t2 a2), callargs)
+#define F3(n, rettype, name, t1, t2, t3, callargs) \
+ F (n, rettype, name, (t1 a1, t2 a2, t3 a3), callargs)
+
+F3 (1a, void *, memcpy, void *, const void *, size_t, (a1, a2, a3))
+F3 (1b, void *, memcpy, void *, const void *, size_t, (a1, a2, 10))
+F3 (2a, void *, mempcpy, void *, const void *, size_t, (a1, a2, a3))
+F3 (2b, void *, mempcpy, void *, const void *, size_t, (a1, a2, 10))
+F3 (3a, void *, memmove, void *, const void *, size_t, (a1, a2, a3))
+F3 (3b, void *, memmove, void *, const void *, size_t, (a1, "abcdefghijklmno", a3))
+F3 (4a, void *, memset, void *, int, size_t, (a1, a2, a3))
+F3 (4b, void *, memset, void *, int, size_t, (a1, a2, 156))
+F3 (4c, void *, memset, void *, int, size_t, (a1, 0, a3))
+F3 (4d, void *, memset, void *, int, size_t, (a1, 0, 10000))
+F3 (5a, int, memcmp, const void *, const void *, size_t, (a1, a2, a3))
+F3 (5b, int, memcmp, const void *, const void *, size_t, (a1, "abcdefghijkl", a3))
+F2 (6, char *, strcpy, char *, const char *, (a1, a2))
+F2 (7, char *, stpcpy, char *, const char *, (a1, a2))
+F3 (8, char *, strncpy, char *, const char *, size_t, (a1, a2, a3))
+F3 (9, char *, stpncpy, char *, const char *, size_t, (a1, a2, a3))
+F2 (10, char *, strcat, char *, const char *, (a1, a2))
+F3 (11, char *, strncat, char *, const char *, size_t, (a1, a2, a3))
+F1 (12a, size_t, strlen, const char *, (a1))
+F1 (12b, size_t, strlen, const char *, ("foobar"))
+F2 (13a, int, strcmp, const char *, const char *, (a1, a2))
+F2 (13b, int, strcmp, const char *, const char *, (a1, "abcdefghijklm"))
+F3 (14a, int, strncmp, const char *, const char *, size_t, (a1, a2, a3))
+F3 (14b, int, strncmp, const char *, const char *, size_t, (a1, "abcdefghijklm", 10))
+F2 (15, char *, strchr, const char *, int, (a1, a2))
+
+/* All the calls above should be tail call optimized on i?86/x86-64. */
+/* { dg-final { scan-assembler-not "call" { target i?86-*-linux* x86_64-*-linux* } } } */