From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2140) id 506663858C41; Fri, 9 Jun 2023 11:32:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 506663858C41 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686310324; bh=XUMHS9PVP78N1pNis+GEzKb11HrPdXWFrhgfdXs1ymE=; h=From:To:Subject:Date:From; b=ZSl57RvSBos5zd7zrajVIWfJk9ZVt2+u2GzwsI3fJLkTB176YnWJhUFQYYIv/VD/y BU3aNlT1HnQ4AXMpTlc8a3yqEOPG8euJiLqDrA1f1oXSkC60I4A8f2lNe2jyAzRz3r 47N/o8HUvN9sDUw2Zo0Era4YWlyFP/gNoLD/8Lio= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Alexandre Oliva To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/aoliva/heads/testme)] enable control flow redundancy hardening unconditionally X-Act-Checkin: gcc X-Git-Author: Alexandre Oliva X-Git-Refname: refs/users/aoliva/heads/testme X-Git-Oldrev: 37d63f69507b9c6384ca74b465f17410b6c85fd0 X-Git-Newrev: 0591d0c06995602bc4f160cfd2dfb0a53c4cda54 Message-Id: <20230609113204.506663858C41@sourceware.org> Date: Fri, 9 Jun 2023 11:32:04 +0000 (GMT) List-Id: https://gcc.gnu.org/g:0591d0c06995602bc4f160cfd2dfb0a53c4cda54 commit 0591d0c06995602bc4f160cfd2dfb0a53c4cda54 Author: Alexandre Oliva Date: Thu Jun 8 01:35:37 2023 -0300 enable control flow redundancy hardening unconditionally Diff: --- gcc/common.opt | 2 +- gcc/gimple-harden-control-flow.cc | 6 ++++++ gcc/params.opt | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gcc/common.opt b/gcc/common.opt index 846f7043897..b23ffbbac43 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -1802,7 +1802,7 @@ Common Var(flag_harden_conditional_branches) Optimization Harden conditional branches by checking reversed conditions. fharden-control-flow-redundancy -Common Var(flag_harden_control_flow_redundancy) Optimization +Common Var(flag_harden_control_flow_redundancy) Init(-1) Optimization Harden control flow by recording and checking execution paths. fhardcfr-skip-leaf diff --git a/gcc/gimple-harden-control-flow.cc b/gcc/gimple-harden-control-flow.cc index 044671cab79..faafaf7c8a0 100644 --- a/gcc/gimple-harden-control-flow.cc +++ b/gcc/gimple-harden-control-flow.cc @@ -91,6 +91,8 @@ public: call and restore it if it returns again. */ if (fun->calls_setjmp) { + if (flag_harden_control_flow_redundancy < 0) + return false; warning_at (DECL_SOURCE_LOCATION (fun->decl), 0, "%qD calls % or similar," " %<-fharden-control-flow-redundancy%> is not supported", @@ -104,6 +106,8 @@ public: enough to make it worthwhile. */ if (fun->has_nonlocal_label) { + if (flag_harden_control_flow_redundancy < 0) + return false; warning_at (DECL_SOURCE_LOCATION (fun->decl), 0, "%qD receives nonlocal gotos," " %<-fharden-control-flow-redundancy%> is not supported", @@ -115,6 +119,8 @@ public: && (n_basic_blocks_for_fn (fun) - NUM_FIXED_BLOCKS > param_hardcfr_max_blocks)) { + if (flag_harden_control_flow_redundancy < 0) + return false; warning_at (DECL_SOURCE_LOCATION (fun->decl), 0, "%qD has more than %u blocks, the requested" " maximum for %<-fharden-control-flow-redundancy%>", diff --git a/gcc/params.opt b/gcc/params.opt index 799ea41cedf..a2b6cefa0cc 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -183,7 +183,7 @@ Common Joined UInteger Var(param_graphite_max_nb_scop_params) Init(10) Param Opt Maximum number of parameters in a SCoP. -param=hardcfr-max-blocks= -Common Joined UInteger Var(param_hardcfr_max_blocks) Init(0) Param Optimization +Common Joined UInteger Var(param_hardcfr_max_blocks) Init(32) Param Optimization Maximum number of blocks for -fharden-control-flow-redundancy. -param=hardcfr-max-inline-blocks=