From patchwork Fri Jun 15 07:23:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 929814 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-479788-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="FZPPAk9V"; 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 416X6D5f65z9s19 for ; Fri, 15 Jun 2018 17:23:47 +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:subject:message-id:mime-version:content-type; q=dns; s= default; b=cBbrYhZ1VXOFNDtntPRLiiGGX2t67aAqbAsIJrWszlepTRtQ9SbKJ WNtGeoFrQ3j1igMAKAvmnxOMkCrqbTVej8Pr9GDjy56m2f6hSrGNppPZ6pf0K/xq yC7kXv/a0hQPJr9UppjIv4biwZ6UrFT5Luqh4JOuPRoX1zdao9DPqw= 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:subject:message-id:mime-version:content-type; s= default; bh=75N2IntEi6FFg1VA8IjJ9vW8KlU=; b=FZPPAk9VZXFMWEni7NSf xPMxpfXlgLsGbX+fYIm5ajBgr/ra2mzv/tN8N5cTXuc5CNQc9WLUMhQjLzWE9XzY PSiEDv88SJWbAmH/lZl3XtKFAZSzQ1/7v042KcPDRt/TRAvB7Vbc/PRLlagwCTM6 aLB2wzsPQ53bCoagIoZgpjk= Received: (qmail 6353 invoked by alias); 15 Jun 2018 07:23:39 -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 6336 invoked by uid 89); 15 Jun 2018 07:23:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2170 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; Fri, 15 Jun 2018 07:23:37 +0000 Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 9DF37AF67 for ; Fri, 15 Jun 2018 07:23:34 +0000 (UTC) Date: Fri, 15 Jun 2018 09:23:34 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR86076 Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 The following fixes move-sese-region-to-function to not clobber shared trees when it changes BLOCK references. Invariant addresses are somewhat special in that they are allowed to be shared (by the verifier) but are actually copied by unshare_expr and friends. Maybe that's something we should change (not allow tree sharing of those). Anyway, bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk and queued for backports. Richard. From 4dab04aa51d234815a44e1d844c515fa18f97dc3 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Thu, 14 Jun 2018 15:04:13 +0200 Subject: [PATCH] fix-pr86076 2018-06-15 Richard Biener PR middle-end/86076 * tree-cfg.c (move_stmt_op): unshare invariant addresses before adjusting their block. * gcc.dg/pr86076.c: New testcase. diff --git a/gcc/testsuite/gcc.dg/pr86076.c b/gcc/testsuite/gcc.dg/pr86076.c new file mode 100644 index 00000000000..019ced3cbf5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr86076.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-parallelize-loops=2 -fno-tree-dce -fno-tree-pre -fno-tree-vrp --param max-loop-header-insns=1" } */ + +int __attribute__ ((noinline)) +lv (int tm) +{ + (void) tm; + + return 0; +} + +void +o7 (int uu) +{ + while (uu < 1) + while (uu != 0) + { + short int ca; + + ca = lv (0); + (void) ca; + ++uu; + } + + lv (lv (0)); +} diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 5f6defa6fe7..e7d16ca0a14 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -6742,7 +6742,16 @@ move_stmt_op (tree *tp, int *walk_subtrees, void *data) ; else if (block == p->orig_block || p->orig_block == NULL_TREE) - TREE_SET_BLOCK (t, p->new_block); + { + /* tree_node_can_be_shared says we can share invariant + addresses but unshare_expr copies them anyways. Make sure + to unshare before adjusting the block in place - we do not + always see a copy here. */ + if (TREE_CODE (t) == ADDR_EXPR + && is_gimple_min_invariant (t)) + *tp = t = unshare_expr (t); + TREE_SET_BLOCK (t, p->new_block); + } else if (flag_checking) { while (block && TREE_CODE (block) == BLOCK && block != p->orig_block)