Commit f5fc4a04 by Ilya Enkovich Committed by Ilya Enkovich

tree-ssa-strlen.c: include ipa-chkp.h, cgraph.h, ipa-ref.h, plugin-api.h.

gcc/

	* tree-ssa-strlen.c: include ipa-chkp.h, cgraph.h,
	ipa-ref.h, plugin-api.h.
	(get_string_length): Handle calls with bounds.
	(adjust_last_stmt): Likewise.
	(handle_builtin_strchr): Likewise.
	(handle_builtin_strcpy): Likewise.
	(handle_builtin_memcpy): Likewise.
	(handle_builtin_strcat): Likewise.

gcc/testsuite/

	* gcc.target/i386/chkp-strlen-1.c: New.
	* gcc.target/i386/chkp-strlen-2.c: New.
	* gcc.target/i386/chkp-strlen-3.c: New.
	* gcc.target/i386/chkp-strlen-4.c: New.
	* gcc.target/i386/chkp-strlen-5.c: New.

From-SVN: r217657
parent e4727812
2014-11-17 Ilya Enkovich <ilya.enkovich@intel.com> 2014-11-17 Ilya Enkovich <ilya.enkovich@intel.com>
* tree-ssa-strlen.c: include ipa-chkp.h, cgraph.h,
ipa-ref.h, plugin-api.h.
(get_string_length): Handle calls with bounds.
(adjust_last_stmt): Likewise.
(handle_builtin_strchr): Likewise.
(handle_builtin_strcpy): Likewise.
(handle_builtin_memcpy): Likewise.
(handle_builtin_strcat): Likewise.
2014-11-17 Ilya Enkovich <ilya.enkovich@intel.com>
* tree-chkp-opt.c (chkp_get_nobnd_fndecl): New. * tree-chkp-opt.c (chkp_get_nobnd_fndecl): New.
(chkp_get_nochk_fndecl): New. (chkp_get_nochk_fndecl): New.
(chkp_optimize_string_function_calls): New. (chkp_optimize_string_function_calls): New.
2014-11-17 Ilya Enkovich <ilya.enkovich@intel.com> 2014-11-17 Ilya Enkovich <ilya.enkovich@intel.com>
* gcc.target/i386/chkp-strlen-1.c: New.
* gcc.target/i386/chkp-strlen-2.c: New.
* gcc.target/i386/chkp-strlen-3.c: New.
* gcc.target/i386/chkp-strlen-4.c: New.
* gcc.target/i386/chkp-strlen-5.c: New.
2014-11-17 Ilya Enkovich <ilya.enkovich@intel.com>
* gcc.target/i386/chkp-stropt-1.c: New. * gcc.target/i386/chkp-stropt-1.c: New.
* gcc.target/i386/chkp-stropt-2.c: New. * gcc.target/i386/chkp-stropt-2.c: New.
* gcc.target/i386/chkp-stropt-3.c: New. * gcc.target/i386/chkp-stropt-3.c: New.
......
/* { dg-do compile } */
/* { dg-require-effective-target mpx } */
/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-strlen" } */
/* { dg-final { scan-tree-dump "memcpy.chkp" "strlen" } } */
/* { dg-final { cleanup-tree-dump "strlen" } } */
#include "string.h"
char *test (char *str1, char *str2)
{
size_t len = strlen (str2);
strcpy (str1, str2);
return str1 + len;
}
/* { dg-do compile } */
/* { dg-require-effective-target mpx } */
/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-strlen" } */
/* { dg-final { scan-tree-dump-not "strlen" "strlen" } } */
/* { dg-final { cleanup-tree-dump "strlen" } } */
#include "string.h"
char *test (char *str1, char *str2)
{
char *p = stpcpy (str1, str2);
size_t len = strlen (str1);
return p + len;
}
/* { dg-do compile } */
/* { dg-require-effective-target mpx } */
/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-strlen" } */
/* { dg-final { scan-tree-dump-times "strlen" 1 "strlen" } } */
/* { dg-final { cleanup-tree-dump "strlen" } } */
#include "string.h"
size_t test (char *str1, char *str2)
{
size_t len = strlen (str2);
memcpy (str1, str2, len + 1);
return len + strlen (str1);
}
/* { dg-do compile } */
/* { dg-require-effective-target mpx } */
/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-strlen -D_GNU_SOURCE" } */
/* { dg-final { scan-tree-dump-times "strlen" 1 "strlen" } } */
/* { dg-final { cleanup-tree-dump "strlen" } } */
#include "string.h"
char * test (char *str1, char *str2)
{
size_t len = strlen (str2);
char *p = (char *)mempcpy (str1, str2, len + 1);
return p + len + strlen (str1);
}
/* { dg-do compile } */
/* { dg-require-effective-target mpx } */
/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-strlen" } */
/* { dg-final { scan-tree-dump-times "strlen" 2 "strlen" } } */
/* { dg-final { scan-tree-dump "memcpy" "strlen" } } */
/* { dg-final { cleanup-tree-dump "strlen" } } */
#include "string.h"
size_t test (char *str1, char *str2)
{
size_t len1 = strlen (str1);
size_t len2 = strlen (str2);
strcat (str1, str2);
return len1 + len2 + strlen (str1);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment