Commit f6f2da7d by Jan Hubicka Committed by Jakub Jelinek

re PR tree-optimization/33434 (inlining miscompilation)

	PR tree-optimization/33434
	* tree-inline.c (setup_one_parameter): If the value passed to
	a parameter is never used, don't set it up.

	* gcc.dg/pr33434-1.c: New test.
	* gcc.dg/pr33434-2.c: New test.
	* gcc.dg/pr33434-3.c: New test.
	* gcc.dg/pr33434-4.c: New test.

From-SVN: r130521
parent 42924ed7
2007-11-29 Jan Hubicka <jh@suse.cz>
Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/33434
* tree-inline.c (setup_one_parameter): If the value passed to
a parameter is never used, don't set it up.
2007-11-29 Jakub Jelinek <jakub@redhat.com>
PR target/32130
2007-11-29 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/33434
* gcc.dg/pr33434-1.c: New test.
* gcc.dg/pr33434-2.c: New test.
* gcc.dg/pr33434-3.c: New test.
* gcc.dg/pr33434-4.c: New test.
PR c++/34270
* g++.dg/template/cond7.C: New test.
/* PR tree-optimization/33434 */
/* { dg-do run } */
/* { dg-options "-O2" } */
int k;
void f1 (int a, int b)
{
a = 1;
b = 1;
if (a)
while (b --)
k = 1;
else
if (b != 1)
__builtin_abort ();
}
int main (void)
{
f1 (1, 1);
if (k != 1)
__builtin_abort ();
return 0;
}
/* PR tree-optimization/33434 */
/* { dg-do run } */
/* { dg-options "-O2" } */
int k;
void f1 (int a)
{
int b;
a = 1;
b = 1;
if (a)
while (b --)
k = 1;
else
if (b != 1)
__builtin_abort ();
}
int main (void)
{
f1 (1);
if (k != 1)
__builtin_abort ();
return 0;
}
/* PR tree-optimization/33434 */
/* { dg-do run } */
/* { dg-options "-O3" } */
int k;
void __attribute__((noinline)) f2 (int b)
{
k = b - 1;
}
void f1 (int a, int b)
{
f2 (b);
a = 1;
b = 1;
if (a)
while (b --)
k = 1;
else
if (b != 1)
__builtin_abort ();
}
int main (void)
{
f1 (1, 1);
if (k != 1)
__builtin_abort ();
return 0;
}
/* PR tree-optimization/33434 */
/* { dg-do compile } */
/* { dg-options "-O2" } */
void *baz (void);
static void *
bar (void *x)
{
x = baz ();
return x;
}
void *
foo (void *x)
{
return bar (x);
}
......@@ -1508,6 +1508,14 @@ setup_one_parameter (copy_body_data *id, tree p, tree value, tree fn,
return;
}
/* If the value of argument is never used, don't care about initializing
it. */
if (gimple_in_ssa_p (cfun) && !def && is_gimple_reg (p))
{
gcc_assert (!value || !TREE_SIDE_EFFECTS (value));
return;
}
/* Initialize this VAR_DECL from the equivalent argument. Convert
the argument to the proper type in case it was promoted. */
if (value)
......
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