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]

[trans-mem] PR46270: handle throwing statements


In this PR we have a call which may throw inside of a relaxed transaction:

<bb 3>
  it = std::list<std::_List_iterator<Game::BuildProject>  >::begin (&erasableBuildProjects); [in atomic]
<bb 4>
  stuff

Throwable statements can only appear at the end of a basic block, so any instrumentation added to this call, will cause it to throw inside of a basic block and wreck havoc.

Enter ugly code...

We need to split the basic block to keep the throwing statement at the end of the basic block. This means keeping the normal and abnormal edges sane, and not getting confused by the new BB we will add midstream. I tried caching the basic blocks ahead of time for the clone case, but noticed that the way gsi_insert_on_edge_immediate() works, the instrumentation will end up in an existing BB and we will instrument already instrumented code:

<bb 3>
  call x
<bb 4>
  instrumentation for call x
  stuff

So what I did was put the instrumentation in BB4 by itself, and mark it to be skipped later. So we will generate something like:

<bb 3>
  call x
<bb 4>
  instrumentation for call x
<bb 999>
  stuff

Collapsing the code in execute_tm_mark() was not strictly necessary, but I'm getting tired of duplicating code everywhere.

Tested on x86-64 Linux.

OK for branch?

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]