Author: shenruifen Date: 2012-07-27 00:12:20 -0400 (Fri, 27 Jul 2012) New Revision: 3993
Modified: trunk/osprey/be/com/clone_DST_utils.cxx trunk/osprey/be/com/clone_DST_utils.h trunk/osprey/common/com/dwarf_DST.h trunk/osprey/common/com/dwarf_DST_producer.cxx trunk/osprey/common/com/dwarf_DST_producer.h trunk/osprey/ipa/common/ipc_main.cxx trunk/osprey/ipa/main/optimize/ipo_inline.cxx Log: Fix [Bug 1003] IPA: Dst merge error when inline Reviewed by Lai jianxin Modified: trunk/osprey/be/com/clone_DST_utils.cxx =================================================================== --- trunk/osprey/be/com/clone_DST_utils.cxx 2012-07-27 02:18:39 UTC (rev 3992) +++ trunk/osprey/be/com/clone_DST_utils.cxx 2012-07-27 04:12:20 UTC (rev 3993) @@ -228,8 +228,54 @@ return concrete_instance; } +typedef std::pair<DST_TYPE, DST_IDX> DST_PAIR; +DST_PAIR +get_abstract_origin_and_dst_for_subroutine(DST_IDX concrete_instance, + DST_TYPE file_dst) +{ + DST_TYPE abstract_dst; + DST_IDX idx; + DST_PAIR pair; + DST_TYPE old_dst = Current_DST; + Current_DST = file_dst; + DST_INFO *dst = DST_INFO_IDX_TO_PTR(concrete_instance); + + if (DST_IS_FOREIGN_OBJ(concrete_instance)) + return std::make_pair(file_dst, concrete_instance); + + DST_INLINED_SUBROUTINE *attr; + + switch (DST_INFO_tag(dst)) { + case DW_TAG_subprogram: + { + pair = std::make_pair(file_dst, concrete_instance); + break; + } + case DW_TAG_inlined_subroutine: + { + attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes(dst), DST_INLINED_SUBROUTINE); + if (DST_IS_NULL(DST_INLINED_SUBROUTINE_abstract_origin(attr))) { + pair = std::make_pair(file_dst, concrete_instance); + } + else { + pair = get_abstract_origin_and_dst_for_subroutine( + DST_INLINED_SUBROUTINE_abstract_origin(attr), + DST_INLINED_SUBROUTINE_abstract_dst(attr)); + } + break; + } + default: + { + Fail_FmtAssertion("get_abstract_origin_and_dst_for_subroutine: Unexpected dst info tag"); + break; + } + } + Current_DST = old_dst; + return pair; +} + static void DST_enter_cloned_childs(DST_IDX parent, DST_IDX inl_routine, @@ -690,6 +736,47 @@ #if (!defined(_LEGO_CLONER)) mUINT16 +DST_Enter_Callee_File_Dst(DST_TYPE caller_file_dst, + DST_TYPE callee_file_dst) +{ + DST_TYPE old_Current_DST = Current_DST; + char *filename = 0; + char *dirname = 0; + UINT64 file_size; + UINT64 fmod_time; + Current_DST = callee_file_dst; + + DST_FILE_IDX callee_idx = DST_get_file_names(); + DST_FILE_NAME *file; + mUINT16 index = 1; + + while (!DST_IS_NULL(callee_idx)) { + Current_DST = callee_file_dst; + file = DST_FILE_IDX_TO_PTR(callee_idx); + file_size = DST_FILE_NAME_size(file); + fmod_time = DST_FILE_NAME_modt(file); + extern char *DST_get_dirname(mUINT16 ordinal); + + dirname = DST_get_dirname(DST_FILE_NAME_dir(file)); + filename = DST_STR_IDX_TO_PTR(DST_FILE_NAME_name(file)); + + if (filename) { + Current_DST = caller_file_dst; + /* Get file id in caller file dst; if no, create a new entry */ + DST_get_cross_inlined_file_id (filename, + dirname, + file_size, + fmod_time); + } + + Current_DST = callee_file_dst; + callee_idx = DST_FILE_NAME_next(file); + index++; + } + Current_DST = old_Current_DST; +} + +mUINT16 DST_get_cross_file_id(DST_IDX parent, DST_IDX inl_routine, DST_TYPE caller_file_dst, @@ -757,7 +844,10 @@ DST_TYPE old_Current_DST = Current_DST; Current_DST = callee_file_dst; #endif - DST_INFO_IDX abstract_origin = get_abstract_origin(inl_routine); + DST_PAIR pair = get_abstract_origin_and_dst_for_subroutine(inl_routine, + callee_file_dst); + DST_TYPE abstract_file_dst = pair.first; + DST_INFO_IDX abstract_origin = pair.second; mUINT16 file_index = cross_file_id; #if !defined(_LEGO_CLONER) @@ -775,7 +865,7 @@ if (caller_file_dst == callee_file_dst) { idx = DST_mk_inlined_subroutine (low_pc, high_pc, - abstract_origin); + abstract_origin, abstract_file_dst); DST_append_child(parent, idx); @@ -796,7 +886,7 @@ UINT64 file_size; UINT64 fmod_time; - Current_DST = callee_file_dst; + Current_DST = abstract_file_dst; DST_SUBPROGRAM *inl_attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes(DST_INFO_IDX_TO_PTR(abstract_origin)), DST_SUBPROGRAM); @@ -818,7 +908,8 @@ DST_SUBPROGRAM_decl_decl(attr), filename, dirname, - abstract_origin); + abstract_origin, + abstract_file_dst); DST_append_child(parent, idx); Modified: trunk/osprey/be/com/clone_DST_utils.h =================================================================== --- trunk/osprey/be/com/clone_DST_utils.h 2012-07-27 02:18:39 UTC (rev 3992) +++ trunk/osprey/be/com/clone_DST_utils.h 2012-07-27 04:12:20 UTC (rev 3993) @@ -52,6 +52,10 @@ class IPO_SYMTAB; extern mUINT16 +DST_Enter_Callee_File_Dst(DST_TYPE caller_file_dst, + DST_TYPE callee_file_dst); + +extern mUINT16 DST_get_cross_file_id(DST_IDX parent, DST_IDX inl_routine, DST_TYPE caller_file_dst, Modified: trunk/osprey/common/com/dwarf_DST.h =================================================================== --- trunk/osprey/common/com/dwarf_DST.h 2012-07-27 02:18:39 UTC (rev 3992) +++ trunk/osprey/common/com/dwarf_DST.h 2012-07-27 04:12:20 UTC (rev 3993) @@ -462,6 +462,7 @@ DST_ASSOC_INFO low_pc; /* Get pc value through back-end LABEL */ DST_ASSOC_INFO high_pc; /* Get pc value through back-end LABEL */ DST_INFO_IDX abstract_origin; /* The abstract version of this instance */ + DST_TYPE abstract_dst; /* dst where abstract_origin is located */ DST_CHILDREN child; /* Formal parameters, and local scope*/ USRCPOS decl; /* so can check if cross-file */ DST_STR_IDX abstract_name; /* "name" for cross-file matching */ @@ -475,6 +476,7 @@ #define DST_INLINED_SUBROUTINE_last_child(attr) ((attr)->child.last) #define DST_INLINED_SUBROUTINE_decl(attr) ((attr)->decl) #define DST_INLINED_SUBROUTINE_abstract_name(attr) ((attr)->abstract_name) +#define DST_INLINED_SUBROUTINE_abstract_dst(attr) ((attr)->abstract_dst) Modified: trunk/osprey/common/com/dwarf_DST_producer.cxx =================================================================== --- trunk/osprey/common/com/dwarf_DST_producer.cxx 2012-07-27 02:18:39 UTC (rev 3992) +++ trunk/osprey/common/com/dwarf_DST_producer.cxx 2012-07-27 04:12:20 UTC (rev 3993) @@ -503,18 +503,21 @@ DST_INFO_IDX DST_mk_inlined_subroutine(ST_IDX low_pc, /* ptr to front-end label */ ST_IDX high_pc, /* ptr to front-end label */ - DST_INFO_IDX abstract_origin) + DST_INFO_IDX abstract_origin, + DST_TYPE abstract_dst) { DST_INFO_IDX info_idx; DST_ATTR_IDX attr_idx; DST_flag flag = DST_no_flag; DST_INLINED_SUBROUTINE *attr; - + DST_TYPE old_dst = Current_DST; #if !(defined(_SUPPORT_IPA) || defined(_STANDALONE_INLINER)) DST_enter_mk(DST_making_dbg_info, last_info_idx); #endif + Current_DST = abstract_dst; DST_check_info_idx(DW_TAG_subprogram, abstract_origin); + Current_DST = old_dst; info_idx = DST_mk_info(); attr_idx = DST_mk_attr(DST_INLINED_SUBROUTINE); @@ -523,6 +526,7 @@ DST_ASSOC_INFO_st_idx(DST_INLINED_SUBROUTINE_low_pc (attr)) = low_pc; DST_ASSOC_INFO_st_idx(DST_INLINED_SUBROUTINE_high_pc(attr)) = high_pc; DST_INLINED_SUBROUTINE_abstract_origin(attr) = abstract_origin; + DST_INLINED_SUBROUTINE_abstract_dst(attr) = abstract_dst; DST_INLINED_SUBROUTINE_first_child(attr) = DST_INVALID_IDX; DST_INLINED_SUBROUTINE_last_child(attr) = DST_INVALID_IDX; @@ -695,7 +699,8 @@ USRCPOS inl_decl, /* inline routine's source position */ char *filename, /* ptr to filename of the inlined routine */ char *dirname, /* ptr to directory path of the inlined routine */ - DST_INFO_IDX abstract_origin) /* The abstract version of this subroutine */ + DST_INFO_IDX abstract_origin, /* The abstract version of this subroutine */ + DST_TYPE abstract_dst) /* dst where abstract_origin is located */ { DST_INFO_IDX info_idx; @@ -734,6 +739,7 @@ DST_INLINED_SUBROUTINE_decl(attr) = decl; DST_INLINED_SUBROUTINE_abstract_origin(attr) = abstract_origin;; + DST_INLINED_SUBROUTINE_abstract_dst(attr) = abstract_dst; DST_INLINED_SUBROUTINE_first_child(attr) = DST_INVALID_IDX; DST_INLINED_SUBROUTINE_last_child(attr) = DST_INVALID_IDX; Modified: trunk/osprey/common/com/dwarf_DST_producer.h =================================================================== --- trunk/osprey/common/com/dwarf_DST_producer.h 2012-07-27 02:18:39 UTC (rev 3992) +++ trunk/osprey/common/com/dwarf_DST_producer.h 2012-07-27 04:12:20 UTC (rev 3993) @@ -230,7 +230,8 @@ extern DST_INFO_IDX DST_mk_inlined_subroutine(ST_IDX low_pc, ST_IDX high_pc, - DST_INFO_IDX abstract_origin); + DST_INFO_IDX abstract_origin, + DST_TYPE abstract_dst); /* Creates a DW_TAG_subprogram entry and returns its idx. @@ -721,7 +722,8 @@ USRCPOS , char *, char *, - DST_INFO_IDX ); + DST_INFO_IDX , + DST_TYPE); #endif #if defined(_SUPPORT_IPA) || defined(_STANDALONE_INLINER) || defined(_LEGO_CLONER) Modified: trunk/osprey/ipa/common/ipc_main.cxx =================================================================== --- trunk/osprey/ipa/common/ipc_main.cxx 2012-07-27 02:18:39 UTC (rev 3992) +++ trunk/osprey/ipa/common/ipc_main.cxx 2012-07-27 04:12:20 UTC (rev 3993) @@ -280,7 +280,6 @@ #else IPA_Enable_AutoGnum = TRUE; #endif - IPA_Enable_DST = FALSE; Process_IPA_Options (argc, argv); Modified: trunk/osprey/ipa/main/optimize/ipo_inline.cxx =================================================================== --- trunk/osprey/ipa/main/optimize/ipo_inline.cxx 2012-07-27 02:18:39 UTC (rev 3992) +++ trunk/osprey/ipa/main/optimize/ipo_inline.cxx 2012-07-27 04:12:20 UTC (rev 3993) @@ -1502,6 +1502,10 @@ #if (!defined(_STANDALONE_INLINER) && !defined(_LIGHTWEIGHT_INLINER)) if (IPA_Enable_DST) { + // Enter the files in callee dst to caller dst, + DST_Enter_Callee_File_Dst(Caller_file_dst(), Callee_file_dst()); + + // Set cross file id Set_callee_cross_file_id(DST_get_cross_file_id (Caller_dst(), Callee_dst(), Caller_file_dst(), ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Open64-devel mailing list Open64-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/open64-devel