@@ -188,7 +188,8 @@ static LL_MDRef lldbg_emit_type(LL_DebugInfo *db, DTYPE dtype, SPTR sptr,
188188static LL_MDRef lldbg_fwd_local_variable (LL_DebugInfo *db, int sptr, int findex,
189189 int emit_dummy_as_local);
190190static void lldbg_emit_imported_entity (LL_DebugInfo *db, SPTR entity_sptr,
191- SPTR func_sptr, IMPORT_TYPE entity_type);
191+ SPTR func_sptr, IMPORT_TYPE entity_type,
192+ LL_MDRef imported_entity_mdnode);
192193static LL_MDRef lldbg_create_subrange_mdnode (LL_DebugInfo *db, LL_MDRef count,
193194 LL_MDRef lb, LL_MDRef ub,
194195 LL_MDRef st);
@@ -474,7 +475,7 @@ lldbg_create_subprogram_mdnode(
474475 LL_MDRef type_mdnode, int is_local, int is_definition, int virtuality,
475476 int vindex, int spFlags, int flags, bool is_optimized,
476477 LL_MDRef template_param_mdnode, LL_MDRef decl_desc_mdnode,
477- LL_MDRef lv_list_mdnode, int scope)
478+ LL_MDRef lv_list_mdnode, int scope, LL_MDRef imported_entities_mdnode )
478479{
479480 LLMD_Builder mdb = llmd_init (db->module );
480481
@@ -527,6 +528,10 @@ lldbg_create_subprogram_mdnode(
527528 }
528529 llmd_add_i32 (mdb, scope);
529530
531+ if (ll_feature_subprogram_imported_entities (&db->module ->ir )) {
532+ llmd_add_md (mdb, imported_entities_mdnode);
533+ }
534+
530535 /* Request a distinct mdnode so that it can be updated with a function pointer
531536 * later. */
532537 llmd_set_distinct (mdb);
@@ -2404,19 +2409,21 @@ lldbg_emit_outlined_subprogram(LL_DebugInfo *db, int sptr, int findex,
24042409 db, file_mdnode, func_name, mips_linkage_name, file_mdnode, lineno,
24052410 type_mdnode, is_local, is_def, virtuality, vindex, spFlags,
24062411 flags, is_optimized, ll_get_md_null (), ll_get_md_null (), lv_list_mdnode,
2407- lineno);
2412+ lineno, ll_get_md_null () );
24082413 else if (ll_feature_debug_info_ver38 (&(db)->module ->ir ))
24092414 lldbg_create_subprogram_mdnode (
24102415 db, lldbg_emit_compile_unit (db), func_name, mips_linkage_name,
24112416 get_filedesc_mdnode (db, findex), lineno, type_mdnode, is_local,
24122417 is_def, virtuality, vindex, spFlags, flags, is_optimized,
2413- ll_get_md_null (), ll_get_md_null (), lv_list_mdnode, lineno);
2418+ ll_get_md_null (), ll_get_md_null (), lv_list_mdnode, lineno,
2419+ ll_get_md_null ());
24142420 else
24152421 lldbg_create_subprogram_mdnode (
24162422 db, file_mdnode, func_name, mips_linkage_name,
24172423 get_filedesc_mdnode (db, findex), lineno, type_mdnode, is_local,
24182424 is_def, virtuality, vindex, spFlags, flags, is_optimized,
2419- ll_get_md_null (), ll_get_md_null (), lv_list_mdnode, lineno);
2425+ ll_get_md_null (), ll_get_md_null (), lv_list_mdnode, lineno,
2426+ ll_get_md_null ());
24202427 db->cur_subprogram_null_loc =
24212428 lldbg_create_location_mdnode (db, lineno, 1 , db->cur_subprogram_mdnode );
24222429 db->cur_subprogram_lineno = lineno;
@@ -2450,6 +2457,7 @@ lldbg_emit_subprogram(LL_DebugInfo *db, SPTR sptr, DTYPE ret_dtype, int findex,
24502457 LL_MDRef lv_list_mdnode;
24512458 LL_MDRef context_mdnode;
24522459 LL_MDRef scope;
2460+ LL_MDRef imported_entities_mdnode;
24532461 char *mips_linkage_name = " " ;
24542462 const char *func_name;
24552463 int virtuality = 0 ;
@@ -2472,6 +2480,7 @@ lldbg_emit_subprogram(LL_DebugInfo *db, SPTR sptr, DTYPE ret_dtype, int findex,
24722480 lldbg_emit_subroutine_type (db, sptr, ret_dtype, findex, file_mdnode);
24732481 db->cur_line_mdnode = ll_get_md_null ();
24742482 lv_list_mdnode = ll_create_flexible_md_node (db->module );
2483+ imported_entities_mdnode = ll_create_flexible_md_node (db->module );
24752484 if (db->routine_idx >= db->routine_count )
24762485 db->routine_count = db->routine_idx + 1 ;
24772486 db->llvm_dbg_lv_array = (LL_MDRef *)realloc (
@@ -2508,15 +2517,17 @@ lldbg_emit_subprogram(LL_DebugInfo *db, SPTR sptr, DTYPE ret_dtype, int findex,
25082517 mips_linkage_name, scope, lineno, type_mdnode,
25092518 is_local, is_def, virtuality, vindex,
25102519 spFlags, flags, is_optimized, ll_get_md_null (),
2511- ll_get_md_null (), lv_list_mdnode, lineno);
2520+ ll_get_md_null (), lv_list_mdnode, lineno,
2521+ imported_entities_mdnode);
25122522 if (!db->subroutine_mdnodes )
25132523 db->subroutine_mdnodes = hashmap_alloc (hash_functions_direct);
25142524 scopeData = (hash_data_t )(unsigned long )db->cur_subprogram_mdnode ;
25152525 hashmap_replace (db->subroutine_mdnodes , INT2HKEY (sptr), &scopeData);
25162526 while (db->import_entity_list ) {
25172527 /* There are pending entities to be imported into this func */
25182528 lldbg_emit_imported_entity (db, db->import_entity_list ->entity , sptr,
2519- db->import_entity_list ->entity_type );
2529+ db->import_entity_list ->entity_type ,
2530+ imported_entities_mdnode);
25202531 db->import_entity_list = db->import_entity_list ->next ;
25212532 }
25222533// AOCC Begin
@@ -4066,7 +4077,7 @@ lldbg_function_end(LL_DebugInfo *db, int func)
40664077
40674078static LL_MDRef
40684079lldbg_create_imported_entity (LL_DebugInfo *db, SPTR entity_sptr, SPTR func_sptr,
4069- IMPORT_TYPE entity_type)
4080+ IMPORT_TYPE entity_type, LL_MDRef imported_entities_mdnode )
40704081{
40714082 LLMD_Builder mdb;
40724083 LL_MDRef entity_mdnode, scope_mdnode, file_mdnode, cur_mdnode;
@@ -4096,7 +4107,7 @@ lldbg_create_imported_entity(LL_DebugInfo *db, SPTR entity_sptr, SPTR func_sptr,
40964107 return ll_get_md_null ();
40974108 }
40984109 mdb = llmd_init (db->module );
4099- scope_mdnode = (func_sptr == gbl.currsub ) ? db->cur_subprogram_mdnode : scope_mdnode ;
4110+ scope_mdnode = (func_sptr == gbl.currsub ) ? db->cur_subprogram_mdnode : 0 ;
41004111 if (!entity_mdnode || !scope_mdnode)
41014112 return ll_get_md_null ();
41024113
@@ -4117,13 +4128,17 @@ lldbg_create_imported_entity(LL_DebugInfo *db, SPTR entity_sptr, SPTR func_sptr,
41174128 }
41184129
41194130 cur_mdnode = llmd_finish (mdb);
4120- ll_extend_md_node (db->module , db->llvm_dbg_imported , cur_mdnode);
4131+ if (ll_feature_subprogram_imported_entities (&db->module ->ir )) {
4132+ ll_extend_md_node (db->module , imported_entities_mdnode, cur_mdnode);
4133+ } else {
4134+ ll_extend_md_node (db->module , db->llvm_dbg_imported , cur_mdnode);
4135+ }
41214136 return cur_mdnode;
41224137}
41234138
41244139static void
41254140lldbg_emit_imported_entity (LL_DebugInfo *db, SPTR entity_sptr, SPTR func_sptr,
4126- IMPORT_TYPE entity_type)
4141+ IMPORT_TYPE entity_type, LL_MDRef imported_entities_mdnode )
41274142{
41284143 static hashset_t entity_func_added;
41294144 const char *entity_func;
@@ -4136,7 +4151,8 @@ lldbg_emit_imported_entity(LL_DebugInfo *db, SPTR entity_sptr, SPTR func_sptr,
41364151 if (hashset_lookup (entity_func_added, entity_func))
41374152 return ;
41384153 hashset_insert (entity_func_added, entity_func);
4139- lldbg_create_imported_entity (db, entity_sptr, func_sptr, entity_type);
4154+ lldbg_create_imported_entity (db, entity_sptr, func_sptr, entity_type,
4155+ imported_entities_mdnode);
41404156}
41414157
41424158void
0 commit comments