From patchwork Thu Jun 21 12:34:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 932710 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-480181-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="gXZxULZV"; 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 41BLkd3jTXz9s2L for ; Thu, 21 Jun 2018 22:35:03 +1000 (AEST) 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:mime-version:content-type; q=dns; s=default; b=T+Pg//wH6rRn3fWAEEvZmDXjvZiYmcBZZ/CO7/VZDFXxA7jtXq Wod4Ym13+jEDHK3j3/LPs4W3/52ZQeYR1H0emv1nrf4KzrwILrgolR64PBh35931 WRqbBpMo7eI1EB0S+39/83jZpSAwFUO0QzBEA2jRwB7vTtFraWpNn+CkA= 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:mime-version:content-type; s= default; bh=SQK0YB1je006x30SAKzk5eWH4IA=; b=gXZxULZVaaWw0667/Ub7 kDm1RSDApgR455F5XwImp+Au6KZRAOVsaR0LPrJzFQou1d5Q+5vjF4n46c/D8whU o5/E7xfxJwiKXSzkyZNQXwaOdeupv4cB4zhGKhcIi3Vhc7zof/7hyjSkwwHtMzHh WfsglC1CMYzC6dmQIJe4CB0= Received: (qmail 77016 invoked by alias); 21 Jun 2018 12:34:55 -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 76851 invoked by uid 89); 21 Jun 2018 12:34:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1693, D*entry X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 21 Jun 2018 12:34:53 +0000 Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C06F3AFF1; Thu, 21 Jun 2018 12:34:50 +0000 (UTC) Date: Thu, 21 Jun 2018 14:34:49 +0200 From: Tom de Vries To: gcc-patches@gcc.gnu.org Cc: Richard Biener , Cary Coutant , Jason Merrill Subject: [testsuite] Fix guality/pr45882.c for flto Message-ID: <20180621123342.fqyitbmaxpkcayih@localhost.localdomain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170912 (1.9.0) X-IsSubscribed: yes Hi, Atm this test in pr45882.c: ... int d = a[i]; /* { dg-final { gdb-test 16 "d" "112" } } */ ... fails as follows with -flto: ... FAIL: gcc.dg/guality/pr45882.c -O2 -flto -fuse-linker-plugin \ -fno-fat-lto-objects line 16 d == 112 ... In more detail, gdb fails to print the value of d: ... Breakpoint 1, foo (i=i@entry=7, j=j@entry=7) at pr45882.c:16 16 ++v; $1 = $2 = 112 != 112 ... Variable d is a local variable in function foo, initialized from global array a. When compiling, first cddce1 removes the initialization of d in foo, given that d is not used afterwards. Then ipa marks array a as write-only, and removes the stores to array a in main. This invalidates the location expression for d, which points to a[i], so it is removed, which is why gdb ends up printing for d. This patches fixes the fail by adding attribute used to array a, preventing array a from being marked as write-only. Tested on x86_64. OK for trunk? Thanks, - Tom [testsuite] Fix guality/pr45882.c for flto 2018-06-21 Tom de Vries * gcc.dg/guality/pr45882.c (a): Add used attribute. --- gcc/testsuite/gcc.dg/guality/pr45882.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/guality/pr45882.c b/gcc/testsuite/gcc.dg/guality/pr45882.c index 5ca22d4f4ad..ece35238a30 100644 --- a/gcc/testsuite/gcc.dg/guality/pr45882.c +++ b/gcc/testsuite/gcc.dg/guality/pr45882.c @@ -3,7 +3,7 @@ /* { dg-options "-g" } */ extern void abort (void); -int a[1024]; +int a[1024] __attribute__((used)); volatile short int v; __attribute__((noinline,noclone,used)) int