diff options
author | Kai Tietz <ktietz@redhat.com> | 2012-11-29 10:21:17 +0100 |
---|---|---|
committer | Kai Tietz <ktietz@gcc.gnu.org> | 2012-11-29 10:21:17 +0100 |
commit | 0abbfd21897f5c2f45d513d6d3212dae188e2bd7 (patch) | |
tree | 011bfcbbda2c911cb07ba96485215e837b59b8aa /gcc | |
parent | 45d5889a070819486a619ca2a2664c186537cb40 (diff) | |
download | gcc-0abbfd21897f5c2f45d513d6d3212dae188e2bd7.zip gcc-0abbfd21897f5c2f45d513d6d3212dae188e2bd7.tar.gz gcc-0abbfd21897f5c2f45d513d6d3212dae188e2bd7.tar.bz2 |
re PR target/55171 (incorrect virtual thunk on mingw)
PR target/55171
* i386.c (get_scratch_register_on_entry): Handle
thiscall-convention.
(split_stack_prologue_scratch_regno): Likewise.
(ix86_static_chain): Likewise.
(x86_output_mi_thunk): Likewise.
From-SVN: r193926
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 35 |
2 files changed, 39 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ddafeec..9494df0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2012-11-29 Kai Tietz <ktietz@redhat.com> + + PR target/55171 + * i386.c (get_scratch_register_on_entry): Handle + thiscall-convention. + (split_stack_prologue_scratch_regno): Likewise. + (ix86_static_chain): Likewise. + (x86_output_mi_thunk): Likewise. + 2012-11-29 Marek Polacek <polacek@redhat.com> * cprop.c (bypass_block): Improve debug message. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index eeb5ac8..812e6bf 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -9655,6 +9655,8 @@ get_scratch_register_on_entry (struct scratch_reg *sr) tree decl = current_function_decl, fntype = TREE_TYPE (decl); bool fastcall_p = lookup_attribute ("fastcall", TYPE_ATTRIBUTES (fntype)) != NULL_TREE; + bool thiscall_p + = lookup_attribute ("thiscall", TYPE_ATTRIBUTES (fntype)) != NULL_TREE; bool static_chain_p = DECL_STATIC_CHAIN (decl); int regparm = ix86_function_regparm (fntype, decl); int drap_regno @@ -9665,10 +9667,15 @@ get_scratch_register_on_entry (struct scratch_reg *sr) if ((regparm < 1 || (fastcall_p && !static_chain_p)) && drap_regno != AX_REG) regno = AX_REG; - else if (regparm < 2 && drap_regno != DX_REG) + /* 'thiscall' sets regparm to 1, uses ecx for arguments and edx + for the static chain register. */ + else if (thiscall_p && !static_chain_p && drap_regno != AX_REG) + regno = AX_REG; + else if (regparm < 2 && !thiscall_p && drap_regno != DX_REG) regno = DX_REG; /* ecx is the static chain register. */ - else if (regparm < 3 && !fastcall_p && !static_chain_p + else if (regparm < 3 && !fastcall_p && !thiscall_p + && !static_chain_p && drap_regno != CX_REG) regno = CX_REG; else if (ix86_save_reg (BX_REG, true)) @@ -11180,12 +11187,15 @@ split_stack_prologue_scratch_regno (void) return R11_REG; else { - bool is_fastcall; + bool is_fastcall, is_thiscall; int regparm; is_fastcall = (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (TREE_TYPE (cfun->decl))) != NULL); + is_thiscall = (lookup_attribute ("thiscall", + TYPE_ATTRIBUTES (TREE_TYPE (cfun->decl))) + != NULL); regparm = ix86_function_regparm (TREE_TYPE (cfun->decl), cfun->decl); if (is_fastcall) @@ -11198,6 +11208,12 @@ split_stack_prologue_scratch_regno (void) } return AX_REG; } + else if (is_thiscall) + { + if (!DECL_STATIC_CHAIN (cfun->decl)) + return DX_REG; + return AX_REG; + } else if (regparm < 3) { if (!DECL_STATIC_CHAIN (cfun->decl)) @@ -25134,7 +25150,7 @@ ix86_static_chain (const_tree fndecl, bool incoming_p) fntype = TREE_TYPE (fndecl); ccvt = ix86_get_callcvt (fntype); - if ((ccvt & (IX86_CALLCVT_FASTCALL | IX86_CALLCVT_THISCALL)) != 0) + if ((ccvt & IX86_CALLCVT_FASTCALL) != 0) { /* Fastcall functions use ecx/edx for arguments, which leaves us with EAX for the static chain. @@ -25142,6 +25158,13 @@ ix86_static_chain (const_tree fndecl, bool incoming_p) leaves us with EAX for the static chain. */ regno = AX_REG; } + else if ((ccvt & IX86_CALLCVT_THISCALL) != 0) + { + /* Thiscall functions use ecx for arguments, which leaves + us with EAX and EDX for the static chain. + We are using for abi-compatibility EAX. */ + regno = AX_REG; + } else if (ix86_function_regparm (fntype, fndecl) == 3) { /* For regparm 3, we have no free call-clobbered registers in @@ -34799,8 +34822,10 @@ x86_output_mi_thunk (FILE *file, else { unsigned int ccvt = ix86_get_callcvt (TREE_TYPE (function)); - if ((ccvt & (IX86_CALLCVT_FASTCALL | IX86_CALLCVT_THISCALL)) != 0) + if ((ccvt & IX86_CALLCVT_FASTCALL) != 0) tmp_regno = AX_REG; + else if ((ccvt & IX86_CALLCVT_THISCALL) != 0) + tmp_regno = DX_REG; else tmp_regno = CX_REG; } |