From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2140) id C87AA3856252; Fri, 6 May 2022 07:19:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C87AA3856252 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: 02acdab6fd66c7e76fb3c1923309032ff4ecd42c X-Git-Newrev: 7eeca96058d2affd9c959fd55ab01ff803f9b880 Message-Id: <20220506071914.C87AA3856252@sourceware.org> Date: Fri, 6 May 2022 07:19:14 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 May 2022 07:19:14 -0000 https://gcc.gnu.org/g:7eeca96058d2affd9c959fd55ab01ff803f9b880 commit 7eeca96058d2affd9c959fd55ab01ff803f9b880 Author: Alexandre Oliva Date: Mon Jan 31 16:00:46 2022 -0300 enable control flow redundancy hardening unconditionally Diff: --- gcc/common.opt | 2 +- gcc/gimple-harden-control-flow.cc | 6 ++++++ gcc/params.opt | 2 +- libgcc/Makefile.in | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/gcc/common.opt b/gcc/common.opt index cb0ce11eee1..a353165ba15 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -1771,7 +1771,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. ; Nonzero means ignore `#ident' directives. 0 means handle them. diff --git a/gcc/gimple-harden-control-flow.cc b/gcc/gimple-harden-control-flow.cc index f3538c895fb..72258f65360 100644 --- a/gcc/gimple-harden-control-flow.cc +++ b/gcc/gimple-harden-control-flow.cc @@ -97,6 +97,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", @@ -110,6 +112,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", @@ -120,6 +124,8 @@ public: if (param_hardcfr_max_blocks > 0 && n_basic_blocks_for_fn (fun) - 2 > 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 b5dd3a92d06..b8cd9f7a4ed 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -202,7 +202,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/Makefile.in b/libgcc/Makefile.in index ff76d29f25b..ce90960de04 100644 --- a/libgcc/Makefile.in +++ b/libgcc/Makefile.in @@ -429,6 +429,8 @@ iterator = $(patsubst %,$(srcdir)/static-object.mk,$(iter-items)) endif LIB2ADD += enable-execute-stack.c + +# Control Flow Redundancy hardening out-of-line checker. LIB2ADD += $(srcdir)/hardcfr.c # While emutls.c has nothing to do with EH, it is in LIB2ADDEH*