diff options
author | Diego Novillo <dnovillo@redhat.com> | 2004-10-18 17:39:47 +0000 |
---|---|---|
committer | Diego Novillo <dnovillo@gcc.gnu.org> | 2004-10-18 13:39:47 -0400 |
commit | bca9e17b5aade3e19ae49ff9c211510674b46a02 (patch) | |
tree | 41b0ff9a0dade709f61ae4c8b7f6c1e781617743 /gcc | |
parent | 18e4be8561b8aee3937528dd27635eaf761e57d0 (diff) | |
download | gcc-bca9e17b5aade3e19ae49ff9c211510674b46a02.zip gcc-bca9e17b5aade3e19ae49ff9c211510674b46a02.tar.gz gcc-bca9e17b5aade3e19ae49ff9c211510674b46a02.tar.bz2 |
re PR tree-optimization/17656 (internal compiler error: in replace_immediate_uses, at tree-ssa.c:1041)
PR tree-optimization/17656
* tree-ssa.c (replace_immediate_uses): When replacing a
constant, if the call to fold_stmt produced a different
statement, get an appropriate statement pointer by scanning
STMT's basic block.
PR tree-optimization/17656
* testsuite/gcc.c-torture/compile/pr17656.c: New test.
From-SVN: r89233
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr17656.c | 18 | ||||
-rw-r--r-- | gcc/tree-ssa.c | 20 |
4 files changed, 49 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8e461b8..c6bcd56 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2004-10-18 Diego Novillo <dnovillo@redhat.com> + + PR tree-optimization/17656 + * tree-ssa.c (replace_immediate_uses): When replacing a + constant, if the call to fold_stmt produced a different + statement, get an appropriate statement pointer by scanning + STMT's basic block. + 2004-10-18 Richard Henderson <rth@redhat.com> * pointer-set.c (hash1): Don't use libm functions in fallback case. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 146312b..0cf098b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-10-18 Diego Novillo <dnovillo@redhat.com> + + PR tree-optimization/17656 + * testsuite/gcc.c-torture/compile/pr17656.c: New test. + 2004-10-18 Nathan Sidwell <nathan@codesourcery.com> * g++.dg/eh/shadow1.C: New. diff --git a/gcc/testsuite/gcc.c-torture/compile/pr17656.c b/gcc/testsuite/gcc.c-torture/compile/pr17656.c new file mode 100644 index 0000000..0acb71f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr17656.c @@ -0,0 +1,18 @@ +int sprintf (char *s, const char *format, ...); + +int foo(int i, int j) +{ + char *buf, *str; + + if (i) + str = ""; + else if (j) + str = ""; + else + return 1; + + /* We were propagating &""[0] here and not calling fold_stmt with a + proper statement pointer. */ + sprintf(buf, str); + return 0; +} diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index affa304..4362e01 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -1093,7 +1093,8 @@ replace_immediate_uses (tree var, tree repl) with a new expression. Since the current def-use machinery does not return pointers to statements, we call fold_stmt with the address of a local temporary, if that call changes - the temporary then we fall on our swords. + the temporary then we fallback on looking for a proper + pointer to STMT by scanning STMT's basic block. Note that all this will become unnecessary soon. This pass is being replaced with a proper copy propagation pass @@ -1103,7 +1104,22 @@ replace_immediate_uses (tree var, tree repl) tree tmp = stmt; fold_stmt (&tmp); if (tmp != stmt) - abort (); + { + basic_block bb = bb_for_stmt (stmt); + block_stmt_iterator si; + + /* Start iterating at the start of the basic block + holding STMT until we reach it. This is slow, but + it's the only way to get a statement pointer + reliably. */ + for (si = bsi_start (bb); !bsi_end_p (si); bsi_next (&si)) + if (bsi_stmt (si) == stmt) + { + fold_stmt (bsi_stmt_ptr (si)); + stmt = bsi_stmt (si); + break; + } + } } /* If REPL is a pointer, it may have different memory tags associated |