From patchwork Mon Jan 16 05:20:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 715588 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3v21mX6njHz9t0J for ; Mon, 16 Jan 2017 16:21:14 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="uznVM4pP"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=BwJPmGvD5n/V8dHKK ShEFH/mLmBbTLkpOnr9rRIQxTm32ZpS7zOfK3OkVS74zOxZhIABj0HkKIB1uuwhm oiNnppix5bCR4TP2RKNC3mxGQTbieNetQfBLwmDEVP38ulTWQZyDa7UVx3Lm2er0 uAXk8DG8V4vn+SMGQNr9RMR3ak= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=rMxiJozOaqiAaauD2NeZB14 g60E=; b=uznVM4pPnQ+RMmnQnx/8Et4s7iy+2dIqqVIkod2eMhDTAJHPiV4GBrc uawhLpWKwM8gVevhxPqDJyeadEw8eY1k6iS6eVn+HYh5UWl3orFnjGSugkgUyC1g ltuOQnX631qJ1BclfrVvAAx6c/s9mxPcDmIeDnTNMb3f87j1q0Bs= Received: (qmail 3043 invoked by alias); 16 Jan 2017 05:20:49 -0000 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 Received: (qmail 2701 invoked by uid 89); 16 Jan 2017 05:20:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=Hx-languages-length:3371, lacked, vi X-HELO: mail-pg0-f65.google.com Received: from mail-pg0-f65.google.com (HELO mail-pg0-f65.google.com) (74.125.83.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 16 Jan 2017 05:20:09 +0000 Received: by mail-pg0-f65.google.com with SMTP id t6so309821pgt.1 for ; Sun, 15 Jan 2017 21:20:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=pUeMo3yEIb55HniwBicxyJIpDMvXHJM6NbY0iyyYPFU=; b=XSYT1B32m1Q4/aMjZpz3D0fGwQ89TVUZMC9h1GnenqVGpzXdHGRsULYcjQRGf48VnB mbu04EpWATuG4Z67ydCk4mmY0uxIukK3SuQLr6QJLZQVKLbZG3ORLt3Oued2MnFPj4wa nR48PKn2lQP8X42Q5IW1M++C3rioxW0N2krWGKxyaH//P7Vl2bX0Q3niP9L1yxXXbiRA VcSmiLSiO2YAYKf1l4A+3Hx1iiVH+gxSy+z8HVwn9/+vtYVr/zakYf/l6hUwhf95RS9D 7pJ+EcWnJWeP/qLK/upnXMTZ9CXjReiERsqAXGfGRbmfXAZXv4Vifq/qzYLIrNkTk6kr oXTg== X-Gm-Message-State: AIkVDXJlgoXkpvNYJ9VdTFcmeaBj2CXow3/OD1KDIjw49Ug1chzJ9c/+5umVan5gHi3YrQ== X-Received: by 10.84.217.68 with SMTP id e4mr13893834plj.99.1484544006492; Sun, 15 Jan 2017 21:20:06 -0800 (PST) Received: from bubble.grove.modra.org (CPE-58-160-71-80.tyqh2.lon.bigpond.net.au. [58.160.71.80]) by smtp.gmail.com with ESMTPSA id s8sm43810117pfj.30.2017.01.15.21.20.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Jan 2017 21:20:05 -0800 (PST) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 76B5DC0398; Mon, 16 Jan 2017 15:50:01 +1030 (ACDT) Date: Mon, 16 Jan 2017 15:50:01 +1030 From: Alan Modra To: Segher Boessenkool Cc: gcc-patches@gcc.gnu.org Subject: Re: PR79066, non-PIC code generated for powerpc glibc with -fpic Message-ID: <20170116052001.GE32333@bubble.grove.modra.org> References: <20170113114012.GT32333@bubble.grove.modra.org> <20170114092851.GW28613@gate.crashing.org> <20170114133839.GZ32333@bubble.grove.modra.org> <20170114151952.GA30284@gate.crashing.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170114151952.GA30284@gate.crashing.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes On Sat, Jan 14, 2017 at 09:19:52AM -0600, Segher Boessenkool wrote: > On Sun, Jan 15, 2017 at 12:08:39AM +1030, Alan Modra wrote: > > > Have you checked if/what this changes for some bigger code? > > > > Well, the bootstrap was all langs (minus ada due to not having ada > > installed) and ppc32 multilibs were built. Plus the testsuite run > > with RUNTESTFLAGS="--target_board=unix'{-m32,-m64}{-mlra,-mno-lra}'" > > > > I would have bootstrapped -m32 except the machine I used lacked 32-bit > > gmp, mpfr, mpc and I was lazy. > > > > > Okay for trunk if there is nothing unexpected. Thanks! > > > > I guess I should at least build glibc. > > Yes exactly, something big that uses pic -- it is pretty obvious it won't > change anything for non-pic. glibc built fine without elf_high/elf_low with no regressions in its testsuite. However, there is a problem in rs6000_emit_allocate_stack -fstack-limit-symbol=SYMBOL code. This now might ICE if someone tries to use the option with -fpic/PIC. I reckon the option combination to be little used, so it shouldn't hurt to disable -fstack-limit-symbol for PIC. (We were generating non-PIC for the trap, so we probably would have gotten a complaint about text relocs in shared libraries.) This revised patch has been bootstrapped and regression tested as before, and tested with glibc too. OK? PR target/79066 * config/rs6000/rs6000.md (elf_high, elf_low): Disable when pic. * config/rs6000/rs6000.c (rs6000_emit_allocate_stack): Don't allow symbolic stack limit when pic. testsuite/ * gcc.target/powerpc/pr79066.c: New. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 11394b2..2dd6bbe 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -27668,7 +27668,8 @@ rs6000_emit_allocate_stack (HOST_WIDE_INT size, rtx copy_reg, int copy_off) } else if (GET_CODE (stack_limit_rtx) == SYMBOL_REF && TARGET_32BIT - && DEFAULT_ABI == ABI_V4) + && DEFAULT_ABI == ABI_V4 + && !flag_pic) { rtx toload = gen_rtx_CONST (VOIDmode, gen_rtx_PLUS (Pmode, diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index b333474..f00334a 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -10581,14 +10581,14 @@ (define_insn_and_split "*tocref" (define_insn "elf_high" [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r") (high:SI (match_operand 1 "" "")))] - "TARGET_ELF && ! TARGET_64BIT" + "TARGET_ELF && !TARGET_64BIT && !flag_pic" "lis %0,%1@ha") (define_insn "elf_low" [(set (match_operand:SI 0 "gpc_reg_operand" "=r") (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b") (match_operand 2 "" "")))] - "TARGET_ELF && ! TARGET_64BIT" + "TARGET_ELF && !TARGET_64BIT && !flag_pic" "la %0,%2@l(%1)") ;; Call and call_value insns diff --git a/gcc/testsuite/gcc.target/powerpc/pr79066.c b/gcc/testsuite/gcc.target/powerpc/pr79066.c new file mode 100644 index 0000000..86b2014 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr79066.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target { fpic && ilp32 } } } */ +/* { dg-options "-O2 -fpic" } */ +/* { dg-final { scan-assembler-not "lis.*@ha" } } */ + +union U { double x; int i[2]; }; + +double +foo (double x) +{ + union U v; + v.i[0] = 0x7ff00000; + v.i[1] = 0; + return x / v.x; +}