Message ID | 9158b0e8-f6b7-8a71-4d78-6f1b174a8405@redhat.com |
---|---|
State | New |
Headers | show |
On Fri, Nov 11, 2016 at 09:10:48AM -0800, Aldy Hernandez wrote: > The problem in this PR is that -fself-test is being run on a non empty > source file. This causes init_emit() to run, which sets: > > REG_POINTER (virtual_incoming_args_rtx) = 1; > > Setting REG_POINTER on the virtual incoming args, causes /f to be printed on > some RTL dumps, causing the -fself-test machinery to fail at matching the > expected value. > > It looks that by design -fself-test is meant to be run before any > initialization like the aforementioned runs. Won't -fself-test -fno-syntax-only still crash? I.e. wouldn't it be better to deal with this e.g. in finish_options? Or perhaps error out if -fself-tests is not used with -fsyntax-only and change the Makefile to invoke it with both options? Jakub
On 11/11/2016 06:10 PM, Aldy Hernandez wrote: > The problem in this PR is that -fself-test is being run on a non empty > source file. This causes init_emit() to run, which sets: > > REG_POINTER (virtual_incoming_args_rtx) = 1; > > Setting REG_POINTER on the virtual incoming args, causes /f to be > printed on some RTL dumps, causing the -fself-test machinery to fail at > matching the expected value. How about always running init_emit and testing for the correct output? Bernd
On Mon, Nov 14, 2016 at 02:18:02PM +0100, Bernd Schmidt wrote: > On 11/11/2016 06:10 PM, Aldy Hernandez wrote: > >The problem in this PR is that -fself-test is being run on a non empty > >source file. This causes init_emit() to run, which sets: > > > > REG_POINTER (virtual_incoming_args_rtx) = 1; > > > >Setting REG_POINTER on the virtual incoming args, causes /f to be > >printed on some RTL dumps, causing the -fself-test machinery to fail at > >matching the expected value. > > How about always running init_emit and testing for the correct output? You mean only if -fself-test, right? Jakub
On 11/14/2016 02:20 PM, Jakub Jelinek wrote: > On Mon, Nov 14, 2016 at 02:18:02PM +0100, Bernd Schmidt wrote: >> On 11/11/2016 06:10 PM, Aldy Hernandez wrote: >>> The problem in this PR is that -fself-test is being run on a non empty >>> source file. This causes init_emit() to run, which sets: >>> >>> REG_POINTER (virtual_incoming_args_rtx) = 1; >>> >>> Setting REG_POINTER on the virtual incoming args, causes /f to be >>> printed on some RTL dumps, causing the -fself-test machinery to fail at >>> matching the expected value. >> >> How about always running init_emit and testing for the correct output? > > You mean only if -fself-test, right? I guess. Bernd
diff --git a/gcc/opts.c b/gcc/opts.c index d2d6100..35357bd 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -1770,6 +1770,16 @@ common_handle_option (struct gcc_options *opts, opts->x_exit_after_options = true; break; + case OPT_fself_test: + /* -fself-test depends on the state of the compiler prior to + compiling anything. Ideally it should be run on an empty + source file. However, in case we get run with actual source, + assume -fsyntax-only which will inhibit any compiler + initialization which may confuse the self tests. */ + if (lang_mask != CL_DRIVER) + flag_syntax_only = 1; + break; + case OPT_fsanitize_: opts->x_flag_sanitize = parse_sanitizer_options (arg, loc, code, diff --git a/gcc/testsuite/gcc.dg/pr78213.c b/gcc/testsuite/gcc.dg/pr78213.c new file mode 100644 index 0000000..b262fa1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr78213.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-fself-test" } */ + +/* Verify that -fself-test does not fail on a non empty source. */ + +int i; void bar(); void foo() +{ + while (i--) + bar(); +}