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
This commit is contained in:
parent
42924ed71f
commit
f6f2da7df7
7 changed files with 121 additions and 0 deletions
|
@ -1,3 +1,10 @@
|
|||
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
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
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.
|
||||
|
||||
|
|
25
gcc/testsuite/gcc.dg/pr33434-1.c
Normal file
25
gcc/testsuite/gcc.dg/pr33434-1.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* 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;
|
||||
}
|
26
gcc/testsuite/gcc.dg/pr33434-2.c
Normal file
26
gcc/testsuite/gcc.dg/pr33434-2.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* 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;
|
||||
}
|
31
gcc/testsuite/gcc.dg/pr33434-3.c
Normal file
31
gcc/testsuite/gcc.dg/pr33434-3.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* 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;
|
||||
}
|
18
gcc/testsuite/gcc.dg/pr33434-4.c
Normal file
18
gcc/testsuite/gcc.dg/pr33434-4.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* 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)
|
||||
|
|
Loading…
Add table
Reference in a new issue