diff mbox

[trans-mem] wrong calling convention _ITM_free with i*86

Message ID 4EA1E3C6.5090504@gmail.com
State New
Headers show

Commit Message

Patrick Marlier Oct. 21, 2011, 9:27 p.m. UTC
The calling convention with i?86 (32bits) is wrong for _ITM_free (and 
_ITM_malloc/_ITM_calloc).
Here an example:

    0x08049fd2 <+251>:   mov    -0x14(%ebp),%eax
    0x08049fd5 <+254>:   call   0x804b150 <_ITM_free(void*)>

Dump of assembler code for function _ITM_free(void*):
    0x0804b150 <+0>:     sub    $0x1c,%esp
    0x0804b153 <+3>:     mov    0x20(%esp),%eax
    0x0804b157 <+7>:     test   %eax,%eax
    0x0804b159 <+9>:     je     0x804b176 <_ITM_free(void*)+38>
    0x0804b15b <+11>:    mov    %gs:0x28,%edx
    0x0804b162 <+18>:    movl   $0x807fbd0,0x8(%esp)
    0x0804b16a <+26>:    mov    %eax,0x4(%esp)
    0x0804b16e <+30>:    mov    %edx,(%esp)
    0x0804b171 <+33>:    call   0x80512a0 
<GTM::gtm_thread::forget_allocation(void*, void (*)(void*))>
    0x0804b176 <+38>:    add    $0x1c,%esp
    0x0804b179 <+41>:    ret

This regression is probably my fault when I propose to simplify 
attribute (r168751). I did not pay attention to ATTR_TM_REGPARM. I am 
really sorry about that.

So either revert the change or apply the attached modification.

Bootstrapped and tested on i686 with same number of errors.

                 === gcc Summary ===

# of expected passes            196
# of unexpected failures        12
# of unsupported tests          1

                 === g++ Summary ===

# of expected passes            102
# of unexpected failures        26
# of unresolved testcases       3

Patrick Marlier.


     * builtin-attrs.def (ATTR_TMPURE_MALLOC_NOTHROW_LIST): Rename from
     ATTR_TM_TMPURE_MALLOC_NOTHROW_LIST attribute.
     (ATTR_TMPURE_NOTHROW_LIST): Added for _ITM_free.
     * gtm-builtins.def: Likewise.

Comments

Aldy Hernandez Oct. 24, 2011, 3:40 p.m. UTC | #1
> Bootstrapped and tested on i686 with same number of errors.

Sorry to ask you to run more tests, but can you also test x86-64?  If 
there are no regressions on x86-64 either, OK.

Aldy
Aldy Hernandez Oct. 24, 2011, 4:19 p.m. UTC | #2
On 10/24/11 10:40, Aldy Hernandez wrote:
>
>> Bootstrapped and tested on i686 with same number of errors.
>
> Sorry to ask you to run more tests, but can you also test x86-64? If
> there are no regressions on x86-64 either, OK.

As discussed off-line, I'll run x86-64 tests for you since you don't 
have a 64-bit available.

Tests finished with no regressions.  Feel free to commit.

Thank you.
diff mbox

Patch

Index: builtin-attrs.def
===================================================================
--- builtin-attrs.def	(revision 180309)
+++ builtin-attrs.def	(working copy)
@@ -241,9 +241,14 @@ 
 		    ATTR_TM_REGPARM, ATTR_NULL, ATTR_NORETURN_NOTHROW_LIST)
 DEF_ATTR_TREE_LIST (ATTR_TM_CONST_NOTHROW_LIST,
 		    ATTR_TM_REGPARM, ATTR_NULL, ATTR_CONST_NOTHROW_LIST)
-DEF_ATTR_TREE_LIST (ATTR_TM_TMPURE_MALLOC_NOTHROW_LIST,
-		    ATTR_TM_TMPURE, ATTR_NULL, ATTR_MALLOC_NOTHROW_LIST)
 
+/* Same attributes used for BUILT_IN_MALLOC except with TM_PURE thrown in.  */
+DEF_ATTR_TREE_LIST (ATTR_TMPURE_MALLOC_NOTHROW_LIST,
+                   ATTR_TM_TMPURE, ATTR_NULL, ATTR_MALLOC_NOTHROW_LIST)
+/* Same attributes used for BUILT_IN_FREE except with TM_PURE thrown in.  */
+DEF_ATTR_TREE_LIST (ATTR_TMPURE_NOTHROW_LIST,
+                   ATTR_TM_TMPURE, ATTR_NULL, ATTR_NOTHROW_LIST)
+
 /* Construct a tree for a format_arg attribute.  */
 #define DEF_FORMAT_ARG_ATTRIBUTE(FA)					\
   DEF_ATTR_TREE_LIST (ATTR_FORMAT_ARG_##FA, ATTR_FORMAT_ARG,		\
Index: gtm-builtins.def
===================================================================
--- gtm-builtins.def	(revision 180309)
+++ gtm-builtins.def	(working copy)
@@ -24,11 +24,11 @@ 
 
 /* Memory allocation builtins.  */
 DEF_TM_BUILTIN (BUILT_IN_TM_MALLOC, "_ITM_malloc",
-	        BT_FN_PTR_SIZE, ATTR_TM_TMPURE_MALLOC_NOTHROW_LIST)
+	        BT_FN_PTR_SIZE, ATTR_TMPURE_MALLOC_NOTHROW_LIST)
 DEF_TM_BUILTIN (BUILT_IN_TM_CALLOC, "_ITM_calloc",
-	        BT_FN_PTR_SIZE_SIZE, ATTR_TM_TMPURE_MALLOC_NOTHROW_LIST)
+	        BT_FN_PTR_SIZE_SIZE, ATTR_TMPURE_MALLOC_NOTHROW_LIST)
 DEF_TM_BUILTIN (BUILT_IN_TM_FREE, "_ITM_free",
-	        BT_FN_VOID_PTR, ATTR_TM_TMPURE_NOTHROW_LIST)
+	        BT_FN_VOID_PTR, ATTR_TMPURE_NOTHROW_LIST)
 
 /* Logging builtins.  */
 DEF_TM_BUILTIN (BUILT_IN_TM_LOG_1, "_ITM_LU1",