@@ -157,6 +157,20 @@ const struct attribute_spec jit_format_attribute_table[] =
157157  { NULL ,                     0 , 0 , false , false , false , false , NULL , NULL  }
158158};
159159
160+ char * jit_personality_func_name = NULL ;
161+ static  tree personality_decl;
162+ 
163+ /*  FIXME: This is a hack to preserve trees that we create from the
164+    garbage collector.  */  
165+ 
166+ static  GTY  (()) tree jit_gc_root;
167+ 
168+ void 
169+ jit_preserve_from_gc  (tree t)
170+ {
171+   jit_gc_root = tree_cons  (NULL_TREE, t, jit_gc_root);
172+ }
173+ 
160174/*  Attribute handlers.  */ 
161175
162176/*  Handle a "noreturn" attribute; arguments as in
@@ -589,6 +603,8 @@ jit_end_diagnostic (diagnostic_context *context,
589603static  bool 
590604jit_langhook_init  (void )
591605{
606+   jit_gc_root = NULL_TREE;
607+   personality_decl = NULL_TREE;
592608  gcc_assert  (gcc::jit::active_playback_ctxt);
593609  JIT_LOG_SCOPE  (gcc::jit::active_playback_ctxt->get_logger  ());
594610
@@ -920,6 +936,25 @@ jit_langhook_getdecls (void)
920936  return  NULL ;
921937}
922938
939+ static  tree
940+ jit_langhook_eh_personality  (void )
941+ {
942+   if  (personality_decl == NULL_TREE)
943+   {
944+     if  (jit_personality_func_name != NULL ) {
945+       personality_decl = build_personality_function_with_name  (jit_personality_func_name);
946+       jit_preserve_from_gc (personality_decl);
947+     }
948+     else  {
949+       return  lhd_gcc_personality ();
950+     }
951+   }
952+   return  personality_decl;
953+ }
954+ 
955+ #undef  LANG_HOOKS_EH_PERSONALITY
956+ #define  LANG_HOOKS_EH_PERSONALITY  jit_langhook_eh_personality
957+ 
923958#undef  LANG_HOOKS_NAME
924959#define  LANG_HOOKS_NAME 		" libgccjit" 
925960
0 commit comments