This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] PR middle-end/55401: uninstrument relevant path in TM clone


In this testcase:

__attribute__((transaction_callable))
void q1()
{
  ringo=666;
  __transaction_atomic {
      george=999;
  }
}

...the clone for q1() ends up with instrumented code on both pathways:

  <bb 6>:
  _12 = tm_state.5_11 & 2;
  if (_12 != 0)
    goto <bb 3>;
  else
    goto <bb 4>;

  <bb 3>:
  _13 = 999;
  __builtin__ITM_WU4 (&george, _13);
  __builtin__ITM_commitTransaction ();
  goto <bb 5>;

  <bb 4>:
  _15 = 999;
  __builtin__ITM_WU4 (&george, _15);
  __builtin__ITM_commitTransaction ();

The reason this happens is because collect_bb2reg() follows the uninstrumented edges while traversing a transaction.

In the attached patch, I added yet another flag (*sigh*) to get_tm_region_blocks() specifying whether we should skip or include the uninstrumented blocks while accumulating basic blocks. To assuage the grief, I make the new argument optional.

With the attached path, we generate this:

  <bb 6>:
  _12 = tm_state.5_11 & 2;
  if (_12 != 0)
    goto <bb 3>;
  else
    goto <bb 4>;

  <bb 3>:
  george = 999;
  __builtin__ITM_commitTransaction ();
  goto <bb 5>;

  <bb 4>:
  _13 = 999;
  __builtin__ITM_WU4 (&george, _13);
  __builtin__ITM_commitTransaction ();

...respecting the uninstrumented flag.

BTW, collect_bb2reg() is also called from execute_tm_edges() (via get_bb_regions_instrumented), hence the additional callback data to collect_bb2reg(). From TMMARK we wish to exclude the instrumented path, but in TMEDGE we should include it, so we can properly add cancel edges from the uninstrumented code path.

[I could abstract get_bb_regions_instrumented into two versions, an instrumented one (as the name suggests) and an uninstrumented one. Perhaps this would be clearer].

Blah.

OK for trunk?

Attachment: curr
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]