From patchwork Thu Dec 6 22:01: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: 204327 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 8B6E32C00A6 for ; Fri, 7 Dec 2012 09:01:24 +1100 (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=1355436084; 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=IBTSHmN 3FoDVRxCNtVFFNw4I9eY=; b=LWix8IGeFgjHo+yuCFBfWmVGKFSnx/hF3i5hK9B g2LyNqR7KGzhHbnkciMv2DRYFPeZeFPVJzR/HXjub7CGFqfVXN41TRXq3bA0mmcX zMGPFwiQxazF/eZ3HntdqKlCSLrTTzTafzZ4GBWL33OI+2UTxiw8/y0rxTNKLbGk 67eA= 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=FopJebBwDxfajOtlskCQrhZVEazBa/AYB6iCEQd3Kdr4yvSdZ3nNWh6REO0+um 3AcwSq/7XNT3dttH43E79RAclk+vR62CQn5pKTcPbg1jice77LRfxDbKSIG0RtIC CDuWuk0ZI17JlnoJAJ+0QX8SmW88x2/dp3ft/ugtld6Rc=; Received: (qmail 3716 invoked by alias); 6 Dec 2012 22:01:22 -0000 Received: (qmail 3697 invoked by uid 22791); 6 Dec 2012 22:01:21 -0000 X-SWARE-Spam-Status: No, hits=-4.2 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_YB, TW_ZJ X-Spam-Check-By: sourceware.org Received: from mail-oa0-f47.google.com (HELO mail-oa0-f47.google.com) (209.85.219.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 06 Dec 2012 22:01:15 +0000 Received: by mail-oa0-f47.google.com with SMTP id h1so7171520oag.20 for ; Thu, 06 Dec 2012 14:01:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.60.170.114 with SMTP id al18mr2245469oec.56.1354831274733; Thu, 06 Dec 2012 14:01:14 -0800 (PST) Received: by 10.182.60.166 with HTTP; Thu, 6 Dec 2012 14:01:14 -0800 (PST) Date: Thu, 6 Dec 2012 23:01:14 +0100 Message-ID: Subject: [PATCH, i386]: Fix PR55597, ICE in plus_constant, at explow.c:88 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! On x32, SImode and DImode symbols are accepted as valid. When SImode symbol is legitimized through legitimize_tls_address, we use Pmode operations and temporaries (in case of -maddress-mode=long, Pmode equals to DImode). In case of Pmode == DImode, we forgot to extend the mode of a sybmol from SImode to DImode, and we set REG_EQUAL to a symbol in wrong mode. The patch extends SImode symbols to DImode using ZERO_EXTEND RTX. 2012-12-06 Uros Bizjak H.J. Lu PR target/55597 * config/i386/i386.c (legitimize_tls_address): Zero-extend x to Pmode, before using it as insn or call equivalent. testsuite/ChangeLog: 2012-12-06 Uros Bizjak PR target/55597 * gcc.target/i386/pr55597.c: New test. Patch was bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32} and by H.J. on x32. Patch was committed to mainline SVN, and will be committed to 4.7. Uros. Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 194263) +++ config/i386/i386.c (working copy) @@ -12785,6 +12785,9 @@ legitimize_tls_address (rtx x, enum tls_model mode tp = get_thread_pointer (Pmode, true); dest = force_reg (Pmode, gen_rtx_PLUS (Pmode, tp, dest)); + if (GET_MODE (x) != Pmode) + x = gen_rtx_ZERO_EXTEND (Pmode, x); + set_unique_reg_note (get_last_insn (), REG_EQUAL, x); } else @@ -12793,15 +12796,20 @@ legitimize_tls_address (rtx x, enum tls_model mode if (TARGET_64BIT) { - rtx rax = gen_rtx_REG (Pmode, AX_REG), insns; + rtx rax = gen_rtx_REG (Pmode, AX_REG); + rtx insns; start_sequence (); - emit_call_insn (ix86_gen_tls_global_dynamic_64 (rax, x, - caddr)); + emit_call_insn + (ix86_gen_tls_global_dynamic_64 (rax, x, caddr)); insns = get_insns (); end_sequence (); RTL_CONST_CALL_P (insns) = 1; + + if (GET_MODE (x) != Pmode) + x = gen_rtx_ZERO_EXTEND (Pmode, x); + emit_libcall_block (insns, dest, rax, x); } else @@ -12842,11 +12850,12 @@ legitimize_tls_address (rtx x, enum tls_model mode if (TARGET_64BIT) { - rtx rax = gen_rtx_REG (Pmode, AX_REG), insns, eqv; + rtx rax = gen_rtx_REG (Pmode, AX_REG); + rtx insns, eqv; start_sequence (); - emit_call_insn (ix86_gen_tls_local_dynamic_base_64 (rax, - caddr)); + emit_call_insn + (ix86_gen_tls_local_dynamic_base_64 (rax, caddr)); insns = get_insns (); end_sequence (); @@ -12871,6 +12880,9 @@ legitimize_tls_address (rtx x, enum tls_model mode { dest = force_reg (Pmode, gen_rtx_PLUS (Pmode, dest, tp)); + if (GET_MODE (x) != Pmode) + x = gen_rtx_ZERO_EXTEND (Pmode, x); + set_unique_reg_note (get_last_insn (), REG_EQUAL, x); } break; Index: testsuite/gcc.target/i386/pr55597.c =================================================================== --- testsuite/gcc.target/i386/pr55597.c (revision 0) +++ testsuite/gcc.target/i386/pr55597.c (working copy) @@ -0,0 +1,18 @@ +/* { dg-do compile { target { ! { ia32 } } } } */ +/* { dg-require-effective-target fpic } */ +/* { dg-options "-O2 -fPIC -mx32 -maddress-mode=long" } */ + +struct initial_sp +{ + void *sp; + int mask; +}; + +__thread struct initial_sp __morestack_initial_sp; + +void foo (int *); + +void __morestack_release_segments (void) +{ + foo (&__morestack_initial_sp.mask); +}