This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE : [trans-mem] optimization problem with ITM functions
- From: MARLIER Patrick <patrick dot marlier at unine dot ch>
- To: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Cc: "rth at redhat dot com" <rth at redhat dot com>, "aldyh at redhat dot com" <aldyh at redhat dot com>, "gokcen dot kestor at bsc dot es" <gokcen dot kestor at bsc dot es>
- Date: Mon, 24 Jan 2011 10:52:38 +0100
- Subject: RE : [trans-mem] optimization problem with ITM functions
- References: <alpine.DEB.2.00.1101202037010.8991@localhost6.localdomain6>
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.marlier@unine.ch]
Date d'envoi : jeudi 20 janvier 2011 20:42
À : gcc@gcc.gnu.org
Cc : rth@redhat.com; aldyh@redhat.com; gokcen.kestor@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.