Fix ICE with -fopt-info-inline (PR ipa/87955)
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 13 Nov 2018 15:59:57 +0000 (15:59 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Tue, 13 Nov 2018 15:59:57 +0000 (15:59 +0000)
PR ipa/87955 reports a problem I introduced in r265920, where I converted
the guard in report_inline_failed_reason from using:
  if (dump_file)
to using
  if (dump_enabled_p ()).
without updating the calls to cl_target_option_print_diff and
cl_optimization_print_diff, which assume that dump_file is non-NULL.

The functions are auto-generated.  Rather than porting them to the dump
API, this patch applies the workaround of adding the missing checks on
dump_file before calling them.

gcc/ChangeLog:
PR ipa/87955
* ipa-inline.c (report_inline_failed_reason): Guard calls to
cl_target_option_print_diff and cl_optimization_print_diff with
if (dump_file).

gcc/testsuite/ChangeLog:
PR ipa/87955
* gcc.target/i386/pr87955.c: New test.

From-SVN: r266079

gcc/ChangeLog
gcc/ipa-inline.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr87955.c [new file with mode: 0644]

index 18acf495a31ec3ea47bbfad153e131fbbaa6a218..ddc99e3102f9dcb59b599901966cb211a9711332 100644 (file)
@@ -1,3 +1,10 @@
+2018-11-13  David Malcolm  <dmalcolm@redhat.com>
+
+       PR ipa/87955
+       * ipa-inline.c (report_inline_failed_reason): Guard calls to
+       cl_target_option_print_diff and cl_optimization_print_diff with
+       if (dump_file).
+
 2018-11-13  David Malcolm  <dmalcolm@redhat.com>
 
        * doc/invoke.texi (-fsave-optimization-record): Note that the
index e04ede774cf8eb1a71e06f96267ebb623428269d..173808a5603bb6d036aae9c3a85adb7a71b5db47 100644 (file)
@@ -244,13 +244,15 @@ report_inline_failed_reason (struct cgraph_edge *e)
                           e->callee->ultimate_alias_target ()->lto_file_data->file_name);
        }
       if (e->inline_failed == CIF_TARGET_OPTION_MISMATCH)
-       cl_target_option_print_diff
-        (dump_file, 2, target_opts_for_fn (e->caller->decl),
-          target_opts_for_fn (e->callee->ultimate_alias_target ()->decl));
+       if (dump_file)
+         cl_target_option_print_diff
+           (dump_file, 2, target_opts_for_fn (e->caller->decl),
+            target_opts_for_fn (e->callee->ultimate_alias_target ()->decl));
       if (e->inline_failed == CIF_OPTIMIZATION_MISMATCH)
-       cl_optimization_print_diff
-         (dump_file, 2, opts_for_fn (e->caller->decl),
-          opts_for_fn (e->callee->ultimate_alias_target ()->decl));
+       if (dump_file)
+         cl_optimization_print_diff
+           (dump_file, 2, opts_for_fn (e->caller->decl),
+            opts_for_fn (e->callee->ultimate_alias_target ()->decl));
     }
 }
 
index 979f5978c494146702379731af067f6d44dd811e..d2f0fd3adc53d0210cc68e7a7126fddbd260857b 100644 (file)
@@ -1,3 +1,8 @@
+2018-11-13  David Malcolm  <dmalcolm@redhat.com>
+
+       PR ipa/87955
+       * gcc.target/i386/pr87955.c: New test.
+
 2018-11-12  Aldy Hernandez  <aldyh@redhat.com>
 
        * gcc.dg/tree-ssa/pr64130.c: Adjust for new value_range pretty
diff --git a/gcc/testsuite/gcc.target/i386/pr87955.c b/gcc/testsuite/gcc.target/i386/pr87955.c
new file mode 100644 (file)
index 0000000..ed87da6
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-options "-O2 -fopt-info-inline-missed" } */
+
+float a;
+
+__attribute__((__target__("fpmath=387")))
+int b() {
+  return a;
+}
+
+int c() { return b(); } /* { dg-missed "not inlinable: c/\[0-9\]* -> b/\[0-9\]*, target specific option mismatch" } */