From patchwork Thu Jan 24 19:28:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1030643 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-494686-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="neQTJJxH"; dkim-atps=neutral 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 43lsdW0v43z9s7T for ; Fri, 25 Jan 2019 06:28:29 +1100 (AEDT) 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:reply-to:mime-version :content-type; q=dns; s=default; b=bsaoGKrjUIXag6B7evbhF/yAVawMh x52WpTHV0c1RNYQi7DtqFClbkttITfxjfPh9onasxPTqej4Bb8I9Y3I+W4M5wIkV xAKLjZgOGoahC4Z3UD1LMQhh9FK9wd/E+80pp9bkrsbKOZ/x/Y42I6RYPmHK2WCB vGHRQLSc4uNfo8= 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:reply-to:mime-version :content-type; s=default; bh=MI0QhucY+2Kn7GnaNGPiQbYgDOY=; b=neQ TJJxHlwQ/Z1Wx8EaBK2UjM96TvA7EoF6/pWqAlvXm2ja0vB2WeiZ4XDxPtFot6fb od827rn/57OBXksvkbQuedKJ/c7ENEAICJfBw2PZr6NJGSdSKCa/McyKCTyjUGIu zzFECqPJWMbV4SOb6TAP/NfByIZ+i7wpx3KhAPro= Received: (qmail 111941 invoked by alias); 24 Jan 2019 19:28:17 -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 111918 invoked by uid 89); 24 Jan 2019 19:28:15 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 24 Jan 2019 19:28:14 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E8AE5A429A; Thu, 24 Jan 2019 19:28:12 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-69.ams2.redhat.com [10.36.116.69]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C1EE6019F; Thu, 24 Jan 2019 19:28:12 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id x0OJSAAo031288; Thu, 24 Jan 2019 20:28:10 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id x0OJS895031147; Thu, 24 Jan 2019 20:28:08 +0100 Date: Thu, 24 Jan 2019 20:28:08 +0100 From: Jakub Jelinek To: Uros Bizjak Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Improve x86 address delegitimization (PR debug/89006) Message-ID: <20190124192808.GR30353@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-IsSubscribed: yes Hi! As the following testcase shows, during var-tracking we can end trying to delegitimize e.g. (plus:SI (unspec:SI ... UNSPEC_SET_GOT) (const:SI (unspec:SI (symbol_ref:SI ...) UNSPEC_GOTOFF)). The code is prepared to handle PIC register + UNSPEC_GOTOFF, delegitimizing that to the underlying SYMBOL_REF, but we can end up with the UNSPEC_SET_GOT instead of the %ebx etc. register, because in the RTL that register is initialized to that UNSPEC_SET_GOT. The following patch handles it like the pic register; the ix86_pic_register_p function is used only in the delegitimization hook. Bootstrapped/regtested on x86_64-linux and i686-linux, the patch removed all 170 non-delegitimized UNSPEC messages from x86_64-linux bootstrap and 142 out of 144 non-delegitimized UNSPEC messages from i686-linux bootstrap, ok for trunk? 2019-01-24 Jakub Jelinek PR debug/89006 * config/i386/i386.c (ix86_pic_register_p): Return true for UNSPEC_SET_GOT too. * g++.dg/debug/pr89006.C: New test. Jakub --- gcc/config/i386/i386.c.jj 2019-01-22 23:26:46.668212957 +0100 +++ gcc/config/i386/i386.c 2019-01-24 11:51:40.050801078 +0100 @@ -16972,6 +16972,8 @@ ix86_pic_register_p (rtx x) if (GET_CODE (x) == VALUE && CSELIB_VAL_PTR (x)) return (pic_offset_table_rtx && rtx_equal_for_cselib_p (x, pic_offset_table_rtx)); + else if (GET_CODE (x) == UNSPEC && XINT (x, 1) == UNSPEC_SET_GOT) + return true; else if (!REG_P (x)) return false; else if (pic_offset_table_rtx) --- gcc/testsuite/g++.dg/debug/pr89006.C.jj 2019-01-24 12:18:59.119838677 +0100 +++ gcc/testsuite/g++.dg/debug/pr89006.C 2019-01-24 12:16:56.642859109 +0100 @@ -0,0 +1,20 @@ +// PR debug/89006 +// { dg-do compile } +// { dg-options "-O2 -g -w" } +// { dg-additional-options "-fPIC" { target fpic } } +// { dg-bogus "non-delegitimized UNSPEC UNSPEC_SET_GOT" "" { target { i?86-*-* x86_64-*-* } } 0 } + +struct A { A (bool); }; + +static void +foo (const char *x) +{ + new A (x); +} + +void +bar () +{ + foo ("foo"); + foo ("bar"); +}