diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2012-06-04 16:51:24 +0000 |
---|---|---|
committer | Aldy Hernandez <aldyh@gcc.gnu.org> | 2012-06-04 16:51:24 +0000 |
commit | 764ce4f20a98a9579c7c972955fd2aa1f245b455 (patch) | |
tree | 227fc61acb843d8ba0a7ed57f7251484fbfc265c /gcc | |
parent | be6b029b8cdf4c17a9f040332b8345f0fa13ed43 (diff) | |
download | gcc-764ce4f20a98a9579c7c972955fd2aa1f245b455.zip gcc-764ce4f20a98a9579c7c972955fd2aa1f245b455.tar.gz gcc-764ce4f20a98a9579c7c972955fd2aa1f245b455.tar.bz2 |
re PR middle-end/47530 ([trans-mem] tail call optimization problem with _ITM_commitTransaction)
PR middle-end/47530
* trans-mem.c (expand_block_edges): Do not skip the first
statement when resetting the BB.
From-SVN: r188190
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/tm/pr47530-2.C | 35 | ||||
-rw-r--r-- | gcc/trans-mem.c | 5 |
3 files changed, 45 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c77ccda..174c1c1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-06-04 Aldy Hernandez <aldyh@redhat.com> + + PR middle-end/47530 + * trans-mem.c (expand_block_edges): Do not skip the first + statement when resetting the BB. + 2012-06-04 Richard Guenther <rguenther@suse.de> * tree-data-ref.c (stores_from_loop): Remove. diff --git a/gcc/testsuite/g++.dg/tm/pr47530-2.C b/gcc/testsuite/g++.dg/tm/pr47530-2.C new file mode 100644 index 0000000..c98e07e --- /dev/null +++ b/gcc/testsuite/g++.dg/tm/pr47530-2.C @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-fgnu-tm -O2 -fno-inline -fdump-tree-tmedge" } + +class RBTree +{ + struct RBNode + { + RBNode* next; + }; + + public: + RBNode* sentinel; + __attribute__((transaction_safe)) bool lookup(); +}; + +bool RBTree::lookup() +{ + RBNode* x = sentinel; + while (x) + x = x->next; + return false; +} + + +RBTree* SET; + +void bench_test() +{ + __transaction_atomic { + SET->lookup(); + } +} + +// { dg-final { scan-tree-dump-times "ITM_commitTransaction.*tail call" 0 "tmedge" } } +// { dg-final { cleanup-tree-dump "tmedge" } } diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c index 7026823..5aae8b2 100644 --- a/gcc/trans-mem.c +++ b/gcc/trans-mem.c @@ -2591,6 +2591,7 @@ expand_block_edges (struct tm_region *region, basic_block bb) for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); ) { + bool do_next = true; gimple stmt = gsi_stmt (gsi); /* ??? TM_COMMIT (and any other tm builtin function) in a nested @@ -2612,6 +2613,7 @@ expand_block_edges (struct tm_region *region, basic_block bb) make_tm_edge (stmt, bb, region); bb = e->dest; gsi = gsi_start_bb (bb); + do_next = false; } /* Delete any tail-call annotation that may have been added. @@ -2620,7 +2622,8 @@ expand_block_edges (struct tm_region *region, basic_block bb) gimple_call_set_tail (stmt, false); } - gsi_next (&gsi); + if (do_next) + gsi_next (&gsi); } } |