public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PR target/78213] Do not ICE on non-empty -fself-test
@ 2016-11-11 17:10 Aldy Hernandez
  2016-11-11 17:24 ` Jakub Jelinek
  2016-11-14 13:18 ` Bernd Schmidt
  0 siblings, 2 replies; 7+ messages in thread
From: Aldy Hernandez @ 2016-11-11 17:10 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

[-- Attachment #1: Type: text/plain, Size: 772 bytes --]

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.

We could error/fail when running -fself-test on a non-empty file, but I 
think we can just enable -fsyntax-only and get the same result.  After 
all, this is an undocumented internal option.

BTW, this is being triggered on aarch64, but will likely show up in 
different ports in different ways.

OK for trunk?

[-- Attachment #2: curr --]
[-- Type: text/plain, Size: 1529 bytes --]

commit f5d7bfbdae2f74d3b98a81e1f3ee7b9b24c8f3be
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Fri Nov 11 06:32:08 2016 -0800

    	PR target/78213
    	* opts.c (common_handle_option): Set -fsyntax-only if running self
    	tests.

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();
+}

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-11-22 16:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-11 17:10 [PR target/78213] Do not ICE on non-empty -fself-test Aldy Hernandez
2016-11-11 17:24 ` Jakub Jelinek
2016-11-14 13:18 ` Bernd Schmidt
2016-11-14 13:20   ` Jakub Jelinek
2016-11-14 13:25     ` Bernd Schmidt
2016-11-17 16:52   ` Aldy Hernandez
2016-11-22 16:42     ` Bernd Schmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).