From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2140) id 24854385C6E7; Tue, 10 Oct 2023 04:14:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 24854385C6E7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696911273; bh=eV3W5zkWlukKSUPCsCkn9+qW2MXum2OA8MFGI2XU/PI=; h=From:To:Subject:Date:From; b=FKYScE0NVQBTtjY7PRmyZMb4IDtYVl2WeAm3uuRWNW4nW3Y7lSMcuILRYzcXScXLr 2QzbiuLv7/qTWj4CvUD4sNYzNuvprrce+zHSPbiZ6BqdLXuwCBCfKF3rigsl9AyQ4q u1UJWpibze7669ZVLom2mT2/cYdPhaQknp6ktZR8= 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: c16b8011e0035cee5024749ccf326456f0ab464f X-Git-Newrev: 3a10b677396864b6227ac77cb2f3720c9637ef4d Message-Id: <20231010041433.24854385C6E7@sourceware.org> Date: Tue, 10 Oct 2023 04:14:33 +0000 (GMT) List-Id: https://gcc.gnu.org/g:3a10b677396864b6227ac77cb2f3720c9637ef4d commit 3a10b677396864b6227ac77cb2f3720c9637ef4d Author: Alexandre Oliva Date: Mon Jul 3 18:09:38 2023 -0300 enable control flow redundancy hardening unconditionally Diff: --- gcc/common.opt | 2 +- gcc/gimple-harden-control-flow.cc | 6 ++++++ gcc/params.opt | 2 +- libgcc/hardcfr.c | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/gcc/common.opt b/gcc/common.opt index 5d318b4290c..90a8cc6cab6 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -1828,7 +1828,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 5c28fd07f33..60f4976d5f8 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 f1202abc00d..45cf6f885d0 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -175,7 +175,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= diff --git a/libgcc/hardcfr.c b/libgcc/hardcfr.c index 7496095b866..549eaa9b4a5 100644 --- a/libgcc/hardcfr.c +++ b/libgcc/hardcfr.c @@ -29,6 +29,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include #include +#define HARDCFR_VERBOSE_FAIL 1 + /* This should be kept in sync with gcc/gimple-harden-control-flow.cc. */ #if __CHAR_BIT__ >= 28 # define VWORDmode __QI__