From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 735523858D37 for ; Thu, 6 Oct 2022 20:40:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 735523858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665088841; 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=IXZYdCQpnXiWeExUnOsPY+Pe7JWlLeEbsqxCDybLO30=; b=Ar2d+H14tDp9vW8ERwD2lzUzh12d+wwJryDWQBpOxOu5kYKMC6KNkPgrOpBz5bfmEZJUyK s6B0yMfMuT4VYHG2E8d+cMMVlGbfJXt2EgKEMwia7sn1npFECcPi280yRlaA60P5KEmoFj UhgZeZOsx+qQeEoizeq7GN+5t4stoTk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-601-olsY6AE-OnKyW86TCijebw-1; Thu, 06 Oct 2022 16:40:40 -0400 X-MC-Unique: olsY6AE-OnKyW86TCijebw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D24FA811E67 for ; Thu, 6 Oct 2022 20:40:39 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 83B8C40C945A; Thu, 6 Oct 2022 20:40:39 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.17.1/8.17.1) with ESMTPS id 296KebUh1796216 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 6 Oct 2022 22:40:37 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 296Kebij1796215; Thu, 6 Oct 2022 22:40:37 +0200 From: Aldy Hernandez To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED] [PR107170] Avoid copying incompatible types in legacy VRP. Date: Thu, 6 Oct 2022 22:40:35 +0200 Message-Id: <20221006204035.1796190-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Legacy VRP is calling ranger deep inside the bowels, and then trying to copy an incompatible type. My previous patch in this area assumed that the only possibility out of vr_values::get_value_range for an unsupported type was VARYING, but UNDEFINED can also be returned. PR tree-optimization/107170 gcc/ChangeLog: * vr-values.cc (vr_values::range_of_expr): Do not die on unsupported types. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr107170.c: New test. --- gcc/testsuite/gcc.dg/tree-ssa/pr107170.c | 8 ++++++++ gcc/vr-values.cc | 24 +++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr107170.c diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr107170.c b/gcc/testsuite/gcc.dg/tree-ssa/pr107170.c new file mode 100644 index 00000000000..7a5a4a363f2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr107170.c @@ -0,0 +1,8 @@ +// { dg-do compile } +// { dg-options "-O2" } + +int main() { + double a; + if (__builtin_signbit(a)) + __builtin_abort(); +} diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc index 626a9189472..71fed1e6a7e 100644 --- a/gcc/vr-values.cc +++ b/gcc/vr-values.cc @@ -184,21 +184,23 @@ vr_values::range_of_expr (vrange &r, tree expr, gimple *stmt) if (const value_range *vr = get_value_range (expr, stmt)) { + if (!vr->supports_type_p (TREE_TYPE (expr))) + { + // vr_values::extract_range_basic() use of ranger's + // fold_range() can create a situation where we are asked + // for the range of an unsupported legacy type. Since + // get_value_range() above will return varying or undefined + // for such types, avoid copying incompatible range types. + if (vr->undefined_p ()) + r.set_undefined (); + else + r.set_varying (TREE_TYPE (expr)); + return true; + } if (vr->undefined_p () || vr->constant_p ()) r = *vr; else { - if (!vr->supports_type_p (TREE_TYPE (expr))) - { - // vr_values::extract_range_basic() use of ranger's - // fold_range() can create a situation where we are - // asked for the range of an unsupported legacy type. - // Since get_value_range() above will return varying for - // such types, avoid copying incompatible range types. - gcc_checking_assert (vr->varying_p ()); - r.set_varying (TREE_TYPE (expr)); - return true; - } value_range tmp = *vr; tmp.normalize_symbolics (); r = tmp; -- 2.37.1