re PR c++/17972 (const/pure functions result in bad asm)
PR c++/17972 * tree-inline.c (expand_call_inline): Set TREE_SIDE_EFFECTS on the STMT_EXPR wrapping up the inlined body. From-SVN: r92210
This commit is contained in:
parent
172b87995c
commit
774a9b00ca
4 changed files with 44 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
|||
2004-12-15 Eric Botcazou <ebotcazou@libertysurf.fr>
|
||||
|
||||
PR c++/17972
|
||||
* tree-inline.c (expand_call_inline): Set TREE_SIDE_EFFECTS
|
||||
on the STMT_EXPR wrapping up the inlined body.
|
||||
|
||||
2004-12-15 Vladimir Makarov <vmakarov@redhat.com>
|
||||
Steven Bosscher <stevenb@suse.de>
|
||||
PR middle end/17340
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2004-12-15 Alan Modra <amodra@bigpond.net.au>
|
||||
|
||||
* g++.dg/opt/inline9.C: New test.
|
||||
|
||||
2004-12-15 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
|
||||
|
||||
PR fortran/18993
|
||||
|
|
29
gcc/testsuite/g++.dg/opt/inline9.C
Normal file
29
gcc/testsuite/g++.dg/opt/inline9.C
Normal file
|
@ -0,0 +1,29 @@
|
|||
// PR c++/17972
|
||||
// Origin: Michal Ostrowski <mostrows@watson.ibm.com>
|
||||
// Testcase by Alan Modra <amodra@bigpond.net.au>
|
||||
// { dg-do run }
|
||||
// { dg-options "-O" }
|
||||
// { dg-options "-O -mtune=i686" { target i?86-*-* } }
|
||||
|
||||
struct thread_info
|
||||
{
|
||||
short preempt_count;
|
||||
} x;
|
||||
|
||||
static inline struct thread_info *cti (void) __attribute__ ((const));
|
||||
static inline struct thread_info *cti (void)
|
||||
{
|
||||
return &x;
|
||||
}
|
||||
|
||||
void fn (void) __attribute__ ((noinline));
|
||||
void fn (void)
|
||||
{
|
||||
++cti()->preempt_count;
|
||||
}
|
||||
|
||||
int main (void)
|
||||
{
|
||||
fn ();
|
||||
return 0;
|
||||
}
|
|
@ -1625,8 +1625,11 @@ expand_call_inline (tree *tp, int *walk_subtrees, void *data)
|
|||
splay_tree_delete (id->decl_map);
|
||||
id->decl_map = st;
|
||||
|
||||
/* The new expression has side-effects if the old one did. */
|
||||
TREE_SIDE_EFFECTS (expr) = TREE_SIDE_EFFECTS (t);
|
||||
/* Although, from the semantic viewpoint, the new expression has
|
||||
side-effects only if the old one did, it is not possible, from
|
||||
the technical viewpoint, to evaluate the body of a function
|
||||
multiple times without serious havoc. */
|
||||
TREE_SIDE_EFFECTS (expr) = 1;
|
||||
|
||||
tsi_link_before (&id->tsi, expr, TSI_SAME_STMT);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue