public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hjl.tools at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/64037] Miscompilation with LTO and enum class : char parameter
Date: Mon, 24 Nov 2014 21:33:00 -0000	[thread overview]
Message-ID: <bug-64037-4-zWOZMCHRbe@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-64037-4@http.gcc.gnu.org/bugzilla/>

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot gnu.org

--- Comment #10 from H.J. Lu <hjl.tools at gmail dot com> ---
To pass

enum class X : unsigned char {
  V = 2,
};

assign_parm_setup_reg calls ix86_promote_function_mode

(gdb) f 0
#0  ix86_promote_function_mode (type=0x7ffff19f85e8, mode=QImode, 
    punsignedp=0x7fffffffd3c4, fntype=0x7ffff19f8738, for_return=2)
    at /export/gnu/import/git/gcc/gcc/config/i386/i386.c:8310
8310      if (type != NULL_TREE && POINTER_TYPE_P (type))
(gdb) call debug_tree (type)
 <enumeral_type 0x7ffff19f85e8 X
    type <integer_type 0x7ffff18a93f0 unsigned char public unsigned string-flag
QI
        size <integer_cst 0x7ffff18a5fa8 constant 8>
        unit size <integer_cst 0x7ffff18a5fc0 constant 1>
        align 8 symtab 0 alias set -1 canonical type 0x7ffff18a93f0 precision 8
min <integer_cst 0x7ffff18a5fd8 0> max <integer_cst 0x7ffff18a5f78 255>>
    static unsigned type_5 QI size <integer_cst 0x7ffff18a5fa8 8> unit size
<integer_cst 0x7ffff18a5fc0 1>
    align 8 symtab 0 alias set -1 canonical type 0x7ffff19f85e8 precision 8 min
<integer_cst 0x7ffff18a5fd8 0> max <integer_cst 0x7ffff18a5f78 255>
    values <tree_list 0x7ffff19fb028
        purpose <identifier_node 0x7ffff19f6738 V
            bindings <(nil)>
            local bindings <(nil)>>
        value <const_decl 0x7ffff18c21c0 V type <enumeral_type 0x7ffff19f85e8
X>
            readonly constant used VOID file pr64037.ii line 2 col 3
            align 1 context <enumeral_type 0x7ffff19f85e8 X> initial
<integer_cst 0x7ffff19d8d08 2>>> context <translation_unit_decl 0x7ffff7ff91e0
D.1>
    chain <type_decl 0x7ffff19f5c78 X>>
(gdb) 

However, setup_incoming_promotions calls ix86_promote_function_mode with

Breakpoint 18, ix86_promote_function_mode (type=0x7ffff18a9690, mode=SImode, 
    punsignedp=0x7fffffffd774, fntype=0x7ffff19f8738, for_return=0)
    at /export/gnu/import/git/gcc/gcc/config/i386/i386.c:8310
8310      if (type != NULL_TREE && POINTER_TYPE_P (type))
(gdb) call debug_tree (type)
 <integer_type 0x7ffff18a9690 int public SI
    size <integer_cst 0x7ffff18a5e70 type <integer_type 0x7ffff18a9150
bitsizetype> constant 32>
    unit size <integer_cst 0x7ffff18a5e88 type <integer_type 0x7ffff18a90a8
sizetype> constant 4>
    align 32 symtab 0 alias set 1 canonical type 0x7ffff18a9690 precision 32
min <integer_cst 0x7ffff18c60c0 -2147483648> max <integer_cst 0x7ffff18c60d8
2147483647>
    pointer_to_this <pointer_type 0x7ffff18cb930>>
(gdb) 

It uses a different type and mode.

If I make this change to combine:

diff --git a/gcc/combine.c b/gcc/combine.c
index 1808f97..8bdfe2b 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -1562,7 +1562,7 @@ setup_incoming_promotions (rtx_insn *first)

       /* The mode and signedness of the argument as it is actually passed,
          after any TARGET_PROMOTE_FUNCTION_ARGS-driven ABI promotions.  */
-      mode3 = promote_function_mode (DECL_ARG_TYPE (arg), mode2, &uns3,
+      mode3 = promote_function_mode (DECL_ARG_TYPE (arg), mode1, &uns1,
                 TREE_TYPE (cfun->decl), 0);

to make setup_incoming_promotions consistent with assign_parm_setup_reg,
the testcase works.


  parent reply	other threads:[~2014-11-24 21:33 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-23 23:07 [Bug c++/64037] New: " js at alien8 dot de
2014-11-23 23:08 ` [Bug c++/64037] " js at alien8 dot de
2014-11-23 23:08 ` js at alien8 dot de
2014-11-23 23:09 ` js at alien8 dot de
2014-11-23 23:15 ` [Bug target/64037] " pinskia at gcc dot gnu.org
2014-11-24 11:13 ` rguenth at gcc dot gnu.org
2014-11-24 17:48 ` hjl.tools at gmail dot com
2014-11-24 17:49 ` pinskia at gcc dot gnu.org
2014-11-24 19:25 ` [Bug rtl-optimization/64037] " hjl.tools at gmail dot com
2014-11-24 19:52 ` hjl.tools at gmail dot com
2014-11-24 21:33 ` hjl.tools at gmail dot com [this message]
2014-11-24 21:39 ` hjl.tools at gmail dot com
2014-11-24 21:40 ` hjl.tools at gmail dot com
2014-11-25 18:23 ` [Bug rtl-optimization/64037] [4.8/4.9/5 Regression] Miscompilation with -Os " hjl.tools at gmail dot com
2014-11-28 15:28 ` hjl at gcc dot gnu.org
2014-11-28 15:32 ` [Bug rtl-optimization/64037] [4.8/4.9 " hjl.tools at gmail dot com
2014-12-05 11:48 ` hjl at gcc dot gnu.org
2014-12-05 12:03 ` hjl at gcc dot gnu.org
2014-12-05 12:07 ` hjl.tools at gmail dot com
2014-12-09 14:35 ` uros at gcc dot gnu.org
2014-12-09 14:41 ` uros at gcc dot gnu.org
2014-12-09 14:44 ` uros at gcc dot gnu.org
2014-12-09 14:48 ` [Bug rtl-optimization/64037] [4.8/4.9/5 " ubizjak at gmail dot com
2014-12-10 13:22 ` rguenth at gcc dot gnu.org
2014-12-14 16:04 ` hjl at gcc dot gnu.org
2014-12-14 16:07 ` hjl at gcc dot gnu.org
2014-12-15 16:01 ` hjl.tools at gmail dot com
2014-12-19 13:40 ` jakub at gcc dot gnu.org
2014-12-19 19:20 ` hjl at gcc dot gnu.org
2014-12-19 19:49 ` 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-64037-4-zWOZMCHRbe@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).