From c71d553d3e5f6753011338dffe5ba0965e8c739a Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Wed, 13 Apr 2016 15:17:14 -0400 Subject: [PATCH 83/91] FIXME: add -fsingle-pass= option --- gcc/rtl/lang.opt | 4 +++ gcc/rtl/rtl-frontend.c | 43 +++++++++++++++++++++--------- gcc/testsuite/rtl.dg/test-loop.cleaned.rtl | 5 ++++ 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/gcc/rtl/lang.opt b/gcc/rtl/lang.opt index 27f9683..54d5aff 100644 --- a/gcc/rtl/lang.opt +++ b/gcc/rtl/lang.opt @@ -29,4 +29,8 @@ froundtrip= RTL Joined RejectNegative FIXME +fsingle-pass= +RTL Joined RejectNegative +FIXME + ; This comment is to ensure we retain the blank line above. diff --git a/gcc/rtl/rtl-frontend.c b/gcc/rtl/rtl-frontend.c index fc6b11e..1400fa3 100644 --- a/gcc/rtl/rtl-frontend.c +++ b/gcc/rtl/rtl-frontend.c @@ -158,6 +158,7 @@ rtl_langhook_init_options_struct (struct gcc_options */*opts*/) } static const char *roundtrip_filename = NULL; +static const char *single_pass_name = NULL; static bool rtl_langhook_handle_option ( @@ -176,6 +177,10 @@ rtl_langhook_handle_option ( roundtrip_filename = xstrdup (arg); break; + case OPT_fsingle_pass_: + single_pass_name = xstrdup (arg); + break; + default: break; } @@ -692,6 +697,27 @@ function_reader::get_insn_by_uid (int uid) return m_insns_by_uid.get (uid); } +/* Locate and run PASS_NAME on cfun. */ + +static void +run_one_pass_by_name (const char *pass_name) +{ + opt_pass *pass = g->get_passes ()->get_pass_by_name (pass_name); + if (!pass) + { + error ("unrecognized pass: %qs", pass_name); + return; + } + + pass_init_dump_file (pass); + current_function_decl = cfun->decl; + pass->execute (cfun); + current_function_decl = NULL; + if (dump_file) + print_rtl_with_bb (dump_file, get_insns (), dump_flags); + pass_fini_dump_file (pass); +} + static void rtl_langhook_parse_file (void) { @@ -723,19 +749,10 @@ rtl_langhook_parse_file (void) error ("unable to open %qs for -froundtrip" , roundtrip_filename); } - /* - Run just one pass e.g. pass_instantiate_virtual_regs - (first after pass_expand). "vregs" - */ - opt_pass *pass = g->get_passes ()->get_pass_by_name ("rtl-vregs"); - gcc_assert (pass); - current_function_decl = cfun->decl; - pass->execute (cfun); - current_function_decl = NULL; - - FILE *out = fopen ("/tmp/after-pass.rtl", "w"); - print_rtl_with_bb (out, reader.get_first_insn (), 1024); - fclose (out); +/* If -fsingle-pass=PASS_NAME was provided, locate and run PASS_NAME + on cfun, as created above. */ + if (single_pass_name) + run_one_pass_by_name (single_pass_name); } static tree diff --git a/gcc/testsuite/rtl.dg/test-loop.cleaned.rtl b/gcc/testsuite/rtl.dg/test-loop.cleaned.rtl index 2ea3fdc..221c5b4 100644 --- a/gcc/testsuite/rtl.dg/test-loop.cleaned.rtl +++ b/gcc/testsuite/rtl.dg/test-loop.cleaned.rtl @@ -1,3 +1,4 @@ +/* { dg-options "-fsingle-pass=rtl-vregs -fdump-rtl-vregs" } */ (note 1 0 6 (nil) NOTE_INSN_DELETED) (note 6 1 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK) (insn 2 6 3 2 (set (mem/c:SI (plus:DI (reg/f:DI 82 virtual-stack-vars) @@ -73,3 +74,7 @@ (nil)) (insn 27 26 0 6 (use (reg/i:SI 0 ax)) ../../src/test-loop.c:7 -1 (nil)) + +/* The 9 instances of "virtual-stack-vars" should now all be "frame". */ +/* { dg-final { scan-rtl-dump-times "frame" 9 "vregs" } } */ +/* { dog-final { scan-rtl-dump-not "virtual-stack-vars" "vregs" } } */ -- 1.8.5.3