diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 13 | ||||
-rw-r--r-- | llvm/lib/IR/Function.cpp | 24 | ||||
-rw-r--r-- | llvm/lib/IR/Globals.cpp | 24 | ||||
-rw-r--r-- | llvm/lib/ProfileData/InstrProf.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Transforms/IPO/FunctionImport.cpp | 2 |
5 files changed, 33 insertions, 32 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 69fb4ece9f3..8d749c29108 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -5506,10 +5506,10 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseValueSymbolTable( auto VLI = ValueIdToLinkageMap.find(ValueID); assert(VLI != ValueIdToLinkageMap.end() && "No linkage found for VST entry?"); - std::string GlobalId = - Function::getGlobalIdentifier(ValueName, VLI->second, SourceFileName); + std::string GlobalId = GlobalValue::getGlobalIdentifier( + ValueName, VLI->second, SourceFileName); TheIndex->addGlobalValueInfo(GlobalId, std::move(GlobalValInfo)); - ValueIdToCallGraphGUIDMap[ValueID] = Function::getGUID(GlobalId); + ValueIdToCallGraphGUIDMap[ValueID] = GlobalValue::getGUID(GlobalId); ValueName.clear(); break; } @@ -5526,10 +5526,11 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseValueSymbolTable( auto VLI = ValueIdToLinkageMap.find(ValueID); assert(VLI != ValueIdToLinkageMap.end() && "No linkage found for VST entry?"); - std::string FunctionGlobalId = - Function::getGlobalIdentifier(ValueName, VLI->second, SourceFileName); + std::string FunctionGlobalId = GlobalValue::getGlobalIdentifier( + ValueName, VLI->second, SourceFileName); TheIndex->addGlobalValueInfo(FunctionGlobalId, std::move(FuncInfo)); - ValueIdToCallGraphGUIDMap[ValueID] = Function::getGUID(FunctionGlobalId); + ValueIdToCallGraphGUIDMap[ValueID] = + GlobalValue::getGUID(FunctionGlobalId); ValueName.clear(); break; diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index 427efbba4f8..3ecf386e9b1 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -1005,27 +1005,3 @@ Optional<uint64_t> Function::getEntryCount() const { } return None; } - -std::string Function::getGlobalIdentifier(StringRef FuncName, - GlobalValue::LinkageTypes Linkage, - StringRef FileName) { - - // Function names may be prefixed with a binary '1' to indicate - // that the backend should not modify the symbols due to any platform - // naming convention. Do not include that '1' in the PGO profile name. - if (FuncName[0] == '\1') - FuncName = FuncName.substr(1); - - std::string NewFuncName = FuncName; - if (llvm::GlobalValue::isLocalLinkage(Linkage)) { - // For local symbols, prepend the main file name to distinguish them. - // Do not include the full path in the file name since there's no guarantee - // that it will stay the same, e.g., if the files are checked out from - // version control in different locations. - if (FileName.empty()) - NewFuncName = NewFuncName.insert(0, "<unknown>:"); - else - NewFuncName = NewFuncName.insert(0, FileName.str() + ":"); - } - return NewFuncName; -} diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp index 7f4b6234b0b..b0d00a42fb5 100644 --- a/llvm/lib/IR/Globals.cpp +++ b/llvm/lib/IR/Globals.cpp @@ -99,6 +99,30 @@ void GlobalObject::copyAttributesFrom(const GlobalValue *Src) { } } +std::string GlobalValue::getGlobalIdentifier(StringRef Name, + GlobalValue::LinkageTypes Linkage, + StringRef FileName) { + + // Value names may be prefixed with a binary '1' to indicate + // that the backend should not modify the symbols due to any platform + // naming convention. Do not include that '1' in the PGO profile name. + if (Name[0] == '\1') + Name = Name.substr(1); + + std::string NewName = Name; + if (llvm::GlobalValue::isLocalLinkage(Linkage)) { + // For local symbols, prepend the main file name to distinguish them. + // Do not include the full path in the file name since there's no guarantee + // that it will stay the same, e.g., if the files are checked out from + // version control in different locations. + if (FileName.empty()) + NewName = NewName.insert(0, "<unknown>:"); + else + NewName = NewName.insert(0, FileName.str() + ":"); + } + return NewName; +} + const char *GlobalValue::getSection() const { if (auto *GA = dyn_cast<GlobalAlias>(this)) { // In general we cannot compute this at the IR level, but we try. diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp index e7e6753f9b3..66ac03770e7 100644 --- a/llvm/lib/ProfileData/InstrProf.cpp +++ b/llvm/lib/ProfileData/InstrProf.cpp @@ -80,7 +80,7 @@ std::string getPGOFuncName(StringRef RawFuncName, GlobalValue::LinkageTypes Linkage, StringRef FileName, uint64_t Version LLVM_ATTRIBUTE_UNUSED) { - return Function::getGlobalIdentifier(RawFuncName, Linkage, FileName); + return GlobalValue::getGlobalIdentifier(RawFuncName, Linkage, FileName); } std::string getPGOFuncName(const Function &F, uint64_t Version) { diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp index 90b36aab363..5de0577f14e 100644 --- a/llvm/lib/Transforms/IPO/FunctionImport.cpp +++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -142,7 +142,7 @@ static void findExternalCalls( ImportedName = Renamed; } // Compute the global identifier used in the summary index. - auto CalledFunctionGlobalID = Function::getGlobalIdentifier( + auto CalledFunctionGlobalID = GlobalValue::getGlobalIdentifier( CalledFunction->getName(), CalledFunction->getLinkage(), CalledFunction->getParent()->getSourceFileName()); |