From patchwork Fri Jan 24 16:17:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 1228889 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-518231-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.a=rsa-sha1 header.s=default header.b=aFV6rgvw; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Wh4+KC65; 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 48446y1FY8z9sRY for ; Sat, 25 Jan 2020 03:17:44 +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:from :to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=dlI8xUddWgwo+PhS FU5x2wuMGg6Tu+HdwX5aKPsPvhWyXukz1yBTZRn6jbL5HPdNCgPVvm2kGnPYl/oR up6c0VUpZF6IIHh7dCzD+fxLrIjkWHJ9bzz4+Yv2Ykx1tmnfD1ZMq/BeBnsOvn/g SsqbCM7b3/UcFrkiaRtSJFBcqL4= 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:from :to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=OYZdFA7rsUM2VJtx4P8sly Reimo=; b=aFV6rgvwW1JEykf7+ZkNPvsm+3y7lkkIOL7aGu3akDHDsT+nQ5GwEZ qYcOCQHGUKUtJ3R136ygEL3T2vLtZHKHHo0MeVWqfulE+zTDdEY7jUOy6tC0g/he 2s/54fjqhDUBT5vDUOOmZdn0gM+mdA/uB4Ua4ItW09DPSB7pSxlxs= Received: (qmail 92604 invoked by alias); 24 Jan 2020 16:17:36 -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 92596 invoked by uid 89); 24 Jan 2020 16:17:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-2.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (205.139.110.61) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 24 Jan 2020 16:17:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579882653; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rufOvjch0y9tEJq63ZJi1jGGLYfSIX1d1TeZYcUuWWw=; b=Wh4+KC65CvC48FKpekiC1+kWTLGNgJu4MkmYPCwATek8NVRLNHXva726mYDT8JzHzQutv+ KQ4dt9mZR+ehnHyuSkdPHh4Bk4BcsgvnX2j2YpKEkdh6nWlkXyRGxkGTH067y3k8MRY/RT Elobx9h9IJe88UE74t9QrHDu7kkzDdk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-338-bDRiDviHPi-hyntYLrHz5g-1; Fri, 24 Jan 2020 11:17:26 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 703519FF6D for ; Fri, 24 Jan 2020 16:17:25 +0000 (UTC) Received: from t470.redhat.com (ovpn-117-41.phx2.redhat.com [10.3.117.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF1435DDB3; Fri, 24 Jan 2020 16:17:24 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH] analyzer: restore input_location (PR 93349) Date: Fri, 24 Jan 2020 11:17:22 -0500 Message-Id: <20200124161722.17334-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-IsSubscribed: yes PR analyzer/93349 reports an ICE in IPA pass: simdclone for some input files when -fanalyzer is supplied, with: error: location references block not in block tree The root cause is that the analyzer touches input_location in some places (to make it easier to track down which source construct the analyzer can't handle in the case of an analyzer ICE) and fails to reset it. For the ICE in question, this sets input_location to a location_t that references some arbitrary block (specifically, that of the last statement to be analyzed, within the original CFG of whichever is the last such function to be analyzed). Later, within omp-simd-clone.c, input_location is used by gimplify_expr (called via gimplify_and_add), which has: 14492 if (!gimple_seq_empty_p (*pre_p)) 14493 annotate_all_with_location_after (*pre_p, pre_last_gsi, input_location); thus using whatever the value of input_location is, leading to statements that reference some arbitrary block in the original CFG. For the reproducer, this happens to be a block in the CFG for the original function, rather than that of the clone, but in general it could be some arbitrary other function in the TU. This code appears to assume that input_location has some arbitrary value *not* in the block tree, which is potentially violated by the analyzer's changes to input_location. This patch adds a save and restore of input_location at the top-level function of the analyzer, fixing the ICE. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. OK for master? gcc/analyzer/ChangeLog: PR analyzer/93349 * engine.cc (run_checkers): Save and restore input_location. gcc/testsuite/ChangeLog: PR analyzer/93349 * gcc.dg/analyzer/torture/pr93349.c: New test. --- gcc/analyzer/engine.cc | 8 ++++++++ gcc/testsuite/gcc.dg/analyzer/torture/pr93349.c | 4 ++++ 2 files changed, 12 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/analyzer/torture/pr93349.c diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc index 939401140e7..b881a1d9218 100644 --- a/gcc/analyzer/engine.cc +++ b/gcc/analyzer/engine.cc @@ -3589,6 +3589,9 @@ impl_run_checkers (logger *logger) void run_checkers () { + /* Save input_location. */ + location_t saved_input_location = input_location; + /* Handle -fdump-analyzer and -fdump-analyzer-stderr. */ FILE *dump_fout = NULL; /* Track if we're responsible for closing dump_fout. */ @@ -3619,6 +3622,11 @@ run_checkers () if (owns_dump_fout) fclose (dump_fout); + + /* Restore input_location. Subsequent passes may assume that input_location + is some arbitrary value *not* in the block tree, which might be violated + if we didn't restore it. */ + input_location = saved_input_location; } } // namespace ana diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/pr93349.c b/gcc/testsuite/gcc.dg/analyzer/torture/pr93349.c new file mode 100644 index 00000000000..a9d06367722 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/torture/pr93349.c @@ -0,0 +1,4 @@ +__attribute__ ((simd)) void +test (void) +{ +}