This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/58782] New: GCC generates unnecessary _ITM_WU8 for local variables.
- From: "srdjan.stipic at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 18 Oct 2013 09:14:47 +0000
- Subject: [Bug c/58782] New: GCC generates unnecessary _ITM_WU8 for local variables.
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58782
Bug ID: 58782
Summary: GCC generates unnecessary _ITM_WU8 for local
variables.
Product: gcc
Version: trans-mem
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: srdjan.stipic at gmail dot com
Created attachment 31031
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31031&action=edit
Minimal test case.
GCC generates unnecessary_ITM_WU8 for local variables.
Example:
typedef struct {
void* firstPtr;
void* secondPtr;
} pair_t;
__attribute__((transaction_safe)) list_find(void*, void*);
void* list_find_helper (void* listPtr, void* keyPtr) {
pair_t findPair;
findPair.firstPtr = keyPtr; // the _ITM_WU8() is generated here
// but is unnecessary because findPair is local
list_find(listPtr, &findPair);
return findPair.secondPtr;
}
Compiled with 4.7.3 -O3 -fgnu-tm
Generated code for transactional clone:
_ZGTt16list_find_helperPvS_:
pushq %rbx
movq %rdi, %rbx
subq $16, %rsp
movq %rsp, %rdi
call _ITM_WU8 // unnecessary write
movq %rsp, %rsi
movq %rbx, %rdi
call _ZGTt9list_findPvS_
leaq 8(%rsp), %rdi
call _ITM_RU8
addq $16, %rsp
popq %rbx
ret
P.S.
This is the example on gcc.godbolt.org:
http://gcc.godbolt.org/#%7B%22version%22%3A3%2C%22filterAsm%22%3A%7B%22labels%22%3Atrue%2C%22directives%22%3Atrue%2C%22commentOnly%22%3Atrue%7D%2C%22compilers%22%3A%5B%7B%22source%22%3A%22typedef%20struct%20%7B%5Cn%20%20void*%20firstPtr%3B%5Cn%20%20void*%20secondPtr%3B%5Cn%7D%20pair_t%3B%5Cn%5Cn__attribute__((transaction_safe))%20void*%20list_find(void*%2C%20void*)%3B%5Cn%5Cn__attribute__((noinline))%5Cnvoid*%20list_find_helper%20(void*%20listPtr%2C%20void*%20keyPtr)%20%7B%5Cn%20%20pair_t%20findPair%3B%5Cn%5Cn%20%20findPair.firstPtr%20%3D%20keyPtr%3B%5Cn%20%20%20%20%5Cn%20%20list_find(listPtr%2C%20%26findPair)%3B%5Cn%20%20return%20findPair.secondPtr%3B%5Cn%7D%5Cn%5Cn%5Cnvoid*%20TMlist_find%20(void*%20hashtablePtr%2C%20void*%20keyPtr)%20%7B%5Cn%20%20void*%20ret%3B%5Cn%20%20__transaction_atomic%20%7B%5Cn%20%20%20%20ret%20%3D%20list_find_helper(hashtablePtr%2C%20keyPtr)%3B%5Cn%20%20%7D%5Cn%20%20return%20ret%3B%5Cn%7D%22%2C%22compiler%22%3A%22%2Fusr%2Fbin%2Fg%2B%2B-4.7%22%2C%22options%22%3A%22-O3%20-fgnu-tm%22%7D%5D%7D