Hello, Here the asm of the previous example:
.globl _ZN5bench10LinkedList6insertEi .type _ZN5bench10LinkedList6insertEi, @function _ZN5bench10LinkedList6insertEi: .LFB46: .loc 1 24 0 .cfi_startproc pushq %r12 .cfi_def_cfa_offset 16 pushq %rbp .cfi_def_cfa_offset 24 pushq %rbx .cfi_def_cfa_offset 32 subq $16, %rsp .cfi_def_cfa_offset 48 ... .cfi_offset 3, -32 .cfi_offset 6, -24 .cfi_offset 12, -16 call _ITM_beginTransaction .L8: ... call _ITM_WU8 .loc 1 46 0 discriminator 4 addq $16, %rsp .cfi_remember_state .cfi_def_cfa_offset 32 popq %rbx .cfi_def_cfa_offset 24 popq %rbp .cfi_def_cfa_offset 16 popq %r12 .cfi_def_cfa_offset 8 .loc 2 56 0 discriminator 4 jmp _ITM_commitTransaction Since _ITM_commitTransaction can jump back to the label L8, the tail call optimization must not be allowed. Is it right? Do some other optimizations can create problems with this longjmp behavior of _ITM_commitTransaction? Does the ECF_RETURNS_TWICE flag is the right way to solve that? Should I fill a bug-report? Thanks. Patrick Marlier. ________________________________________ De : Patrick Marlier [patrick.marl...@unine.ch] Date d'envoi : jeudi 20 janvier 2011 20:42 À : gcc@gcc.gnu.org Cc : r...@redhat.com; al...@redhat.com; gokcen.kes...@bsc.es Objet : [trans-mem] optimization problem with ITM functions Hello, Attached the cpp example. While I was trying to understand the problem (segfault), I found this: In special_function_p function (calls.c), ECF_TM_OPS flag is returned for all TM builtin call except BUILT_IN_TM_START. Question: is it really intentional or missing? Moreover since BUILT_IN_TM_START is doing a setjmp, I suppose it should add also the flag ECS_RETURNS_TWICE. If I add this, the generated code is a bit different (more things happen in the stack, which I suppose right). BUILT_IN_TM_ABORT is kind of longjmp, it should then add ECF_NORETURN, right?. Otherwise I have a strange bug with the attached cpp file when _ITM_commitTransaction is the last call of a function with optimization level>=2. This call is optimized as a tail call thus the epilogue is before the jmp. But in this specific case, if the _ITM_commitTransaction aborts and roll backs, it seems it creates a problem (corrupted stack) but I didn't figure out the real reason. To avoid this problem I have added ECF_RETURNS_TWICE for the transaction commit which avoid this tail call optimization but I am sure this is not the way to fix this. Attached the patch for these problems. Thanks for any help. Patrick Marlier.