[trans-mem] PR47690: redirect recursive calls in a clone correctly

Aldy Hernandez aldyh@redhat.com
Tue Feb 15 15:37:00 GMT 2011


Consider a sample where a transaction callable function has a recursive 
call to itself:

int george;
void NewQueueNode()
{
         __transaction [[atomic]] { george=999; }
         NewQueueNode();
}

Currently, when we are transforming calls to their transactional clone 
counterparts, we stop transforming once we reach the end of a 
transaction.  Ultimately, this means that in the cloned function, the 
recursive call to NewQueueNode() will have the edges redirected to the 
clone, but the gimple_call_fndecl() in the clone will still be pointing 
to the original function.  This causes cgraph verification to fail with 
a "edge points to wrong declaration" ICE.

I think the original (not-cloned) version of NewQueueNode() should 
recurse to the original version.  And the cloned version of 
NewQueueNode() should recurse to the cloned function.  I have done this 
in the patch below by continuing the call transformation past the end of 
a transaction, but only on recursive calls to the cloned function.

With my patch, the original function gets instrumented like this:

NewQueueNode:
         pushl   %ebp
         movl    %esp, %ebp
         subl    $8, %esp
         movl    $41, %eax
         call    _ITM_beginTransaction
         movl    $999, %edx
         movl    $george, %eax
         call    _ITM_WU4
         call    _ITM_commitTransaction
         call    NewQueueNode
         leave

And the cloned function gets instrumented like this:

_ZGTt12NewQueueNode:
         pushl   %ebp
         movl    %esp, %ebp
         subl    $8, %esp
         movl    $41, %eax
         call    _ITM_beginTransaction
         movl    $999, %edx
         movl    $george, %eax
         call    _ITM_WU4
         call    _ITM_commitTransaction
         call    _ZGTt12NewQueueNode
         leave

What do you think?
Aldy

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: curr
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110215/45bc8be7/attachment.ksh>


More information about the Gcc-patches mailing list