================ @@ -144,25 +145,27 @@ void GlobalObject::copyAttributesFrom(const GlobalObject *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 = std::string(Name); + SmallString<64> GlobalName; 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>:"); + GlobalName.append("<unknown>"); else - NewName = NewName.insert(0, FileName.str() + ":"); + GlobalName.append(FileName.str()); + + GlobalName.append({kGlobalIdentifierDelimiter}); ---------------- minglotus-6 wrote:
Done, use `+=` for all previous `append` calls since the operator is [overloaded](https://github.com/llvm/llvm-project/blob/a52ac7f93a31c664d8943242bdafd719d38f2ffa/llvm/include/llvm/ADT/SmallString.h#L279-L286) for `StringRef` and `char` https://github.com/llvm/llvm-project/pull/74008 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits