diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-08-27 10:52:09 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-08-27 10:52:09 +0000 |
commit | 0d21cbc776f7eff52137e72df2aa9f704fd1355a (patch) | |
tree | 3e8fb1c2bde96aeaa58b82d6a0b7220780808412 /gcc | |
parent | 0fee47f4b75b538c02375f8bf0e4b23ccd107fac (diff) | |
download | gcc-0d21cbc776f7eff52137e72df2aa9f704fd1355a.tar.gz |
* builtins.c (expand_builtin_expect_jump): Save pending_stack_adjust
and restore it if returning NULL.
* gcc.dg/20030826-2.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@70844 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/builtins.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/20030826-2.c | 64 |
4 files changed, 78 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ef8624fef17..0300d78069f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2003-08-27 Jakub Jelinek <jakub@redhat.com> + + * builtins.c (expand_builtin_expect_jump): Save pending_stack_adjust + and restore it if returning NULL. + 2003-08-27 Richard Sandiford <rsandifo@redhat.com> * calls.c (initialize_argument_information): If an argument has no diff --git a/gcc/builtins.c b/gcc/builtins.c index 227bb49c32e..37dc4e5eaa2 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -4330,6 +4330,7 @@ expand_builtin_expect_jump (tree exp, rtx if_false_label, rtx if_true_label) && (integer_zerop (arg1) || integer_onep (arg1))) { int num_jumps = 0; + int save_pending_stack_adjust = pending_stack_adjust; rtx insn; /* If we fail to locate an appropriate conditional jump, we'll @@ -4421,7 +4422,10 @@ expand_builtin_expect_jump (tree exp, rtx if_false_label, rtx if_true_label) /* If no jumps were modified, fail and do __builtin_expect the normal way. */ if (num_jumps == 0) - ret = NULL_RTX; + { + ret = NULL_RTX; + pending_stack_adjust = save_pending_stack_adjust; + } } return ret; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2cabf340166..2e96a627549 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2003-08-27 Jakub Jelinek <jakub@redhat.com> + + * gcc.dg/20030826-2.c: New test. + 2003-08-26 Roger Sayle <roger@eyesopen.com> PR middle-end/12002 diff --git a/gcc/testsuite/gcc.dg/20030826-2.c b/gcc/testsuite/gcc.dg/20030826-2.c new file mode 100644 index 00000000000..f25887d47d2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20030826-2.c @@ -0,0 +1,64 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fomit-frame-pointer" } */ +/* { dg-options "-O2 -fomit-frame-pointer -march=i386" { target i?86-*-* } } */ + +extern void abort (void); +extern void exit (int); + +struct S +{ + int *a; + unsigned char *b, c; +}; + +int u, v, w; + +void +foo (unsigned short x) +{ + u += x; +} + +int +bar (struct S **x, int *y) +{ + w += *y; + *y = w + 25; + return 0; +} + +int +baz (struct S **x) +{ + struct S *y = *x; + unsigned char *a = y->b; + + foo (*a); + + if (__builtin_expect (y->c != 0 || y->a == &v, 0)) + return 1; + + if (__builtin_expect (*a == 1, 0)) + { + int a, b = bar (x, &a); + + if (a) + return b; + } + + return 0; +} + +int +main (void) +{ + struct S a, *b = &a; + unsigned char c; + + __builtin_memset (b, 0, sizeof (a)); + a.a = &v; + a.b = &c; + if (baz (&b) != 1) + abort (); + exit (0); +} |