@@ -188,10 +188,11 @@ static LL_MDRef lldbg_fwd_local_variable(LL_DebugInfo *db, int sptr, int findex,
188188static LL_MDRef lldbg_create_imported_entity (LL_DebugInfo *db, SPTR entity_sptr,
189189 SPTR func_sptr,
190190 IMPORT_TYPE entity_type,
191- LL_MDRef elements_mdnode);
191+ LL_MDRef elements_mdnode,
192+ LL_MDRef imported_list);
192193static void lldbg_emit_imported_entity (LL_DebugInfo *db, SPTR entity_sptr,
193194 SPTR func_sptr, IMPORT_TYPE entity_type,
194- LL_MDRef elements);
195+ LL_MDRef elements, LL_MDRef imported_list );
195196static LL_MDRef lldbg_create_subrange_mdnode (LL_DebugInfo *db, LL_MDRef count,
196197 LL_MDRef lb, LL_MDRef ub,
197198 LL_MDRef st);
@@ -530,6 +531,7 @@ lldbg_create_subprogram_mdnode(
530531 llmd_add_md (mdb, lv_list_mdnode);
531532 } else if (ll_feature_debug_info_ver13 (&db->module ->ir ))
532533 llmd_add_md (mdb, lv_list_mdnode);
534+
533535 llmd_add_i32 (mdb, scope);
534536
535537 /* Request a distinct mdnode so that it can be updated with a function pointer
@@ -2417,6 +2419,7 @@ lldbg_emit_subprogram(LL_DebugInfo *db, SPTR sptr, DTYPE ret_dtype, int findex,
24172419 LL_MDRef lv_list_mdnode;
24182420 LL_MDRef context_mdnode;
24192421 LL_MDRef scope;
2422+ LL_MDRef imported_list;
24202423 const char *mips_linkage_name = " " ;
24212424 const char *func_name;
24222425 int virtuality = 0 ;
@@ -2471,6 +2474,8 @@ lldbg_emit_subprogram(LL_DebugInfo *db, SPTR sptr, DTYPE ret_dtype, int findex,
24712474 ll_get_md_null (), lv_list_mdnode, lineno);
24722475 if (!db->subroutine_mdnodes )
24732476 db->subroutine_mdnodes = hashmap_alloc (hash_functions_direct);
2477+ imported_list = ll_feature_debug_info_ver17 (&db->module ->ir ) ?
2478+ lv_list_mdnode : db->llvm_dbg_imported ;
24742479 scopeData = (hash_data_t )(unsigned long )db->cur_subprogram_mdnode ;
24752480 hashmap_replace (db->subroutine_mdnodes , INT2HKEY (sptr), &scopeData);
24762481 while (db->import_entity_list ) {
@@ -2480,10 +2485,12 @@ lldbg_emit_subprogram(LL_DebugInfo *db, SPTR sptr, DTYPE ret_dtype, int findex,
24802485 /* There are pending entities to be imported into this func */
24812486 lldbg_emit_imported_entity (db, db->import_entity_list ->entity , sptr,
24822487 db->import_entity_list ->entity_type ,
2483- elements_mdnode);
2488+ elements_mdnode, imported_list );
24842489 while (child) {
24852490 LL_MDRef element = lldbg_create_imported_entity (db, child->entity , sptr,
2486- child->entity_type , (LL_MDRef) NULL );
2491+ child->entity_type ,
2492+ (LL_MDRef) NULL ,
2493+ (LL_MDRef) NULL );
24872494 ll_extend_md_node (db->module , elements_mdnode, element);
24882495 child = child->next ;
24892496 }
@@ -4107,7 +4114,8 @@ lldbg_function_end(LL_DebugInfo *db, int func)
41074114
41084115static LL_MDRef
41094116lldbg_create_imported_entity (LL_DebugInfo *db, SPTR entity_sptr, SPTR func_sptr,
4110- IMPORT_TYPE entity_type, LL_MDRef elements_mdnode)
4117+ IMPORT_TYPE entity_type, LL_MDRef elements_mdnode,
4118+ LL_MDRef imported_list)
41114119{
41124120 LLMD_Builder mdb;
41134121 LL_MDRef entity_mdnode, scope_mdnode = 0 , file_mdnode, cur_mdnode;
@@ -4164,14 +4172,16 @@ lldbg_create_imported_entity(LL_DebugInfo *db, SPTR entity_sptr, SPTR func_sptr,
41644172 llmd_add_md (mdb, elements_mdnode); // elements
41654173
41664174 cur_mdnode = llmd_finish (mdb);
4167- ll_extend_md_node (db->module , db->llvm_dbg_imported , cur_mdnode);
4175+ if (imported_list)
4176+ ll_extend_md_node (db->module , imported_list, cur_mdnode);
41684177 return cur_mdnode;
41694178}
41704179
41714180static void
41724181lldbg_emit_imported_entity (LL_DebugInfo *db, SPTR entity_sptr,
41734182 SPTR func_sptr, IMPORT_TYPE entity_type,
4174- LL_MDRef elements_mdnode)
4183+ LL_MDRef elements_mdnode,
4184+ LL_MDRef imported_list)
41754185{
41764186 static hashset_t entity_func_added;
41774187 const char *entity_func;
@@ -4185,7 +4195,7 @@ lldbg_emit_imported_entity(LL_DebugInfo *db, SPTR entity_sptr,
41854195 return ;
41864196 hashset_insert (entity_func_added, entity_func);
41874197 lldbg_create_imported_entity (db, entity_sptr, func_sptr, entity_type,
4188- elements_mdnode);
4198+ elements_mdnode, imported_list );
41894199}
41904200
41914201void
0 commit comments