diff options
author | Richard Guenther <rguenther@suse.de> | 2008-01-24 15:59:18 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2008-01-24 15:59:18 +0000 |
commit | 7aa5d8b6abb11da4a0f5cd37512d759e593431c3 (patch) | |
tree | 84dcb04b4c63cfcabd4952367ebf9d0f0c599744 | |
parent | 38a572927387e7c2379517bdae726d23848d728b (diff) | |
download | gcc-7aa5d8b6abb11da4a0f5cd37512d759e593431c3.tar.gz |
re PR c++/34953 (ICE on destructor + noreturn-function at -O3)
2008-01-24 Richard Guenther <rguenther@suse.de>
PR middle-end/34953
* predict.c (apply_return_prediction): Check for empty blocks.
(tree_estimate_probability): Likewise.
* g++.dg/torture/pr34953.C: New testcase.
From-SVN: r131781
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/predict.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/torture/pr34953.C | 17 |
4 files changed, 34 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4d5341e13f8..b89f2d9ff2c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-01-24 Richard Guenther <rguenther@suse.de> + + PR middle-end/34953 + * predict.c (apply_return_prediction): Check for empty blocks. + (tree_estimate_probability): Likewise. + 2008-01-23 Richard Guenther <rguenther@suse.de> Backport from mainline diff --git a/gcc/predict.c b/gcc/predict.c index 8b356e5eb93..ad78c323af1 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -1198,7 +1198,8 @@ apply_return_prediction (int *heads) FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds) { return_stmt = last_stmt (e->src); - if (TREE_CODE (return_stmt) == RETURN_EXPR) + if (return_stmt + && TREE_CODE (return_stmt) == RETURN_EXPR) break; } if (!e) @@ -1311,11 +1312,14 @@ tree_estimate_probability (void) FOR_EACH_EDGE (e, ei, bb->succs) { + tree tmp; + /* Predict early returns to be probable, as we've already taken care for error returns and other cases are often used for fast paths through function. */ if (e->dest == EXIT_BLOCK_PTR - && TREE_CODE (last_stmt (bb)) == RETURN_EXPR + && (tmp = last_stmt (bb)) + && TREE_CODE (tmp) == RETURN_EXPR && !single_pred_p (bb)) { edge e1; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 12ddd8ef2ca..5a2d6c7e258 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-01-24 Richard Guenther <rguenther@suse.de> + + PR middle-end/34953 + * g++.dg/torture/pr34953.C: New testcase. + 2008-01-22 Eric Botcazou <ebotcazou@adacore.com> * gcc.c-torture/execute/20080122-1.c: New test. diff --git a/gcc/testsuite/g++.dg/torture/pr34953.C b/gcc/testsuite/g++.dg/torture/pr34953.C new file mode 100644 index 00000000000..5d7b38c92e6 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr34953.C @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-w" } */ + +void B_CLEAR(void* ret); +void B_NeverReturns(void* ret) __attribute__((noreturn)); + +int main() +{ + const struct AutoErrPop { ~AutoErrPop() { } } AutoErrPopper = { }; + B_NeverReturns(0); +} + +void B_NeverReturns(void* ret) +{ + B_CLEAR(ret); /* Never returns (does a setjmp/goto) */ +} + |