From patchwork Tue Jul 3 10:55:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 168787 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id ECB092C00CB for ; Tue, 3 Jul 2012 20:57:07 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1341917828; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=MojMmY1 qy7kZj/rNuFetvUGxWac=; b=FAZv4S3Aw2ovmKKmu7Qh2I3GBeuvh63plmlHETQ HYozGNR9D3y4wXg2+sD3C1kJqSVzeLAX1KVV93Joyww1hkuxF0LmpqYcTNvR5MrK TuAz5TTHS0hj04LkMbfK/jrZUQs9y8GASA+uleOiNBGJ5QWma/4QCaHc0miVHGvc GmOU= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:MIME-Version:Received:Received:Date:Message-ID:Subject:From:To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=GLPhCfgiDSNg5qVsWZzTVDaogBS7FlV9pTjV211tC8NS3C9EmhGZfDuil6UjJU 6kTL5V8r8mSqATd76+2z7vjo4VFPfoEHnIW7aUdL20tm7fdpENedsDcuA1GxdWZi 4Ym3qiN1l8QeNyrbvaoNmHtppu6YAz8Wt5tiWN9IrrVUU=; Received: (qmail 2813 invoked by alias); 3 Jul 2012 10:57:03 -0000 Received: (qmail 2792 invoked by uid 22791); 3 Jul 2012 10:57:02 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, MEDICAL_SUBJECT, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, TW_ZJ X-Spam-Check-By: sourceware.org Received: from mail-pb0-f47.google.com (HELO mail-pb0-f47.google.com) (209.85.160.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 03 Jul 2012 10:55:56 +0000 Received: by pbbrq2 with SMTP id rq2so9279153pbb.20 for ; Tue, 03 Jul 2012 03:55:55 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.131.10 with SMTP id oi10mr6031555pbb.122.1341312955539; Tue, 03 Jul 2012 03:55:55 -0700 (PDT) Received: by 10.66.11.130 with HTTP; Tue, 3 Jul 2012 03:55:55 -0700 (PDT) Date: Tue, 3 Jul 2012 12:55:55 +0200 Message-ID: Subject: [PATCH, i386]: Fix PR 53811, ICE: in insn_default_length, at config/i386/i386.md:529 (unrecognizable insn) with -mcmodel=large From: Uros Bizjak To: gcc-patches@gcc.gnu.org Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hello! Attached patch fixes PR 53811. gcc failed to check if symbol_ref operands fits sibcall_insn_operand predicate. In case of -mcmodel=large, we must emit indirect jump for a sibcall. 2012-07-03 Uros Bizjak PR target/53811 * config/i386/i386.c (x86_output_mi_thunk): Check if fnaddr satisfies sibcall_insn_operand. Move it to a temporary register if not. testsuite/ChangLog: 2012-07-03 Uros Bizjak PR target/53811 * g++.dg/other/pr53811.C: New test. Tested on x86_64-pc-linux-gnu, committed to mainline SVN, similar patch will be committed to 4.7 branch. Uros. Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 189191) +++ config/i386/i386.c (working copy) @@ -32931,7 +32931,19 @@ x86_output_mi_thunk (FILE *file, { rtx this_param = x86_this_parameter (function); rtx this_reg, tmp, fnaddr; + unsigned int tmp_regno; + if (TARGET_64BIT) + tmp_regno = R10_REG; + else + { + unsigned int ccvt = ix86_get_callcvt (TREE_TYPE (function)); + if ((ccvt & (IX86_CALLCVT_FASTCALL | IX86_CALLCVT_THISCALL)) != 0) + tmp_regno = AX_REG; + else + tmp_regno = CX_REG; + } + emit_note (NOTE_INSN_PROLOGUE_END); /* If VCALL_OFFSET, we'll need THIS in a register. Might as well @@ -32957,7 +32969,7 @@ x86_output_mi_thunk (FILE *file, { if (!x86_64_general_operand (delta_rtx, Pmode)) { - tmp = gen_rtx_REG (Pmode, R10_REG); + tmp = gen_rtx_REG (Pmode, tmp_regno); emit_move_insn (tmp, delta_rtx); delta_rtx = tmp; } @@ -32970,18 +32982,7 @@ x86_output_mi_thunk (FILE *file, if (vcall_offset) { rtx vcall_addr, vcall_mem, this_mem; - unsigned int tmp_regno; - if (TARGET_64BIT) - tmp_regno = R10_REG; - else - { - unsigned int ccvt = ix86_get_callcvt (TREE_TYPE (function)); - if ((ccvt & (IX86_CALLCVT_FASTCALL | IX86_CALLCVT_THISCALL)) != 0) - tmp_regno = AX_REG; - else - tmp_regno = CX_REG; - } tmp = gen_rtx_REG (Pmode, tmp_regno); this_mem = gen_rtx_MEM (ptr_mode, this_reg); @@ -33056,6 +33057,15 @@ x86_output_mi_thunk (FILE *file, emit_jump_insn (gen_indirect_jump (fnaddr)); else { + if (!sibcall_insn_operand (fnaddr, word_mode)) + { + tmp = gen_rtx_REG (word_mode, tmp_regno); + if (GET_MODE (fnaddr) != word_mode) + fnaddr = gen_rtx_ZERO_EXTEND (word_mode, fnaddr); + emit_move_insn (tmp, fnaddr); + fnaddr = tmp; + } + tmp = gen_rtx_MEM (QImode, fnaddr); tmp = gen_rtx_CALL (VOIDmode, tmp, const0_rtx); tmp = emit_call_insn (tmp); Index: testsuite/g++.dg/other/pr53811.C =================================================================== --- testsuite/g++.dg/other/pr53811.C (revision 0) +++ testsuite/g++.dg/other/pr53811.C (working copy) @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-options "-mcmodel=large" { target { { i?86-*-* x86_64-*-* } && lp64 } } } + +struct ICCStringClass +{ + virtual void * + CreateString (const char *fromText) = 0; +}; + +struct AGSCCDynamicObject +{ + virtual void + Unserialize (int index, const char *serializedData, int dataSize) = 0; +}; + + +struct ScriptString:AGSCCDynamicObject, ICCStringClass +{ + virtual void *CreateString (const char *fromText); +}; + +const char * +CreateNewScriptString (const char *fromText, bool reAllocate = true); + +void * +ScriptString::CreateString (const char *fromText) +{ + return (void *) CreateNewScriptString (fromText); +}