From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12241 invoked by alias); 24 Nov 2014 21:33:30 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 12202 invoked by uid 48); 24 Nov 2014 21:33:25 -0000 From: "hjl.tools at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 4.9.2 X-Bugzilla-Keywords: ABI, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: hjl.tools at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.9.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: 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-11/txt/msg02903.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64037 H.J. Lu changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ebotcazou at gcc dot gnu.org --- Comment #10 from H.J. Lu --- 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) unit size align 8 symtab 0 alias set -1 canonical type 0x7ffff18a93f0 precision 8 min max > static unsigned type_5 QI size unit size align 8 symtab 0 alias set -1 canonical type 0x7ffff19f85e8 precision 8 min max values local bindings <(nil)>> value readonly constant used VOID file pr64037.ii line 2 col 3 align 1 context initial >> context chain > (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) constant 32> unit size constant 4> align 32 symtab 0 alias set 1 canonical type 0x7ffff18a9690 precision 32 min max pointer_to_this > (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.