diff --git a/src/mapleall/maple_ir/include/mir_module.h b/src/mapleall/maple_ir/include/mir_module.h index c62444e5fd39e86cba5dec89763113d11288f169..fefc53d0892bb0a4f2d9dff2f2c917d33056339c 100644 --- a/src/mapleall/maple_ir/include/mir_module.h +++ b/src/mapleall/maple_ir/include/mir_module.h @@ -21,6 +21,7 @@ #include "mpl_logging.h" #include "muid.h" #include "profile.h" +#include "namemangler.h" #if MIR_FEATURE_FULL #include #include @@ -317,6 +318,15 @@ class MIRModule { fileName = name; } + std::string GetProfileDataFileName() const { + std::string profileDataFileName = fileName.substr(0, fileName.find_last_of(".")); + std::replace(profileDataFileName.begin(), profileDataFileName.end(), '.', '_'); + std::replace(profileDataFileName.begin(), profileDataFileName.end(), '-', '_'); + std::replace(profileDataFileName.begin(), profileDataFileName.end(), '/', '_'); + profileDataFileName = profileDataFileName + namemangler::kProfFileNameExt; + return profileDataFileName; + } + bool IsJavaModule() const { return srcLang == kSrcLangJava; } diff --git a/src/mapleall/maple_util/include/namemangler.h b/src/mapleall/maple_util/include/namemangler.h index 9a838540e0ace5b9a213017f665b91bbdefe888e..997335883d4790dd755fab5daeafd3dbf07da7da 100644 --- a/src/mapleall/maple_util/include/namemangler.h +++ b/src/mapleall/maple_util/include/namemangler.h @@ -183,6 +183,7 @@ static constexpr const char kprefixProfExit[] = "__mpl_prof_exit_"; static constexpr const char kGCCProfInit[] = "__gcov_init"; static constexpr const char kGCCProfExit[] = "__gcov_exit"; static constexpr const char kMplMergeFuncAdd[] = "__gcov_merge_add"; +static constexpr const char kProfFileNameExt[] = ".gcda"; static constexpr const char kBindingProtectedRegionStr[] = "__BindingProtectRegion__"; diff --git a/src/mapleall/mpl2mpl/include/gen_profile.h b/src/mapleall/mpl2mpl/include/gen_profile.h index 060056b029d3fc48413fc56fd19be42db70473a2..55908c70f02d0de5a1265685caf3633f4485c8de 100644 --- a/src/mapleall/mpl2mpl/include/gen_profile.h +++ b/src/mapleall/mpl2mpl/include/gen_profile.h @@ -24,8 +24,7 @@ namespace maple { static constexpr const uint32_t kMplModProfMergeFuncs = 9; // gcov reserves 9 slots static constexpr const uint32_t kGCCVersion = 0x4137352A; // gcc v7.5 under tools -//static constexpr const uint32_t kGCCVersion = 0x4139342A; // GCC V9.3/9.4 -static constexpr const char kProfFileNameExt[] = ".gcda"; +// static constexpr const uint32_t kGCCVersion = 0x4139342A; // GCC V9.3/9.4 // anything other than merge_add will be supported supported in future static constexpr const uint32_t kMplFuncProfCtrInfoNum = 1; diff --git a/src/mapleall/mpl2mpl/src/gen_profile.cpp b/src/mapleall/mpl2mpl/src/gen_profile.cpp index 88ed5134e162522677f4460ab35bd818cc04d70f..b88e2d8c21c20bdfaa3496a0d31ecb161105a91f 100644 --- a/src/mapleall/mpl2mpl/src/gen_profile.cpp +++ b/src/mapleall/mpl2mpl/src/gen_profile.cpp @@ -15,6 +15,7 @@ #include #include "gen_profile.h" #include "ipa_phase_manager.h" +#include "namemangler.h" // namespace maple namespace maple { @@ -102,7 +103,7 @@ void ProfileGen::CreateModProfDesc() { modProfDescSymMirConst->AddItem(checksumMirConst, 5); // Make the profile file name as fileName.gcda - std::string profFileName = flatenName(srcFN.substr(0,srcFN.find_last_of("."))) + kProfFileNameExt; + std::string profFileName = mod.GetProfileDataFileName(); MIRStrConst *profileFNMirConst = modMP->New( "./" + profFileName, *GlobalTables::GetTypeTable().GetTypeFromTyIdx((TyIdx)PTY_a64)); modProfDescSymMirConst->AddItem(profileFNMirConst, 6);