From patchwork Fri Jan 24 22:52:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 1229099 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-518243-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=KQUrGJ4T; 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=VmMgHvOq; 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 484Dv90W9Gz9sP6 for ; Sat, 25 Jan 2020 09:53:07 +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 :message-id:subject:from:reply-to:to:date:mime-version :content-type; q=dns; s=default; b=P2AXXi8PDP8BQAxhySeLYfdJ9EvDd MUSubCoUMIrwjpKfuXX0KnQj+AegrQsFxA7uJyfQxQJBOHToIUz8oBkd4T05uNAl vXRnLQuPdtwqzBccCrVn/b6JnYEtrREiMO+kBMR6HbiVR2aXX79XKKZhzP9jxuXv eVm25IynG01TWI= 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 :message-id:subject:from:reply-to:to:date:mime-version :content-type; s=default; bh=rxsEp+jSZszYfrD8tzVKad6d1PY=; b=KQU rGJ4T63m86Lb1eOabHls9PHod5tMssHYA78uxTlEwzOCmHHBf02oummtXjZ+0bUc ShQr5DTiv95kLprwI5JgrqbyUE6CPu5R3N0k3uyF2oYzNXemG5uxFpvFLCMOplzy PS9874AEgL7CDFXEHI9ae/kiWDVwbv5G18CZ8CP0= Received: (qmail 8023 invoked by alias); 24 Jan 2020 22:52:59 -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 8015 invoked by uid 89); 24 Jan 2020 22:52:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-14.6 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=abnormal, new_allocator X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (207.211.31.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 24 Jan 2020 22:52:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579906375; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type; bh=2PbaSmJXprOOA0k5RshBfbzKwfGZEKHyHIkzjZ5Sg90=; b=VmMgHvOquylovEAO/OwXBYzOJ+uVA86ZIaPFcojvG5F4P4HutF/yHr+I8ZV0V6TkglPsOi AKetTZY60EHHBYdsO8dF1ehJ6Wp9Y4NrCLOeeEWU3BgNYSjXYAw4n+t693vqJCed3BuBUI zTNJA3mU0gqvrBM4OYNtCT2U06+8Xqg= 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-205-eZZkL7iBMNqVoKsx6tyA0w-1; Fri, 24 Jan 2020 17:52:53 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8259618A8C85 for ; Fri, 24 Jan 2020 22:52:52 +0000 (UTC) Received: from ovpn-117-120.phx2.redhat.com (ovpn-117-120.phx2.redhat.com [10.3.117.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 495731001B03 for ; Fri, 24 Jan 2020 22:52:52 +0000 (UTC) Message-ID: Subject: [committed] [PR tree-optimization/92788] Check right edge flags when suppressing jump threading From: Jeff Law Reply-To: law@redhat.com To: gcc-patches Date: Fri, 24 Jan 2020 15:52:51 -0700 User-Agent: Evolution 3.34.3 (3.34.3-1.fc31) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-IsSubscribed: yes When we thread through the successor of a joiner block we make a clone of the joiner block and redirect its outgoing edges. Of course if there's cases where we can't redirect an edge, then bad things will happen. The code already checked for EDGE_ABNORMAL to suppress threading in that case. But it really should have been checking EDGE_COMPLEX which includes ABNORMAL_CALL, EH and PRESERVE. This patch fixes that oversight and resolves the BZ. Bootstrapped and regression tested on x86_64. Committed to the trunk. jeff commit 98181563dc4c65c9d23eaa99134e18876b6ec671 Author: Jeff Law Date: Fri Jan 24 17:44:10 2020 -0500 Fix ICE due to invalid jump threading request PR tree-optimization/92788 * tree-ssa-threadedge.c (thread_across_edge): Check EDGE_COMPLEX not EDGE_ABNORMAL. PR tree-optimization/92788 * g++.dg/pr92788.C: New test. diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b1b46326306..0f19fc44212 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2020-01-24 Jeff Law + + PR tree-optimization/92788 + * tree-ssa-threadedge.c (thread_across_edge): Check EDGE_COMPLEX + not EDGE_ABNORMAL. + 2020-01-24 Jakub Jelinek PR target/93395 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1fc95b334a8..a8d517ad8a3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-01-24 Jeff Law PR target/93395 diff --git a/gcc/testsuite/g++.dg/pr92788.C b/gcc/testsuite/g++.dg/pr92788.C new file mode 100644 index 00000000000..b92ae38f7aa --- /dev/null +++ b/gcc/testsuite/g++.dg/pr92788.C @@ -0,0 +1,470 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-require-effective-target c++11 } */ +/* { dg-options "-O3 -fnon-call-exceptions -ftracer -march=k8 -Wno-return-type" } */ + + +template struct integral_constant { + + static constexpr int value = __v; + +}; + +template using __bool_constant = integral_constant<__v>; + +template + +struct is_same : integral_constant {}; + +template using __enable_if_t = _Tp; + +void *operator new(unsigned long, void *__p) { return __p; } + +template class __normal_iterator { + + _Iterator _M_current; + + + +public: + + __normal_iterator(_Iterator) {} + + void operator++() { ++_M_current; } + + _Iterator base() { return _M_current; } + +}; + +template + +bool operator!=(__normal_iterator<_IteratorL, _Container> __lhs, + + __normal_iterator<_IteratorR, _Container> __rhs) { + + return __lhs.base() != __rhs.base(); + +} + +template void construct_at(_Tp *__location) noexcept { + + new (__location) _Tp; + +} + +template void _Construct(_Tp __p) { construct_at(__p); } + +struct _Any_data { + + template _Tp _M_access(); + +}; + +enum _Manager_operation {}; + +template class function; + +class _Function_base { + +public: + + template class _Base_manager { + +public: + + static bool _M_manager(_Any_data, _Any_data __source, _Manager_operation) { + + _Functor(*__source._M_access<_Functor *>()); + + return true; + + } + + }; + + typedef bool (*_Manager_type)(_Any_data &, const _Any_data &, + + _Manager_operation); + + _Manager_type _M_manager; + +}; + +template class _Function_handler; + +template + +class _Function_handler<_Res(_ArgTypes...), _Functor> : _Function_base { + +public: + + static bool _M_manager(_Any_data &__dest, const _Any_data &__source, + + _Manager_operation __op) { + + _Base_manager<_Functor>::_M_manager(__dest, __source, __op); + + } + +}; + +template + +class function<_Res(_ArgTypes...)> : _Function_base { + + template using _Requires = _Tp; + + + +public: + + template , void>, + + typename = _Requires<_Functor, void>> + + function(_Functor); + +}; + +template + +template + +function<_Res(_ArgTypes...)>::function(_Functor) { + + _M_manager = _Function_handler<_Res(), _Functor>::_M_manager; + +} + +template class new_allocator { + +public: + + _Tp *allocate(long) { return static_cast<_Tp *>(operator new(sizeof(_Tp))); } + +}; + +namespace std { + + template struct allocator_traits; + + template struct allocator_traits> { + + using allocator_type = new_allocator<_Tp>; + + using pointer = _Tp *; + + using const_pointer = _Tp *; + + using size_type = long; + + template using rebind_alloc = new_allocator<_Up>; + + static pointer allocate(allocator_type __a, size_type __n) { + + return __a.allocate(__n); + + } + + static void deallocate(allocator_type, pointer, size_type); + + }; + +} + +template + +struct __alloc_traits : std::allocator_traits<_Alloc> { + + template struct rebind { + + typedef typename std::allocator_traits<_Alloc>::template rebind_alloc<_Tp> other; + + }; + +}; + +namespace std { + + struct __uninitialized_copy { + + template + + static _ForwardIterator __uninit_copy(_InputIterator __first, + + _InputIterator __last, + + _ForwardIterator __result) { + + for (; __first != __last; ++__first, ++__result) + + _Construct(__result); + + return __result; + + } + + }; + + template + + _ForwardIterator uninitialized_copy(_InputIterator __first, + + _InputIterator __last, + + _ForwardIterator __result) { + + return __uninitialized_copy::__uninit_copy(__first, __last, __result); + + } + + template + + _ForwardIterator __uninitialized_copy_a(_InputIterator __first, + + _InputIterator __last, + + _ForwardIterator __result, _Tp) { + + return uninitialized_copy(__first, __last, __result); + + } + + template struct _Vector_base { + + typedef typename __alloc_traits<_Alloc>::template rebind<_Tp>::other _Tp_alloc_type; + + typedef typename __alloc_traits<_Tp_alloc_type>::pointer pointer; + + struct _Vector_impl_data { + + pointer _M_start; + + pointer _M_finish; + + }; + + struct _Vector_impl : _Tp_alloc_type, _Vector_impl_data {}; + + _Tp_alloc_type _M_get_Tp_allocator(); + + _Vector_base(long, _Alloc) { + + _M_impl._M_start = _M_allocate(); + + _M_impl._M_finish = _M_impl._M_start; + + } + + ~_Vector_base() { _M_deallocate(_M_impl._M_start); } + + _Vector_impl _M_impl; + + long _M_allocate___n; + + pointer _M_allocate() { + + typedef __alloc_traits<_Tp_alloc_type> _Tr; + + return _M_allocate___n ? _Tr::allocate(_M_impl, _M_allocate___n) + + : pointer(); + + } + + long _M_deallocate___n; + + void _M_deallocate(pointer __p) { + + typedef __alloc_traits<_Tp_alloc_type> _Tr; + + if (__p) + + _Tr::deallocate(_M_impl, __p, _M_deallocate___n); + + } + + }; + + template > + + class vector : _Vector_base<_Tp, _Alloc> { + + typedef _Vector_base<_Tp, _Alloc> _Base; + + typedef __normal_iterator< + + typename __alloc_traits::const_pointer, + + int> + + const_iterator; + + using _Base::_M_get_Tp_allocator; + + + +public: + + vector(); + + vector(vector &__x) : _Base(0, _M_get_Tp_allocator()) { + + this->_M_impl._M_finish = __uninitialized_copy_a(__x.begin(), __x.end(), + + this->_M_impl._M_start, 0); + + } + + const_iterator begin() noexcept { return this->_M_impl._M_start; } + + const_iterator end() noexcept { return this->_M_impl._M_finish; } + + }; + + template class __shared_ptr_access { + +public: + + using element_type = _Tp; + + element_type *operator->(); + + }; + + enum syntax_option_type : int; + + template using _Matcher = function; + + struct _NFA { + + void _M_insert_matcher(_Matcher); + + }; + + template class _Compiler { + +public: + + typedef typename _TraitsT::char_type *_IterT; + + _Compiler(_IterT, _IterT, const typename _TraitsT::locale_type &, syntax_option_type); + + template void _M_insert_character_class_matcher(); + + syntax_option_type _M_flags; + + __shared_ptr_access<_NFA> _M_nfa; + + _TraitsT _M_traits; + + }; + + template + + using __enable_if_contiguous_iter = + + __enable_if_t::value, + + __shared_ptr_access<_NFA>>; + + syntax_option_type __compile_nfa___flags; + + struct Trans_NS___cxx11_regex_traits { + + typedef char char_type; + + typedef int locale_type; + + struct _RegexMask { + + short _M_base; + + char _M_extended; + + _RegexMask() : _M_extended() {} + + } typedef char_class_type; + + }; + + template + + __enable_if_contiguous_iter<_FwdIter, char> __compile_nfa(_FwdIter) { + + auto __cfirst = nullptr; + + using _Cmplr = _Compiler; + + _Cmplr(__cfirst, __cfirst, 0, __compile_nfa___flags); + + } + + class _RegexTranslatorBase { + +public: + + _RegexTranslatorBase(Trans_NS___cxx11_regex_traits); + + }; + + class _RegexTranslator : _RegexTranslatorBase { + + typedef _RegexTranslatorBase _Base; + + using _Base::_Base; + + }; + + template struct _BracketMatcher { + + _BracketMatcher(bool, _TraitsT __traits) : _M_translator(__traits) {} + + vector _M_neg_class_set; + + _RegexTranslator _M_translator; + + }; + + template + + _Compiler<_TraitsT>::_Compiler(_IterT __b, _IterT __e, + + const typename _TraitsT::locale_type &__loc, + + syntax_option_type) { + + _M_insert_character_class_matcher(); + + _M_insert_character_class_matcher(); + + } + + template + + template + + void _Compiler<_TraitsT>::_M_insert_character_class_matcher() { + + _BracketMatcher<_TraitsT, __collate> __matcher(0, _M_traits); + + _M_nfa->_M_insert_matcher(__matcher); + + } + + class Trans_NS___cxx11_basic_regex { + +public: + + char Trans_NS___cxx11_basic_regex___last; + + Trans_NS___cxx11_basic_regex() + + : _M_automaton(__compile_nfa(Trans_NS___cxx11_basic_regex___last)) {} /* { dg-error } */ + + __shared_ptr_access<_NFA> _M_automaton; + + } regex_sanity_check___f; + +} diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c index 35440b020cc..c7c08213f9a 100644 --- a/gcc/tree-ssa-threadedge.c +++ b/gcc/tree-ssa-threadedge.c @@ -1323,7 +1323,7 @@ thread_across_edge (gcond *dummy_cond, /* If E->dest has abnormal outgoing edges, then there's no guarantee we can safely redirect any of the edges. Just punt those cases. */ FOR_EACH_EDGE (taken_edge, ei, e->dest->succs) - if (taken_edge->flags & EDGE_ABNORMAL) + if (taken_edge->flags & EDGE_COMPLEX) { const_and_copies->pop_to_marker (); avail_exprs_stack->pop_to_marker ();