LTO stream out not only happens with LTO (-flto) but also for
the offloaded functions with OpenMP/OpenACC.

Without using -flto, this leads to an ICE as a recent patch
(r11-525-g03d90a20a1afcbb9c30da8d4adf4922b0685061f) added the
check to DFS::DFS (lto-streamer-out.c:639):
   if (ob->local_trees && local_tree_p (expr))
where local_tree_p calls odr_type_t.

And the latter that contains the following assert, which fails:

  /* We do not have this information when not in LTO, but we do not need
     to care, since it is used only for type merging.  */
  gcc_checking_assert (in_lto_p || flag_lto);

Adding 'in_lto_p &&' before the 'odr_type_t (t) &&' in local_tree_p
works for offloading but this causes an ICE:
   FAIL: g++.dg/asan/pr85774.C   -O2 -flto -fno-use-linker-plugin 
-flto-partition=none  (internal compiler error)
lto1: internal compiler error: in unify_scc, at lto/lto-common.c:1678

Hence, the simple solution is to add flag_generate_offload to the
assert, which this patch does.

OK for the trunk?

Tobias

-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander 
Walter
[LTO/offloading] Fix offloading-compilation ICE without -flto (PR84320)

gcc/ChangeLog:
	PR ipa/95320
	* ipa-utils.h (odr_type_p): Also permit calls with
	only flag_generate_offload set.

 gcc/ipa-utils.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/ipa-utils.h b/gcc/ipa-utils.h
index 98edc383461..d0ac3ec86f8 100644
--- a/gcc/ipa-utils.h
+++ b/gcc/ipa-utils.h
@@ -243,7 +243,7 @@ odr_type_p (const_tree t)
 {
   /* We do not have this information when not in LTO, but we do not need
      to care, since it is used only for type merging.  */
-  gcc_checking_assert (in_lto_p || flag_lto);
+  gcc_checking_assert (in_lto_p || flag_lto || flag_generate_offload);
   return TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL
          && DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t));
 }

Reply via email to