diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-09-27 16:15:46 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-09-27 16:15:46 +0000 |
commit | 9efe50a4d79824946b1ee2e1ba14f454de1f3fe5 (patch) | |
tree | c8200cc6b87f6842f33b4c4ff883b03d7a81bc54 /gcc/testsuite/gcc.dg/strlenopt.h | |
parent | b26725ca1e5813a9009a0765e701cef281ccd900 (diff) | |
download | gcc-9efe50a4d79824946b1ee2e1ba14f454de1f3fe5.tar.gz |
* common.opt: Add -foptimize-strlen option.
* Makefile.in (OBJS): Add tree-ssa-strlen.o.
(tree-sssa-strlen.o): Add dependencies.
* opts.c (default_options_table): Enable -foptimize-strlen
by default at -O2 if not -Os.
* passes.c (init_optimization_passes): Add pass_strlen
after pass_object_sizes.
* timevar.def (TV_TREE_STRLEN): New timevar.
* params.def (PARAM_MAX_TRACKED_STRLENS): New parameter.
* tree-pass.h (pass_strlen): Declare.
* tree-ssa-strlen.c: New file.
* c-decl.c (merge_decls): If compatible stpcpy prototype
is seen, set implicit_built_in_decls[BUILT_IN_STPCPY].
cp/
* decl.c (duplicate_decls): If compatible stpcpy prototype
is seen, set implicit_built_in_decls[BUILT_IN_STPCPY].
testsuite/
* gcc.dg/strlenopt-1.c: New test.
* gcc.dg/strlenopt-1f.c: New test.
* gcc.dg/strlenopt-2.c: New test.
* gcc.dg/strlenopt-2f.c: New test.
* gcc.dg/strlenopt-3.c: New test.
* gcc.dg/strlenopt-4.c: New test.
* gcc.dg/strlenopt-4g.c: New test.
* gcc.dg/strlenopt-4gf.c: New test.
* gcc.dg/strlenopt-5.c: New test.
* gcc.dg/strlenopt-6.c: New test.
* gcc.dg/strlenopt-7.c: New test.
* gcc.dg/strlenopt-8.c: New test.
* gcc.dg/strlenopt-9.c: New test.
* gcc.dg/strlenopt-10.c: New test.
* gcc.dg/strlenopt-11.c: New test.
* gcc.dg/strlenopt-12.c: New test.
* gcc.dg/strlenopt-12g.c: New test.
* gcc.dg/strlenopt-13.c: New test.
* gcc.dg/strlenopt-14g.c: New test.
* gcc.dg/strlenopt-14gf.c: New test.
* gcc.dg/strlenopt-15.c: New test.
* gcc.dg/strlenopt-16g.c: New test.
* gcc.dg/strlenopt-17g.c: New test.
* gcc.dg/strlenopt-18g.c: New test.
* gcc.dg/strlenopt.h: New file.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@179277 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/strlenopt.h')
-rw-r--r-- | gcc/testsuite/gcc.dg/strlenopt.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/strlenopt.h b/gcc/testsuite/gcc.dg/strlenopt.h new file mode 100644 index 00000000000..ef47e5ac9ad --- /dev/null +++ b/gcc/testsuite/gcc.dg/strlenopt.h @@ -0,0 +1,59 @@ +/* This is a replacement of needed parts from stdlib.h and string.h + for -foptimize-strlen testing, to ensure we are testing the builtins + rather than whatever the OS has in its headers. */ + +#define NULL ((void *) 0) +typedef __SIZE_TYPE__ size_t; +extern void abort (void); +void *malloc (size_t); +void free (void *); +char *strdup (const char *); +size_t strlen (const char *); +void *memcpy (void *__restrict, const void *__restrict, size_t); +char *strcpy (char *__restrict, const char *__restrict); +char *strcat (char *__restrict, const char *__restrict); +char *strchr (const char *, int); +void *memset (void *, int, size_t); +int memcmp (const void *, const void *, size_t); +int strcmp (const char *, const char *); +#ifdef USE_GNU +void *mempcpy (void *__restrict, const void *__restrict, size_t); +char *stpcpy (char *__restrict, const char *__restrict); +#endif + +#if defined(FORTIFY_SOURCE) && FORTIFY_SOURCE > 0 && __OPTIMIZE__ +# define bos(ptr) __builtin_object_size (ptr, FORTIFY_SOURCE > 0) +# define bos0(ptr) __builtin_object_size (ptr, 0) + +extern inline __attribute__((gnu_inline, always_inline, artificial)) void * +memcpy (void *__restrict dest, const void *__restrict src, size_t len) +{ + return __builtin___memcpy_chk (dest, src, len, bos0 (dest)); +} + +extern inline __attribute__((gnu_inline, always_inline, artificial)) char * +strcpy (char *__restrict dest, const char *__restrict src) +{ + return __builtin___strcpy_chk (dest, src, bos (dest)); +} + +extern inline __attribute__((gnu_inline, always_inline, artificial)) char * +strcat (char *__restrict dest, const char *__restrict src) +{ + return __builtin___strcat_chk (dest, src, bos (dest)); +} + +# ifdef USE_GNU +extern inline __attribute__((gnu_inline, always_inline, artificial)) void * +mempcpy (void *__restrict dest, const void *__restrict src, size_t len) +{ + return __builtin___mempcpy_chk (dest, src, len, bos0 (dest)); +} + +extern inline __attribute__((gnu_inline, always_inline, artificial)) char * +stpcpy (char *__restrict dest, const char *__restrict src) +{ + return __builtin___stpcpy_chk (dest, src, bos (dest)); +} +# endif +#endif |