From patchwork Fri Jul 6 09:58:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 169402 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 020402C0089 for ; Fri, 6 Jul 2012 19:58:32 +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=1342173513; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=hAlR/NA FkU0drY+mYIB4k1tvwQ0=; b=Kr+jwyw67YaR4nFzdfNOXfvC3L6Hg7luMfZNq+k /dMlOLbses8sah676WnQcmkCKV10FwlUSlhELOUVGKmtAMwbm+vZwP5+xGfv3LgU vObKQWiXYhxnrV99vyc3T+moRPRPSx5mCuecdMHildLh68OnpyCqk2Mv9XK/Ak8W PHD0= 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:Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=FpvgJw3uFIghRYI2lOCHrvB16maS8+zV8UdA2RVFzGY4IAshU9Q4LwigovIppJ xX6E1ZqEWM9g8QHIrmZ2Eu6gJX6bSq5Erydvzhb1haTKfKKaR/dSTEg9eaGt/qVA sjVaev3XNHu/CqGxIvjhcj0GZMTLwHxQWpmrwqhT9amDM=; Received: (qmail 16159 invoked by alias); 6 Jul 2012 09:58:28 -0000 Received: (qmail 16150 invoked by uid 22791); 6 Jul 2012 09:58:27 -0000 X-SWARE-Spam-Status: No, hits=-4.1 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, TW_DD, TW_ZJ X-Spam-Check-By: sourceware.org Received: from mail-ob0-f175.google.com (HELO mail-ob0-f175.google.com) (209.85.214.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 06 Jul 2012 09:58:15 +0000 Received: by obcva7 with SMTP id va7so15680503obc.20 for ; Fri, 06 Jul 2012 02:58:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.164.8 with SMTP id ym8mr24949807obb.51.1341568694548; Fri, 06 Jul 2012 02:58:14 -0700 (PDT) Received: by 10.76.112.44 with HTTP; Fri, 6 Jul 2012 02:58:14 -0700 (PDT) Date: Fri, 6 Jul 2012 11:58:14 +0200 Message-ID: Subject: [PATCH, i386]: Fix PR 53853, FAIL: g++.dg/other/pr53811.C -std=gnu++* (internal compiler error) with -fPIC From: Uros Bizjak To: gcc-patches@gcc.gnu.org Cc: Jan Hubicka , Jakub Jelinek 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! Symbol references are not legitimate sibcall operands for -mcmodel=large, so have to be moved to registers (using movabs). Unfortunately, moving symbol references for CM_LARGE_PIC requires PIC fixup which by default generates Pmode pseudos. When generating thunk in x86_output_mi_thunk, we are already past reload time, so pseudos are not allowed. The solution is to call legitimize_pic_address with hard temporary Pmode register in advance, to avoid situations that would lead to generation of pseudo registers in emit_move_insn. Patched gcc generates: .set .LTHUNK0,_ZN1D4foo2Ev .p2align 4,,15 .globl _ZThn16_N1D4foo2Ev .type _ZThn16_N1D4foo2Ev, @function _ZThn16_N1D4foo2Ev: .LFB15: .cfi_startproc subq $16, %rdi movabsq $.LTHUNK0@GOTOFF, %r10 addq %rbx, %r10 jmp *%r10 .cfi_endproc .LFE15: .size _ZThn16_N1D4foo2Ev, .-_ZThn16_N1D4foo2Ev which is the same as when calling static local functions with -mcmodel=large -fPIC. 2012-07-06 Uros Bizjak PR target/53811 * config/i386/i386.c (x86_output_mi_thunk): For CM_LARGE_PIC model, emit PIC sequence for fnaddr symbol reference in advance. Tested on x86_64-pc-linux-gnu {,-m32} and by testing various runtime tests in testsuite/g++.dg/inherit with "-mcmodel=large -fPIC". Committed to mainline SVN, will backport to 4.7. Uros. Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 189310) +++ config/i386/i386.c (working copy) @@ -33057,6 +33057,10 @@ x86_output_mi_thunk (FILE *file, emit_jump_insn (gen_indirect_jump (fnaddr)); else { + if (ix86_cmodel == CM_LARGE_PIC && SYMBOLIC_CONST (fnaddr)) + fnaddr = legitimize_pic_address (fnaddr, + gen_rtx_REG (Pmode, tmp_regno)); + if (!sibcall_insn_operand (fnaddr, word_mode)) { tmp = gen_rtx_REG (word_mode, tmp_regno);