From patchwork Wed Oct 26 14:46:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georg-Johann Lay X-Patchwork-Id: 687117 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 3t3tC42rLnz9sf9 for ; Thu, 27 Oct 2016 01:46:55 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=tlbn75a6; 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:cc:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=VD/XEiYwcPLdYZ2LkimZq30szDBnI7ZYC0awxWaWD9qi20u16u NM+iFPLIqS6y0XgM2fAkRB5pUgPTlhSbSQ0gtt9ZRL3sHwSamdsRjlOWiuCfMCJk kIgzhgMuqUga7liRU8zBYz40kCDuzIwiwtHAeqTefYrGuz/y2RH9/VjVk= 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:cc:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=3Os1ggMVF/p/eeZyoJFG2IUH6tQ=; b=tlbn75a6U61KjDRB/+k6 wI5YPF3XMf0YTayg+qYvMjB6Q1QtHlu2P8oQHLyIgjO4xmCdVQQaDWtrb6ZOUtup GUfFWyTHbq83q+Z2Rmvcsi6dvQ1eBOt1Q6jgSOXPRcTqUfQG8hXFYzAo4fABy10C Naacsgte3hM+nAXLZT6TLLQ= Received: (qmail 15832 invoked by alias); 26 Oct 2016 14:46:48 -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 15814 invoked by uid 89); 26 Oct 2016 14:46:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=restrict, introduces X-HELO: mo4-p00-ob.smtp.rzone.de Received: from mo4-p00-ob.smtp.rzone.de (HELO mo4-p00-ob.smtp.rzone.de) (81.169.146.162) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 26 Oct 2016 14:46:37 +0000 X-RZG-AUTH: :LXoWVUeid/7A29J/hMvvT3ol15ykJcYwTPLBCxG2PQt7BpWLF2I= X-RZG-CLASS-ID: mo00 Received: from [192.168.0.123] (ip5f5871bb.dynamic.kabel-deutschland.de [95.88.113.187]) by smtp.strato.de (RZmta 39.7 DYNA|AUTH) with ESMTPSA id e05257s9QEkY9xa (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Wed, 26 Oct 2016 16:46:34 +0200 (CEST) Cc: Mike Stump To: gcc-patches From: Georg-Johann Lay Subject: [patch, testsuite] Support dg-require-effective-target label_offsets. Message-ID: Date: Wed, 26 Oct 2016 16:46:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 X-IsSubscribed: yes There are targets that support taking values of labels but where any arithmetic on such values might produce garbage. This patch introduces new dg-require-effective-target label_offsets which is a subset of label_values, and adjusts respective test cases to the more restricted predicate. Run tests against avr-unknown-none ATmega2560 where it makes actually a difference between label_values and label_offsets. Ok for trunk? Johann gcc/testsuite/ * lib/target-supports.exp (check_effective_target_label_offsets): New proc. * gcc.dg/20021029-1.c (dg-require-effective-target): Require more restrict label_offsets instead of label_values. * gcc.dg/pr16973.c: Dito. * gcc.dg/torture/pr66123.c: Dito. * gcc.dg/torture/pr66178.c: Dito. * gcc.c-torture/compile/20021108-1.c: Dito. * gcc.c-torture/compile/920501-7.c: Dito. * gcc.c-torture/compile/labels-2.c: Dito. * gcc.c-torture/compile/labels-3.c: Dito. * gcc.c-torture/execute/pr70460.c: Dito. Index: gcc.c-torture/compile/20021108-1.c =================================================================== --- gcc.c-torture/compile/20021108-1.c (revision 241546) +++ gcc.c-torture/compile/20021108-1.c (working copy) @@ -1,4 +1,4 @@ -/* { dg-require-effective-target label_values } */ +/* { dg-require-effective-target label_offsets } */ int main() Index: gcc.c-torture/compile/920501-7.c =================================================================== --- gcc.c-torture/compile/920501-7.c (revision 241546) +++ gcc.c-torture/compile/920501-7.c (working copy) @@ -1,3 +1,3 @@ -/* { dg-require-effective-target label_values } */ +/* { dg-require-effective-target label_offsets } */ x(){if(&&e-&&b<0)x();b:goto*&&b;e:;} Index: gcc.c-torture/compile/labels-2.c =================================================================== --- gcc.c-torture/compile/labels-2.c (revision 241546) +++ gcc.c-torture/compile/labels-2.c (working copy) @@ -1,4 +1,4 @@ -/* { dg-require-effective-target label_values } */ +/* { dg-require-effective-target label_offsets } */ struct bp { void *v, *b, *e; }; f () Index: gcc.c-torture/compile/labels-3.c =================================================================== --- gcc.c-torture/compile/labels-3.c (revision 241546) +++ gcc.c-torture/compile/labels-3.c (working copy) @@ -1,6 +1,6 @@ /* Verify that we can narrow the storage associated with label diffs. */ /* { dg-require-effective-target indirect_jumps } */ -/* { dg-require-effective-target label_values } */ +/* { dg-require-effective-target label_offsets } */ int foo (int a) { Index: gcc.c-torture/execute/pr70460.c =================================================================== --- gcc.c-torture/execute/pr70460.c (revision 241546) +++ gcc.c-torture/execute/pr70460.c (working copy) @@ -1,5 +1,5 @@ /* { dg-require-effective-target indirect_jumps } */ -/* { dg-require-effective-target label_values } */ +/* { dg-require-effective-target label_offsets } */ /* PR rtl-optimization/70460 */ Index: gcc.dg/20021029-1.c =================================================================== --- gcc.dg/20021029-1.c (revision 241546) +++ gcc.dg/20021029-1.c (working copy) @@ -3,7 +3,7 @@ /* { dg-do compile { target fpic } } */ /* { dg-options "-O2 -fpic" } */ /* { dg-final { scan-assembler-not ".data.rel.ro.local" } } */ -/* { dg-require-effective-target label_values } */ +/* { dg-require-effective-target label_offsets } */ /* { dg-require-effective-target indirect_jumps } */ int foo (int a) Index: gcc.dg/pr16973.c =================================================================== --- gcc.dg/pr16973.c (revision 241546) +++ gcc.dg/pr16973.c (working copy) @@ -3,7 +3,7 @@ to add back the label. */ /* { dg-options "" } */ -/* { dg-require-effective-target label_values } */ +/* { dg-require-effective-target label_offsets } */ void f (void) Index: gcc.dg/torture/pr66123.c =================================================================== --- gcc.dg/torture/pr66123.c (revision 241546) +++ gcc.dg/torture/pr66123.c (working copy) @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-require-effective-target label_values } */ +/* { dg-require-effective-target label_offsets } */ int test (int foo) Index: gcc.dg/torture/pr66178.c =================================================================== --- gcc.dg/torture/pr66178.c (revision 241546) +++ gcc.dg/torture/pr66178.c (working copy) @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-require-effective-target label_values } */ +/* { dg-require-effective-target label_offsets } */ int test(void) { Index: lib/target-supports.exp =================================================================== --- lib/target-supports.exp (revision 241546) +++ lib/target-supports.exp (working copy) @@ -740,6 +740,31 @@ proc check_effective_target_label_values }] } +# Return 1 if offsetting label values is supported, 0 otherwise. +# A typical offset is the value of a different label like in +# &&lab1 - &&lab2. + +proc check_effective_target_label_offsets {} { + # Offsetting labels implies we can take values of labels. + if { ![check_effective_target_label_values] } { + return 0; + } + if { [istarget avr-*-*] } { + # If the value of a label does not fit into 16 bits, the linker + # will generate a stub (containing a direct jump) and we end up + # with the address of the stub instead of the address of the very + # label. Whereas it is legitimate to use such addresses for + # indirect jumps, it makes no sense to perform any arithmetic + # on such addresses. + return [check_no_compiler_messages label_offsets assembly { + #ifdef __AVR_3_BYTE_PC__ + #error NO + #endif + }] + } + return 1; +} + # Return 1 if builtin_return_address and builtin_frame_address are # supported, 0 otherwise.