From 79f4a793e9c9e9c3ef7056c3d8cbec2024051322 Mon Sep 17 00:00:00 2001 From: aldyh Date: Mon, 3 Dec 2012 16:11:21 +0000 Subject: [PATCH] PR middle-end/55401 * trans-mem.c (get_tm_region_blocks): Exclude uninstrumented blocks from vector if requested. (collect_bb2reg): Pass new argument to get_tm_region_blocks. (get_bb_regions_instrumented): Add INCLUDE_UNINSTRUMENTED_P argument, and pass it to expand_regions. (execute_tm_mark): Pass new argument to get_bb_regions_instrumented. (execute_tm_edges): Same. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@194099 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 13 ++++++++++++ gcc/testsuite/gcc.dg/tm/pr55401.c | 22 ++++++++++++++++++++ gcc/trans-mem.c | 43 ++++++++++++++++++++++++++++++--------- 3 files changed, 68 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/tm/pr55401.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 774695322dc..84833f4352c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2012-12-03 Aldy Hernandez + + PR middle-end/55401 + * trans-mem.c (get_tm_region_blocks): Exclude uninstrumented + blocks from vector if requested. + (collect_bb2reg): Pass new argument to + get_tm_region_blocks. + (get_bb_regions_instrumented): Add INCLUDE_UNINSTRUMENTED_P + argument, and pass it to expand_regions. + (execute_tm_mark): Pass new argument to + get_bb_regions_instrumented. + (execute_tm_edges): Same. + 2012-12-03 Jakub Jelinek * asan.c (instrument_mem_region_access): Don't instrument diff --git a/gcc/testsuite/gcc.dg/tm/pr55401.c b/gcc/testsuite/gcc.dg/tm/pr55401.c new file mode 100644 index 00000000000..1ac7d975715 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tm/pr55401.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm -O0 -fdump-tree-optimized" } */ + +int george; +int ringo; + +__attribute__((transaction_callable)) +void foo() +{ + ringo=666; + __transaction_atomic { + george=999; + } +} + +/* There should only be 2 instrumented writes to GEORGE: one in FOO, + and one in the transactional clone to FOO. There should NOT be + more than one instrumented write to GEORGE in the clone of + FOO. */ +/* { dg-final { scan-tree-dump-times "ITM_WU\[0-9\] \\(&george," 2 "optimized" } } */ + +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c index 0a428fea800..8762ad358bd 100644 --- a/gcc/trans-mem.c +++ b/gcc/trans-mem.c @@ -2394,14 +2394,19 @@ expand_block_tm (struct tm_region *region, basic_block bb) /* Return the list of basic-blocks in REGION. STOP_AT_IRREVOCABLE_P is true if caller is uninterested in blocks - following a TM_IRREVOCABLE call. */ + following a TM_IRREVOCABLE call. + + INCLUDE_UNINSTRUMENTED_P is TRUE if we should include the + uninstrumented code path blocks in the list of basic blocks + returned, false otherwise. */ static vec get_tm_region_blocks (basic_block entry_block, bitmap exit_blocks, bitmap irr_blocks, bitmap all_region_blocks, - bool stop_at_irrevocable_p) + bool stop_at_irrevocable_p, + bool include_uninstrumented_p = true) { vec bbs = vNULL; unsigned i; @@ -2427,7 +2432,9 @@ get_tm_region_blocks (basic_block entry_block, continue; FOR_EACH_EDGE (e, ei, bb->succs) - if (!bitmap_bit_p (visited_blocks, e->dest->index)) + if ((include_uninstrumented_p + || !(e->flags & EDGE_TM_UNINSTRUMENTED)) + && !bitmap_bit_p (visited_blocks, e->dest->index)) { bitmap_set_bit (visited_blocks, e->dest->index); bbs.safe_push (e->dest); @@ -2442,11 +2449,19 @@ get_tm_region_blocks (basic_block entry_block, return bbs; } +// Callback data for collect_bb2reg. +struct bb2reg_stuff +{ + vec *bb2reg; + bool include_uninstrumented_p; +}; + // Callback for expand_regions, collect innermost region data for each bb. static void * collect_bb2reg (struct tm_region *region, void *data) { - vec *bb2reg = (vec *) data; + struct bb2reg_stuff *stuff = (struct bb2reg_stuff *)data; + vec *bb2reg = stuff->bb2reg; vec queue; unsigned int i; basic_block bb; @@ -2455,7 +2470,8 @@ collect_bb2reg (struct tm_region *region, void *data) region->exit_blocks, region->irr_blocks, NULL, - /*stop_at_irr_p=*/true); + /*stop_at_irr_p=*/true, + stuff->include_uninstrumented_p); // We expect expand_region to perform a post-order traversal of the region // tree. Therefore the last region seen for any bb is the innermost. @@ -2468,7 +2484,8 @@ collect_bb2reg (struct tm_region *region, void *data) // Returns a vector, indexed by BB->INDEX, of the innermost tm_region to // which a basic block belongs. Note that we only consider the instrumented -// code paths for the region; the uninstrumented code paths are ignored. +// code paths for the region; the uninstrumented code paths are ignored if +// INCLUDE_UNINSTRUMENTED_P is false. // // ??? This data is very similar to the bb_regions array that is collected // during tm_region_init. Or, rather, this data is similar to what could @@ -2489,14 +2506,18 @@ collect_bb2reg (struct tm_region *region, void *data) // only known instance of this block sharing. static vec -get_bb_regions_instrumented (bool traverse_clones) +get_bb_regions_instrumented (bool traverse_clones, + bool include_uninstrumented_p) { unsigned n = last_basic_block; + struct bb2reg_stuff stuff; vec ret; ret.create (n); ret.safe_grow_cleared (n); - expand_regions (all_tm_regions, collect_bb2reg, &ret, traverse_clones); + stuff.bb2reg = &ret; + stuff.include_uninstrumented_p = include_uninstrumented_p; + expand_regions (all_tm_regions, collect_bb2reg, &stuff, traverse_clones); return ret; } @@ -2830,7 +2851,8 @@ execute_tm_mark (void) tm_log_init (); vec bb_regions - = get_bb_regions_instrumented (/*traverse_clones=*/true); + = get_bb_regions_instrumented (/*traverse_clones=*/true, + /*include_uninstrumented_p=*/false); struct tm_region *r; unsigned i; @@ -3004,7 +3026,8 @@ static unsigned int execute_tm_edges (void) { vec bb_regions - = get_bb_regions_instrumented (/*traverse_clones=*/false); + = get_bb_regions_instrumented (/*traverse_clones=*/false, + /*include_uninstrumented_p=*/true); struct tm_region *r; unsigned i; -- 2.11.4.GIT