Commit 706eb1a7 by Martin Sebor Committed by Martin Sebor

re PR tree-optimization/79715 (hand-rolled strdup with unused result not eliminated)

gcc/testsuite/ChangeLog:
	PR tree-optimization/79715
	* gcc.dg/pr79715.c: New test.

From-SVN: r247440
parent a6c78ea3
2017-05-01 Martin Sebor <msebor@redhat.com>
PR tree-optimization/79715
* gcc.dg/pr79715.c: New test.
2017-05-01 Tom de Vries <tom@codesourcery.com> 2017-05-01 Tom de Vries <tom@codesourcery.com>
PR testsuite/65941 PR testsuite/65941
......
/* PR tree-optimization/79715 - hand-rolled strdup with unused result
not eliminated
{ dg-do compile }
{ dg-options "-O2 -Wall -fdump-tree-optimized" } */
void f (const char *s)
{
unsigned n = __builtin_strlen (s) + 1;
char *p = __builtin_malloc (n);
__builtin_memcpy (p, s, n);
__builtin_free (p);
}
void g (const char *s)
{
unsigned n = __builtin_strlen (s) + 1;
char *p = __builtin_malloc (n);
__builtin_strcpy (p, s);
__builtin_free (p);
}
/* { dg-final { scan-tree-dump-not "free" "optimized" } }
{ dg-final { scan-tree-dump-not "malloc" "optimized" } }
{ dg-final { scan-tree-dump-not "memcpy" "optimized" } }
{ dg-final { scan-tree-dump-not "strcpy" "optimized" } }
{ dg-final { scan-tree-dump-not "strlen" "optimized" } } */
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