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] PR47690: redirect recursive calls in a clone correctly


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

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]