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.133.124]) by sourceware.org (Postfix) with ESMTPS id 052EC3835778 for ; Wed, 22 Jun 2022 08:06:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 052EC3835778 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-142-OEajyxn6PRu8zE5SdyF-lg-1; Wed, 22 Jun 2022 04:06:02 -0400 X-MC-Unique: OEajyxn6PRu8zE5SdyF-lg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CE78F398CA6A; Wed, 22 Jun 2022 08:06:01 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8A6F79D7F; Wed, 22 Jun 2022 08:06:01 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 25M85x3t698873 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 22 Jun 2022 10:05:59 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 25M85w5l698872; Wed, 22 Jun 2022 10:05:58 +0200 Date: Wed, 22 Jun 2022 10:05:58 +0200 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org, richard.guenther@gmail.com, jwakely.gcc@gmail.com Subject: Re: [PATCH RFA] ubsan: default to trap on unreachable at -O0 and -Og [PR104642] Message-ID: Reply-To: Jakub Jelinek References: <20220613195313.3240547-1-jason@redhat.com> <6c78210d-f2a8-3371-5d88-74bdab399706@redhat.com> <98e07b35-6472-aec1-abbb-a4cf49d66a9c@redhat.com> <32f7c45f-c70a-1b60-391a-9f642a4a0f4c@redhat.com> MIME-Version: 1.0 In-Reply-To: <32f7c45f-c70a-1b60-391a-9f642a4a0f4c@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jun 2022 08:06:05 -0000 On Tue, Jun 21, 2022 at 11:59:56PM -0400, Jason Merrill wrote: > PR c++/104642 > > gcc/ChangeLog: > > * common.opt: Add -funreachable-traps. > * doc/invoke.texi (-funreachable-traps): Document it. > * opts.cc (finish_options): Enable at -O0 or -Og. > * tree.cc (build_common_builtin_nodes): Add __builtin_trap. > (builtin_decl_unreachable, build_builtin_unreachable): New. > * tree.h: Declare them. > * ubsan.cc (sanitize_unreachable_fn): Factor out. > (ubsan_instrument_unreachable): Use > gimple_build_builtin_unreachable. > * ubsan.h (sanitize_unreachable_fn): Declare. > * gimple.cc (gimple_build_builtin_unreachable): New. > * gimple.h: Declare it. > * builtins.cc (expand_builtin_unreachable): Add assert. > (fold_builtin_0): Call build_builtin_unreachable. > * sanopt.cc: Don't run for just SANITIZE_RETURN > or SANITIZE_UNREACHABLE when trapping. > * cgraphunit.cc (walk_polymorphic_call_targets): Use new > unreachable functions. > * gimple-fold.cc (gimple_fold_call) > (gimple_get_virt_method_for_vtable) > * ipa-fnsummary.cc (redirect_to_unreachable) > * ipa-prop.cc (ipa_make_edge_direct_to_target) > (ipa_impossible_devirt_target) > * ipa.cc (walk_polymorphic_call_targets) > * tree-cfg.cc (pass_warn_function_return::execute) > (execute_fixup_cfg) > * tree-ssa-loop-ivcanon.cc (remove_exits_and_undefined_stmts) > (unloop_loops) > * tree-ssa-sccvn.cc (eliminate_dom_walker::eliminate_stmt): > Likewise. > > gcc/cp/ChangeLog: > > * constexpr.cc (cxx_eval_builtin_function_call): Handle > unreachable/trap earlier. > * cp-gimplify.cc (cp_maybe_instrument_return): Use > build_builtin_unreachable. > > gcc/testsuite/ChangeLog: > > * g++.dg/ubsan/return-8a.C: New test. > * g++.dg/ubsan/return-8b.C: New test. > * g++.dg/ubsan/return-8d.C: New test. > * g++.dg/ubsan/return-8e.C: New test. LGTM, thanks. Jakub