From patchwork Fri Nov 11 17:10:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 693821 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 3tFmf24tdjz9t1F for ; Sat, 12 Nov 2016 04:11:05 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="dHpqH7jf"; 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:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=gr6PYhNUlERIBIB9cy3uINQEaZJkxGbBa0g9Tld56qgmdt+JwA sUR5vzJdMD8yBqlSCHhIddJqHTiJcZs7qBlVCn8Sq0VmJfWytMFDxqPwfhpxQ6Kt fPjx320MVVz895Hg9ELm4wFS14G5/zLF9vf+qqioqcfXv55rpRwzgGfA0= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=2hMnsHYSNt+MP5v7k25QbE2OJ3Y=; b=dHpqH7jfHKTnDjUEsv8A Qkh9c4PGp+yG9SfuUDtFz+x5XaE90RwM2fUQZ92s7B5GiB0kWigGnUD4ilnccz84 7R5MzT11egCim8qn/we/DElKxAEaTszIR9vGVfsO9UAqnJ7ME7B2WVGDMgNfkYVV NxEmxJqFSCC4QmF/sYg2pOg= Received: (qmail 972 invoked by alias); 11 Nov 2016 17:10:54 -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 934 invoked by uid 89); 11 Nov 2016 17:10:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=incoming 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; Fri, 11 Nov 2016 17:10:51 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ACFF3C05678D for ; Fri, 11 Nov 2016 17:10:50 +0000 (UTC) Received: from reynosa.quesejoda.com (vpn-62-127.rdu2.redhat.com [10.10.62.127]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uABHAn5e019185; Fri, 11 Nov 2016 12:10:49 -0500 To: gcc-patches Cc: David Malcolm From: Aldy Hernandez Subject: [PR target/78213] Do not ICE on non-empty -fself-test Message-ID: <9158b0e8-f6b7-8a71-4d78-6f1b174a8405@redhat.com> Date: Fri, 11 Nov 2016 09:10:48 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 The problem in this PR is that -fself-test is being run on a non empty source file. This causes init_emit() to run, which sets: REG_POINTER (virtual_incoming_args_rtx) = 1; Setting REG_POINTER on the virtual incoming args, causes /f to be printed on some RTL dumps, causing the -fself-test machinery to fail at matching the expected value. It looks that by design -fself-test is meant to be run before any initialization like the aforementioned runs. We could error/fail when running -fself-test on a non-empty file, but I think we can just enable -fsyntax-only and get the same result. After all, this is an undocumented internal option. BTW, this is being triggered on aarch64, but will likely show up in different ports in different ways. OK for trunk? commit f5d7bfbdae2f74d3b98a81e1f3ee7b9b24c8f3be Author: Aldy Hernandez Date: Fri Nov 11 06:32:08 2016 -0800 PR target/78213 * opts.c (common_handle_option): Set -fsyntax-only if running self tests. diff --git a/gcc/opts.c b/gcc/opts.c index d2d6100..35357bd 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -1770,6 +1770,16 @@ common_handle_option (struct gcc_options *opts, opts->x_exit_after_options = true; break; + case OPT_fself_test: + /* -fself-test depends on the state of the compiler prior to + compiling anything. Ideally it should be run on an empty + source file. However, in case we get run with actual source, + assume -fsyntax-only which will inhibit any compiler + initialization which may confuse the self tests. */ + if (lang_mask != CL_DRIVER) + flag_syntax_only = 1; + break; + case OPT_fsanitize_: opts->x_flag_sanitize = parse_sanitizer_options (arg, loc, code, diff --git a/gcc/testsuite/gcc.dg/pr78213.c b/gcc/testsuite/gcc.dg/pr78213.c new file mode 100644 index 0000000..b262fa1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr78213.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-fself-test" } */ + +/* Verify that -fself-test does not fail on a non empty source. */ + +int i; void bar(); void foo() +{ + while (i--) + bar(); +}