This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[trans-mem] PR46270: handle throwing statements
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 19 Nov 2010 11:00:11 -0500
- Subject: [trans-mem] PR46270: handle throwing statements
- References: <20101118164328.GA15050@redhat.com> <4CE55C0B.2050005@redhat.com>
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