From patchwork Tue Dec 10 23:23:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1207325 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-515660-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.b="EMWwFr2f"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="UzEIU9vt"; 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 47Xbjp4RwRz9sPK for ; Wed, 11 Dec 2019 10:24:12 +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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=Qop ouEMQZEAf5Vc2gcaPb3Bpp7cWFNYDeduLHponn/VKtdQuZwSTZIca93dTUfosewd YNttRGKrQCPPn9+VSi95BuWkiISM+jFcepF17Ko8RWPaNwOYt7Z4TPfT0cCHKG9+ AGg9LbAY2DEJ5XRpWADFrSsIG1XTzy+ppC4Mzfv0= 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:reply-to:mime-version :content-type:content-transfer-encoding; s=default; bh=n+KxSm7Er yvlPpdZPsRXcTtLiNE=; b=EMWwFr2fl9JMnfZuJDEhmSIXumbkwoWdR0uD49rgG VYHt9oLZ0MppgRxjCNL89ibsJgFGn57xFfP42CrJd/YdzwEmrTCJ6oq7tUeiZ79Z I4yyQwkZSN2Ty/ICNCLKHhLmsKVwZgll853e7MjxsnzgDCTYsRZzc8w0pp5r6Qy3 /s= Received: (qmail 25787 invoked by alias); 10 Dec 2019 23:24:03 -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 25765 invoked by uid 89); 10 Dec 2019 23:24:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=builtinscjj, HX-Languages-Length:1691, anti-ranges, builtins.c.jj X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-2.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (207.211.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Dec 2019 23:24:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576020240; h=from:from:reply-to: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=CmONHw1vagvLphNhrHnNfI8vRu8H6qSXulgdWmEy/Ok=; b=UzEIU9vtWvZjKMDHKFf54ZQ/CDDuKqoE2RPV2Gyi28KCwjEi4J8yZJRbW7O8dgsjKEfZfH TRDI+Qt/oI2T8N4hU1SFabWg4T/K5DKcSxBazy1oLfGSgQzv8T3PKA3TqIUcXtFPotsfUk oL/W3viUcg9+4zMfIxGyZcaQA3nDCNM= 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-55-Z2OCreY7OmuI6a04BM1z7w-1; Tue, 10 Dec 2019 18:23:57 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F2336DB77; Tue, 10 Dec 2019 23:23:55 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-117-59.ams2.redhat.com [10.36.117.59]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C4595C3F8; Tue, 10 Dec 2019 23:23:54 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id xBANNpvU005241; Wed, 11 Dec 2019 00:23:52 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id xBANNoek005240; Wed, 11 Dec 2019 00:23:50 +0100 Date: Wed, 11 Dec 2019 00:23:50 +0100 From: Jakub Jelinek To: Jeff Law Cc: gcc-patches@gcc.gnu.org, Martin Sebor Subject: [PATCH] Fix ICE in compute_objsize (PR tree-optimization/92891) Message-ID: <20191210232350.GN10088@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Mimecast-Spam-Score: 0 Content-Disposition: inline X-IsSubscribed: yes Hi! The following testcase ICEs, because gimple_call_alloc_size doesn't always return a sizetype typed INTEGER_CST, which the callers rely on (compare those converted to wide_int with other wide_ints with the sizetype precision). If alloc_size attribute has two arguments, gimple_call_alloc_size will always build a sizetype INTEGER_CST, but if it is just one, it returns what is passed to the argument, whatever type it has, so could be wider (e.g. __int128) or narrower like in the testcase on lp64. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2019-12-10 Jakub Jelinek PR tree-optimization/92891 * builtins.c (gimple_call_alloc_size): Convert size to sizetype before returning it. * gcc.c-torture/compile/pr92891.c: New test. Jakub --- gcc/builtins.c.jj 2019-12-09 19:50:24.733953169 +0100 +++ gcc/builtins.c 2019-12-10 20:56:53.619769947 +0100 @@ -3755,7 +3755,7 @@ gimple_call_alloc_size (gimple *stmt) return NULL_TREE; if (argidx2 > nargs && TREE_CODE (size) == INTEGER_CST) - return size; + return fold_convert (sizetype, size); /* To handle ranges do the math in wide_int and return the product of the upper bounds as a constant. Ignore anti-ranges. */ --- gcc/testsuite/gcc.c-torture/compile/pr92891.c.jj 2019-12-10 21:09:14.137648344 +0100 +++ gcc/testsuite/gcc.c-torture/compile/pr92891.c 2019-12-10 21:08:56.902907013 +0100 @@ -0,0 +1,16 @@ +/* PR tree-optimization/92891 */ + +int a, b; +char *foo (int) __attribute__((alloc_size(1))); + +void +bar (void) +{ + char *e = foo (2); + while (a) + { + if (b <= 0) + continue; + e[b] = 0; + } +}