public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ubizjak at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/58192] G++ emits incorrect code when passing enum classes as function parameters
Date: Fri, 19 Sep 2014 13:07:00 -0000	[thread overview]
Message-ID: <bug-58192-4-ze84UvTQHW@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-58192-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58192

--- Comment #9 from Uroš Bizjak <ubizjak at gmail dot com> ---
Looking at dumps, obtained with -m32 -O1, we have following sequence before the
call to _ZN2S1Ut_3setE3Foo:

_.dfinit:

(insn 7 3 8 2 (parallel [
            (set (reg:SI 88)
                (lshiftrt:SI (reg/v:SI 86 [ t ])
                    (const_int 16 [0x10])))
            (clobber (reg:CC 17 flags))
        ]) 539 {*lshrsi3_1}
     (nil))
(insn 8 7 9 2 (parallel [
            (set (reg:QI 85 [ t$2 ])
                (and:QI (subreg:QI (reg:SI 88) 0)
                    (const_int -1 [0xffffffffffffffff])))
            (clobber (reg:CC 17 flags))
        ]) 379 {*andqi_1}
     (nil))

...

(insn 10 9 11 2 (set (reg:QI 1 dx)
        (reg:QI 85 [ t$2 ])) gcc-bug.cc:72 93 {*movqi_internal}
     (nil))

...

(call_insn 12 11 13 2 (call (mem:QI (symbol_ref:SI ("_ZN2S1Ut_3setE3Foo")
[flags 0x3]  <function_decl 0x2ad94c491438 set>) [0 set S1 A8])
        (const_int 0 [0])) gcc-bug.cc:72 651 {*call}
     (expr_list:REG_EH_REGION (const_int 0 [0])
        (nil))
    (expr_list:SI (use (reg:SI 0 ax))
        (expr_list:QI (use (reg:QI 1 dx))
            (nil))))

_.cse1 mangles argument setup to:

(insn 8 7 9 2 (set (reg:QI 85 [ t$2 ])
        (subreg:QI (reg:SI 88) 0)) 93 {*movqi_internal}
     (expr_list:REG_DEAD (reg:SI 88)
        (expr_list:REG_UNUSED (reg:CC 17 flags)
            (nil))))

...

(insn 10 9 11 2 (set (reg:QI 1 dx)
        (subreg:QI (reg:SI 88) 0)) gcc-bug.cc:72 93 {*movqi_internal}
     (nil))

and _.fwprop1 merges both to:

(insn 10 9 11 2 (set (reg:QI 1 dx)
        (subreg:QI (reg:SI 88) 0)) gcc-bug.cc:72 93 {*movqi_internal}
     (nil))

resulting in:

#(insn 10 9 34 2 (set (reg:QI 1 dx)
#        (reg:QI 3 bx [88])) gcc-bug.cc:72 93 {*movqi_internal}
#     (nil))
    movl    %ebx, %edx    # 10    *movqi_internal/1    [length = 2]

However, x86 ABI mandates that arguments should be properly extended in the
call to the function. I don't think original (insn 8) is correct, as it is
effectively a NOP.
>From gcc-bugs-return-462096-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Sep 19 13:11:17 2014
Return-Path: <gcc-bugs-return-462096-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 2073 invoked by alias); 19 Sep 2014 13:11:16 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 2050 invoked by uid 48); 19 Sep 2014 13:11:10 -0000
From: "marcos.diaz at tallertechnologies dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/63301] inconsistency on wchar_t and wint_t types and sizes for diverse architectures
Date: Fri, 19 Sep 2014 13:11:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c
X-Bugzilla-Version: 4.8.3
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: marcos.diaz at tallertechnologies dot com
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-63301-4-9fWWlDk79k@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-63301-4@http.gcc.gnu.org/bugzilla/>
References: <bug-63301-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-09/txt/msg01930.txt.bz2
Content-length: 294

https://gcc.gnu.org/bugzilla/show_bug.cgi?idc301

--- Comment #2 from Marcos Diaz <marcos.diaz at tallertechnologies dot com> ---
Sorry, I expressed wrong the issue I was reporting, What I want to ask is the
following:

Is it ok that the wchar_t is a long int and the wint_t is just an int?


  parent reply	other threads:[~2014-09-19 13:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-19  6:27 [Bug c++/58192] New: " temporal at gmail dot com
2013-08-19  6:29 ` [Bug c++/58192] " temporal at gmail dot com
2013-08-19  6:38 ` temporal at gmail dot com
2013-08-19 16:49 ` temporal at gmail dot com
2013-08-19 16:59 ` paolo.carlini at oracle dot com
2013-08-19 18:09 ` jakub at gcc dot gnu.org
2014-09-18  9:20 ` paolo.carlini at oracle dot com
2014-09-18 10:01 ` jakub at gcc dot gnu.org
2014-09-19 12:10 ` ubizjak at gmail dot com
2014-09-19 13:07 ` ubizjak at gmail dot com [this message]
2014-09-19 14:10 ` jakub at gcc dot gnu.org
2014-12-15 14:30 ` ubizjak at gmail dot com
2014-12-15 14:55 ` hjl.tools at gmail dot com
2014-12-15 16:01 ` hjl.tools 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-58192-4-ze84UvTQHW@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: link
Be 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).