public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mitza at ociweb dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/55171] incorrect virtual thunk on mingw Date: Wed, 07 Nov 2012 21:10:00 -0000 [thread overview] Message-ID: <bug-55171-4-HFeQhVugQo@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-55171-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55171 --- Comment #4 from Adam Mitz <mitza at ociweb dot com> 2012-11-07 21:10:26 UTC --- The generated code for the thunk is incorrect in that it re-uses the %eax register, clobbering the original "this" value: Dump of assembler code for function _ZTv0_n16_NK7Derived3fooEv: => 0x004019d1 <+0>: mov 0x4(%esp),%eax 0x004019d5 <+4>: mov (%eax),%eax 0x004019d7 <+6>: add -0x10(%eax),%eax 0x004019da <+9>: mov %eax,0x4(%esp) 0x004019de <+13>: jmp 0x401932 <Derived::foo() const> vtable = *base_this derived_this = vtable + *(vtable - 16) The same thunk on Linux uses both %eax and %ecx: Dump of assembler code for function _ZTv0_n16_NK7Derived3fooEv: => 0x08048eab <+0>: mov 0x8(%esp),%eax 0x08048eaf <+4>: mov (%eax),%ecx 0x08048eb1 <+6>: add -0x10(%ecx),%eax 0x08048eb4 <+9>: mov %eax,0x8(%esp) 0x08048eb8 <+13>: jmp 0x8048e08 <Derived::foo() const> vtable = *base_this derived_this = base_this + (*vtable - 16) The MinGW version must either clobber a scratch register like %ecx or %edx, or if this isn't possible (fastcall/thiscall?), save to the stack and restore.
next prev parent reply other threads:[~2012-11-07 21:10 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-11-01 21:11 [Bug c++/55171] New: " mitza at ociweb dot com 2012-11-02 11:13 ` [Bug c++/55171] " paolo.carlini at oracle dot com 2012-11-02 19:51 ` mitza at ociweb dot com 2012-11-02 20:13 ` [Bug target/55171] " paolo.carlini at oracle dot com 2012-11-07 21:10 ` mitza at ociweb dot com [this message] 2012-11-11 14:30 ` mikpe at it dot uu.se 2012-11-23 21:57 ` paolo.carlini at oracle dot com 2012-11-24 12:47 ` [Bug c++/55171] [4.7/4.8 Regression] " ktietz at gcc dot gnu.org 2012-11-24 12:54 ` ktietz at gcc dot gnu.org 2012-11-25 15:55 ` [Bug target/55171] " rguenth at gcc dot gnu.org 2012-11-29 9:19 ` ktietz at gcc dot gnu.org 2012-11-29 9:21 ` ktietz at gcc dot gnu.org 2012-11-29 9:25 ` ktietz at gcc dot gnu.org 2013-05-06 1:10 ` steve.k.chiu at gmail dot com 2013-05-06 22:31 ` i.nixman at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-55171-4-HFeQhVugQo@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).