From patchwork Wed Oct 8 19:27:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 397704 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 14FA11400A3 for ; Thu, 9 Oct 2014 06:27:52 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=GJ1RSVqh0PN3ro2duqToovV78wr/6iRH983TcFjGaP9gvBu7/w pAX+PYefViCoXK4fOBDl8jTYwazGBQmJKR3PfER4goA6lKNb0ZOKzRFvTN4C+yfO y2MmBQ/JKHrAsyQMZeazAJ6QXCyl0DLtbiYwTe0zYb8D4sCvcEVI2CCs8= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=dA8IBTSwL6IP7DJ0oo9XaCjuHQ4=; b=mQTxDh7WhIKc9kndkOL2 8CZbFJnGxYipHJBIZmLQKiL2mTFO4dHXn9ZeWIMmdK9o1utqb1oKttWaJGfi2cIn FzBIvotXiCxv5V9t6Bxd7EgIeNSqEk8d4nehi8Pu29e2T9yLH6hAxebZrQtH/O9R 71IH6YYJ2pvOaWn/o0Pe0yc= Received: (qmail 26046 invoked by alias); 8 Oct 2014 19:27:44 -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 26034 invoked by uid 89); 8 Oct 2014 19:27:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f51.google.com Received: from mail-pa0-f51.google.com (HELO mail-pa0-f51.google.com) (209.85.220.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 08 Oct 2014 19:27:41 +0000 Received: by mail-pa0-f51.google.com with SMTP id lj1so9658613pab.10 for ; Wed, 08 Oct 2014 12:27:39 -0700 (PDT) X-Received: by 10.66.139.234 with SMTP id rb10mr13575352pab.104.1412796459617; Wed, 08 Oct 2014 12:27:39 -0700 (PDT) Received: from msticlxl57.ims.intel.com (fmdmzpr03-ext.fm.intel.com. [192.55.54.38]) by mx.google.com with ESMTPSA id oo8sm668906pdb.86.2014.10.08.12.27.37 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Oct 2014 12:27:39 -0700 (PDT) Date: Wed, 8 Oct 2014 23:27:33 +0400 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Cc: Jeff Law Subject: [PATCH, Pointer Bounds Checker 14/x] Passes [17/n] Add checker passes into passes list Message-ID: <20141008192733.GQ13454@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Hi, This patch adds instrumentation passes into passes list. Thanks, Ilya --- gcc/ 2014-10-08 Ilya Enkovich * passes.def (pass_ipa_chkp_versioning): New. (pass_early_local_passes): Renamed to pass_build_ssa_passes. (pass_fixup_cfg): Moved to pass_chkp_instrumentation_passes. (pass_chkp_instrumentation_passes): New. (pass_ipa_chkp_produce_thunks): New. (pass_local_optimization_passes): New. (pass_chkp_opt): New. * toplev.c: include tree-chkp.h. (compile_file): Add chkp_finish_file call. * tree-pass.h (make_pass_ipa_chkp_versioning): New. (make_pass_ipa_chkp_produce_thunks): New. (make_pass_chkp): New. (make_pass_chkp_opt): New. (make_pass_early_local_passes): Renamed to ... (make_pass_build_ssa_passes): This. (make_pass_chkp_instrumentation_passes): New. (make_pass_local_optimization_passes): New. * passes.c (pass_manager::execute_early_local_passes): Execute early passes in three steps. (execute_all_early_local_passes): Renamed to ... (execute_build_ssa_passes): This. (pass_data_early_local_passes): Renamed to ... (pass_data_build_ssa_passes): This. (pass_early_local_passes): Renamed to ... (pass_build_ssa_passes): This. (pass_data_chkp_instrumentation_passes): New. (pass_chkp_instrumentation_passes): New. (pass_data_local_optimization_passes): New. (pass_local_optimization_passes): New. (make_pass_early_local_passes): Renamed to ... (make_pass_build_ssa_passes): This. (make_pass_chkp_instrumentation_passes): New. (make_pass_local_optimization_passes): New. gcc/testsuite 2014-10-08 Ilya Enkovich * gcc.dg/pr37858.c: Replace early_local_cleanups pass name with build_ssa_passes. diff --git a/gcc/passes.c b/gcc/passes.c index 5001c3d..a6c3718 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -133,7 +133,9 @@ opt_pass::opt_pass (const pass_data &data, context *ctxt) void pass_manager::execute_early_local_passes () { - execute_pass_list (cfun, pass_early_local_passes_1->sub); + execute_pass_list (cfun, pass_build_ssa_passes_1->sub); + execute_pass_list (cfun, pass_chkp_instrumentation_passes_1->sub); + execute_pass_list (cfun, pass_local_optimization_passes_1->sub); } unsigned int @@ -325,7 +327,7 @@ finish_optimization_passes (void) } static unsigned int -execute_all_early_local_passes (void) +execute_build_ssa_passes (void) { /* Once this pass (and its sub-passes) are complete, all functions will be in SSA form. Technically this state change is happening @@ -340,10 +342,10 @@ execute_all_early_local_passes (void) namespace { -const pass_data pass_data_early_local_passes = +const pass_data pass_data_build_ssa_passes = { SIMPLE_IPA_PASS, /* type */ - "early_local_cleanups", /* name */ + "build_ssa_passes", /* name */ OPTGROUP_NONE, /* optinfo_flags */ TV_EARLY_LOCAL, /* tv_id */ 0, /* properties_required */ @@ -355,11 +357,11 @@ const pass_data pass_data_early_local_passes = 0, /* todo_flags_finish */ }; -class pass_early_local_passes : public simple_ipa_opt_pass +class pass_build_ssa_passes : public simple_ipa_opt_pass { public: - pass_early_local_passes (gcc::context *ctxt) - : simple_ipa_opt_pass (pass_data_early_local_passes, ctxt) + pass_build_ssa_passes (gcc::context *ctxt) + : simple_ipa_opt_pass (pass_data_build_ssa_passes, ctxt) {} /* opt_pass methods: */ @@ -371,17 +373,87 @@ public: virtual unsigned int execute (function *) { - return execute_all_early_local_passes (); + return execute_build_ssa_passes (); } -}; // class pass_early_local_passes +}; // class pass_build_ssa_passes + +const pass_data pass_data_chkp_instrumentation_passes = +{ + SIMPLE_IPA_PASS, /* type */ + "chkp_passes", /* name */ + OPTGROUP_NONE, /* optinfo_flags */ + TV_NONE, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ +}; + +class pass_chkp_instrumentation_passes : public simple_ipa_opt_pass +{ +public: + pass_chkp_instrumentation_passes (gcc::context *ctxt) + : simple_ipa_opt_pass (pass_data_chkp_instrumentation_passes, ctxt) + {} + + /* opt_pass methods: */ + virtual bool gate (function *) + { + /* Don't bother doing anything if the program has errors. */ + return (!seen_error () && !in_lto_p); + } + +}; // class pass_chkp_instrumentation_passes + +const pass_data pass_data_local_optimization_passes = +{ + SIMPLE_IPA_PASS, /* type */ + "opt_local_passes", /* name */ + OPTGROUP_NONE, /* optinfo_flags */ + TV_NONE, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ +}; + +class pass_local_optimization_passes : public simple_ipa_opt_pass +{ +public: + pass_local_optimization_passes (gcc::context *ctxt) + : simple_ipa_opt_pass (pass_data_local_optimization_passes, ctxt) + {} + + /* opt_pass methods: */ + virtual bool gate (function *) + { + /* Don't bother doing anything if the program has errors. */ + return (!seen_error () && !in_lto_p); + } + +}; // class pass_local_optimization_passes } // anon namespace simple_ipa_opt_pass * -make_pass_early_local_passes (gcc::context *ctxt) +make_pass_build_ssa_passes (gcc::context *ctxt) +{ + return new pass_build_ssa_passes (ctxt); +} + +simple_ipa_opt_pass * +make_pass_chkp_instrumentation_passes (gcc::context *ctxt) +{ + return new pass_chkp_instrumentation_passes (ctxt); +} + +simple_ipa_opt_pass * +make_pass_local_optimization_passes (gcc::context *ctxt) { - return new pass_early_local_passes (ctxt); + return new pass_local_optimization_passes (ctxt); } namespace { diff --git a/gcc/passes.def b/gcc/passes.def index 334c670..8b31f36 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -49,14 +49,27 @@ along with GCC; see the file COPYING3. If not see INSERT_PASSES_AFTER (all_small_ipa_passes) NEXT_PASS (pass_ipa_free_lang_data); NEXT_PASS (pass_ipa_function_and_variable_visibility); - NEXT_PASS (pass_early_local_passes); - PUSH_INSERT_PASSES_WITHIN (pass_early_local_passes) + NEXT_PASS (pass_ipa_chkp_versioning); + NEXT_PASS (pass_build_ssa_passes); + PUSH_INSERT_PASSES_WITHIN (pass_build_ssa_passes) NEXT_PASS (pass_fixup_cfg); NEXT_PASS (pass_init_datastructures); - NEXT_PASS (pass_build_ssa); NEXT_PASS (pass_ubsan); NEXT_PASS (pass_early_warn_uninitialized); + POP_INSERT_PASSES () + + NEXT_PASS (pass_chkp_instrumentation_passes); + PUSH_INSERT_PASSES_WITHIN (pass_chkp_instrumentation_passes) + NEXT_PASS (pass_fixup_cfg); + NEXT_PASS (pass_chkp); + NEXT_PASS (pass_rebuild_cgraph_edges); + POP_INSERT_PASSES () + NEXT_PASS (pass_ipa_chkp_produce_thunks); + + NEXT_PASS (pass_local_optimization_passes); + PUSH_INSERT_PASSES_WITHIN (pass_local_optimization_passes) + NEXT_PASS (pass_fixup_cfg); NEXT_PASS (pass_rebuild_cgraph_edges); NEXT_PASS (pass_inline_parameters); NEXT_PASS (pass_early_inline); @@ -78,13 +91,13 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_early_ipa_sra); NEXT_PASS (pass_tail_recursion); NEXT_PASS (pass_convert_switch); - NEXT_PASS (pass_cleanup_eh); - NEXT_PASS (pass_profile); - NEXT_PASS (pass_local_pure_const); + NEXT_PASS (pass_cleanup_eh); + NEXT_PASS (pass_profile); + NEXT_PASS (pass_local_pure_const); /* Split functions creates parts that are not run through early optimizations again. It is thus good idea to do this - late. */ - NEXT_PASS (pass_split_functions); + late. */ + NEXT_PASS (pass_split_functions); POP_INSERT_PASSES () NEXT_PASS (pass_release_ssa_names); NEXT_PASS (pass_rebuild_cgraph_edges); @@ -152,6 +165,7 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_fre); NEXT_PASS (pass_merge_phi); NEXT_PASS (pass_vrp); + NEXT_PASS (pass_chkp_opt); NEXT_PASS (pass_dce); NEXT_PASS (pass_call_cdce); NEXT_PASS (pass_cselim); diff --git a/gcc/testsuite/gcc.dg/pr37858.c b/gcc/testsuite/gcc.dg/pr37858.c index f606d4a..577b661 100644 --- a/gcc/testsuite/gcc.dg/pr37858.c +++ b/gcc/testsuite/gcc.dg/pr37858.c @@ -1,7 +1,7 @@ /* PR middle-end/37858 */ /* ??? With -dv removed, this test is a bit silly. */ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-ipa-early_local_cleanups" } */ +/* { dg-options "-O2 -fdump-ipa-build_ssa_passes" } */ int main (void) @@ -9,4 +9,4 @@ main (void) return 0; } -/* { dg-final { cleanup-ipa-dump "early_local_cleanups" } } */ +/* { dg-final { cleanup-ipa-dump "build_ssa_passes" } } */ diff --git a/gcc/toplev.c b/gcc/toplev.c index 932ac66..a1d8eeb 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -80,6 +80,7 @@ along with GCC; see the file COPYING3. If not see #include "context.h" #include "pass_manager.h" #include "optabs.h" +#include "tree-chkp.h" #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) #include "dbxout.h" @@ -580,6 +581,9 @@ compile_file (void) if (flag_sanitize & SANITIZE_THREAD) tsan_finish_file (); + if (flag_check_pointer_bounds) + chkp_finish_file (); + output_shared_constant_pool (); output_object_blocks (); finish_tm_clone_pairs (); diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index ed109c3..0378efd 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -332,6 +332,10 @@ extern void register_pass (register_pass_info *); extern void register_pass (opt_pass* pass, pass_positioning_ops pos, const char* ref_pass_name, int ref_pass_inst_number); +extern simple_ipa_opt_pass *make_pass_ipa_chkp_versioning (gcc::context *ctxt); +extern simple_ipa_opt_pass *make_pass_ipa_chkp_produce_thunks (gcc::context *ctxt); +extern gimple_opt_pass *make_pass_chkp (gcc::context *ctxt); +extern gimple_opt_pass *make_pass_chkp_opt (gcc::context *ctxt); extern gimple_opt_pass *make_pass_asan (gcc::context *ctxt); extern gimple_opt_pass *make_pass_asan_O0 (gcc::context *ctxt); extern gimple_opt_pass *make_pass_tsan (gcc::context *ctxt); @@ -450,7 +454,9 @@ extern simple_ipa_opt_pass *make_pass_ipa_function_and_variable_visibility (gcc::context *ctxt); extern simple_ipa_opt_pass *make_pass_ipa_tree_profile (gcc::context *ctxt); -extern simple_ipa_opt_pass *make_pass_early_local_passes (gcc::context *ctxt); +extern simple_ipa_opt_pass *make_pass_build_ssa_passes (gcc::context *ctxt); +extern simple_ipa_opt_pass *make_pass_chkp_instrumentation_passes (gcc::context *ctxt); +extern simple_ipa_opt_pass *make_pass_local_optimization_passes (gcc::context *ctxt); extern ipa_opt_pass_d *make_pass_ipa_whole_program_visibility (gcc::context *ctxt);